bgc-c/docs/vector2/copy-eng.md

57 lines
1.5 KiB
Markdown

# Copying of coordinate values
[Русская версия / Russian version](copy-rus.md)
The function for **BGC_FP32_Vector2**:
```c
inline void bgc_fp32_vector2_copy(BGC_FP32_Vector2* const destination, const BGC_FP32_Vector2* const source);
```
The function for **BGC_FP64_Vector2**:
```c
inline void bgc_fp64_vector2_copy(BGC_FP64_Vector2* const destination, const BGC_FP64_Vector2* const source);
```
These functions allow to copy the values of the coordinates of one 2D-vector to another 2D-vector of the same type.
Each of these functions is equivalent to the following lines of code:
```c
destination->x = source->x;
destination->y = source->y;
```
### Parameters
| Parameter | Direction | Description |
| ----------- | ---------- | ----------------------------------------------------------------------- |
| destination | out | A pointer to a vector to set coordinate values from *source* |
| source | in | A pointer to a vector which coordinates 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_Vector2 v1, v2;
v1.x = -2.0f;
v1.y = 7.4f;
bgc_fp32_vector2_copy(&v2, &v1);
printf("x = %f, y = %f\n", v2.x, v2.y);
return 0;
}
```
[Documentation](../intro-eng.md) / [2D vectors](../vector2-eng.md)