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

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,27 +1,35 @@
# 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
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
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:
```c
to->x1 = x1;
to->x2 = x2;
destination->x = x;
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:
@ -31,11 +39,11 @@ Example of use:
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;
}