Обновление документации по векторам и кватернионам

This commit is contained in:
Andrey Pokidov 2026-03-30 01:05:57 +07:00
parent 2fd2578bb3
commit 460fe94830
20 changed files with 237 additions and 138 deletions

View file

@ -1,5 +1,7 @@
# Basic Geomtric Computations # Basic Geomtric Computations
[Русская версия / Russian version](intro-rus.md)
## Naming ## Naming
### Prefixes ### Prefixes
@ -13,14 +15,14 @@ name conflict with of othr libraries.
The main prefix is **BGC** which means **B**asic **G**eometric **C**omputations. The main prefix is **BGC** which means **B**asic **G**eometric **C**omputations.
The structure types and contstans have prefix in the form **Bgc**. For example: 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_Vector3, BGC_FP32_Quaternion, BGC_FP32_Matrix2x2, BGC_FP32_EPSILON,
BGC_FP64_TWO_PI. BGC_FP64_TWO_PI.
The constants have prefix in the form **BGC_**. For example: BGC_EPSYLON_FP32, The constants have prefix in the form **BGC_**. For example: BGC_EPSYLON_FP32,
BGC_TWO_PI_FP64. BGC_TWO_PI_FP64.
The functions have prefix in the form **bgc_**. For example: The functions have prefix in the form **bgc_**. For example:
bgc_versor_combine_fp32, bgc_matrix3x3_subtract_fp32. bgc_fp32_turn3_combine, bgc_fp64_matrix3x3_subtract.
### Suffixes ### Suffixes

View file

@ -1,5 +1,7 @@
# Библиотека базовых геометрических вычислений # Библиотека базовых геометрических вычислений
[English version / Английская версия](intro-eng.md)
## Особенности наименования ## Особенности наименования
### Префиксы ### Префиксы
@ -15,7 +17,7 @@
**C**omputations / Базовые Геометрие Вычисления). **C**omputations / Базовые Геометрие Вычисления).
Для констант и структур данных префикс имеет вид **BGC_**, например: Для констант и структур данных префикс имеет вид **BGC_**, например:
BgcVector3FP64, BGC_FP32_Quaternion, BGC_FP32_Matrix2x2, BGC_FP32_EPSILON, BGC_FP64_Vector3, BGC_FP32_Quaternion, BGC_FP32_Matrix2x2, BGC_FP32_EPSILON,
BGC_FP64_TWO_PI. BGC_FP64_TWO_PI.
Функции имеют префикс в виде **bgc_**, например: bgc_fp32_turn3_combine, Функции имеют префикс в виде **bgc_**, например: bgc_fp32_turn3_combine,
@ -49,4 +51,4 @@ bcg_fp32_vector2_get_length, bgc_fp32_radians_to_degrees.
bgc_fp64_vector3_reset, bgc_fp64_normalize_radians. bgc_fp64_vector3_reset, bgc_fp64_normalize_radians.
Использование подобных префиксов позволяет расширять библиотеку используя новые Использование подобных префиксов позволяет расширять библиотеку используя новые
новые базовые типы в будущем. базовые типы в будущем.

View file

@ -1,6 +1,6 @@
# Quaternions # Quaternions
[Ðóññêàÿ âåðñèÿ / Russian version](quaternion-rus.md) [Русская версия / Russian version](quaternion-rus.md)
Quaternions are hypercomplex numbers that extend the concept of complex numbers. Quaternions are hypercomplex numbers that extend the concept of complex numbers.
They consist of one real component and three imaginary components: They consist of one real component and three imaginary components:
@ -38,7 +38,7 @@ Structure definitions:
``` ```
Fields: Fields:
- **s** is the real part of the quaternion. It is named after the word Scalar. - **s** is the real part of the quaternion. It is named after the word "scalar".
- **x**, **y**, **z** - Imaginary components of the quaternion. - **x**, **y**, **z** - Imaginary components of the quaternion.
[Documentation](intro-eng.md) [Documentation](intro-eng.md)

View file

