Переименование s0 -> s, x1 -> x, x2 -> y, x3 -> z, что должно упростить читаемость кода. Также обновление документации

This commit is contained in:
Andrey Pokidov 2026-03-29 22:06:01 +07:00
parent d83ab7160d
commit b8d383da33
38 changed files with 2104 additions and 2070 deletions

View file

@ -4,12 +4,17 @@
### Prefixes
The library uses prefixes in names of types, constants and functions.
C programming language does not have namespaces, thus prefixes often play role
of namespaces in C code.
The library uses prefixes in names of types, constants and functions to avoid
name conflict with of othr libraries.
The main prefix is **BGC** which means **B**asic **G**eometric **C**omputations.
The structure types have prefix in the form **Bgc**. For example: BgcVector3FP64,
BgcVersorFP32, BgcMatrix2x2FP32.
The structure types and contstans have prefix in the form **Bgc**. For example:
BgcVector3FP64, BGC_FP32_Quaternion, BGC_FP32_Matrix2x2, BGC_FP32_EPSILON,
BGC_FP64_TWO_PI.
The constants have prefix in the form **BGC_**. For example: BGC_EPSYLON_FP32,
BGC_TWO_PI_FP64.
@ -31,29 +36,19 @@ Thus there are two suffixes of types:
* **FP64** - means **F**loating **P**oint, **64** bit, which corresponds to the
**double** type of the C language.
The types of structures which are based in the **float** type have **FP32** as
the type prefix: BgcVector3FP32, BgcMatrix3x2FP32, BgcQuaternionFP32.
The constants and the types of structures which are based in the **float** type
have **FP32** as the type prefix: BGC_FP32_Vector3, BGC_FP32_Matrix3x2,
BGC_FP32_Quaternion, BGC_FP32_PI, BGC_FP32_EPSILON.
The types of structures which are based in the **double** type have **FP64** as
the type prefix: BgcVector2FP64, BgcMatrix2x3FP64, BgcVersorFP64.
The constants of the **float** type have **_FP32** as the type suffix:
BGC_PI_FP32, BGC_EPSYLON_FP32.
The constants of the **double** type have **_FP64** as the type suffix:
BGC_HALF_PI_FP64, BGC_ONE_THIRD_FP64.
The constants and the types of structures which are based in the **double** type
have **FP64** as the type prefix: BGC_FP64_Vector2, BGC_FP64_Matrix2x3,
BGC_FP64_Turn3, BGC_FP64_HALF_PI, BGC_FP64_ONE_THIRD.
The functions which works with data of the **float** type have **_fp32** as
the type suffix: bgc_vector2_get_modulus_fp64, bgc_radians_to_degrees_fp32.
the type suffix: bcg_fp32_vector2_get_length, bgc_fp32_radians_to_degrees.
The functions which works with data of the **double** type have **_fp64** as
the type suffix: bgc_vector3_reset_fp64, bgc_radians_normalize_fp64.
## Entities
- [Angles](angle-eng.md)
- [Vectors 2D](vector2-eng.md)
- [Vectors 3D](vector3-eng.md)
- [Quaternions](quaternion-eng.md)
- [Versors](versor-eng.md)
the type suffix: bgc_fp64_vector3_reset, bgc_fp64_normalize_radians.
Using of such prefixes of a basic type allows to enhance the library with new
basic types in future.

View file

