Актуализация документации по проекту

This commit is contained in:
Andrey Pokidov 2026-03-31 20:43:10 +07:00
parent ed404690ed
commit 8ba075b557
16 changed files with 279 additions and 222 deletions

View file

@ -4,53 +4,66 @@
## Naming
### Prefixes
C programming language does not have namespaces, thus prefixes often play role of namespaces in C code.
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 library uses prefixes in names of types, constants and functions to avoid
name conflict with of othr libraries.
### Library prefix (the main prefix)
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:
BGC_FP64_Vector3, BGC_FP32_Quaternion, BGC_FP32_Matrix2x2, BGC_FP32_EPSILON,
BGC_FP64_TWO_PI.
The structure types and the contstans have prefix in the form **BGC_**.
The constants have prefix in the form **BGC_**. For example: BGC_EPSYLON_FP32,
BGC_TWO_PI_FP64.
For example, structures:
- BGC_FP64_Vector3
- BGC_FP32_Quaternion
- BGC_FP32_Matrix2x2
The functions have prefix in the form **bgc_**. For example:
bgc_fp32_turn3_combine, bgc_fp64_matrix3x3_subtract.
Constants:
- BGC_FP32_EPSILON
- BGC_FP64_TWO_PI
### Suffixes
The functions have prefix in the form **bgc_**, for example:
- bgc_fp32_turn3_combine
- bgc_fp64_matrix3x3_subtract
Suffixs of type ends the names of constats, types and functions of the library.
The library uses two types of floating point numbers: **float** and **double**
(**binary32** and **binary64** types of the **IEEE 754** standard).
### Basic type prefix (the secondary prefix)
Thus there are two suffixes of types:
Prefixs of type ends the names of constats, types and functions of the library.
* **FP32** - means **F**loating **P**oint, **32** bit, which corresponds to the
**float** type of the C language.
The library uses two types of floating point numbers: **float** and **double** (**binary32** and **binary64** types of the **IEEE 754** standard).
* **FP64** - means **F**loating **P**oint, **64** bit, which corresponds to the
**double** type of the C language.
Thus there are two prefixes of types:
- **FP32** - means **F**loating **P**oint, **32** bit, which corresponds to the **float** type of the C programming language.
- **FP64** - means **F**loating **P**oint, **64** bit, which corresponds to the **double** type of the C programming language.
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 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 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 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: bcg_fp32_vector2_get_length, bgc_fp32_radians_to_degrees.
The functions which works with data of the **float** type have **fp32_** as the type prefix:
- 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_fp64_vector3_reset, bgc_fp64_normalize_radians.
The functions which works with data of the **double** type have **fp64_** as the type prefix:
- 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.
### Data types
- [2D-vectors](vector2-eng.md)
- [3D-vectors](vector3-eng.md)
- [Quaternions](quaternion-rus.md)
Using of such prefixes of a basic type allows to enhance the library with new
basic types in future.

View file

@ -4,51 +4,66 @@
## Особенности наименования
### Префиксы
В языке программирования C (Си) нет пространств имён, потому роль пространств имён играют префиксы в названиях.
В языке программирования C (Си) нет пространств имён, потому роль пространств
имён играют префиксы в названиях.
Библиотека использует префиксы в названиях типов, констант и функций для того, чтобы избежать конфликтов в названиях констант, типов и функций с другими библиотеками.
Библиотека использует префиксы в названиях типов, констант и функций для
того, чтобы избежать конфликтов в названиях констант, типов и функций с другими
библиотеками.
### Префикс библиотеки (основной префикс)
Основным префиксом является **BGC** (сокращение от **B**asic **G**eometric
**C**omputations / Базовые Геометрие Вычисления).
Основным префиксом является **BGC** (сокращение от **B**asic **G**eometric **C**omputations, что можно перевести как "Базовые Геометрие Вычисления").
Для констант и структур данных префикс имеет вид **BGC_**, например:
BGC_FP64_Vector3, BGC_FP32_Quaternion, BGC_FP32_Matrix2x2, BGC_FP32_EPSILON,
BGC_FP64_TWO_PI.
Для констант и структур данных префикс имеет вид **BGC_**
Функции имеют префикс в виде **bgc_**, например: bgc_fp32_turn3_combine,
bgc_fp64_matrix3x3_subtract.
Например, структуры:
- BGC_FP64_Vector3
- BGC_FP32_Quaternion
- BGC_FP32_Matrix2x2
Константы:
- BGC_FP32_EPSILON
- BGC_FP64_TWO_PI
Функции имеют префикс в виде **bgc_**, например:
- bgc_fp32_turn3_combine
- bgc_fp64_matrix3x3_subtract
### Префикс базового типа (вторичный префикс)
После префикса библиотеки идёт префикс базового типа.
Библиотека использует два типа чисел с плавающей запятой: **float** и **double**
(типы **binary32** и **binary64** стандарта **IEEE 754**).
Библиотека использует два типа чисел с плавающей запятой: **float** и **double** (типы **binary32** и **binary64** стандарта **IEEE 754**).
Поэтому в библиотеке есть два префикса типа:
* **FP32** - означает **F**loating **P**oint **32** bit, то есть, число с
плавающей запятой, 32 бита, что соответствует типу **float** языка Си.
* **FP64** - означает **F**loating **P**oint **64** bit, то есть, число с
плавающей запятой, 64 бита, что соответствует типу **double** языка Си.
- **FP32** - означает **F**loating **P**oint **32** bit, то есть, число с плавающей запятой, 32 бита, что соответствует типу **float** языка программирования Си.
- **FP64** - означает **F**loating **P**oint **64** bit, то есть, число с плавающей запятой, 64 бита, что соответствует типу **double** языка программирования Си.
Типы структур и константы, основанные на типе **float** имеют префикс **FP32_**:
BGC_FP32_Vector3, BGC_FP32_Matrix3x2, BGC_FP32_Quaternion, BGC_FP32_PI,
BGC_FP32_EPSILON.
- BGC_FP32_Vector3
- BGC_FP32_Matrix3x2
- BGC_FP32_Quaternion
- BGC_FP32_PI
- BGC_FP32_EPSILON
Типы структур и константы, основанные на типе **double** имеют префикс
**FP64_**: BGC_FP64_Vector2, BGC_FP64_Matrix2x3, BGC_FP64_Turn3,
BGC_FP64_HALF_PI, BGC_FP64_ONE_THIRD.
Типы структур и константы, основанные на типе **double** имеют префикс **FP64_**:
- BGC_FP64_Vector2
- BGC_FP64_Matrix2x3
- BGC_FP64_Turn3
- BGC_FP64_HALF_PI
- BGC_FP64_ONE_THIRD
Функции, которые работают с данными типа **float** имеют суффикс **_fp32**:
bcg_fp32_vector2_get_length, bgc_fp32_radians_to_degrees.
Функции, которые работают с данными типа **float** имеют префикс **fp32_**:
- bgc_fp32_vector2_get_length
- bgc_fp32_radians_to_degrees
Функции, которые работают с данными типа **double** имеют суффикс **_fp64**:
bgc_fp64_vector3_reset, bgc_fp64_normalize_radians.
Функции, которые работают с данными типа **double** имеют префикс **fp64_**:
- bgc_fp64_vector3_reset
- bgc_fp64_normalize_radians
Использование подобных префиксов позволяет расширять библиотеку используя новые базовые типы в будущем.
### Типы данных
- [Двумерные векторы](vector2-rus.md)
- [Трёхмерные векторы](vector3-rus.md)
- [Кватернионы](quaternion-rus.md)
Использование подобных префиксов позволяет расширять библиотеку используя новые
базовые типы в будущем.

View file

