Добавление документации по трёхмерным векторам и исправления
This commit is contained in:
parent
e15070ce45
commit
02bcb1bd33
24 changed files with 593 additions and 132 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -140,12 +140,20 @@ int main()
|
|||
//#include <stdio.h>
|
||||
//#include <basic-geometry.h>
|
||||
|
||||
int main() {
|
||||
BgcVersorFP64 versor;
|
||||
#include <stdio.h>
|
||||
#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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -21,7 +21,7 @@ Each of these functions is equivalent to the following lines of code:
|
|||
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.
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
to->x2 = from->x2;
|
||||
```
|
||||
|
||||
В данные функции не следует передавать некорректные указатели. Значение NULL (0) также считается некорректным.
|
||||
Параметры **from** и **to** не должны быть некорректными указателями. Значение NULL (0) также считается некорректным.
|
||||
|
||||
Параметр **from** должен быть указателем на двумерный вектор, координаты которого должны быть скопированы. Координаты вектора **from** не изменятся после вызова функции.
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
vector->x2 = 0;
|
||||
```
|
||||
|
||||
В данные функции не следует передавать некорректные указатели. Значение NULL (0) также считается некорректным.
|
||||
В параметре **vector** не следует передавать некорректные указатели. Значение NULL (0) также считается некорректным.
|
||||
|
||||
Пример применения:
|
||||
|
||||
|
|
|
@ -17,11 +17,11 @@ Function for **BgcVector2FP32**:
|
|||
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:
|
||||
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
Каждая из данных функции эквивалентна следующим строкам кода:
|
||||
|
||||
```c
|
||||
vector->x1 = x1;
|
||||
vector->x2 = x2;
|
||||
to->x1 = x1;
|
||||
to->x2 = x2;
|
||||
```
|
||||
|
||||
В данные функции не следует передавать некорректные указатели. Значение NULL (0) также считается некорректным.
|
||||
В параметре **to** не следует передавать некорректные указатели. Значение NULL (0) также считается некорректным.
|
||||
|
||||
Пример применения:
|
||||
|
||||
|
|
|
@ -14,9 +14,10 @@ Function for **BgcVector2FP32**:
|
|||
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:
|
||||
|
|
|
@ -1,25 +1,26 @@
|
|||
# Обмен
|
||||
# Обмен
|
||||
|
||||
Функции обмена позволяют двум векторам одного типа обменяться значениями координат.
|
||||
Функции обмена позволяют двум векторам одного типа обменяться значениями координат.
|
||||
|
||||
Функция для **BgcVector2FP32**:
|
||||
Функция для **BgcVector2FP32**:
|
||||
|
||||
```c
|
||||
inline void bgc_vector2_swap_fp32(BgcVector2FP32* vector1, BgcVector2FP32* vector2);
|
||||
```
|
||||
|
||||
Функция для **BgcVector2FP32**:
|
||||
Функция для **BgcVector2FP32**:
|
||||
|
||||
```c
|
||||
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 <stdio.h>
|
||||
|
@ -41,4 +42,4 @@
|
|||
}
|
||||
```
|
||||
|
||||
[Документация](../intro-rus.md) / [2D векторы](../vector2-rus.md)
|
||||
[Документация](../intro-rus.md) / [2D векторы](../vector2-rus.md)
|
||||
|
|
31
docs/vector3-eng.md
Normal file
31
docs/vector3-eng.md
Normal 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
30
docs/vector3-rus.md
Normal 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
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