@ -4,26 +4,27 @@
### Префиксы
Библиотека использует префиксы в названиях типов, констант и функций.
В языке программирования C (Си) нет пространств имён, потому роль пространств
имён играют префиксы в названиях.
Библиотека использует префиксы в названиях типов, констант и функций для
того, чтобы избежать конфликтов в названиях констант, типов и функций с другими
библиотеками.
Основным префиксом является **BGC** (сокращение от **B**asic **G**eometric
**C**omputations / Базовые Геометрие Вычисления).
Для структур данных префикс имеет вид **Bgc**, например: BgcVector3FP64,
BgcVersorFP32, BgcMatrix2x2FP32.
Для констант и структур данных префикс имеет вид **BGC_**, например:
BgcVector3FP64, BGC_FP32_Quaternion, BGC_FP32_Matrix2x2, BGC_FP32_EPSILON,
BGC_FP64_TWO_PI.
Константы имеют префикс в виде **BGC_**, например: BGC_EPSYLON_FP32,
BGC_TWO_PI_FP64.
Функции имеют префикс в виде **bgc_**, например: bgc_fp32_turn3_combine,
bgc_fp64_matrix3x3_subtract.
Функции имеют префикс в виде **bgc_**, например: bgc_versor_combine_fp32,
bgc_matrix3x3_subtract_fp64.
После префикса библиотеки идёт префикс базового типа.
### Cуффиксы
Названия констант, типов и функций оканчиваются суффиксом, указывающим на
базовый тип. Библиотека использует два типа чисел с плавающей запятой:
**float** и **double** (типы **binary32** и **binary64** стандарта
**IEEE 754**).
Библиотека использует два типа чисел с плавающей запятой: **float** и **double**
(типы **binary32** и **binary64** стандарта **IEEE 754**).
Поэтому в библиотеке есть два префикса типа:
@ -33,27 +34,19 @@ bgc_matrix3x3_subtract_fp64.
* **FP64** - означает **F**loating **P**oint **64** bit, то есть, число с
плавающей запятой, 64 бита, что соответствует типу **double** языка Си.
Типы структур, использующие тип **float** имеют суффикс **FP32**:
BgcVector3FP32, BgcMatrix3x2FP32, BgcQuaternionFP32
Типы структур и константы, основанные на типе **float** имеют префикс **FP32_**:
BGC_FP32_Vector3, BGC_FP32_Matrix3x2, BGC_FP32_Quaternion, BGC_FP32_PI,
BGC_FP32_EPSILON.
Типы структур, использующие тип **double** имеют суффикс **FP64**:
BgcVector2FP64, BgcMatrix2x3FP64, BgcVersorFP64
Константы типа **float** имеют суффикс **_FP32**: BGC_PI_FP32, BGC_EPSYLON_FP32.
Константы типа **double** имеют суффикс **_FP64**: BGC_HALF_PI_FP64,
BGC_ONE_THIRD_FP64.
Типы структур и константы, основанные на типе **double** имеют префикс
**FP64_**: BGC_FP64_Vector2, BGC_FP64_Matrix2x3, BGC_FP64_Turn3,
BGC_FP64_HALF_PI, BGC_FP64_ONE_THIRD.
Функции, которые работают с данными типа **float** имеют суффикс **_fp32**:
bcg_vector2_get_modulus_fp32, bgc_radians_to_degrees_fp32.
bcg_fp32_vector2_get_length, bgc_fp32_radians_to_degrees.
Функции, которые работают с данными типа **double** имеют суффикс **_fp64**:
bgc_vector3_reset_fp64, bgc_radians_normalize_fp64.
bgc_fp64_vector3_reset, bgc_fp64_normalize_radians.
## Сущности
- [Углы](angle-rus.md)
- [2D векторы](vector2-rus.md)
- [3D векторы](vector2-rus.md)
- [Кватернионы](quaternion-rus.md)
- [Версоры](versor-rus.md)
Использование подобных префиксов позволяет расширять библиотеку используя новые
новые базовые типы в будущем.

View file

@ -1,21 +1,21 @@
# 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
- **BGC_FP32_Vector3** - vector using single-precision floating-point numbers
- **BGC_FP64_Vector3** - vector using double-precision floating-point numbers
Structure definitions:
```c
typedef struct
{
float x1, x2, x3;
} BgcVector3FP32;
float x, y, z;
} BGC_FP32_Vector3;
typedef struct
{
double x1, x2, x3;
} BgcVector3FP64;
double x, y, z;
} BGC_FP64_Vector3;
```
## Functions

View file

@ -1,30 +1,32 @@
# Трёхмерные векторы векторы
В библиотеке есть два типа двумерных векторов:
- **BgcVector3FP32** - вектор с использованием чисел с плавающей запятой одинарной точности
- **BgcVector3FP64** - вектор с использованием чисел с плавающей запятой двойной точности
В библиотеке есть два типа трёхмерных векторов:
- **BGC_FP32_Vector3** - вектор с использованием чисел с плавающей запятой
одинарной точности
- **BGC_FP64_Vector3** - вектор с использованием чисел с плавающей запятой
двойной точности
Определения структур:
```c
typedef struct
{
float x1, x2, x3;
} BgcVector3FP32;
float x, y, z;
} BGC_FP32_Vector3;
typedef struct
{
double x1, x2, x3;
} BgcVector3FP64;
double x, y, z;
} BGC_FP64_Vector3;
```
## Функции
| Функции для 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) |
| [bgc_fp32_vector3_reset](vector3/reset-rus.md) | [bgc_fp64_vector3_reset](vector3/reset-rus.md) |
| [bgc_fp32_vector3_set_values](vector3/set-values-rus.md) | [bgc_fp64_vector3_set_values](vector3/set-values-rus.md) |
| [bgc_fp32_vector3_copy](vector3/copy-rus.md) | [bgc_fp64_vector3_copy](vector3/copy-rus.md) |
| [bgc_fp32_vector3_swap](vector3/swap-rus.md) | [bgc_fp64_vector3_swap](vector3/swap-rus.md) |
[Документация](intro-rus.md)

View file

