Добавление документации по трёхмерным векторам и исправления
This commit is contained in:
parent
e15070ce45
commit
02bcb1bd33
24 changed files with 593 additions and 132 deletions
51
docs/vector3/copy-eng.md
Normal file
51
docs/vector3/copy-eng.md
Normal 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
51
docs/vector3/copy-rus.md
Normal 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
45
docs/vector3/reset-eng.md
Normal 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
45
docs/vector3/reset-rus.md
Normal 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)
|
||||
45
docs/vector3/set-values-eng.md
Normal file
45
docs/vector3/set-values-eng.md
Normal 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)
|
||||
45
docs/vector3/set-values-rus.md
Normal file
45
docs/vector3/set-values-rus.md
Normal 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
52
docs/vector3/swap-eng.md
Normal 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
52
docs/vector3/swap-rus.md
Normal 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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue