Добавление документации по трёхмерным векторам и исправления

This commit is contained in:
Andrey Pokidov 2025-02-08 01:51:53 +07:00
parent e15070ce45
commit 02bcb1bd33
24 changed files with 593 additions and 132 deletions

View file

@ -2,7 +2,9 @@
## Library of basic geometric computations for C ## Library of basic geometric computations for C
[Версия на русском языке / Russian version](./README.md) [Версия на русском языке / Russian version](README.md)
[Documentation](docs/intro-eng.md)
Programming language: C (C99) Programming language: C (C99)

View file

@ -4,7 +4,9 @@
(English: library of basic geometric computations) (English: library of basic geometric computations)
[English version / версия на английском языке](./README-Eng.md) [English version / версия на английском языке](README-Eng.md)
[Документация](docs/intro-rus.md)
Язык программирования: Си (C99) Язык программирования: Си (C99)

View file

@ -140,12 +140,20 @@ int main()
//#include <stdio.h> //#include <stdio.h>
//#include <basic-geometry.h> //#include <basic-geometry.h>
int main() { #include <stdio.h>
BgcVersorFP64 versor; #include <basic-geometry.h>
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; return 0;
} }

View file

@ -51,7 +51,7 @@ the type suffix: bgc_vector3_reset_fp64, bgc_radians_normalize_fp64.
## Entities ## Entities
- [Vectors 2D](vector-eng.md) - [Vectors 2D](vector2-eng.md)
- Vectors 3D - Vectors 3D
- [Quaternions](quaternion-eng.md) - [Quaternions](quaternion-eng.md)
- [Versors](versor-eng.md) - [Versors](versor-eng.md)

View file

@ -52,7 +52,7 @@ bgc_vector3_reset_fp64, bgc_radians_normalize_fp64.
## Сущности ## Сущности
- [2D векторы](vector-rus.md) - [2D векторы](vector2-rus.md)
- 3D векторы - 3D векторы
- [Кватернионы](quaternion-rus.md) - [Кватернионы](quaternion-rus.md)
- [Версоры](versor-rus.md) - [Версоры](versor-rus.md)

View file

@ -1,4 +1,4 @@
# Two dimensional vectors # Two-dimensional vectors
There are two types of 2D vectors in the library: There are two types of 2D vectors in the library:
- **BgcVector2FP32** - vector using single-precision floating-point numbers - **BgcVector2FP32** - vector using single-precision floating-point numbers

View file