@ -1,32 +1,39 @@
# Copying
The copy functions allow you to copy the coordinate values of one vector to another vector.
The copy functions allow you to copy the coordinate values of one vector
to another vector.
Function for **BgcVector3FP32**:
Function for **BGC_FP32_Vector3**:
```c
inline void bgc_vector3_copy_fp32(const BgcVector3FP32* from, BgcVector3FP32* to);
inline void bgc_fp32_vector3_copy(BGC_FP32_Vector3* const destination, const BGC_FP32_Vector3* const source);
```
Function for **BgcVector3FP64**:
Function for **BGC_FP64_Vector3**:
```c
inline void bgc_vector3_copy_fp64(const BgcVector3FP64* from, BgcVector3FP64* to);
inline void bgc_fp64_vector3_copy(BGC_FP64_Vector3* const destination, const BGC_FP64_Vector3* const source);
```
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;
destination->x = source->x;
destination->y = source->y;
destination->z = source->z;
```
The **from** and **to** parameters must not be invalid pointers. The NULL (0) value is also considered invalid.
The **source** and **destination** 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 **source** parameter must be a pointer to a three-dimensional vector whose
coordinates are to be copied. The coordinates of the **source** 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.
The **destination** parameter must be a pointer to a three-dimensional vector
whose coordinates are to be changed. The coordinates of the **destination**
vector will become the same as those of the **source** vector after the function
call.
Example of use:
@ -36,13 +43,15 @@ Example of use:
int main()
{
BgcVector3FP32 my_vector1, my_vector3;
BGC_FP32_Vector3 my_vector1, my_vector2;
bgc_vector3_set_values_fp32(-2, 7, 1, &my_vector1);
my_vector1.x = -2.0f;
my_vector1.y = 7.4f;
my_vector1.z = 1.8f;
bgc_vector3_copy_fp32(&my_vector1, &my_vector3);
bgc_fp32_vector3_copy(&my_vector2, &my_vector1);
printf("x1 = %f, x2 = %f, x3 = %f\n", my_vector3.x1, my_vector3.x2, my_vector3.x3);
printf("x = %f, y = %f, z = %f\n", my_vector2.x, my_vector2.y, my_vector2.z);
return 0;
}

View file

@ -1,32 +1,38 @@
# Копирование
Функции копирования позволяют скопировать значения координат одного вектора в другой вектор.
Ôóíêöèè êîïèðîâàíèÿ ïîçâîëÿþò ñêîïèðîâàòü çíà÷åíèÿ êîîðäèíàò îäíîãî âåêòîðà
â äðóãîé âåêòîð.
Функция для **BgcVector3FP32**:
Ôóíêöèÿ äëÿ **BGC_FP32_Vector3**:
```c
inline void bgc_vector3_copy_fp32(const BgcVector3FP32* from, BgcVector3FP32* to);
inline void bgc_fp32_vector3_copy(BGC_FP32_Vector3* const destination, const BGC_FP32_Vector3* const source);
```
Функция для **BgcVector3FP64**:
Ôóíêöèÿ äëÿ **BGC_FP64_Vector3**:
```c
inline void bgc_vector3_copy_fp64(const BgcVector3FP64* from, BgcVector3FP64* to);
inline void bgc_fp64_vector3_copy(BGC_FP64_Vector3* const destination, const BGC_FP64_Vector3* const source);
```
Каждая из данных функции эквивалентна следующим строкам кода:
```c
to->x1 = from->x1;
to->x2 = from->x2;
to->x3 = from->x3;
destination->x = source->x;
destination->y = source->y;
destination->z = source->z;
```
Параметры **from** и **to** не должны быть некорректными указателями. Значение NULL (0) также считается некорректным.
Ïàðàìåòðû **source** è **destination** íå äîëæíû áûòü íåêîððåêòíûìè óêàçàòåëÿìè.
Çíà÷åíèå NULL (0) òàêæå ñ÷èòàåòñÿ íåêîððåêòíûì.
Параметр **from** должен быть указателем на трёхмерный вектор, координаты которого должны быть скопированы. Координаты вектора **from** не изменятся после вызова функции.
Ïàðàìåòð **source** äîëæåí áûòü óêàçàòåëåì íà òð¸õìåðíûé âåêòîð, êîîðäèíàòû
êîòîðîãî äîëæíû áûòü ñêîïèðîâàíû. Êîîðäèíàòû âåêòîðà **source** íå èçìåíÿòñÿ
ïîñëå âûçîâà ôóíêöèè.
Параметр **to** должен быть указателем на трёхмерный вектор, координаты которого должны быть изменены. Координаты вектора **to** после вызова функции станут такими же, как и у вектора **from**.
Ïàðàìåòð **destination** äîëæåí áûòü óêàçàòåëåì íà òð¸õìåðíûé âåêòîð, êîîðäèíàòû
êîòîðîãî äîëæíû áûòü èçìåíåíû. Êîîðäèíàòû âåêòîðà **destination** ïîñëå âûçîâà
ôóíêöèè ñòàíóò òàêèìè æå, êàê è ó âåêòîðà **source**.
Пример применения:
@ -36,13 +42,15 @@ to->x3 = from->x3;
int main()
{
BgcVector3FP32 my_vector1, my_vector3;
BGC_FP32_Vector3 my_vector1, my_vector2;
bgc_vector3_set_values_fp32(-2, 7, 1, &my_vector1);
my_vector1.x = -2.0f;
my_vector1.y = 7.4f;
my_vector1.z = 1.8f;
bgc_vector3_copy_fp32(&my_vector1, &my_vector3);
bgc_fp32_vector3_copy(&my_vector2, &my_vector1);
printf("x1 = %f, x2 = %f, x3 = %f\n", my_vector3.x1, my_vector3.x2, my_vector3.x3);
printf("x = %f, y = %f, z = %f\n", my_vector2.x, my_vector2.y, my_vector2.z);
return 0;
}

View file

@ -2,27 +2,30 @@
These functions set all coordinates of 3D vectors to 0.
Function for **BgcVector3FP32**:
Function for **BGC_FP32_Vector3**:
```c
inline void bgc_vector3_reset_fp32(BgcVector3FP32* vector);
inline void bgc_fp32_vector3_reset(BGC_FP32_Vector3* vector);
```
Function for **BgcVector3FP64**:
Function for **BGC_FP64_Vector3**:
```c
inline void bgc_vector3_reset_fp64(BgcVector3FP64* vector);
inline void bgc_fp64_vector3_reset(BGC_FP64_Vector3* vector);
```
Each of these functions is equivalent to the following lines of code:
```c
vector->x1 = 0;
vector->x2 = 0;
vector->x3 = 0;
vector->x = 0;
vector->y = 0;
vector->z = 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.
This function is good for setting up the initial state of a 3D vector.
Example of use:
@ -32,11 +35,11 @@ Example of use:
int main()
{
BgcVector3FP32 my_vector;
BGC_FP32_Vector3 my_vector;
bgc_vector3_reset_fp32(&my_vector);
bgc_fp32_vector3_reset(&my_vector);
printf("x1 = %f, x2 = %f, x3 = %f\n", my_vector.x1, my_vector.x2, my_vector.x3);
printf("x = %f, y = %f, z = %f\n", my_vector.x, my_vector.y, my_vector.z);
return 0;
}

View file

@ -2,27 +2,30 @@
Функции устанавливают значение 0 всем координатам трёхмерных векторов.
Ôóíêöèÿ äëÿ **BgcVector3FP32**:
Ôóíêöèÿ äëÿ **BGC_FP32_Vector3**:
```c
inline void bgc_vector3_reset_fp32(BgcVector3FP32* vector);
inline void bgc_fp32_vector3_reset(BGC_FP32_Vector3* vector);
```
Ôóíêöèÿ äëÿ **BgcVector3FP64**:
Ôóíêöèÿ äëÿ **BGC_FP64_Vector3**:
```c
inline void bgc_vector3_reset_fp64(BgcVector3FP64* vector);
inline void bgc_fp64_vector3_reset(BGC_FP64_Vector3* vector);
```
Каждая из данных функции эквивалентна следующим строкам кода:
```c
vector->x1 = 0;
vector->x2 = 0;
vector->x3 = 0;
vector->x = 0;
vector->y = 0;
vector->z = 0;
```
 äàííûå ôóíêöèè íå ñëåäóåò ïåðåäàâàòü íåêîððåêòíûå óêàçàòåëè. Çíà÷åíèå NULL (0) òàêæå ñ÷èòàåòñÿ íåêîððåêòíûì.
 äàííûå ôóíêöèè íå ñëåäóåò ïåðåäàâàòü íåêîððåêòíûå óêàçàòåëè. Çíà÷åíèå NULL (0)
òàêæå ñ÷èòàåòñÿ íåêîððåêòíûì.
Äàííàÿ ôóíêöèÿ õîðîøî ïîäõîäèò äëÿ èíèöèàëèçàöèè íà÷àëüíîãî ñîñòîÿíèÿ âåêòîðà.
Пример применения:
@ -32,11 +35,11 @@ vector->x3 = 0;
int main()
{
BgcVector3FP32 my_vector;
BGC_FP32_Vector3 my_vector;
bgc_vector3_reset_fp32(&my_vector);
bgc_fp32_vector3_reset(&my_vector);
printf("x1 = %f, x2 = %f, x3 = %f\n", my_vector.x1, my_vector.x2, my_vector.x3);
printf("x = %f, y = %f, z = %f\n", my_vector.x, my_vector.y, my_vector.z);
return 0;
}

View file

@ -1,28 +1,34 @@
# 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.
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**:
Function for **BGC_FP32_Vector3**:
```c
inline void bgc_vector3_set_values_fp32(const float x1, const float x2, const float x3, BgcVector3FP32* to);
inline void bgc_fp32_vector3_set_values(BGC_FP32_Vector3* const destination, const float x, const float y, const float z);
```
Function for **BgcVector3FP32**:
Function for **BGC_FP64_Vector3**:
```c
inline void bgc_vector3_set_values_fp64(const double x1, const double x2, const double x3, BgcVector3FP64* to);
inline void bgc_fp64_vector3_set_values(BGC_FP64_Vector3* const destination, const double x, const double y, const double z);
```
Each of these functions is equivalent to the following lines of code:
```c
to->x1 = x1;
to->x2 = x2;
to->x3 = x3;
destination->x = x;
destination->y = y;
destination->z = z;
```
Invalid pointers should not be passed in the **to** parameter. The NULL (0) value is also considered invalid.
Invalid pointers should not be passed in the **destination** parameter.
The NULL (0) value is also considered invalid.
This function is good for setting up the initial values of coordinates with
one-line especially when the values are fixed constants like in the example
below.
Example of use:
@ -32,11 +38,11 @@ Example of use:
int main()
{
BgcVector3FP32 my_vector;
BGC_FP32_Vector3 my_vector;
bgc_vector3_set_values_fp32(-2, 7, 10, &my_vector);
bgc_fp32_vector3_set_values(&my_vector, -2.2f, 7.1f, 10.01f);
printf("x1 = %f, x2 = %f, x3 = %f\n", my_vector.x1, my_vector.x2, my_vector.x3);
printf("x = %f, y = %f, z = %f\n", my_vector.x, my_vector.y, my_vector.z);
return 0;
}

View file

@ -1,28 +1,35 @@
# Задание координат трёхмерного вектора
# Указание координат трёхмерного вектора
Задавать координаты векторов можно как напрямую, так и спомощью функций. Функции задания значений координат позволяют сделать это одной строкой.
Указать координаты векторов можно как напрямую, так и спомощью функций.
Принципиальной разницы нет, но функции указания координат позволяют сделать это
одной строкой.
Функция для **BgcVector3FP32**:
Функция для **BGC_FP32_Vector3**:
```c
inline void bgc_vector3_set_values_fp32(const float x1, const float x2, const float x3, BgcVector3FP32* to);
inline void bgc_fp32_vector3_set_values(BGC_FP32_Vector3* const destination, const float x, const float y, const float z);
```
Функция для **BgcVector3FP32**:
Функция для **BGC_FP64_Vector3**:
```c
inline void bgc_vector3_set_values_fp64(const double x1, const double x2, const double x3, BgcVector3FP64* to);
inline void bgc_fp64_vector3_set_values(BGC_FP64_Vector3* const destination, const double x, const double y, const double z);
```
Каждая из данных функции эквивалентна следующим строкам кода:
```c
to->x1 = x1;
to->x2 = x2;
to->x3 = x3;
destination->x = x;
destination->y = y;
destination->z = z;
```
В параметре **to** не следует передавать некорректные указатели. Значение NULL (0) также считается некорректным.
В параметре **destination** не следует передавать некорректные указатели.
Значение NULL (0) также считается некорректным.
Данная функция хорошо подходит для заданя значений координат вектора одной
строкой. Особенно если надо указать фиксированные значения координат как
в примере ниже.
Пример применения:
@ -32,11 +39,11 @@ to->x3 = x3;
int main()
{
BgcVector3FP32 my_vector;
BGC_FP32_Vector3 my_vector;
bgc_vector3_set_values_fp32(-2, 7, 10, &my_vector);
bgc_fp32_vector3_set_values(&my_vector, -2.2f, 7.1f, 10.01f);
printf("x1 = %f, x2 = %f, x3 = %f\n", my_vector.x1, my_vector.x2, my_vector.x3);
printf("x = %f, y = %f, z = %f\n", my_vector.x, my_vector.y, my_vector.z);
return 0;
}

View file