@ -20,6 +20,8 @@ Structure definitions:
} BGC_FP64_Vector2;
```
The fields *x* and *y* are the coordinates of a 3D vector.
## Functions
- [Reset](vector2/reset-eng.md)
@ -38,5 +40,5 @@ Structure definitions:
- bgc_fp32_vector2_swap
- bgc_fp64_vector2_swap
[Documentation](intro-eng.md)

View file

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

View file

@ -1,21 +1,21 @@
# Copying
# Copying of coordinate values
[Русская версия / Russian version](copy-rus.md)
The copy functions allow you to copy the coordinate values of one vector to another vector.
Function for **BGC_FP32_Vector2**:
The function for **BGC_FP32_Vector2**:
```c
inline void bgc_fp32_vector2_copy(BGC_FP32_Vector2* const destination, const BGC_FP32_Vector2* const source);
```
Function for **BGC_FP64_Vector2**:
The function for **BGC_FP64_Vector2**:
```c
inline void bgc_fp64_vector2_copy(BGC_FP64_Vector2* const destination, const BGC_FP64_Vector2* const source);
```
These functions allow to copy the values of the coordinates of one 2D-vector to another 2D-vector of the same type.
Each of these functions is equivalent to the following lines of code:
```c
@ -23,19 +23,16 @@ destination->x = source->x;
destination->y = source->y;
```
The **source** and **destination** parameters must be valid pointers.
The NULL (0) value is also considered invalid.
### Parameters
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.
| Parameter | Direction | Description |
| ----------- | ---------- | ----------------------------------------------------------------------- |
| destination | out | A pointer to a vector to set coordinate values from *source* |
| source | in | A pointer to a vector which coordinates will be copied to *destination* |
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.
The **source** and **destination** parameters must be valid pointers. The NULL (0) value is also considered invalid.
Example of use:
### Example
```c
#include <stdio.h>
@ -57,3 +54,4 @@ int main()
```
[Documentation](../intro-eng.md) / [2D vectors](../vector2-eng.md)

View file

@ -1,41 +1,38 @@
# Копирование
# Копирование значений координат
[English version / Английская версия](copy-eng.md)
[English version / Английская версия](copy-eng.md)
Функции копирования позволяют скопировать значения координат одного вектора
в другой вектор.
Функция для **BGC_FP32_Vector2**:
Функция для **BGC_FP32_Vector2**:
```c
inline void bgc_fp32_vector2_copy(BGC_FP32_Vector2* const destination, const BGC_FP32_Vector2* const source);
```
Функция для **BGC_FP64_Vector2**:
Функция для **BGC_FP64_Vector2**:
```c
inline void bgc_fp64_vector2_copy(BGC_FP64_Vector2* const destination, const BGC_FP64_Vector2* const source);
```
Каждая из данных функции эквивалентна следующим строкам кода:
Функции копирования позволяют скопировать значения координат одного вектора в координаты другого вектора. Оба вектора должны иметь одинаковый тип.
Каждая из данных функции эквивалентна следующим строкам кода:
```c
destination->x = source->x;
destination->y = source->y;
```
Параметры **source** и **destination** должны быть корректными указателями.
Значение NULL (0) также считается некорректным.
### Параметры
Параметр **source** должен быть указателем на двумерный вектор, координаты
которого должны быть скопированы. Координаты вектора **source** не изменятся
после вызова функции.
Параметр **destination** должен быть указателем на двумерный вектор, координаты
которого должны быть изменены. Координаты вектора **destination** после вызова
функции станут такими же, как и у вектора **source**.
| Параметр | Направление | Описание |
| ----------- | ----------- | -------------------------------------------------------------------------------- |
| destination | исходящий | Указатель на вектор, в который будут скопированы значения координат из *source* |
| source | входящий | Указатель на вектор, координаты которого должны быть скопированы в *destination* |
Пример применения:
Параметры *source* и *destination* должны быть корректными указателями. Значение NULL (0) также считается некорректным.
### Пример
```c
#include <stdio.h>
@ -56,4 +53,6 @@ int main()
}
```
[Документация](../intro-rus.md) / [2D векторы](../vector2-rus.md)
[Документация](../intro-rus.md) / [Двумерные векторы](../vector2-rus.md)

View file

@ -20,6 +20,8 @@ Structure definitions:
} BGC_FP64_Vector3;
```
The fields *x*, *y* and *z* are the coordinates of a 3D vector.
## Functions
- [Reset](vector3/reset-eng.md)
@ -39,3 +41,4 @@ Structure definitions:
- bgc_fp64_vector3_swap
[Documentation](intro-eng.md)

View file

