61 lines
1.6 KiB
Markdown
61 lines
1.6 KiB
Markdown
# Copying of component values
|
|
|
|
[Русская версия / Russian version](copy-rus.md)
|
|
|
|
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);
|
|
```
|
|
|
|
These functions allow to copy the component values of one quaternion to another quaternion.
|
|
|
|
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;
|
|
```
|
|
|
|
### Parameters
|
|
|
|
| Parameter | Direction | Description |
|
|
| ----------- | ---------- | -------------------------------------------------------------------------------- |
|
|
| destination | out | A pointer to a quaternion to set component values from *source* |
|
|
| source | in | A pointer to a quaternion which component values will be copied to *destination* |
|
|
|
|
The *source* and *destination* parameters must be valid pointers. The NULL (0) value is also considered invalid.
|
|
|
|
### Example
|
|
|
|
```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)
|
|
|