@ -5,23 +5,23 @@ The copy functions allow you to copy the coordinate values of one vector to anot
Function for **BgcVector2FP32**: Function for **BgcVector2FP32**:
```c ```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**: Function for **BgcVector2FP64**:
```c ```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: Each of these functions is equivalent to the following lines of code:
```c ```c
to->x1 = from->x1; to->x1 = from->x1;
to->x2 = from->x2; 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. 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: Example of use:
```c ```c
#include <stdio.h> #include <stdio.h>
#include <basic-geometry.h> #include <basic-geometry.h>
int main() int main()
{ {
BgcVector2FP32 my_vector1, my_vector2; 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) [Documentation](../intro-eng.md) / [2D vectors](../vector2-eng.md)

View file

@ -5,23 +5,23 @@
Функция для **BgcVector2FP32**: Функция для **BgcVector2FP32**:
```c ```c
inline void bgc_vector2_copy_fp32(const BgcVector2FP32* from, BgcVector2FP32* to); inline void bgc_vector2_copy_fp32(const BgcVector2FP32* from, BgcVector2FP32* to);
``` ```
Функция для **BgcVector2FP64**: Функция для **BgcVector2FP64**:
```c ```c
inline void bgc_vector2_copy_fp64(const BgcVector2FP64* from, BgcVector2FP64* to); inline void bgc_vector2_copy_fp64(const BgcVector2FP64* from, BgcVector2FP64* to);
``` ```
Каждая из данных функции эквивалентна следующим строкам кода: Каждая из данных функции эквивалентна следующим строкам кода:
```c ```c
to->x1 = from->x1; to->x1 = from->x1;
to->x2 = from->x2; to->x2 = from->x2;
``` ```
 äàííûå ôóíêöèè íå ñëåäóåò ïåðåäàâàòü íåêîððåêòíûå óêàçàòåëè. Çíà÷åíèå NULL (0) òàêæå ñ÷èòàåòñÿ íåêîððåêòíûì. Ïàðàìåòðû **from** è **to** íå äîëæíû áûòü íåêîððåêòíûìè óêàçàòåëÿìè. Çíà÷åíèå NULL (0) òàêæå ñ÷èòàåòñÿ íåêîððåêòíûì.
Параметр **from** должен быть указателем на двумерный вектор, координаты которого должны быть скопированы. Координаты вектора **from** не изменятся после вызова функции. Параметр **from** должен быть указателем на двумерный вектор, координаты которого должны быть скопированы. Координаты вектора **from** не изменятся после вызова функции.
@ -30,21 +30,21 @@
Пример применения: Пример применения:
```c ```c
#include <stdio.h> #include <stdio.h>
#include <basic-geometry.h> #include <basic-geometry.h>
int main() int main()
{ {
BgcVector2FP32 my_vector1, my_vector2; 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) [Документация](../intro-rus.md) / [2D векторы](../vector2-rus.md)

View file

@ -5,20 +5,20 @@ These functions set all coordinates of 2D vectors to 0.
Function for **BgcVector2FP32**: Function for **BgcVector2FP32**:
```c ```c
inline void bgc_vector2_reset_fp32(BgcVector2FP32* vector); inline void bgc_vector2_reset_fp32(BgcVector2FP32* vector);
``` ```
Function for **BgcVector2FP64**: Function for **BgcVector2FP64**:
```c ```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: Each of these functions is equivalent to the following lines of code:
```c ```c
vector->x1 = 0; vector->x1 = 0;
vector->x2 = 0; vector->x2 = 0;
``` ```
You should not pass invalid pointers to these functions. The NULL (0) value is also considered invalid. 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: Example of use:
```c ```c
#include <stdio.h> #include <stdio.h>
#include <basic-geometry.h> #include <basic-geometry.h>
int main() int main()
{ {
BgcVector2FP32 my_vector; 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) [Documentation](../intro-eng.md) / [2D vectors](../vector2-eng.md)

View file

@ -5,40 +5,40 @@
Функция для **BgcVector2FP32**: Функция для **BgcVector2FP32**:
```c ```c
inline void bgc_vector2_reset_fp32(BgcVector2FP32* vector); inline void bgc_vector2_reset_fp32(BgcVector2FP32* vector);
``` ```
Функция для **BgcVector2FP64**: Функция для **BgcVector2FP64**:
```c ```c
inline void bgc_vector2_reset_fp64(BgcVector2FP64* vector); inline void bgc_vector2_reset_fp64(BgcVector2FP64* vector);
``` ```
Каждая из данных функции эквивалентна следующим строкам кода: Каждая из данных функции эквивалентна следующим строкам кода:
```c ```c
vector->x1 = 0; vector->x1 = 0;
vector->x2 = 0; vector->x2 = 0;
``` ```
 äàííûå ôóíêöèè íå ñëåäóåò ïåðåäàâàòü íåêîððåêòíûå óêàçàòåëè. Çíà÷åíèå NULL (0) òàêæå ñ÷èòàåòñÿ íåêîððåêòíûì.  ïàðàìåòðå **vector** íå ñëåäóåò ïåðåäàâàòü íåêîððåêòíûå óêàçàòåëè. Çíà÷åíèå NULL (0) òàêæå ñ÷èòàåòñÿ íåêîððåêòíûì.
Пример применения: Пример применения:
```c ```c
#include <stdio.h> #include <stdio.h>
#include <basic-geometry.h> #include <basic-geometry.h>
int main() int main()
{ {
BgcVector2FP32 my_vector; 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) [Документация](../intro-rus.md) / [2D векторы](../vector2-rus.md)

View file

@ -5,40 +5,40 @@ You can set the coordinates of vectors either directly or using functions. The f
Function for **BgcVector2FP32**: Function for **BgcVector2FP32**:
```c ```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**: Function for **BgcVector2FP32**:
```c ```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: Each of these functions is equivalent to the following lines of code:
```c ```c
vector->x1 = x1; to->x1 = x1;
vector->x2 = x2; 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: Example of use:
```c ```c
#include <stdio.h> #include <stdio.h>
#include <basic-geometry.h> #include <basic-geometry.h>
int main() int main()
{ {
BgcVector2FP32 my_vector; 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) [Documentation](../intro-eng.md) / [2D vectors](../vector2-eng.md)

View file

@ -5,40 +5,40 @@
Функция для **BgcVector2FP32**: Функция для **BgcVector2FP32**:
```c ```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**: Функция для **BgcVector2FP32**:
```c ```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 ```c
vector->x1 = x1; to->x1 = x1;
vector->x2 = x2; to->x2 = x2;
``` ```
 äàííûå ôóíêöèè íå ñëåäóåò ïåðåäàâàòü íåêîððåêòíûå óêàçàòåëè. Çíà÷åíèå NULL (0) òàêæå ñ÷èòàåòñÿ íåêîððåêòíûì.  ïàðàìåòðå **to** íå ñëåäóåò ïåðåäàâàòü íåêîððåêòíûå óêàçàòåëè. Çíà÷åíèå NULL (0) òàêæå ñ÷èòàåòñÿ íåêîððåêòíûì.
Пример применения: Пример применения:
```c ```c
#include <stdio.h> #include <stdio.h>
#include <basic-geometry.h> #include <basic-geometry.h>
int main() int main()
{ {
BgcVector2FP32 my_vector; 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) [Документация](../intro-rus.md) / [2D векторы](../vector2-rus.md)

View file

@ -5,40 +5,41 @@ The exchange functions allow two vectors of the same type to exchange coordinate
Function for **BgcVector2FP32**: Function for **BgcVector2FP32**:
```c ```c
inline void bgc_vector2_swap_fp32(BgcVector2FP32* vector1, BgcVector2FP32* vector2); inline void bgc_vector2_swap_fp32(BgcVector2FP32* vector1, BgcVector2FP32* vector2);
``` ```
Function for **BgcVector2FP32**: Function for **BgcVector2FP32**:
```c ```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. 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. And vector **vector2** after calling this function will have the same coordinate values that vector **vector1** had before calling the function.
Example of use: Example of use:
```c ```c
#include <stdio.h> #include <stdio.h>
#include <basic-geometry.h> #include <basic-geometry.h>
int main() int main()
{ {
BgcVector2FP32 my_vector1, my_vector2; 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_set_values_fp32(10, -1, &my_vector2); 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 #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 #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) [Documentation](../intro-eng.md) / [2D vectors](../vector2-eng.md)

View file

@ -1,44 +1,45 @@
# Îáìåí # Обмен
Ôóíêöèè îáìåíà ïîçâîëÿþò äâóì âåêòîðàì îäíîãî òèïà îáìåíÿòüñÿ çíà÷åíèÿìè êîîðäèíàò. Функции обмена позволяют двум векторам одного типа обменяться значениями координат.
Ôóíêöèÿ äëÿ **BgcVector2FP32**: Функция для **BgcVector2FP32**:
```c ```c
inline void bgc_vector2_swap_fp32(BgcVector2FP32* vector1, BgcVector2FP32* vector2); inline void bgc_vector2_swap_fp32(BgcVector2FP32* vector1, BgcVector2FP32* vector2);
``` ```
Ôóíêöèÿ äëÿ **BgcVector2FP32**: Функция для **BgcVector2FP32**:
```c ```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** äî âûçîâà ôóíêöèè. Вектор **vector1** после вызова данной функции будет иметь значения координат, какие имел вектор **vector2** до вызова функции.
À âåêòîð **vector2** ïîñëå âûçîâà äàííîé ôóíêöèè áóäåò èìåòü òàêèå æå çíà÷åíèÿ êîîðäèíàò, êàêèå èìåë âåêòîð **vector1** äî âûçîâà ôóíêöèè.
Ïðèìåð ïðèìåíåíèÿ: А вектор **vector2** после вызова данной функции будет иметь такие же значения координат, какие имел вектор **vector1** до вызова функции.
Пример применения:
```c ```c
#include <stdio.h> #include <stdio.h>
#include <basic-geometry.h> #include <basic-geometry.h>
int main() int main()
{ {
BgcVector2FP32 my_vector1, my_vector2; 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_set_values_fp32(10, -1, &my_vector2); 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 #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 #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)

31
docs/vector3-eng.md Normal file
View file

@ -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)

30
docs/vector3-rus.md Normal file
View file

@ -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)

51
docs/vector3/copy-eng.md Normal file
View file

@ -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 <stdio.h>
#include <basic-geometry.h>
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)

51
docs/vector3/copy-rus.md Normal file
View file

@ -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 <stdio.h>
#include <basic-geometry.h>
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)

45
docs/vector3/reset-eng.md Normal file
View file

@ -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 <stdio.h>
#include <basic-geometry.h>
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)

45
docs/vector3/reset-rus.md Normal file
View file

@ -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 <stdio.h>
#include <basic-geometry.h>
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)

View file

@ -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 <stdio.h>
#include <basic-geometry.h>
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)

View file

@ -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 <stdio.h>
#include <basic-geometry.h>
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)

52
docs/vector3/swap-eng.md Normal file
View file

@ -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 <stdio.h>
#include <basic-geometry.h>
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)

52
docs/vector3/swap-rus.md Normal file
View file

@ -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 <stdio.h>
#include <basic-geometry.h>
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)