59 lines
1.4 KiB
Markdown
59 lines
1.4 KiB
Markdown
# Copying
|
|
|
|
[Русская версия / Russian version](copy-rus.md)
|
|
|
|
The copy functions allow you to copy the coordinate values of one vector to another vector.
|
|
|
|
Function for **BGC_FP32_Vector2**:
|
|
|
|
```c
|
|
inline void bgc_fp32_vector2_copy(BGC_FP32_Vector2* const destination, const BGC_FP32_Vector2* const source);
|
|
```
|
|
|
|
Function for **BGC_FP64_Vector2**:
|
|
|
|
```c
|
|
inline void bgc_fp64_vector2_copy(BGC_FP64_Vector2* const destination, const BGC_FP64_Vector2* const source);
|
|
```
|
|
|
|
Each of these functions is equivalent to the following lines of code:
|
|
|
|
```c
|
|
destination->x = source->x;
|
|
destination->y = source->y;
|
|
```
|
|
|
|
The **source** and **destination** parameters must be valid pointers.
|
|
The NULL (0) value is also considered invalid.
|
|
|
|
The **source** parameter must be a pointer to a two-dimensional vector whose
|
|
coordinates are to be copied. The coordinates of the **source** vector will
|
|
not change after the function call.
|
|
|
|
The **destination** parameter must be a pointer to a two-dimensional vector
|
|
whose coordinates are to be changed. The coordinates of the **destination**
|
|
vector will become the same as those of the **source** vector after the function
|
|
call.
|
|
|
|
Example of use:
|
|
|
|
```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)
|