Удаление функций set_value для структур с открытыми полями (векторы и кватернионы)
This commit is contained in:
parent
e2bf8d28a8
commit
abf99a7126
25 changed files with 597 additions and 707 deletions
|
|
@ -38,7 +38,7 @@ C 语言没有命名空间,因此名称中的前缀起到了命名空间的作
|
|||
该库使用两种浮点数类型:**float** 和 **double**(**IEEE 754** 标准的 **binary32** 和 **binary64** 类型)。
|
||||
|
||||
因此,该库有两个类型前缀:
|
||||
- **FP32** - 表示 Floating Point 32-bit, 即 32 位浮点数,对应于 C 语言中的 **float** 类型。
|
||||
- **FP32** - 表示 Floating Point 32-bit,即 32 位浮点数,对应于 C 语言中的 **float** 类型。
|
||||
- **FP64** - 表示 Floating Point 64-bit,即 64 位浮点数,对应于 C 语言中的 **double** 类型。
|
||||
|
||||
基于浮点数类型的结构体和常量以 FP32_** 为前缀:
|
||||
|
|
|
|||
|
|
@ -2,15 +2,11 @@
|
|||
|
||||
[Русская версия / Russian version](copy-rus.md)
|
||||
|
||||
Function for **BGC_FP32_Quaternion**:
|
||||
## Function options
|
||||
|
||||
```c
|
||||
inline void bgc_fp32_quaternion_copy(BGC_FP32_Quaternion* const destination, const BGC_FP32_Quaternion* const source);
|
||||
```
|
||||
|
||||
Function for **BGC_FP64_Quaternion**:
|
||||
|
||||
```c
|
||||
inline void bgc_fp64_quaternion_copy(BGC_FP64_Quaternion* const destination, const BGC_FP64_Quaternion* const source);
|
||||
```
|
||||
|
||||
|
|
@ -25,7 +21,7 @@ destination->y = source->y;
|
|||
destination->z = source->z;
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
| Parameter | Direction | Description |
|
||||
| ----------- | ---------- | -------------------------------------------------------------------------------- |
|
||||
|
|
@ -34,7 +30,7 @@ destination->z = source->z;
|
|||
|
||||
The *source* and *destination* parameters must be valid pointers. The NULL (0) value is also considered invalid.
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
```c
|
||||
#include <stdio.h>
|
||||
|
|
|
|||
|
|
@ -2,15 +2,9 @@
|
|||
|
||||
[English version / Английская версия](copy-eng.md)
|
||||
|
||||
Функция для **BGC_FP32_Quaternion**:
|
||||
|
||||
```c
|
||||
inline void bgc_fp32_quaternion_copy(BGC_FP32_Quaternion* const destination, const BGC_FP32_Quaternion* const source);
|
||||
```
|
||||
|
||||
Функция для **BGC_FP64_Quaternion**:
|
||||
|
||||
```c
|
||||
inline void bgc_fp64_quaternion_copy(BGC_FP64_Quaternion* const destination, const BGC_FP64_Quaternion* const source);
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -28,10 +28,6 @@ The fields *x* and *y* are the coordinates of a 3D vector.
|
|||
- bgc_fp32_vector2_reset
|
||||
- bgc_fp64_vector2_reset
|
||||
|
||||
- [Set Values](vector2/set-values-eng.md)
|
||||
- bgc_fp32_vector2_set_values
|
||||
- bgc_fp64_vector2_set_values
|
||||
|
||||
- [Copy](vector2/copy-eng.md)
|
||||
- bgc_fp32_vector2_copy
|
||||
- bgc_fp64_vector2_copy
|
||||
|
|
|
|||
|
|
@ -28,10 +28,6 @@
|
|||
- bgc_fp32_vector2_reset
|
||||
- bgc_fp64_vector2_reset
|
||||
|
||||
- [Установка значений координат](vector2/set-values-rus.md)
|
||||
- bgc_fp32_vector2_set_values
|
||||
- bgc_fp64_vector2_set_values
|
||||
|
||||
- [Копирование значений координат](vector2/copy-rus.md)
|
||||
- bgc_fp32_vector2_copy
|
||||
- bgc_fp64_vector2_copy
|
||||
|
|
|
|||
|
|
@ -1,52 +0,0 @@
|
|||
# Setting the coordinates of a two-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_Vector2**:
|
||||
|
||||
```c
|
||||
inline void bgc_fp32_vector2_set_values(BGC_FP32_Vector2* const destination, const float x, const float y);
|
||||
```
|
||||
|
||||
Function for **BGC_FP64_Vector2**:
|
||||
|
||||
```c
|
||||
inline void bgc_fp64_vector2_set_values(BGC_FP64_Vector2* const destination, const double x, const double y);
|
||||
```
|
||||
|
||||
Each of these functions is equivalent to the following lines of code:
|
||||
|
||||
```c
|
||||
destination->x = x;
|
||||
destination->y = y;
|
||||
```
|
||||
|
||||
Valid pointers should pass in the **destination** parameter.
|
||||
The NULL (0) value is 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_Vector2 v;
|
||||
|
||||
bgc_fp32_vector2_set_values(&v, -2.2f, 7.1f);
|
||||
|
||||
printf("x = %f, y = %f\n", v.x, v.y);
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
[Documentation](../intro-eng.md) / [2D vectors](../vector2-eng.md)
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
# Задание координат двумерного вектора
|
||||
|
||||
[English version / Английская версия](set-values-eng.md)
|
||||
|
||||
Задавать координаты векторов можно как напрямую, так и спомощью функций. Функции
|
||||
задания значений координат позволяют сделать это одной строкой.
|
||||
|
||||
Функция для **BGC_FP32_Vector2**:
|
||||
|
||||
```c
|
||||
inline void bgc_fp32_vector2_set_values(BGC_FP32_Vector2* const destination, const float x, const float y);
|
||||
```
|
||||
|
||||
Функция для **BGC_FP64_Vector2**:
|
||||
|
||||
```c
|
||||
inline void bgc_fp64_vector2_set_values(BGC_FP64_Vector2* const destination, const double x, const double y);
|
||||
```
|
||||
|
||||
Каждая из данных функции эквивалентна следующим строкам кода:
|
||||
|
||||
```c
|
||||
destination->x = x;
|
||||
destination->y = y;
|
||||
```
|
||||
|
||||
В параметре **destination** следует передавать корректные указатели.
|
||||
Значение NULL (0) считается некорректным.
|
||||
|
||||
Данная функция хорошо подходит для заданя значений координат вектора одной
|
||||
строкой. Особенно если надо указать фиксированные значения координат как
|
||||
в примере ниже.
|
||||
|
||||
Пример применения:
|
||||
|
||||
```c
|
||||
#include <stdio.h>
|
||||
#include <basic-geometry.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
BGC_FP32_Vector2 v;
|
||||
|
||||
bgc_fp32_vector2_set_values(&v, -2.2f, 7.1f);
|
||||
|
||||
printf("x = %f, y = %f\n", v.x, v.y);
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
[Документация](../intro-rus.md) / [2D векторы](../vector2-rus.md)
|
||||
|
|
@ -28,10 +28,6 @@ The fields *x*, *y* and *z* are the coordinates of a 3D vector.
|
|||
- bgc_fp32_vector3_reset
|
||||
- bgc_fp64_vector3_reset
|
||||
|
||||
- [Set Values](vector3/set-values-eng.md)
|
||||
- bgc_fp32_vector3_set_values
|
||||
- bgc_fp64_vector3_set_values
|
||||
|
||||
- [Copy](vector3/copy-eng.md)
|
||||
- bgc_fp32_vector3_copy
|
||||
- bgc_fp64_vector3_copy
|
||||
|
|
|
|||
|
|
@ -28,10 +28,6 @@
|
|||
- bgc_fp32_vector3_reset
|
||||
- bgc_fp64_vector3_reset
|
||||
|
||||
- [Установка значений координат](vector3/set-values-rus.md)
|
||||
- bgc_fp32_vector3_set_values
|
||||
- bgc_fp64_vector3_set_values
|
||||
|
||||
- [Копирование координат](vector3/copy-rus.md)
|
||||
- bgc_fp32_vector3_copy
|
||||
- bgc_fp64_vector3_copy
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
# Setting the coordinates of a three-dimensional vector
|
||||
|
||||
[Русская версия / Russian version](set-values-rus.md)
|
||||
|
||||
The 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);
|
||||
```
|
||||
|
||||
The 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);
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
```c
|
||||
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
|
||||
|
||||
```c
|
||||
#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](../intro-eng.md) / [3D vectors](../vector3-eng.md)
|
||||
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
# Задание координат трёхмерного вектора.
|
||||
|
||||
[English version / Английская версия](set-values-eng.md)
|
||||
|
||||
Функция для **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);
|
||||
```
|
||||
|
||||
Функция для **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);
|
||||
```
|
||||
|
||||
Данные функции позволяют задать значения координат вектора одной строкой.
|
||||
|
||||
Такая возможность может быть удобна, когда нужно указать значения координат с помощью числовых констант как в примере ниже.
|
||||
|
||||
Каждая из функций аналогична следующим трём строкам кода:
|
||||
|
||||
```c
|
||||
destination->x = x;
|
||||
destination->y = y;
|
||||
destination->z = z;
|
||||
```
|
||||
|
||||
### Параметры
|
||||
|
||||
| Параметр | Направление | Описание |
|
||||
| ----------- | ----------- | -------------------------------------------------------------- |
|
||||
| destination | исходящий | Указатель на вектор, координаты которого будут заданы функцией |
|
||||
| x | входящий | Значение координаты X |
|
||||
| y | входящий | Значение координаты Y |
|
||||
| z | входящий | Значение координаты Z |
|
||||
|
||||
Параметр *destination* должен быть корректным указателем. Значение NULL (0) считается некорректным.
|
||||
|
||||
### Пример
|
||||
|
||||
```c
|
||||
#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;
|
||||
}
|
||||
```
|
||||
|
||||
[Документация](../intro-rus.md) / [Трёхмерные векторы](../vector3-rus.md)
|
||||
Loading…
Add table
Add a link
Reference in a new issue