Улучшение читаемости примеров для векторов, добавление описания функций copy и swap для кватернионов
This commit is contained in:
parent
cc3ce1f327
commit
f402f68516
22 changed files with 325 additions and 77 deletions
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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue