54 lines
1.3 KiB
Markdown
54 lines
1.3 KiB
Markdown
# Swapping
|
|
|
|
[Русская версия / Russian version](swap-rus.md)
|
|
|
|
set-values-rus.md
|
|
|
|
The exchange functions allow two vectors of the same type to exchange coordinate
|
|
values.
|
|
|
|
Function for **BGC_FP32_Vector2**:
|
|
|
|
```c
|
|
inline void bgc_fp32_vector2_swap(BGC_FP32_Vector2* const vector1, BGC_FP32_Vector2* const vector2);
|
|
```
|
|
|
|
Function for **BGC_FP64_Vector2**:
|
|
|
|
```c
|
|
inline void bgc_fp64_vector2_swap(BGC_FP64_Vector2* const vector1, BGC_FP64_Vector2* const vector2);
|
|
```
|
|
|
|
The **vector1** and **vector2** parameters must be valid pointers.
|
|
The NULL (0) value is considered invalid.
|
|
|
|
Vector **vector1** after calling this function will have the coordinate values
|
|
that vector **vector2** had before calling the function.
|
|
|
|
And vector **vector2** after calling this function will have the same coordinate
|
|
values that vector **vector1** had before calling the function.
|
|
|
|
Example of use:
|
|
|
|
```c
|
|
#include <stdio.h>
|
|
#include <basic-geometry.h>
|
|
|
|
int main()
|
|
{
|
|
BGC_FP32_Vector2 v1, v2;
|
|
|
|
|
|
bgc_fp32_vector2_set_values(&v1, -2, 7);
|
|
bgc_fp32_vector2_set_values(&v2, 10, -1);
|
|
|
|
bgc_fp32_vector2_swap(&v1, &v2);
|
|
|
|
printf("Vector #1: x = %f, y = %f\n", v1.x, v1.y);
|
|
printf("Vector #2: x = %f, y = %f\n", v2.x, v2.y);
|
|
|
|
return 0;
|
|
}
|
|
```
|
|
|
|
[Documentation](../intro-eng.md) / [2D vectors](../vector2-eng.md)
|