@ -3,10 +3,8 @@
[English version / Английская версия](vector3-eng.md)
В библиотеке есть два типа трёхмерных векторов:
- **BGC_FP32_Vector3** - вектор с использованием чисел с плавающей запятой
одинарной точности
- **BGC_FP64_Vector3** - вектор с использованием чисел с плавающей запятой
двойной точности
- **BGC_FP32_Vector3** - вектор с использованием чисел с плавающей запятой одинарной точности
- **BGC_FP64_Vector3** - вектор с использованием чисел с плавающей запятой двойной точности
Определения структур:
@ -22,22 +20,25 @@
} BGC_FP64_Vector3;
```
Поля *x*, *y* и *z* содержат координаты трёхмерного вектора.
## Функции
- [Сброс](vector3/reset-rus.md)
- [Сброс значений координат](vector3/reset-rus.md)
- bgc_fp32_vector3_reset
- bgc_fp64_vector3_reset
- [Установка координат](vector3/set-values-rus.md)
- [Установка значений координат](vector3/set-values-rus.md)
- bgc_fp32_vector3_set_values
- bgc_fp64_vector3_set_values
- [Копирование](vector3/copy-rus.md)
- [Копирование координат](vector3/copy-rus.md)
- bgc_fp32_vector3_copy
- bgc_fp64_vector3_copy
- [Обмен значениями](vector3/swap-rus.md)
- [Обмен значениями координат](vector3/swap-rus.md)
- bgc_fp32_vector3_swap
- bgc_fp64_vector3_swap
[Документация](intro-rus.md)

View file

@ -1,22 +1,21 @@
# Copying
# Copying of coordinate values
[Русская версия / Russian version](copy-rus.md)
The copy functions allow you to copy the coordinate values of one vector
to another vector.
Function for **BGC_FP32_Vector3**:
The function for **BGC_FP32_Vector3**:
```c
inline void bgc_fp32_vector3_copy(BGC_FP32_Vector3* const destination, const BGC_FP32_Vector3* const source);
```
Function for **BGC_FP64_Vector3**:
The function for **BGC_FP64_Vector3**:
```c
inline void bgc_fp64_vector3_copy(BGC_FP64_Vector3* const destination, const BGC_FP64_Vector3* const source);
```
These functions allow to copy the values of the coordinates of one 3D-vector to another 3D-vector of the same type.
Each of these functions is equivalent to the following lines of code:
```c
@ -25,19 +24,16 @@ destination->y = source->y;
destination->z = source->z;
```
The **source** and **destination** parameters must not be invalid pointers.
The NULL (0) value is also considered invalid.
### Parameters
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.
| Parameter | Direction | Description |
| ----------- | ---------- | ----------------------------------------------------------------------- |
| destination | out | A pointer to a vector to set coordinate values from *source* |
| source | in | A pointer to a vector which coordinates will be copied to *destination* |
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.
The **source** and **destination** parameters must be valid pointers. The NULL (0) value is also considered invalid.
Example of use:
### Example
```c
#include <stdio.h>
@ -60,3 +56,4 @@ int main()
```
[Documentation](../intro-eng.md) / [3D vectors](../vector3-eng.md)

View file

@ -1,10 +1,7 @@
# Копирование
# Копирование значений координат
[English version / Английская версия](copy-eng.md)
Функции копирования позволяют скопировать значения координат одного вектора
в другой вектор.
Функция для **BGC_FP32_Vector3**:
```c
@ -17,6 +14,8 @@ inline void bgc_fp32_vector3_copy(BGC_FP32_Vector3* const destination, const BGC
inline void bgc_fp64_vector3_copy(BGC_FP64_Vector3* const destination, const BGC_FP64_Vector3* const source);
```
Функции копирования позволяют скопировать значения координат одного вектора в координаты другого вектора. Оба вектора должны иметь одинаковый тип.
Каждая из данных функции эквивалентна следующим строкам кода:
```c
@ -25,18 +24,16 @@ destination->y = source->y;
destination->z = source->z;
```
Параметры **source** и **destination** не должны быть некорректными указателями.
Значение NULL (0) также считается некорректным.
### Параметры
Параметр **source** должен быть указателем на трёхмерный вектор, координаты
которого должны быть скопированы. Координаты вектора **source** не изменятся
после вызова функции.
Параметр **destination** должен быть указателем на трёхмерный вектор, координаты
которого должны быть изменены. Координаты вектора **destination** после вызова
функции станут такими же, как и у вектора **source**.
| Параметр | Направление | Описание |
| ----------- | ----------- | -------------------------------------------------------------------------------- |
| destination | исходящий | Указатель на вектор, в который будут скопированы значения координат из *source* |
| source | входящий | Указатель на вектор, координаты которого должны быть скопированы в *destination* |
Пример применения:
Параметры *source* и *destination* должны быть корректными указателями. Значение NULL (0) также считается некорректным.
### Пример
```c
#include <stdio.h>
@ -58,4 +55,6 @@ int main()
}
```
[Документация](../intro-rus.md) / [3D векторы](../vector3-rus.md)
[Документация](../intro-rus.md) / [Трёхмерные векторы](../vector3-rus.md)

View file

@ -2,20 +2,20 @@
[Русская версия / Russian version](reset-rus.md)
These functions set all coordinates of 3D vectors to 0.
Function for **BGC_FP32_Vector3**:
The function for **BGC_FP32_Vector3**:
```c
inline void bgc_fp32_vector3_reset(BGC_FP32_Vector3* const vector);
```
Function for **BGC_FP64_Vector3**:
The function for **BGC_FP64_Vector3**:
```c
inline void bgc_fp64_vector3_reset(BGC_FP64_Vector3* const vector);
```
These functions set all coordinates of 3D vectors to 0.
Each of these functions is equivalent to the following lines of code:
```c
@ -24,12 +24,17 @@ vector->y = 0;
vector->z = 0;
```
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:
### Parameters
| Parameter | Direction | Description |
| ---------- | ---------- | -------------------------------------------------------- |
| vector | out | A pointer to a vector which coordinated must be set to 0 |
You should pass only valid pointers in the parameter *vector*. The NULL (0) value is considered invalid.
### Example
```c
#include <stdio.h>
@ -48,3 +53,4 @@ int main()
```
[Documentation](../intro-eng.md) / [3D vectors](../vector3-eng.md)

View file

@ -1,22 +1,22 @@
# Сброс состояния трёхмерного вектора
# Сброс состояния трёхмерного вектора
[English version / Английская версия](reset-eng.md)
[English version / Английская версия](reset-eng.md)
Функции устанавливают значение 0 всем координатам трёхмерных векторов.
Функция для **BGC_FP32_Vector3**:
Функиция для **BGC_FP32_Vector3**:
```c
inline void bgc_fp32_vector3_reset(BGC_FP32_Vector3* const vector);
```
Функция для **BGC_FP64_Vector3**:
Функиция для **BGC_FP64_Vector3**:
```c
inline void bgc_fp64_vector3_reset(BGC_FP64_Vector3* const vector);
```
Каждая из данных функции эквивалентна следующим строкам кода:
Данные функции устанавливают значения всех кооординат равным 0.
Каждая из функций соответствуют следуюим трём строкам кода:
```c
vector->x = 0;
@ -24,12 +24,17 @@ vector->y = 0;
vector->z = 0;
```
В данные функции не следует передавать некорректные указатели. Значение NULL (0)
также считается некорректным.
Данные функции подходят для иницализации начального состояния трёхмерного вектора.
Данная функция хорошо подходит для инициализации начального состояния вектора.
### Параметры
Пример применения:
| Параметр | Направление | Описание |
| -------- | ----------- | -------------------------------------------------------------------- |
| vector | исходящий | Указатель на вектор, координаты которого должны быть установлены в 0 |
Необходимо передавать только корректные указатели в параметр *vector*. Значение NULL (0) также считается некорректным.
### Пример
```c
#include <stdio.h>
@ -47,4 +52,5 @@ int main()
}
```
[Документация](../intro-rus.md) / [3D векторы](../vector3-rus.md)
[Документация](../intro-eng.md) / [Трёхмерные векторы](../vector3-eng.md)

View file

@ -2,21 +2,22 @@
[Русская версия / Russian version](set-values-rus.md)
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_Vector3**:
The function for **BGC_FP32_Vector3**:
```c
inline void bgc_fp32_vector3_set_values(BGC_FP32_Vector3* const destination, const float x, const float y, const float z);
```
Function for **BGC_FP64_Vector3**:
The function for **BGC_FP64_Vector3**:
```c
inline void bgc_fp64_vector3_set_values(BGC_FP64_Vector3* const destination, const double x, const double y, const double z);
```
These functions allow to set the values of coordinates in one-line.
The functions are especially useful when the values are constants like in the example below.
Each of these functions is equivalent to the following lines of code:
```c
@ -25,14 +26,18 @@ destination->y = y;
destination->z = z;
```
Invalid pointers should not be passed in the **destination** parameter.
The NULL (0) value is also considered invalid.
### Parameters
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.
| Parameter | Direction | Description |
| ----------- | --------- | ------------------------------------------------------- |
| destination | out | A pointer to a 3D-vector, which coordinates must be set |
| x | in | A new value for the X-coordinate |
| y | in | A new value for the Y-coordinate |
| z | in | A new value for the Z-coordinate |
Example of use:
The *destination* parameter must be a valid pointer. The NULL (0) value is considered invalid.
### Example
```c
#include <stdio.h>
@ -42,7 +47,7 @@ int main()
{
BGC_FP32_Vector3 v;
bgc_fp32_vector3_set_values(&v, -2.2f, 7.1f, 10.01f);
bgc_fp32_vector3_set_values(&v, -2.2f, 7.8f, 10.01f);
printf("x = %f, y = %f, z = %f\n", v.x, v.y, v.z);
@ -51,3 +56,4 @@ int main()
```
[Documentation](../intro-eng.md) / [3D vectors](../vector3-eng.md)

View file

@ -1,24 +1,24 @@
# Указание координат трёхмерного вектора
# Задание координат трёхмерного вектора.
[English version / Английская версия](set-values-eng.md)
[English version / Английская версия](set-values-eng.md)
Указать координаты векторов можно как напрямую, так и спомощью функций.
Принципиальной разницы нет, но функции указания координат позволяют сделать это
одной строкой.
Функция для **BGC_FP32_Vector3**:
Функция для **BGC_FP32_Vector3**:
```c
inline void bgc_fp32_vector3_set_values(BGC_FP32_Vector3* const destination, const float x, const float y, const float z);
```
Функция для **BGC_FP64_Vector3**:
Функция для **BGC_FP64_Vector3**:
```c
inline void bgc_fp64_vector3_set_values(BGC_FP64_Vector3* const destination, const double x, const double y, const double z);
```
Каждая из данных функции эквивалентна следующим строкам кода:
Данные функции позволяют задать значения координат вектора одной строкой.
Такая возможность может быть удобна, когда нужно указать значения координат с помощью числовых констант как в примере ниже.
Каждая из функций аналогична следующим трём строкам кода:
```c
destination->x = x;
@ -26,14 +26,18 @@ destination->y = y;
destination->z = z;
```
В параметре **destination** не следует передавать некорректные указатели.
Значение NULL (0) также считается некорректным.
### Параметры
Данная функция хорошо подходит для заданя значений координат вектора одной
строкой. Особенно если надо указать фиксированные значения координат как
в примере ниже.
| Параметр | Направление | Описание |
| ----------- | ----------- | -------------------------------------------------------------- |
| destination | исходящий | Указатель на вектор, координаты которого будут заданы функцией |
| x | входящий | Значение координаты X |
| y | входящий | Значение координаты Y |
| z | входящий | Значение координаты Z |
Пример применения:
Параметр *destination* должен быть корректным указателем. Значение NULL (0) считается некорректным.
### Пример
```c
#include <stdio.h>
@ -43,7 +47,7 @@ int main()
{
BGC_FP32_Vector3 v;
bgc_fp32_vector3_set_values(&v, -2.2f, 7.1f, 10.01f);
bgc_fp32_vector3_set_values(&v, -2.2f, 7.8f, 10.01f);
printf("x = %f, y = %f, z = %f\n", v.x, v.y, v.z);
@ -51,4 +55,4 @@ int main()
}
```
[Документация](../intro-rus.md) / [3D векторы](../vector3-rus.md)
[Документация](../intro-rus.md) / [Трёхмерные векторы](../vector3-rus.md)

View file

@ -1,32 +1,35 @@
# Swapping
# Swapping of coordinate values
[Русская версия / Russian version](swap-rus.md)
The exchange functions allow two vectors of the same type to exchange coordinate
values.
Function for **BGC_FP32_Vector3**:
The function for **BGC_FP32_Vector3**:
```c
inline void bgc_fp32_vector3_swap(BGC_FP32_Vector3* const vector1, BGC_FP32_Vector3* const vector2);
```
Function for **BGC_FP64_Vector3**:
The function for **BGC_FP64_Vector3**:
```c
inline void bgc_fp64_vector3_swap(BGC_FP64_Vector3* const vector1, BGC_FP64_Vector3* const vector2);
```
The **vector1** and **vector2** parameters must be valid pointers.
The NULL (0) value is considered invalid.
These functions allow to swap the values of the coordinates of two vectors of the same type.
Vector **vector1** after calling this function will have the coordinate values
that vector **vector3** had before calling the function.
### Parameters
And vector **vector3** after calling this function will have the same coordinate
values that vector **vector1** had before calling the function.
| Parameter | Direction | Description |
| --------- | --------- | ---------------------------------------------------------------------------------------- |
| vector1 | in / out | A pointer to a 3D vector where the values of the coordinates of *vector2* will be copied |
| vector2 | in / out | A pointer to a 3D vector where the values of the coordinates of *vector1* will be copied |
Example of use:
The *vector1* and *vector2* parameters must be valid pointers. The NULL (0) value is considered invalid.
The *vector1* vector will have the same values of the coordinates as *vector2* had before the calling of the function.
And the *vector2* vector will have the same values of the coordinates as *vector1* had before the calling of the function.
### Example
```c
#include <stdio.h>
@ -48,7 +51,7 @@ int main()
}
```
Result:
Output:
```
Vector #1: x = 10.000000, y = -1.000000, z = -3.000000