@ -1,24 +1,28 @@
# Swapping
The exchange functions allow two vectors of the same type to exchange coordinate values.
The exchange functions allow two vectors of the same type to exchange coordinate
values.
Function for **BgcVector3FP32**:
Function for **BGC_FP32_Vector3**:
```c
inline void bgc_vector3_swap_fp32(BgcVector3FP32* vector1, BgcVector3FP32* vector2);
inline void bgc_fp32_vector3_swap(BGC_FP32_Vector3* const vector1, BGC_FP32_Vector3* const vector2);
```
Function for **BgcVector3FP32**:
Function for **BGC_FP64_Vector3**:
```c
inline void bgc_vector3_swap_fp64(BgcVector3FP64* vector1, BgcVector3FP64* vector2);
inline void bgc_fp64_vector3_swap(BGC_FP64_Vector3* const vector1, BGC_FP64_Vector3* const vector2);
```
The **vector1** and **vector2** parameters must not be invalid pointers. The NULL (0) value is also considered invalid.
The **vector1** and **vector2** parameters must be valid pointers.
The NULL (0) value is considered invalid.
Vector **vector1** after calling this function will have the coordinate values that vector **vector3** had before calling the function.
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.
And vector **vector3** after calling this function will have the same coordinate
values that vector **vector1** had before calling the function.
Example of use:
@ -28,15 +32,15 @@ Example of use:
int main()
{
BgcVector3FP32 my_vector1, my_vector2;
BGC_FP32_Vector3 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_fp32_vector3_set_values(&my_vector1, -2, 7, 5);
bgc_fp32_vector3_set_values(&my_vector2, 10, -1, -3);
bgc_vector3_swap_fp32(&my_vector1, &my_vector2);
bgc_fp32_vector3_swap(&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);
printf("Vector #1: x = %f, y = %f, z = %f\n", my_vector1.x, my_vector1.y, my_vector1.z);
printf("Vector #2: x = %f, y = %f, z = %f\n", my_vector2.x, my_vector2.y, my_vector2.z);
return 0;
}
@ -45,8 +49,8 @@ int main()
Result:
```
Vector #1: x1 = 10.000000, x2 = -1.000000, x3 = -3.000000
Vector #2: x1 = -2.000000, x2 = 7.000000, x3 = 5.000000
Vector #1: x = 10.000000, y = -1.000000, z = -3.000000
Vector #2: x = -2.000000, y = 7.000000, z = 5.000000
```
[Documentation](../intro-eng.md) / [3D vectors](../vector3-eng.md)

View file

@ -1,6 +1,7 @@
# Обмен
# Обмен значениями
Функции обмена позволяют двум векторам одного типа обменяться значениями координат.
Функции обмена позволяют двум векторам одного типа обменяться значениями
координат.
Функция для **BgcVector3FP32**:
@ -14,11 +15,14 @@ inline void bgc_vector3_swap_fp32(BgcVector3FP32* vector1, BgcVector3FP32* vecto
inline void bgc_vector3_swap_fp64(BgcVector3FP64* vector1, BgcVector3FP64* vector2);
```
Параметры **vector1** и **vector2** не должны быть некорректными указателями. Значение NULL (0) также считается некорректным.
Параметры **vector1** и **vector2** не должны быть некорректными указателями.
Значение NULL (0) также считается некорректным.
Вектор **vector1** после вызова данной функции будет иметь значения координат, какие имел вектор **vector2** до вызова функции.
Вектор **vector1** после вызова данной функции будет иметь значения координат,
какие имел вектор **vector2** до вызова функции.
А вектор **vector2** после вызова данной функции будет иметь такие же значения координат, какие имел вектор **vector1** до вызова функции.
А вектор **vector2** после вызова данной функции будет иметь такие же значения
координат, какие имел вектор **vector1** до вызова функции.
Пример применения:
@ -28,15 +32,15 @@ inline void bgc_vector3_swap_fp64(BgcVector3FP64* vector1, BgcVector3FP64* vecto
int main()
{
BgcVector3FP32 my_vector1, my_vector2;
BGC_FP32_Vector3 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_fp32_vector3_set_values(&my_vector1, -2, 7, 5);
bgc_fp32_vector3_set_values(&my_vector2, 10, -1, -3);
bgc_vector3_swap_fp32(&my_vector1, &my_vector2);
bgc_fp32_vector3_swap(&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);
printf("Vector #1: x = %f, y = %f, z = %f\n", my_vector1.x, my_vector1.y, my_vector1.z);
printf("Vector #2: x = %f, y = %f, z = %f\n", my_vector2.x, my_vector2.y, my_vector2.z);
return 0;
}
@ -45,8 +49,8 @@ int main()
Результат:
```
Vector #1: x1 = 10.000000, x2 = -1.000000, x3 = -3.000000
Vector #2: x1 = -2.000000, x2 = 7.000000, x3 = 5.000000
Vector #1: x = 10.000000, y = -1.000000, z = -3.000000
Vector #2: x = -2.000000, y = 7.000000, z = 5.000000
```
[Документация](../intro-rus.md) / [3D векторы](../vector3-rus.md)