diff --git a/README-Eng.md b/README-Eng.md index 04d06b9..e5849fb 100644 --- a/README-Eng.md +++ b/README-Eng.md @@ -2,7 +2,9 @@ ## Library of basic geometric computations for C -[Версия на русском языке / Russian version](./README.md) +[Версия на русском языке / Russian version](README.md) + +[Documentation](docs/intro-eng.md) Programming language: C (C99) diff --git a/README.md b/README.md index a81bd61..440a2d8 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ (English: library of basic geometric computations) -[English version / версия на английском языке](./README-Eng.md) +[English version / версия на английском языке](README-Eng.md) + +[Документация](docs/intro-rus.md) Язык программирования: Си (C99) diff --git a/basic-geometry-dev/main.c b/basic-geometry-dev/main.c index 1725c3e..06bb601 100644 --- a/basic-geometry-dev/main.c +++ b/basic-geometry-dev/main.c @@ -140,12 +140,20 @@ int main() //#include //#include -int main() { - BgcVersorFP64 versor; +#include +#include - bgc_versor_set_values_fp64(0, 0, 0, 0, &versor); +int main() +{ + BgcVector3FP32 my_vector1, my_vector2; - printf("Versor: (%lf, %lf, %lf, %lf)\n", versor.s0, versor.x1, versor.x2, versor.x3); + bgc_vector3_set_values_fp32(-2, 7, 5, &my_vector1); + bgc_vector3_set_values_fp32(10, -1, -3, &my_vector2); + + bgc_vector3_swap_fp32(&my_vector1, &my_vector2); + + printf("Vector #1: x1 = %f, x2 = %f, x3 = %f\n", my_vector1.x1, my_vector1.x2, my_vector1.x3); + printf("Vector #2: x1 = %f, x2 = %f, x3 = %f\n", my_vector2.x1, my_vector2.x2, my_vector2.x3); return 0; } diff --git a/docs/intro-eng.md b/docs/intro-eng.md index a809ed9..5ff1441 100644 --- a/docs/intro-eng.md +++ b/docs/intro-eng.md @@ -51,7 +51,7 @@ the type suffix: bgc_vector3_reset_fp64, bgc_radians_normalize_fp64. ## Entities -- [Vectors 2D](vector-eng.md) +- [Vectors 2D](vector2-eng.md) - Vectors 3D - [Quaternions](quaternion-eng.md) - [Versors](versor-eng.md) diff --git a/docs/intro-rus.md b/docs/intro-rus.md index ab3f929..48b463f 100644 --- a/docs/intro-rus.md +++ b/docs/intro-rus.md @@ -52,7 +52,7 @@ bgc_vector3_reset_fp64, bgc_radians_normalize_fp64. ## Сущности -- [2D векторы](vector-rus.md) +- [2D векторы](vector2-rus.md) - 3D векторы - [Кватернионы](quaternion-rus.md) - [Версоры](versor-rus.md) diff --git a/docs/vector2-eng.md b/docs/vector2-eng.md index f77012c..cd81a00 100644 --- a/docs/vector2-eng.md +++ b/docs/vector2-eng.md @@ -1,4 +1,4 @@ -# Two dimensional vectors +# Two-dimensional vectors There are two types of 2D vectors in the library: - **BgcVector2FP32** - vector using single-precision floating-point numbers diff --git a/docs/vector2/copy-eng.md b/docs/vector2/copy-eng.md index 2348ee3..a192bd6 100644 --- a/docs/vector2/copy-eng.md +++ b/docs/vector2/copy-eng.md @@ -5,23 +5,23 @@ The copy functions allow you to copy the coordinate values of one vector to anot Function for **BgcVector2FP32**: ```c - inline void bgc_vector2_copy_fp32(const BgcVector2FP32* from, BgcVector2FP32* to); +inline void bgc_vector2_copy_fp32(const BgcVector2FP32* from, BgcVector2FP32* to); ``` Function for **BgcVector2FP64**: ```c - inline void bgc_vector2_copy_fp64(const BgcVector2FP64* from, BgcVector2FP64* to); +inline void bgc_vector2_copy_fp64(const BgcVector2FP64* from, BgcVector2FP64* to); ``` Each of these functions is equivalent to the following lines of code: ```c - to->x1 = from->x1; - to->x2 = from->x2; +to->x1 = from->x1; +to->x2 = from->x2; ``` -You should not pass invalid pointers to these functions. The NULL (0) value is also considered invalid. +The **from** and **to** parameters must not be invalid pointers. The NULL (0) value is also considered invalid. The **from** parameter must be a pointer to a two-dimensional vector whose coordinates are to be copied. The coordinates of the **from** vector will not change after the function call. @@ -30,21 +30,21 @@ The **to** parameter must be a pointer to a two-dimensional vector whose coordin Example of use: ```c - #include - #include +#include +#include - int main() - { - BgcVector2FP32 my_vector1, my_vector2; +int main() +{ + BgcVector2FP32 my_vector1, my_vector2; - bgc_vector2_set_values_fp32(-2, 7, &my_vector1); + bgc_vector2_set_values_fp32(-2, 7, &my_vector1); - bgc_vector2_copy_fp32(&my_vector1, &my_vector2); + bgc_vector2_copy_fp32(&my_vector1, &my_vector2); - printf("x1 = %f, x2 = %f\n", my_vector2.x1, my_vector2.x2); + printf("x1 = %f, x2 = %f\n", my_vector2.x1, my_vector2.x2); - return 0; - } + return 0; +} ``` [Documentation](../intro-eng.md) / [2D vectors](../vector2-eng.md) diff --git a/docs/vector2/copy-rus.md b/docs/vector2/copy-rus.md index b57aaa6..28c5950 100644 --- a/docs/vector2/copy-rus.md +++ b/docs/vector2/copy-rus.md @@ -5,23 +5,23 @@ **BgcVector2FP32**: ```c - inline void bgc_vector2_copy_fp32(const BgcVector2FP32* from, BgcVector2FP32* to); +inline void bgc_vector2_copy_fp32(const BgcVector2FP32* from, BgcVector2FP32* to); ``` **BgcVector2FP64**: ```c - inline void bgc_vector2_copy_fp64(const BgcVector2FP64* from, BgcVector2FP64* to); +inline void bgc_vector2_copy_fp64(const BgcVector2FP64* from, BgcVector2FP64* to); ``` : ```c - to->x1 = from->x1; - to->x2 = from->x2; +to->x1 = from->x1; +to->x2 = from->x2; ``` - . NULL (0) . + **from** **to** . NULL (0) . **from** , . **from** . @@ -30,21 +30,21 @@ : ```c - #include - #include +#include +#include - int main() - { - BgcVector2FP32 my_vector1, my_vector2; +int main() +{ + BgcVector2FP32 my_vector1, my_vector2; - bgc_vector2_set_values_fp32(-2, 7, &my_vector1); + bgc_vector2_set_values_fp32(-2, 7, &my_vector1); - bgc_vector2_copy_fp32(&my_vector1, &my_vector2); + bgc_vector2_copy_fp32(&my_vector1, &my_vector2); - printf("x1 = %f, x2 = %f\n", my_vector2.x1, my_vector2.x2); + printf("x1 = %f, x2 = %f\n", my_vector2.x1, my_vector2.x2); - return 0; - } + return 0; +} ``` [](../intro-rus.md) / [2D ](../vector2-rus.md) diff --git a/docs/vector2/reset-eng.md b/docs/vector2/reset-eng.md index cda4f65..8333ae5 100644 --- a/docs/vector2/reset-eng.md +++ b/docs/vector2/reset-eng.md @@ -5,20 +5,20 @@ These functions set all coordinates of 2D vectors to 0. Function for **BgcVector2FP32**: ```c - inline void bgc_vector2_reset_fp32(BgcVector2FP32* vector); +inline void bgc_vector2_reset_fp32(BgcVector2FP32* vector); ``` Function for **BgcVector2FP64**: ```c - inline void bgc_vector2_reset_fp64(BgcVector2FP64* vector); +inline void bgc_vector2_reset_fp64(BgcVector2FP64* vector); ``` Each of these functions is equivalent to the following lines of code: ```c - vector->x1 = 0; - vector->x2 = 0; +vector->x1 = 0; +vector->x2 = 0; ``` You should not pass invalid pointers to these functions. The NULL (0) value is also considered invalid. @@ -26,19 +26,19 @@ You should not pass invalid pointers to these functions. The NULL (0) value is a Example of use: ```c - #include - #include +#include +#include - int main() - { - BgcVector2FP32 my_vector; +int main() +{ + BgcVector2FP32 my_vector; - bgc_vector2_reset_fp32(&my_vector); + bgc_vector2_reset_fp32(&my_vector); - printf("x1 = %f, x2 = %f\n", my_vector.x1, my_vector.x2); + printf("x1 = %f, x2 = %f\n", my_vector.x1, my_vector.x2); - return 0; - } + return 0; +} ``` [Documentation](../intro-eng.md) / [2D vectors](../vector2-eng.md) diff --git a/docs/vector2/reset-rus.md b/docs/vector2/reset-rus.md index 82a22af..677f33a 100644 --- a/docs/vector2/reset-rus.md +++ b/docs/vector2/reset-rus.md @@ -5,40 +5,40 @@ **BgcVector2FP32**: ```c - inline void bgc_vector2_reset_fp32(BgcVector2FP32* vector); +inline void bgc_vector2_reset_fp32(BgcVector2FP32* vector); ``` **BgcVector2FP64**: ```c - inline void bgc_vector2_reset_fp64(BgcVector2FP64* vector); +inline void bgc_vector2_reset_fp64(BgcVector2FP64* vector); ``` : ```c - vector->x1 = 0; - vector->x2 = 0; +vector->x1 = 0; +vector->x2 = 0; ``` - . NULL (0) . + **vector** . NULL (0) . : ```c - #include - #include +#include +#include - int main() - { - BgcVector2FP32 my_vector; +int main() +{ + BgcVector2FP32 my_vector; - bgc_vector2_reset_fp32(&my_vector); + bgc_vector2_reset_fp32(&my_vector); - printf("x1 = %f, x2 = %f\n", my_vector.x1, my_vector.x2); + printf("x1 = %f, x2 = %f\n", my_vector.x1, my_vector.x2); - return 0; - } + return 0; +} ``` [](../intro-rus.md) / [2D ](../vector2-rus.md) diff --git a/docs/vector2/set-values-eng.md b/docs/vector2/set-values-eng.md index 3886894..76635a8 100644 --- a/docs/vector2/set-values-eng.md +++ b/docs/vector2/set-values-eng.md @@ -5,40 +5,40 @@ You can set the coordinates of vectors either directly or using functions. The f Function for **BgcVector2FP32**: ```c - inline void bgc_vector2_set_values_fp32(const float x1, const float x2, BgcVector2FP32* to); +inline void bgc_vector2_set_values_fp32(const float x1, const float x2, BgcVector2FP32* to); ``` Function for **BgcVector2FP32**: ```c - inline void bgc_vector2_set_values_fp64(const double x1, const double x2, BgcVector2FP64* to); +inline void bgc_vector2_set_values_fp64(const double x1, const double x2, BgcVector2FP64* to); ``` Each of these functions is equivalent to the following lines of code: ```c - vector->x1 = x1; - vector->x2 = x2; +to->x1 = x1; +to->x2 = x2; ``` -You should not pass invalid pointers to these functions. The value NULL (0) is also considered invalid. +Invalid pointers should not be passed in the **to** parameter. The NULL (0) value is also considered invalid. Example of use: ```c - #include - #include +#include +#include - int main() - { - BgcVector2FP32 my_vector; +int main() +{ + BgcVector2FP32 my_vector; - bgc_vector2_set_values_fp32(-2, 7, &my_vector); + bgc_vector2_set_values_fp32(-2, 7, &my_vector); - printf("x1 = %f, x2 = %f\n", my_vector.x1, my_vector.x2); + printf("x1 = %f, x2 = %f\n", my_vector.x1, my_vector.x2); - return 0; - } + return 0; +} ``` [Documentation](../intro-eng.md) / [2D vectors](../vector2-eng.md) diff --git a/docs/vector2/set-values-rus.md b/docs/vector2/set-values-rus.md index 8cf1756..b10f676 100644 --- a/docs/vector2/set-values-rus.md +++ b/docs/vector2/set-values-rus.md @@ -5,40 +5,40 @@ **BgcVector2FP32**: ```c - inline void bgc_vector2_set_values_fp32(const float x1, const float x2, BgcVector2FP32* to); +inline void bgc_vector2_set_values_fp32(const float x1, const float x2, BgcVector2FP32* to); ``` **BgcVector2FP32**: ```c - inline void bgc_vector2_set_values_fp64(const double x1, const double x2, BgcVector2FP64* to); +inline void bgc_vector2_set_values_fp64(const double x1, const double x2, BgcVector2FP64* to); ``` : ```c - vector->x1 = x1; - vector->x2 = x2; +to->x1 = x1; +to->x2 = x2; ``` - . NULL (0) . + **to** . NULL (0) . : ```c - #include - #include +#include +#include - int main() - { - BgcVector2FP32 my_vector; +int main() +{ + BgcVector2FP32 my_vector; - bgc_vector2_set_values_fp32(-2, 7, &my_vector); + bgc_vector2_set_values_fp32(-2, 7, &my_vector); - printf("x1 = %f, x2 = %f\n", my_vector.x1, my_vector.x2); + printf("x1 = %f, x2 = %f\n", my_vector.x1, my_vector.x2); - return 0; - } + return 0; +} ``` [](../intro-rus.md) / [2D ](../vector2-rus.md) diff --git a/docs/vector2/swap-eng.md b/docs/vector2/swap-eng.md index 9dec23f..65915d5 100644 --- a/docs/vector2/swap-eng.md +++ b/docs/vector2/swap-eng.md @@ -5,40 +5,41 @@ The exchange functions allow two vectors of the same type to exchange coordinate Function for **BgcVector2FP32**: ```c - inline void bgc_vector2_swap_fp32(BgcVector2FP32* vector1, BgcVector2FP32* vector2); +inline void bgc_vector2_swap_fp32(BgcVector2FP32* vector1, BgcVector2FP32* vector2); ``` Function for **BgcVector2FP32**: ```c - inline void bgc_vector2_swap_fp64(BgcVector2FP64* vector1, BgcVector2FP64* vector2); +inline void bgc_vector2_swap_fp64(BgcVector2FP64* vector1, BgcVector2FP64* vector2); ``` -You should not pass invalid pointers to these functions. The value NULL (0) is also considered invalid. +The **vector1** and **vector2** parameters must not be invalid pointers. The NULL (0) value is also considered invalid. Vector **vector1** after calling this function will have the coordinate values that vector **vector2** had before calling the function. + And vector **vector2** after calling this function will have the same coordinate values that vector **vector1** had before calling the function. Example of use: ```c - #include - #include +#include +#include - int main() - { - BgcVector2FP32 my_vector1, my_vector2; +int main() +{ + BgcVector2FP32 my_vector1, my_vector2; - bgc_vector2_set_values_fp32(-2, 7, &my_vector1); - bgc_vector2_set_values_fp32(10, -1, &my_vector2); + bgc_vector2_set_values_fp32(-2, 7, &my_vector1); + bgc_vector2_set_values_fp32(10, -1, &my_vector2); - bgc_vector2_swap_fp32(&my_vector1, &my_vector2); + bgc_vector2_swap_fp32(&my_vector1, &my_vector2); - printf("Vector #1: x1 = %f, x2 = %f\n", my_vector1.x1, my_vector1.x2); - printf("Vector #2: x1 = %f, x2 = %f\n", my_vector2.x1, my_vector2.x2); + printf("Vector #1: x1 = %f, x2 = %f\n", my_vector1.x1, my_vector1.x2); + printf("Vector #2: x1 = %f, x2 = %f\n", my_vector2.x1, my_vector2.x2); - return 0; - } + return 0; +} ``` [Documentation](../intro-eng.md) / [2D vectors](../vector2-eng.md) diff --git a/docs/vector2/swap-rus.md b/docs/vector2/swap-rus.md index 1f9adb5..509fc8e 100644 --- a/docs/vector2/swap-rus.md +++ b/docs/vector2/swap-rus.md @@ -1,44 +1,45 @@ -# +# Обмен - . +Функции обмена позволяют двум векторам одного типа обменяться значениями координат. - **BgcVector2FP32**: +Функция для **BgcVector2FP32**: ```c - inline void bgc_vector2_swap_fp32(BgcVector2FP32* vector1, BgcVector2FP32* vector2); +inline void bgc_vector2_swap_fp32(BgcVector2FP32* vector1, BgcVector2FP32* vector2); ``` - **BgcVector2FP32**: +Функция для **BgcVector2FP32**: ```c - inline void bgc_vector2_swap_fp64(BgcVector2FP64* vector1, BgcVector2FP64* vector2); +inline void bgc_vector2_swap_fp64(BgcVector2FP64* vector1, BgcVector2FP64* vector2); ``` - . NULL (0) . +Параметры **vector1** и **vector2** не должны быть некорректными указателями. Значение NULL (0) также считается некорректным. - **vector1** , **vector2** . - **vector2** , **vector1** . +Вектор **vector1** после вызова данной функции будет иметь значения координат, какие имел вектор **vector2** до вызова функции. - : +А вектор **vector2** после вызова данной функции будет иметь такие же значения координат, какие имел вектор **vector1** до вызова функции. + +Пример применения: ```c - #include - #include +#include +#include - int main() - { - BgcVector2FP32 my_vector1, my_vector2; +int main() +{ + BgcVector2FP32 my_vector1, my_vector2; - bgc_vector2_set_values_fp32(-2, 7, &my_vector1); - bgc_vector2_set_values_fp32(10, -1, &my_vector2); + bgc_vector2_set_values_fp32(-2, 7, &my_vector1); + bgc_vector2_set_values_fp32(10, -1, &my_vector2); - bgc_vector2_swap_fp32(&my_vector1, &my_vector2); + bgc_vector2_swap_fp32(&my_vector1, &my_vector2); - printf("Vector #1: x1 = %f, x2 = %f\n", my_vector1.x1, my_vector1.x2); - printf("Vector #2: x1 = %f, x2 = %f\n", my_vector2.x1, my_vector2.x2); + printf("Vector #1: x1 = %f, x2 = %f\n", my_vector1.x1, my_vector1.x2); + printf("Vector #2: x1 = %f, x2 = %f\n", my_vector2.x1, my_vector2.x2); - return 0; - } + return 0; +} ``` -[](../intro-rus.md) / [2D ](../vector2-rus.md) +[Документация](../intro-rus.md) / [2D векторы](../vector2-rus.md) diff --git a/docs/vector3-eng.md b/docs/vector3-eng.md new file mode 100644 index 0000000..80d6146 --- /dev/null +++ b/docs/vector3-eng.md @@ -0,0 +1,31 @@ +# Three-dimensional vectors + +There are two types of 3D vectors in the library: +- **BgcVector3FP32** - vector using single-precision floating-point numbers +- **BgcVector3FP64** - vector using double-precision floating-point numbers + +Structure definitions: + +```c + typedef struct + { + float x1, x2, x3; + } BgcVector3FP32; + + typedef struct + { + double x1, x2, x3; + } BgcVector3FP64; +``` + +## Functions + +| Funtions for BgcVector3FP32 | Funtions for BgcVector3FP64 | +|:-------------------------------------------------------------:|:-------------------------------------------------------------:| +| [bgc_vector3_reset_fp32](vector3/reset-eng.md) | [bgc_vector3_reset_fp64](vector3/reset-eng.md) | +| [bgc_vector3_set_values_fp32](vector3/set-values-eng.md) | [bgc_vector3_set_values_fp64](vector3/set-values-eng.md) | +| [bgc_vector3_copy_fp32](vector3/copy-eng.md) | [bgc_vector3_copy_fp64](vector3/copy-eng.md) | +| [bgc_vector3_swap_fp32](vector3/swap-eng.md) | [bgc_vector3_swap_fp64](vector3/swap-eng.md) | + + +[Documentation](intro-eng.md) diff --git a/docs/vector3-rus.md b/docs/vector3-rus.md new file mode 100644 index 0000000..2a8e4d4 --- /dev/null +++ b/docs/vector3-rus.md @@ -0,0 +1,30 @@ +# Трёхмерные векторы векторы + +В библиотеке есть два типа двумерных векторов: +- **BgcVector3FP32** - вектор с использованием чисел с плавающей запятой одинарной точности +- **BgcVector3FP64** - вектор с использованием чисел с плавающей запятой двойной точности + +Определения структур: + +```c + typedef struct + { + float x1, x2, x3; + } BgcVector3FP32; + + typedef struct + { + double x1, x2, x3; + } BgcVector3FP64; +``` + +## Функции + +| Функции для BgcVector3FP32 | Функции для BgcVector3FP64 | +|:-------------------------------------------------------------:|:-------------------------------------------------------------:| +| [bgc_vector3_reset_fp32](vector3/reset-rus.md) | [bgc_vector3_reset_fp64](vector3/reset-rus.md) | +| [bgc_vector3_set_values_fp32](vector3/set-values-rus.md) | [bgc_vector3_set_values_fp64](vector3/set-values-rus.md) | +| [bgc_vector3_copy_fp32](vector3/copy-rus.md) | [bgc_vector3_copy_fp64](vector3/copy-rus.md) | +| [bgc_vector3_swap_fp32](vector3/swap-rus.md) | [bgc_vector3_swap_fp64](vector3/swap-rus.md) | + +[Документация](intro-rus.md) diff --git a/docs/vector3/copy-eng.md b/docs/vector3/copy-eng.md new file mode 100644 index 0000000..fceb461 --- /dev/null +++ b/docs/vector3/copy-eng.md @@ -0,0 +1,51 @@ +# Copying + +The copy functions allow you to copy the coordinate values of one vector to another vector. + +Function for **BgcVector3FP32**: + +```c +inline void bgc_vector3_copy_fp32(const BgcVector3FP32* from, BgcVector3FP32* to); +``` + +Function for **BgcVector3FP64**: + +```c +inline void bgc_vector3_copy_fp64(const BgcVector3FP64* from, BgcVector3FP64* to); +``` + +Each of these functions is equivalent to the following lines of code: + +```c +to->x1 = from->x1; +to->x2 = from->x2; +to->x3 = from->x3; +``` + +The **from** and **to** parameters must not be invalid pointers. The NULL (0) value is also considered invalid. + +The **from** parameter must be a pointer to a three-dimensional vector whose coordinates are to be copied. The coordinates of the **from** vector will not change after the function call. + +The **to** parameter must be a pointer to a three-dimensional vector whose coordinates are to be changed. The coordinates of the **to** vector will become the same as those of the **from** vector after the function call. + +Example of use: + +```c +#include +#include + +int main() +{ + BgcVector3FP32 my_vector1, my_vector3; + + bgc_vector3_set_values_fp32(-2, 7, 1, &my_vector1); + + bgc_vector3_copy_fp32(&my_vector1, &my_vector3); + + printf("x1 = %f, x2 = %f, x3 = %f\n", my_vector3.x1, my_vector3.x2, my_vector3.x3); + + return 0; +} +``` + +[Documentation](../intro-eng.md) / [2D vectors](../vector3-eng.md) diff --git a/docs/vector3/copy-rus.md b/docs/vector3/copy-rus.md new file mode 100644 index 0000000..c473264 --- /dev/null +++ b/docs/vector3/copy-rus.md @@ -0,0 +1,51 @@ +# + + . + + **BgcVector3FP32**: + +```c +inline void bgc_vector3_copy_fp32(const BgcVector3FP32* from, BgcVector3FP32* to); +``` + + **BgcVector3FP64**: + +```c +inline void bgc_vector3_copy_fp64(const BgcVector3FP64* from, BgcVector3FP64* to); +``` + + : + +```c +to->x1 = from->x1; +to->x2 = from->x2; +to->x3 = from->x3; +``` + + **from** **to** . NULL (0) . + + **from** , . **from** . + + **to** , . **to** , **from**. + + : + +```c +#include +#include + +int main() +{ + BgcVector3FP32 my_vector1, my_vector3; + + bgc_vector3_set_values_fp32(-2, 7, 1, &my_vector1); + + bgc_vector3_copy_fp32(&my_vector1, &my_vector3); + + printf("x1 = %f, x2 = %f, x3 = %f\n", my_vector3.x1, my_vector3.x2, my_vector3.x3); + + return 0; +} +``` + +[](../intro-rus.md) / [2D ](../vector3-rus.md) diff --git a/docs/vector3/reset-eng.md b/docs/vector3/reset-eng.md new file mode 100644 index 0000000..dee9b0d --- /dev/null +++ b/docs/vector3/reset-eng.md @@ -0,0 +1,45 @@ +# Resetting the state of a 2D vector + +These functions set all coordinates of 2D vectors to 0. + +Function for **BgcVector3FP32**: + +```c +inline void bgc_vector3_reset_fp32(BgcVector3FP32* vector); +``` + +Function for **BgcVector3FP64**: + +```c +inline void bgc_vector3_reset_fp64(BgcVector3FP64* vector); +``` + +Each of these functions is equivalent to the following lines of code: + +```c +vector->x1 = 0; +vector->x2 = 0; +vector->x3 = 0; +``` + +You should not pass invalid pointers to these functions. The NULL (0) value is also considered invalid. + +Example of use: + +```c +#include +#include + +int main() +{ + BgcVector3FP32 my_vector; + + bgc_vector3_reset_fp32(&my_vector); + + printf("x1 = %f, x2 = %f, x3 = %f\n", my_vector.x1, my_vector.x2, my_vector.x3); + + return 0; +} +``` + +[Documentation](../intro-eng.md) / [2D vectors](../vector3-eng.md) diff --git a/docs/vector3/reset-rus.md b/docs/vector3/reset-rus.md new file mode 100644 index 0000000..24c9543 --- /dev/null +++ b/docs/vector3/reset-rus.md @@ -0,0 +1,45 @@ +# + + 0 . + + **BgcVector3FP32**: + +```c +inline void bgc_vector3_reset_fp32(BgcVector3FP32* vector); +``` + + **BgcVector3FP64**: + +```c +inline void bgc_vector3_reset_fp64(BgcVector3FP64* vector); +``` + + : + +```c +vector->x1 = 0; +vector->x2 = 0; +vector->x3 = 0; +``` + + . NULL (0) . + + : + +```c +#include +#include + +int main() +{ + BgcVector3FP32 my_vector; + + bgc_vector3_reset_fp32(&my_vector); + + printf("x1 = %f, x2 = %f, x3 = %f\n", my_vector.x1, my_vector.x2, my_vector.x3); + + return 0; +} +``` + +[](../intro-rus.md) / [2D ](../vector3-rus.md) diff --git a/docs/vector3/set-values-eng.md b/docs/vector3/set-values-eng.md new file mode 100644 index 0000000..5102ecb --- /dev/null +++ b/docs/vector3/set-values-eng.md @@ -0,0 +1,45 @@ +# Setting the coordinates of a three-dimensional vector + +You can set the coordinates of vectors either directly or using functions. The functions for setting coordinate values allow you to do this in one line. + +Function for **BgcVector3FP32**: + +```c +inline void bgc_vector3_set_values_fp32(const float x1, const float x2, const float x3, BgcVector3FP32* to); +``` + +Function for **BgcVector3FP32**: + +```c +inline void bgc_vector3_set_values_fp64(const double x1, const double x2, const double x3, BgcVector3FP64* to); +``` + +Each of these functions is equivalent to the following lines of code: + +```c +to->x1 = x1; +to->x2 = x2; +to->x3 = x3; +``` + +Invalid pointers should not be passed in the **to** parameter. The NULL (0) value is also considered invalid. + +Example of use: + +```c +#include +#include + +int main() +{ + BgcVector3FP32 my_vector; + + bgc_vector3_set_values_fp32(-2, 7, 10, &my_vector); + + printf("x1 = %f, x2 = %f, x3 = %f\n", my_vector.x1, my_vector.x2, my_vector.x3); + + return 0; +} +``` + +[Documentation](../intro-eng.md) / [2D vectors](../vector3-eng.md) diff --git a/docs/vector3/set-values-rus.md b/docs/vector3/set-values-rus.md new file mode 100644 index 0000000..ae04ec9 --- /dev/null +++ b/docs/vector3/set-values-rus.md @@ -0,0 +1,45 @@ +# + + , . . + + **BgcVector3FP32**: + +```c +inline void bgc_vector3_set_values_fp32(const float x1, const float x2, const float x3, BgcVector3FP32* to); +``` + + **BgcVector3FP32**: + +```c +inline void bgc_vector3_set_values_fp64(const double x1, const double x2, const double x3, BgcVector3FP64* to); +``` + + : + +```c +to->x1 = x1; +to->x2 = x2; +to->x3 = x3; +``` + + **to** . NULL (0) . + + : + +```c +#include +#include + +int main() +{ + BgcVector3FP32 my_vector; + + bgc_vector3_set_values_fp32(-2, 7, 10, &my_vector); + + printf("x1 = %f, x2 = %f, x3 = %f\n", my_vector.x1, my_vector.x2, my_vector.x3); + + return 0; +} +``` + +[](../intro-rus.md) / [2D ](../vector3-rus.md) diff --git a/docs/vector3/swap-eng.md b/docs/vector3/swap-eng.md new file mode 100644 index 0000000..0adb099 --- /dev/null +++ b/docs/vector3/swap-eng.md @@ -0,0 +1,52 @@ +# Swapping + +The exchange functions allow two vectors of the same type to exchange coordinate values. + +Function for **BgcVector3FP32**: + +```c +inline void bgc_vector3_swap_fp32(BgcVector3FP32* vector1, BgcVector3FP32* vector2); +``` + +Function for **BgcVector3FP32**: + +```c +inline void bgc_vector3_swap_fp64(BgcVector3FP64* vector1, BgcVector3FP64* vector2); +``` + +The **vector1** and **vector2** parameters must not be invalid pointers. The NULL (0) value is also considered invalid. + +Vector **vector1** after calling this function will have the coordinate values that vector **vector3** had before calling the function. + +And vector **vector3** after calling this function will have the same coordinate values that vector **vector1** had before calling the function. + +Example of use: + +```c +#include +#include + +int main() +{ + BgcVector3FP32 my_vector1, my_vector2; + + bgc_vector3_set_values_fp32(-2, 7, 5, &my_vector1); + bgc_vector3_set_values_fp32(10, -1, -3, &my_vector2); + + bgc_vector3_swap_fp32(&my_vector1, &my_vector2); + + printf("Vector #1: x1 = %f, x2 = %f, x3 = %f\n", my_vector1.x1, my_vector1.x2, my_vector1.x3); + printf("Vector #2: x1 = %f, x2 = %f, x3 = %f\n", my_vector2.x1, my_vector2.x2, my_vector2.x3); + + return 0; +} +``` + +Result: + +``` +Vector #1: x1 = 10.000000, x2 = -1.000000, x3 = -3.000000 +Vector #2: x1 = -2.000000, x2 = 7.000000, x3 = 5.000000 +``` + +[Documentation](../intro-eng.md) / [2D vectors](../vector3-eng.md) diff --git a/docs/vector3/swap-rus.md b/docs/vector3/swap-rus.md new file mode 100644 index 0000000..e458d18 --- /dev/null +++ b/docs/vector3/swap-rus.md @@ -0,0 +1,52 @@ +# Обмен + +Функции обмена позволяют двум векторам одного типа обменяться значениями координат. + +Функция для **BgcVector3FP32**: + +```c +inline void bgc_vector3_swap_fp32(BgcVector3FP32* vector1, BgcVector3FP32* vector2); +``` + +Функция для **BgcVector3FP32**: + +```c +inline void bgc_vector3_swap_fp64(BgcVector3FP64* vector1, BgcVector3FP64* vector2); +``` + +Параметры **vector1** и **vector2** не должны быть некорректными указателями. Значение NULL (0) также считается некорректным. + +Вектор **vector1** после вызова данной функции будет иметь значения координат, какие имел вектор **vector2** до вызова функции. + +А вектор **vector2** после вызова данной функции будет иметь такие же значения координат, какие имел вектор **vector1** до вызова функции. + +Пример применения: + +```c +#include +#include + +int main() +{ + BgcVector3FP32 my_vector1, my_vector2; + + bgc_vector3_set_values_fp32(-2, 7, 5, &my_vector1); + bgc_vector3_set_values_fp32(10, -1, -3, &my_vector2); + + bgc_vector3_swap_fp32(&my_vector1, &my_vector2); + + printf("Vector #1: x1 = %f, x2 = %f, x3 = %f\n", my_vector1.x1, my_vector1.x2, my_vector1.x3); + printf("Vector #2: x1 = %f, x2 = %f, x3 = %f\n", my_vector2.x1, my_vector2.x2, my_vector2.x3); + + return 0; +} +``` + +Результат: + +``` +Vector #1: x1 = 10.000000, x2 = -1.000000, x3 = -3.000000 +Vector #2: x1 = -2.000000, x2 = 7.000000, x3 = 5.000000 +``` + +[Документация](../intro-rus.md) / [2D векторы](../vector3-rus.md)