Улучшение читаемости примеров для векторов, добавление описания функций copy и swap для кватернионов
This commit is contained in:
parent
cc3ce1f327
commit
f402f68516
22 changed files with 325 additions and 77 deletions
63
docs/quaternion/copy-eng.md
Normal file
63
docs/quaternion/copy-eng.md
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
# Copying
|
||||
|
||||
[Русская версия / Russian version](copy-rus.md)
|
||||
|
||||
The copy functions allow you to copy the component values of one quaternion
|
||||
to another quaternion.
|
||||
|
||||
Function for **BGC_FP32_Quaternion**:
|
||||
|
||||
```c
|
||||
inline void bgc_fp32_quaternion_copy(BGC_FP32_Quaternion* const destination, const BGC_FP32_Quaternion* const source);
|
||||
```
|
||||
|
||||
Function for **BGC_FP64_Quaternion**:
|
||||
|
||||
```c
|
||||
inline void bgc_fp64_quaternion_copy(BGC_FP64_Quaternion* const destination, const BGC_FP64_Quaternion* const source);
|
||||
```
|
||||
|
||||
Each of these functions is equivalent to the following lines of code:
|
||||
|
||||
```c
|
||||
destination->s = source->s;
|
||||
destination->x = source->x;
|
||||
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.
|
||||
|
||||
The **source** parameter must be a pointer to a quaternion which components
|
||||
are to be copied. The coordinates of the **source** quaternion will
|
||||
not change after the function call.
|
||||
|
||||
The **destination** parameter must be a pointer to a quaternion which components
|
||||
are to be changed. The coordinates of the **destination** quaternion will become
|
||||
the same as those of the **source** quaternion after the function call.
|
||||
|
||||
Example of use:
|
||||
|
||||
```c
|
||||
#include <stdio.h>
|
||||
#include <basic-geometry.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
BGC_FP32_Quaternion q1, q2;
|
||||
|
||||
q1.s = 1.1f;
|
||||
q1.x = -2.0f;
|
||||
q1.y = 7.4f;
|
||||
q1.z = 1.8f;
|
||||
|
||||
bgc_fp32_quaternion_copy(&q2, &q1);
|
||||
|
||||
printf("s = %f, x = %f, y = %f, z = %f\n", q2.s, q2.x, q2.y, q2.z);
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
[Documentation](../intro-eng.md) / [Quaternions](../quaternion-eng.md)
|
||||
63
docs/quaternion/copy-rus.md
Normal file
63
docs/quaternion/copy-rus.md
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
# Копирование
|
||||
|
||||
[English version / Английская версия](copy-eng.md)
|
||||
|
||||
Функции копирования позволяют скопировать значения компонент одного кватерниона
|
||||
в другой кватернион.
|
||||
|
||||
Функция для **BGC_FP32_Quaternion**:
|
||||
|
||||
```c
|
||||
inline void bgc_fp32_quaternion_copy(BGC_FP32_Quaternion* const destination, const BGC_FP32_Quaternion* const source);
|
||||
```
|
||||
|
||||
Функция для **BGC_FP64_Quaternion**:
|
||||
|
||||
```c
|
||||
inline void bgc_fp64_quaternion_copy(BGC_FP64_Quaternion* const destination, const BGC_FP64_Quaternion* const source);
|
||||
```
|
||||
|
||||
Каждая из данных функции эквивалентна следующим строкам кода:
|
||||
|
||||
```c
|
||||
destination->s = source->s;
|
||||
destination->x = source->x;
|
||||
destination->y = source->y;
|
||||
destination->z = source->z;
|
||||
```
|
||||
|
||||
Параметры **source** и **destination** должны быть корректными указателями.
|
||||
Значение NULL (0) также считается некорректным.
|
||||
|
||||
Параметр **source** должен быть указателем на кватернион, компоненты которого
|
||||
должны быть скопированы. Компоненты кватерниона **source** не изменятся после
|
||||
вызова функции.
|
||||
|
||||
Параметр **destination** должен быть указателем на кватернионы, компоненты
|
||||
которого должны быть изменены. Координаты кватерниона **destination** после
|
||||
вызова функции станут такими же, как и у кватерниона **source**.
|
||||
|
||||
Пример применения:
|
||||
|
||||
```c
|
||||
#include <stdio.h>
|
||||
#include <basic-geometry.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
BGC_FP32_Quaternion q1, q2;
|
||||
|
||||
q1.s = 1.1f;
|
||||
q1.x = -2.0f;
|
||||
q1.y = 7.4f;
|
||||
q1.z = 1.8f;
|
||||
|
||||
bgc_fp32_quaternion_copy(&q2, &q1);
|
||||
|
||||
printf("s = %f, x = %f, y = %f, z = %f\n", q2.s, q2.x, q2.y, q2.z);
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
[Документация](../intro-rus.md) / [Кватернионы](../quaternion-rus.md)
|
||||
|
|
@ -19,8 +19,10 @@ inline void bgc_fp64_quaternion_reset(BGC_FP64_Quaternion* const quaternion);
|
|||
Each of these functions is equivalent to the following lines of code:
|
||||
|
||||
```c
|
||||
vector->s = 0;
|
||||
vector->x = 0;
|
||||
vector->y = 0;
|
||||
vector->z = 0;
|
||||
```
|
||||
|
||||
You should pass valid pointers to these functions. The NULL (0) value is also
|
||||
|
|
@ -36,14 +38,14 @@ Example of use:
|
|||
|
||||
int main()
|
||||
{
|
||||
BGC_FP64_Quaternion quaternion;
|
||||
BGC_FP64_Quaternion q;
|
||||
|
||||
bgc_fp32_quaternion_reset(&quaternion);
|
||||
bgc_fp64_quaternion_reset(&q);
|
||||
|
||||
printf("s = %lf, x = %lf, y = %lf, z = %lf\n", quaternion.s, quaternion.x, quaternion.y, quaternion.z);
|
||||
printf("s = %lf, x = %lf, y = %lf, z = %lf\n", q.s, q.x, q.y, q.z);
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
[Documentation](../intro-eng.md) / [2D vectors](../quaternion-eng.md)
|
||||
[Documentation](../intro-eng.md) / [Quaternions](../quaternion-eng.md)
|
||||
|
|
|
|||
|
|
@ -19,8 +19,10 @@ inline void bgc_fp64_quaternion_reset(BGC_FP64_Quaternion* const quaternion);
|
|||
Каждая из данных функции эквивалентна следующим строкам кода:
|
||||
|
||||
```c
|
||||
vector->s = 0;
|
||||
vector->x = 0;
|
||||
vector->y = 0;
|
||||
vector->z = 0;
|
||||
```
|
||||
|
||||
В параметре **quaternion** следует передавать корректный указатель на
|
||||
|
|
@ -37,11 +39,11 @@ vector->y = 0;
|
|||
|
||||
int main()
|
||||
{
|
||||
BGC_FP64_Quaternion quaternion;
|
||||
BGC_FP64_Quaternion q;
|
||||
|
||||
bgc_fp32_quaternion_reset(&quaternion);
|
||||
bgc_fp64_quaternion_reset(&q);
|
||||
|
||||
printf("s = %lf, x = %lf, y = %lf, z = %lf\n", quaternion.s, quaternion.x, quaternion.y, quaternion.z);
|
||||
printf("s = %lf, x = %lf, y = %lf, z = %lf\n", q.s, q.x, q.y, q.z);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
60
docs/quaternion/swap-eng.md
Normal file
60
docs/quaternion/swap-eng.md
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
# Swapping
|
||||
|
||||
[Русская версия / Russian version](swap-rus.md)
|
||||
|
||||
The exchange functions allow two quaternions of the same type to exchange
|
||||
component values.
|
||||
|
||||
Function for **BGC_FP32_Quaternion**:
|
||||
|
||||
```c
|
||||
inline void bgc_fp32_quaternion_swap(BGC_FP32_Quaternion* const quarternion1, BGC_FP32_Quaternion* const quarternion2);
|
||||
```
|
||||
|
||||
Function for **BGC_FP64_Quaternion**:
|
||||
|
||||
```c
|
||||
inline void bgc_fp64_quaternion_swap(BGC_FP64_Quaternion* const quarternion1, BGC_FP64_Quaternion* const quarternion2);
|
||||
```
|
||||
|
||||
The **quarternion1** and **quarternion2** parameters must be valid pointers.
|
||||
The NULL (0) value is considered invalid.
|
||||
|
||||
The quaternion **quarternion1** after calling this function will have the same
|
||||
component values the quaternion **quarternion2** had before calling
|
||||
the function.
|
||||
|
||||
And the quaternion **quarternion2** after calling this function will have
|
||||
the same compnent values the quaternion **quarternion1** had before calling
|
||||
the function.
|
||||
|
||||
Example of use:
|
||||
|
||||
```c
|
||||
#include <stdio.h>
|
||||
#include <basic-geometry.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
BGC_FP32_Quaternion q1, q2;
|
||||
|
||||
bgc_fp32_quaternion_set_values(&q1, 4, -2, 7, 5);
|
||||
bgc_fp32_quaternion_set_values(&q2, -5, 10, -1, -3);
|
||||
|
||||
bgc_fp32_quaternion_swap(&q1, &q2);
|
||||
|
||||
printf("Quaternion #1: s = %f, x = %f, y = %f, z = %f\n", q1.s, q1.x, q1.y, q1.z);
|
||||
printf("Quaternion #2: s = %f, x = %f, y = %f, z = %f\n", q2.s, q2.x, q2.y, q2.z);
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
The console output:
|
||||
|
||||
```
|
||||
Quaternion #1: s = -5.000000, x = 10.000000, y = -1.000000, z = -3.000000
|
||||
Quaternion #2: s = 4.000000, x = -2.000000, y = 7.000000, z = 5.000000
|
||||
```
|
||||
|
||||
[Documentation](../intro-eng.md) / [Quaternions](../quaternion-eng.md)
|
||||
58
docs/quaternion/swap-rus.md
Normal file
58
docs/quaternion/swap-rus.md
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
# Обмен значениями
|
||||
|
||||
[English version / Английская версия](swap-eng.md)
|
||||
|
||||
Функции обмена позволяют двум кватернионам одного типа обменяться значениями
|
||||
координат.
|
||||
|
||||
Функция для **BGC_FP32_Quaternion**:
|
||||
|
||||
```c
|
||||
inline void bgc_fp32_quaternion_swap(BGC_FP32_Quaternion* const quarternion1, BGC_FP32_Quaternion* const quarternion2);
|
||||
```
|
||||
|
||||
Функция для **BGC_FP64_Quaternion**:
|
||||
|
||||
```c
|
||||
inline void bgc_fp64_quaternion_swap(BGC_FP64_Quaternion* const quarternion1, BGC_FP64_Quaternion* const quarternion2);
|
||||
```
|
||||
|
||||
Параметры **quarternion1** и **quarternion2** должны быть корректными
|
||||
указателями. Значение NULL (0) также считается некорректным.
|
||||
|
||||
Кватернион **quarternion1** после вызова данной функции будет иметь значения
|
||||
компонент такие же, какие имел кватернион **quarternion2** до вызова функции.
|
||||
|
||||
А кватернион **quarternion2** после вызова данной функции будет иметь такие же
|
||||
значения компонет, какие имел кватернион **quarternion1** до вызова функции.
|
||||
|
||||
Пример применения:
|
||||
|
||||
```c
|
||||
#include <stdio.h>
|
||||
#include <basic-geometry.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
BGC_FP32_Quaternion q1, q2;
|
||||
|
||||
bgc_fp32_quaternion_set_values(&q1, 4, -2, 7, 5);
|
||||
bgc_fp32_quaternion_set_values(&q2, -5, 10, -1, -3);
|
||||
|
||||
bgc_fp32_quaternion_swap(&q1, &q2);
|
||||
|
||||
printf("Quaternion #1: s = %f, x = %f, y = %f, z = %f\n", q1.s, q1.x, q1.y, q1.z);
|
||||
printf("Quaternion #2: s = %f, x = %f, y = %f, z = %f\n", q2.s, q2.x, q2.y, q2.z);
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
Вывод в консоль:
|
||||
|
||||
```
|
||||
Quaternion #1: s = -5.000000, x = 10.000000, y = -1.000000, z = -3.000000
|
||||
Quaternion #2: s = 4.000000, x = -2.000000, y = 7.000000, z = 5.000000
|
||||
```
|
||||
|
||||
[Документация](../intro-rus.md) / [Кватернионы](../quaternion-rus.md)
|
||||
Loading…
Add table
Add a link
Reference in a new issue