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

1.7 KiB

Setting the coordinates of a three-dimensional vector

Русская версия / Russian version

The function for BGC_FP32_Vector3:

inline void bgc_fp32_vector3_set_values(BGC_FP32_Vector3* const destination, const float x, const float y, const float z);

The function for BGC_FP64_Vector3:

inline void bgc_fp64_vector3_set_values(BGC_FP64_Vector3* const destination, const double x, const double y, const double z);

These functions allow to set the values of coordinates in one-line.

The functions are especially useful when the values are constants like in the example below.

Each of these functions is equivalent to the following lines of code:

destination->x = x;
destination->y = y;
destination->z = z;

Parameters

Parameter Direction Description
destination out A pointer to a 3D-vector, which coordinates must be set
x in A new value for the X-coordinate
y in A new value for the Y-coordinate
z in A new value for the Z-coordinate

The destination parameter must be a valid pointer. The NULL (0) value is considered invalid.

Example

#include <stdio.h>
#include <basic-geometry.h>

int main()
{
    BGC_FP32_Vector3 v;

    bgc_fp32_vector3_set_values(&v, -2.2f, 7.8f, 10.01f);

    printf("x = %f, y = %f, z = %f\n", v.x, v.y, v.z);

    return 0;
}

Documentation / 3D vectors