bgc-c/docs/vector3/set-values-eng.md

53 lines
1.4 KiB
Markdown

# Setting the coordinates of a three-dimensional vector
[Русская версия / 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**:
```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**:
```c
inline void bgc_fp64_vector3_set_values(BGC_FP64_Vector3* const destination, const double x, const double y, const double z);
```
Each of these functions is equivalent to the following lines of code:
```c
destination->x = x;
destination->y = y;
destination->z = z;
```
Invalid pointers should not be passed in the **destination** parameter.
The NULL (0) value is also 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:
```c
#include <stdio.h>
#include <basic-geometry.h>
int main()
{
BGC_FP32_Vector3 my_vector;
bgc_fp32_vector3_set_values(&my_vector, -2.2f, 7.1f, 10.01f);
printf("x = %f, y = %f, z = %f\n", my_vector.x, my_vector.y, my_vector.z);
return 0;
}
```
[Documentation](../intro-eng.md) / [3D vectors](../vector3-eng.md)