@ -39,7 +39,7 @@ q = s + ix + jy + kz
Поля: Поля:
- **s** - это вещественная часть кватерниона, буква выбрана от английского слова - **s** - это вещественная часть кватерниона, буква выбрана от английского слова
scalar - скалярная величина. "scalar" - скалярная величина.
- **x**, **y**, **z** - мнимые компоненты кватерниона. - **x**, **y**, **z** - мнимые компоненты кватерниона.
[Документация](intro-rus.md) [Документация](intro-rus.md)

View file

@ -1,6 +1,6 @@
# Two-dimensional vectors # Two-dimensional vectors
[Ðóññêàÿ âåðñèÿ / Russian version](vector2-rus.md) [Русская версия / Russian version](vector2-rus.md)
There are two types of 2D vectors in the library: There are two types of 2D vectors in the library:
- **BGC_FP32_Vector2** - vector using single-precision floating-point numbers - **BGC_FP32_Vector2** - vector using single-precision floating-point numbers
@ -22,12 +22,21 @@ Structure definitions:
## Functions ## Functions
| Funtions for BGC_FP32_Vector2 | Funtions for BGC_FP64_Vector2 | - [Reset](vector2/reset-eng.md)
|:-------------------------------------------------------------:|:-------------------------------------------------------------:| - bgc_fp32_vector2_reset
| [bgc_fp32_vector2_reset](vector2/reset-eng.md) | [bgc_fp64_vector2_reset](vector2/reset-eng.md) | - bgc_fp64_vector2_reset
| [bgc_fp32_vector2_set_values](vector2/set-values-eng.md) | [bgc_fp64_vector2_set_values](vector2/set-values-eng.md) |
| [bgc_fp32_vector2_copy](vector2/copy-eng.md) | [bgc_fp64_vector2_copy](vector2/copy-eng.md) | - [Set Values](vector2/set-values-eng.md)
| [bgc_fp32_vector2_swap](vector2/swap-eng.md) | [bgc_fp64_vector2_swap](vector2/swap-eng.md) | - bgc_fp32_vector2_set_values
- bgc_fp64_vector2_set_values
- [Copy](vector2/copy-eng.md)
- bgc_fp32_vector2_copy
- bgc_fp64_vector2_copy
- [Swap](vector2/swap-eng.md)
- bgc_fp32_vector2_swap
- bgc_fp64_vector2_swap
[Documentation](intro-eng.md) [Documentation](intro-eng.md)

View file

@ -3,9 +3,9 @@
[English version / Английская версия](vector2-eng.md) [English version / Английская версия](vector2-eng.md)
В библиотеке есть два типа двумерных векторов: В библиотеке есть два типа двумерных векторов:
- **BGC_FP32_Vector3** - вектор с использованием чисел с плавающей запятой - **BGC_FP32_Vector2** - вектор с использованием чисел с плавающей запятой
одинарной точности одинарной точности
- **BGC_FP64_Vector3** - вектор с использованием чисел с плавающей запятой - **BGC_FP64_Vector2** - вектор с использованием чисел с плавающей запятой
двойной точности двойной точности
Определения структур: Определения структур:
@ -24,11 +24,20 @@
## Функции ## Функции
| Функции для BGC_FP32_Vector2 | Функции для BGC_FP64_Vector2 | - [Сброс](vector2/reset-rus.md)
|:-------------------------------------------------------------:|:-------------------------------------------------------------:| - bgc_fp32_vector2_reset
| [bgc_fp32_vector2_reset](vector2/reset-rus.md) | [bgc_fp64_vector2_reset](vector2/reset-rus.md) | - bgc_fp64_vector2_reset
| [bgc_fp32_vector2_set_values](vector2/set-values-rus.md) | [bgc_fp64_vector2_set_values](vector2/set-values-rus.md) |
| [bgc_fp32_vector2_copy](vector2/copy-rus.md) | [bgc_fp64_vector2_copy](vector2/copy-rus.md) | - [Установка координат](vector2/set-values-rus.md)
| [bgc_fp32_vector2_swap](vector2/swap-rus.md) | [bgc_fp64_vector2_swap](vector2/swap-rus.md) | - bgc_fp32_vector2_set_values
- bgc_fp64_vector2_set_values
- [Копирование](vector2/copy-rus.md)
- bgc_fp32_vector2_copy
- bgc_fp64_vector2_copy
- [Обмен значениями](vector2/swap-rus.md)
- bgc_fp32_vector2_swap
- bgc_fp64_vector2_swap
[Документация](intro-rus.md) [Документация](intro-rus.md)