View file

@ -1,10 +1,7 @@
# Обмен значениями
# Обмен значениями координат
[English version / Английская версия](swap-eng.md)
Функции обмена позволяют двум векторам одного типа обменяться значениями
координат.
Функция для **BGC_FP32_Vector3**:
```c
@ -17,16 +14,22 @@ inline void bgc_fp32_vector3_swap(BGC_FP32_Vector3* const vector1, BGC_FP32_Vect
inline void bgc_fp64_vector3_swap(BGC_FP64_Vector3* const vector1, BGC_FP64_Vector3* const vector2);
```
Параметры **vector1** и **vector2** не должны быть некорректными указателями.
Значение NULL (0) также считается некорректным.
Функции обмена значениями позволяют двум векторам одного типа обменяться значениями координат.
Вектор **vector1** после вызова данной функции будет иметь значения координат,
какие имел вектор **vector2** до вызова функции.
### Параметры
А вектор **vector2** после вызова данной функции будет иметь такие же значения
координат, какие имел вектор **vector1** до вызова функции.
| Параметр | Направление | Описание |
| --------- | -------------------- | -------------------------------------------------------------------------------- |
| vector1 | исходящий / входящий | Указатель на вектор, в который будут скопированы значения координат из *vector2* |
| vector2 | исходящий / входящий | Указатель на вектор, в который будут скопированы значения координат из *vector1* |
Пример применения:
Параметры *vector1* и *vector2* должны быть корректными указателями на структуры трёхмерных векторов. Значение NULL (0) считается некорректным.
После вызова функции вектор *vector1* будет иметь такие же значения координат, как вектор *vector2* до вызова функции.
А вектор *vector2* после вызова функции будет иметь координаты, такие же, как у вектора *vector1* до вызова функции.
### Пример
```c
#include <stdio.h>
@ -55,4 +58,5 @@ 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)
[Документация](../intro-rus.md) / [Трёхмерные векторы](../vector3-rus.md)