View file

@ -1,31 +1,39 @@
# Copying # Copying
[Русская версия / Russian version](copy-rus.md)
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 **BgcVector2FP32**: Function for **BGC_FP32_Vector2**:
```c ```c
inline void bgc_vector2_copy_fp32(const BgcVector2FP32* from, BgcVector2FP32* to); inline void bgc_fp32_vector2_copy(BGC_FP32_Vector2* const destination, const BGC_FP32_Vector2* const source);
``` ```
Function for **BgcVector2FP64**: Function for **BGC_FP64_Vector2**:
```c ```c
inline void bgc_vector2_copy_fp64(const BgcVector2FP64* from, BgcVector2FP64* to); inline void bgc_fp64_vector2_copy(BGC_FP64_Vector2* const destination, const BGC_FP64_Vector2* const source);
``` ```
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; destination->x = source->x;
to->x2 = from->x2; destination->y = source->y;
``` ```
The **from** and **to** parameters must not be invalid pointers. The NULL (0) value is also considered invalid. The **source** and **destination** parameters must be valid 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 **source** parameter must be a pointer to a two-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 two-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 two-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: Example of use:
@ -35,13 +43,14 @@ Example of use:
int main() int main()
{ {
BgcVector2FP32 my_vector1, my_vector2; BGC_FP32_Vector2 my_vector1, my_vector2;
bgc_vector2_set_values_fp32(-2, 7, &my_vector1); my_vector1.x = -2.0f;
my_vector1.y = 7.4f;
bgc_vector2_copy_fp32(&my_vector1, &my_vector2); bgc_fp32_vector2_copy(&my_vector2, &my_vector1);
printf("x1 = %f, x2 = %f\n", my_vector2.x1, my_vector2.x2); printf("x = %f, y = %f\n", my_vector2.x, my_vector2.y);
return 0; return 0;
} }

View file

@ -1,31 +1,39 @@
# Копирование # Копирование
Функции копирования позволяют скопировать значения координат одного вектора в другой вектор. [English version / Àíãëèéñêàÿ âåðñèÿ](copy-eng.md)
Функция для **BgcVector2FP32**: Ôóíêöèè êîïèðîâàíèÿ ïîçâîëÿþò ñêîïèðîâàòü çíà÷åíèÿ êîîðäèíàò îäíîãî âåêòîðà
â äðóãîé âåêòîð.
Ôóíêöèÿ äëÿ **BGC_FP32_Vector2**:
```c ```c
inline void bgc_vector2_copy_fp32(const BgcVector2FP32* from, BgcVector2FP32* to); inline void bgc_fp32_vector2_copy(BGC_FP32_Vector2* const destination, const BGC_FP32_Vector2* const source);
``` ```
Функция для **BgcVector2FP64**: Ôóíêöèÿ äëÿ **BGC_FP64_Vector2**:
```c ```c
inline void bgc_vector2_copy_fp64(const BgcVector2FP64* from, BgcVector2FP64* to); inline void bgc_fp64_vector2_copy(BGC_FP64_Vector2* const destination, const BGC_FP64_Vector2* const source);
``` ```
Каждая из данных функции эквивалентна следующим строкам кода: Каждая из данных функции эквивалентна следующим строкам кода:
```c ```c
to->x1 = from->x1; destination->x = source->x;
to->x2 = from->x2; destination->y = source->y;
``` ```
Параметры **from** и **to** не должны быть некорректными указателями. Значение NULL (0) также считается некорректным. Ïàðàìåòðû **source** è **destination** äîëæíû áûòü êîððåêòíûìè óêàçàòåëÿìè.
Çíà÷åíèå NULL (0) òàêæå ñ÷èòàåòñÿ íåêîððåêòíûì.
Параметр **from** должен быть указателем на двумерный вектор, координаты которого должны быть скопированы. Координаты вектора **from** не изменятся после вызова функции. Ïàðàìåòð **source** äîëæåí áûòü óêàçàòåëåì íà äâóìåðíûé âåêòîð, êîîðäèíàòû
êîòîðîãî äîëæíû áûòü ñêîïèðîâàíû. Êîîðäèíàòû âåêòîðà **source** íå èçìåíÿòñÿ
ïîñëå âûçîâà ôóíêöèè.
Параметр **to** должен быть указателем на двумерный вектор, координаты которого должны быть изменены. Координаты вектора **to** после вызова функции станут такими же, как и у вектора **from**. Ïàðàìåòð **destination** äîëæåí áûòü óêàçàòåëåì íà äâóìåðíûé âåêòîð, êîîðäèíàòû
êîòîðîãî äîëæíû áûòü èçìåíåíû. Êîîðäèíàòû âåêòîðà **destination** ïîñëå âûçîâà
ôóíêöèè ñòàíóò òàêèìè æå, êàê è ó âåêòîðà **source**.
Пример применения: Пример применения:
@ -35,13 +43,14 @@ to->x2 = from->x2;
int main() int main()
{ {
BgcVector2FP32 my_vector1, my_vector2; BGC_FP32_Vector2 my_vector1, my_vector2;
bgc_vector2_set_values_fp32(-2, 7, &my_vector1); my_vector1.x = -2.0f;
my_vector1.y = 7.4f;
bgc_vector2_copy_fp32(&my_vector1, &my_vector2); bgc_fp32_vector2_copy(&my_vector2, &my_vector1);
printf("x1 = %f, x2 = %f\n", my_vector2.x1, my_vector2.x2); printf("x = %f, y = %f\n", my_vector2.x, my_vector2.y);
return 0; return 0;
} }

View file

@ -1,27 +1,32 @@
# Resetting the state of a 2D vector # Resetting the state of a 2D vector
[Русская версия / Russian version](reset-rus.md)
These functions set all coordinates of 2D vectors to 0. These functions set all coordinates of 2D vectors to 0.
Function for **BgcVector2FP32**: Function for **BGC_FP32_Vector2**:
```c ```c
inline void bgc_vector2_reset_fp32(BgcVector2FP32* vector); inline void bgc_fp32_vector2_reset(BGC_FP32_Vector2* const vector);
``` ```
Function for **BgcVector2FP64**: Function for **BGC_FP64_Vector2**:
```c ```c
inline void bgc_vector2_reset_fp64(BgcVector2FP64* vector); inline void bgc_fp64_vector2_reset(BGC_FP64_Vector2* const 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->x = 0;
vector->x2 = 0; vector->y = 0;
``` ```
You should not pass invalid pointers to these functions. The NULL (0) value is also considered invalid. You should pass valid 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: Example of use:
@ -31,11 +36,11 @@ Example of use:
int main() int main()
{ {
BgcVector2FP32 my_vector; BGC_FP32_Vector2 my_vector;
bgc_vector2_reset_fp32(&my_vector); bgc_fp32_vector2_reset(&my_vector);
printf("x1 = %f, x2 = %f\n", my_vector.x1, my_vector.x2); printf("x = %f, y = %f\n", my_vector.x1, my_vector.x2);
return 0; return 0;
} }

View file

@ -1,27 +1,32 @@
# Сброс состояния двумерного вектора # Сброс состояния двумерного вектора
[English version / Àíãëèéñêàÿ âåðñèÿ](reset-eng.md)
Функции устанавливают значение 0 всем координатам двумерных векторов. Функции устанавливают значение 0 всем координатам двумерных векторов.
Ôóíêöèÿ äëÿ **BgcVector2FP32**: Ôóíêöèÿ äëÿ **BGC_FP32_Vector2**:
```c ```c
inline void bgc_vector2_reset_fp32(BgcVector2FP32* vector); inline void bgc_fp32_vector2_reset(BGC_FP32_Vector2* const vector);
``` ```
Ôóíêöèÿ äëÿ **BgcVector2FP64**: Ôóíêöèÿ äëÿ **BGC_FP64_Vector2**:
```c ```c
inline void bgc_vector2_reset_fp64(BgcVector2FP64* vector); inline void bgc_fp64_vector2_reset(BGC_FP64_Vector2* const vector);
``` ```
Каждая из данных функции эквивалентна следующим строкам кода: Каждая из данных функции эквивалентна следующим строкам кода:
```c ```c
vector->x1 = 0; vector->x = 0;
vector->x2 = 0; vector->y = 0;
``` ```
 ïàðàìåòðå **vector** íå ñëåäóåò ïåðåäàâàòü íåêîððåêòíûå óêàçàòåëè. Çíà÷åíèå NULL (0) òàêæå ñ÷èòàåòñÿ íåêîððåêòíûì.  ïàðàìåòðå **vector** ñëåäóåò ïåðåäàâàòü êîððåêòíûå óêàçàòåëè. Çíà÷åíèå
NULL (0) òàêæå ñ÷èòàåòñÿ íåêîððåêòíûì.
Äàííàÿ ôóíêöèÿ õîðîøî ïîäõîäèò äëÿ èíèöèàëèçàöèè íà÷àëüíîãî ñîñòîÿíèÿ âåêòîðà.
Пример применения: Пример применения:
@ -31,11 +36,11 @@ vector->x2 = 0;
int main() int main()
{ {
BgcVector2FP32 my_vector; BGC_FP32_Vector2 my_vector;
bgc_vector2_reset_fp32(&my_vector); bgc_fp32_vector2_reset(&my_vector);
printf("x1 = %f, x2 = %f\n", my_vector.x1, my_vector.x2); printf("x = %f, y = %f\n", my_vector.x1, my_vector.x2);
return 0; return 0;
} }

View file

@ -1,27 +1,35 @@
# Setting the coordinates of a two-dimensional vector # Setting the coordinates of a two-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. [Русская версия / Russian version](set-values-rus.md)
Function for **BgcVector2FP32**: 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 **BGC_FP32_Vector2**:
```c ```c
inline void bgc_vector2_set_values_fp32(const float x1, const float x2, BgcVector2FP32* to); inline void bgc_fp32_vector2_set_values(BGC_FP32_Vector2* const destination, const float x, const float y);
``` ```
Function for **BgcVector2FP32**: Function for **BGC_FP64_Vector2**:
```c ```c
inline void bgc_vector2_set_values_fp64(const double x1, const double x2, BgcVector2FP64* to); inline void bgc_fp64_vector2_set_values(BGC_FP64_Vector2* const destination, const double x, const double y);
``` ```
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 = x1; destination->x = x;
to->x2 = x2; destination->y = y;
``` ```
Invalid pointers should not be passed in the **to** parameter. The NULL (0) value is also considered invalid. Valid pointers should pass in the **destination** parameter.
The NULL (0) value is 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: Example of use:
@ -31,11 +39,11 @@ Example of use:
int main() int main()
{ {
BgcVector2FP32 my_vector; BGC_FP32_Vector2 my_vector;
bgc_vector2_set_values_fp32(-2, 7, &my_vector); bgc_fp32_vector2_set_values(&my_vector, -2.2f, 7.1f);
printf("x1 = %f, x2 = %f\n", my_vector.x1, my_vector.x2); printf("x = %f, y = %f\n", my_vector.x, my_vector.y);
return 0; return 0;
} }

View file

@ -1,27 +1,35 @@
# Задание координат двумерного вектора # Задание координат двумерного вектора
Задавать координаты векторов можно как напрямую, так и спомощью функций. Функции задания значений координат позволяют сделать это одной строкой. [English version / Àíãëèéñêàÿ âåðñèÿ](set-values-eng.md)
Функция для **BgcVector2FP32**: Çàäàâàòü êîîðäèíàòû âåêòîðîâ ìîæíî êàê íàïðÿìóþ, òàê è ñïîìîùüþ ôóíêöèé. Ôóíêöèè
çàäàíèÿ çíà÷åíèé êîîðäèíàò ïîçâîëÿþò ñäåëàòü ýòî îäíîé ñòðîêîé.
Ôóíêöèÿ äëÿ **BGC_FP32_Vector2**:
```c ```c
inline void bgc_vector2_set_values_fp32(const float x1, const float x2, BgcVector2FP32* to); inline void bgc_fp32_vector2_set_values(BGC_FP32_Vector2* const destination, const float x, const float y);
``` ```
Функция для **BgcVector2FP32**: Ôóíêöèÿ äëÿ **BGC_FP64_Vector2**:
```c ```c
inline void bgc_vector2_set_values_fp64(const double x1, const double x2, BgcVector2FP64* to); inline void bgc_fp64_vector2_set_values(BGC_FP64_Vector2* const destination, const double x, const double y);
``` ```
Каждая из данных функции эквивалентна следующим строкам кода: Каждая из данных функции эквивалентна следующим строкам кода:
```c ```c
to->x1 = x1; destination->x = x;
to->x2 = x2; destination->y = y;
``` ```
В параметре **to** не следует передавать некорректные указатели. Значение NULL (0) также считается некорректным. Â ïàðàìåòðå **destination** ñëåäóåò ïåðåäàâàòü êîððåêòíûå óêàçàòåëè.
Çíà÷åíèå NULL (0) ñ÷èòàåòñÿ íåêîððåêòíûì.
Äàííàÿ ôóíêöèÿ õîðîøî ïîäõîäèò äëÿ çàäàíÿ çíà÷åíèé êîîðäèíàò âåêòîðà îäíîé
ñòðîêîé. Îñîáåííî åñëè íàäî óêàçàòü ôèêñèðîâàííûå çíà÷åíèÿ êîîðäèíàò êàê
â ïðèìåðå íèæå.
Пример применения: Пример применения:
@ -31,11 +39,11 @@ to->x2 = x2;
int main() int main()
{ {
BgcVector2FP32 my_vector; BGC_FP32_Vector2 my_vector;
bgc_vector2_set_values_fp32(-2, 7, &my_vector); bgc_fp32_vector2_set_values(&my_vector, -2.2f, 7.1f);
printf("x1 = %f, x2 = %f\n", my_vector.x1, my_vector.x2); printf("x = %f, y = %f\n", my_vector.x, my_vector.y);
return 0; return 0;
} }

View file

@ -1,24 +1,32 @@
# Swapping # Swapping
The exchange functions allow two vectors of the same type to exchange coordinate values. [Русская версия / Russian version](swap-rus.md)
Function for **BgcVector2FP32**: set-values-rus.md
The exchange functions allow two vectors of the same type to exchange coordinate
values.
Function for **BGC_FP32_Vector2**:
```c ```c
inline void bgc_vector2_swap_fp32(BgcVector2FP32* vector1, BgcVector2FP32* vector2); inline void bgc_fp32_vector2_swap(BGC_FP32_Vector2* const vector1, BGC_FP32_Vector2* const vector2);
``` ```
Function for **BgcVector2FP32**: Function for **BGC_FP64_Vector2**:
```c ```c
inline void bgc_vector2_swap_fp64(BgcVector2FP64* vector1, BgcVector2FP64* vector2); inline void bgc_fp64_vector2_swap(BGC_FP64_Vector2* const vector1, BGC_FP64_Vector2* 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 **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:
@ -28,15 +36,16 @@ Example of use:
int main() int main()
{ {
BgcVector2FP32 my_vector1, my_vector2; BGC_FP32_Vector2 my_vector1, 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_fp32_vector2_set_values(&my_vector1, -2, 7);
bgc_fp32_vector2_set_values(&my_vector2, 10, -1);
printf("Vector #1: x1 = %f, x2 = %f\n", my_vector1.x1, my_vector1.x2); bgc_fp32_vector2_swap(&my_vector1, &my_vector2);
printf("Vector #2: x1 = %f, x2 = %f\n", my_vector2.x1, my_vector2.x2);
printf("Vector #1: x = %f, y = %f\n", my_vector1.x, my_vector1.y);
printf("Vector #2: x = %f, y = %f\n", my_vector2.x, my_vector2.y);
return 0; return 0;
} }

View file

@ -1,24 +1,30 @@
# Обмен # Обмен
Функции обмена позволяют двум векторам одного типа обменяться значениями координат. [English version / Английская версия](swap-eng.md)
Функция для **BgcVector2FP32**: Функции обмена позволяют двум векторам одного типа обменяться значениями
координат.
Функция для **BGC_FP32_Vector2**:
```c ```c
inline void bgc_vector2_swap_fp32(BgcVector2FP32* vector1, BgcVector2FP32* vector2); inline void bgc_fp32_vector2_swap(BGC_FP32_Vector2* const vector1, BGC_FP32_Vector2* const vector2);
``` ```
Функция для **BgcVector2FP32**: Функция для **BGC_FP64_Vector2**:
```c ```c
inline void bgc_vector2_swap_fp64(BgcVector2FP64* vector1, BgcVector2FP64* vector2); inline void bgc_fp64_vector2_swap(BGC_FP64_Vector2* const vector1, BGC_FP64_Vector2* const vector2);
``` ```
Параметры **vector1** и **vector2** не должны быть некорректными указателями. Значение NULL (0) также считается некорректным. Параметры **vector1** и **vector2** должны быть корректными указателями.
Значение NULL (0) также считается некорректным.
Вектор **vector1** после вызова данной функции будет иметь значения координат, какие имел вектор **vector2** до вызова функции. Вектор **vector1** после вызова данной функции будет иметь значения координат,
какие имел вектор **vector2** до вызова функции.
А вектор **vector2** после вызова данной функции будет иметь такие же значения координат, какие имел вектор **vector1** до вызова функции. А вектор **vector2** после вызова данной функции будет иметь такие же значения
координат, какие имел вектор **vector1** до вызова функции.
Пример применения: Пример применения:
@ -28,15 +34,16 @@ inline void bgc_vector2_swap_fp64(BgcVector2FP64* vector1, BgcVector2FP64* vecto
int main() int main()
{ {
BgcVector2FP32 my_vector1, my_vector2; BGC_FP32_Vector2 my_vector1, 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_fp32_vector2_set_values(&my_vector1, -2, 7);
bgc_fp32_vector2_set_values(&my_vector2, 10, -1);
printf("Vector #1: x1 = %f, x2 = %f\n", my_vector1.x1, my_vector1.x2); bgc_fp32_vector2_swap(&my_vector1, &my_vector2);
printf("Vector #2: x1 = %f, x2 = %f\n", my_vector2.x1, my_vector2.x2);
printf("Vector #1: x = %f, y = %f\n", my_vector1.x, my_vector1.y);
printf("Vector #2: x = %f, y = %f\n", my_vector2.x, my_vector2.y);
return 0; return 0;
} }

View file

@ -1,6 +1,6 @@
# Three-dimensional vectors # Three-dimensional vectors
[Ðóññêàÿ âåðñèÿ / Russian version](vector3-rus.md) [Русская версия / Russian version](vector3-rus.md)
There are two types of 3D vectors in the library: There are two types of 3D vectors in the library:
- **BGC_FP32_Vector3** - vector using single-precision floating-point numbers - **BGC_FP32_Vector3** - vector using single-precision floating-point numbers
@ -22,12 +22,20 @@ Structure definitions:
## Functions ## Functions
| Funtions for BGC_FP32_Vector3 | Funtions for BGC_FP64_Vector3 | - [Reset](vector3/reset-eng.md)
|:-------------------------------------------------------------:|:-------------------------------------------------------------:| - bgc_fp32_vector3_reset
| [bgc_fp32_vector3_reset](vector3/reset-eng.md) | [bgc_fp64_vector3_reset](vector3/reset-eng.md) | - bgc_fp64_vector3_reset
| [bgc_fp32_vector3_set_values](vector3/set-values-eng.md) | [bgc_fp64_vector3_set_values](vector3/set-values-eng.md) |
| [bgc_fp32_vector3_copy](vector3/copy-eng.md) | [bgc_fp64_vector3_copy](vector3/copy-eng.md) |
| [bgc_fp32_vector3_swap](vector3/swap-eng.md) | [bgc_fp64_vector3_swap](vector3/swap-eng.md) |
- [Set Values](vector3/set-values-eng.md)
- bgc_fp32_vector3_set_values
- bgc_fp64_vector3_set_values
- [Copy](vector3/copy-eng.md)
- bgc_fp32_vector3_copy
- bgc_fp64_vector3_copy
- [Swap](vector3/swap-eng.md)
- bgc_fp32_vector3_swap
- bgc_fp64_vector3_swap
[Documentation](intro-eng.md) [Documentation](intro-eng.md)

View file

@ -24,11 +24,20 @@
## Функции ## Функции
| Функции для BGC_FP32_Vector3 | Функции для BGC_FP64_Vector3 | - [Сброс](vector3/reset-rus.md)
|:-------------------------------------------------------------:|:-------------------------------------------------------------:| - bgc_fp32_vector3_reset
| [bgc_fp32_vector3_reset](vector3/reset-rus.md) | [bgc_fp64_vector3_reset](vector3/reset-rus.md) | - bgc_fp64_vector3_reset
| [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) | - [Установка координат](vector3/set-values-rus.md)
| [bgc_fp32_vector3_swap](vector3/swap-rus.md) | [bgc_fp64_vector3_swap](vector3/swap-rus.md) | - bgc_fp32_vector3_set_values
- bgc_fp64_vector3_set_values
- [Копирование](vector3/copy-rus.md)
- bgc_fp32_vector3_copy
- bgc_fp64_vector3_copy
- [Обмен значениями](vector3/swap-rus.md)
- bgc_fp32_vector3_swap
- bgc_fp64_vector3_swap
[Документация](intro-rus.md) [Документация](intro-rus.md)

View file

@ -1,6 +1,6 @@
# Copying # Copying
[Ðóññêàÿ âåðñèÿ / Russian version](copy-rus.md) [Русская версия / Russian version](copy-rus.md)
The copy functions allow you to copy the coordinate values of one vector The copy functions allow you to copy the coordinate values of one vector
to another vector. to another vector.

View file

@ -1,19 +1,19 @@
# Resetting the state of a 3D vector # Resetting the state of a 3D vector
[Ðóññêàÿ âåðñèÿ / Russian version](reset-rus.md) [Русская версия / Russian version](reset-rus.md)
These functions set all coordinates of 3D vectors to 0. These functions set all coordinates of 3D vectors to 0.
Function for **BGC_FP32_Vector3**: Function for **BGC_FP32_Vector3**:
```c ```c
inline void bgc_fp32_vector3_reset(BGC_FP32_Vector3* vector); inline void bgc_fp32_vector3_reset(BGC_FP32_Vector3* const vector);
``` ```
Function for **BGC_FP64_Vector3**: Function for **BGC_FP64_Vector3**:
```c ```c
inline void bgc_fp64_vector3_reset(BGC_FP64_Vector3* vector); inline void bgc_fp64_vector3_reset(BGC_FP64_Vector3* const 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:

View file

@ -1,6 +1,6 @@
# Setting the coordinates of a three-dimensional vector # Setting the coordinates of a three-dimensional vector
[Ðóññêàÿ âåðñèÿ / Russian version](set-values-rus.md) [Русская версия / Russian version](set-values-rus.md)
You can set the coordinates of vectors either directly or using functions. 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. The functions for setting coordinate values allow you to do this in one line.

View file

@ -1,6 +1,6 @@
# Swapping # Swapping
[Ðóññêàÿ âåðñèÿ / Russian version](swap-rus.md) [Русская версия / Russian version](swap-rus.md)
The exchange functions allow two vectors of the same type to exchange coordinate The exchange functions allow two vectors of the same type to exchange coordinate
values. values.