Добавление функций восстановления позиции в трёхмерном пространстве (position3) по аффинному преобрезованию (affine3); небольшие исправления в документации, а также переименование некоторых переменных
This commit is contained in:
parent
39352af3f9
commit
178e004e3f
5 changed files with 122 additions and 68 deletions
|
|
@ -33,9 +33,15 @@ extern inline void bgc_fp64_position3_exclude(BGC_FP64_Position3* const differen
|
||||||
extern inline void bgc_fp32_position3_get_affine(BGC_FP32_Affine3* const outward_affine_map, const BGC_FP32_Position3* const position);
|
extern inline void bgc_fp32_position3_get_affine(BGC_FP32_Affine3* const outward_affine_map, const BGC_FP32_Position3* const position);
|
||||||
extern inline void bgc_fp64_position3_get_affine(BGC_FP64_Affine3* const outward_affine_map, const BGC_FP64_Position3* const position);
|
extern inline void bgc_fp64_position3_get_affine(BGC_FP64_Affine3* const outward_affine_map, const BGC_FP64_Position3* const position);
|
||||||
|
|
||||||
|
extern inline int bgc_fp32_position3_set_affine(BGC_FP32_Position3* const position, const BGC_FP32_Affine3* const affine_map);
|
||||||
|
extern inline int bgc_fp64_position3_set_affine(BGC_FP64_Position3* const position, const BGC_FP64_Affine3* const affine_map);
|
||||||
|
|
||||||
extern inline void bgc_fp32_position3_get_reverse_affine(BGC_FP32_Affine3* const inward_affine_map, const BGC_FP32_Position3* const position);
|
extern inline void bgc_fp32_position3_get_reverse_affine(BGC_FP32_Affine3* const inward_affine_map, const BGC_FP32_Position3* const position);
|
||||||
extern inline void bgc_fp64_position3_get_reverse_affine(BGC_FP64_Affine3* const inward_affine_map, const BGC_FP64_Position3* const position);
|
extern inline void bgc_fp64_position3_get_reverse_affine(BGC_FP64_Affine3* const inward_affine_map, const BGC_FP64_Position3* const position);
|
||||||
|
|
||||||
|
extern inline int bgc_fp32_position3_set_reverse_affine(BGC_FP32_Position3* const position, const BGC_FP32_Affine3* const affine_map);
|
||||||
|
extern inline int bgc_fp64_position3_set_reverse_affine(BGC_FP64_Position3* const position, const BGC_FP64_Affine3* const affine_map);
|
||||||
|
|
||||||
extern inline void bgc_fp32_position3_transform_point(BGC_FP32_Vector3* const transformed_point, const BGC_FP32_Position3* const position, const BGC_FP32_Vector3* const initial_point);
|
extern inline void bgc_fp32_position3_transform_point(BGC_FP32_Vector3* const transformed_point, const BGC_FP32_Position3* const position, const BGC_FP32_Vector3* const initial_point);
|
||||||
extern inline void bgc_fp64_position3_transform_point(BGC_FP64_Vector3* const transformed_point, const BGC_FP64_Position3* const position, const BGC_FP64_Vector3* const initial_point);
|
extern inline void bgc_fp64_position3_transform_point(BGC_FP64_Vector3* const transformed_point, const BGC_FP64_Position3* const position, const BGC_FP64_Vector3* const initial_point);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -170,6 +170,28 @@ inline void bgc_fp64_position3_get_affine(BGC_FP64_Affine3* const affine_map, co
|
||||||
bgc_fp64_vector3_copy(&affine_map->shift, &position->shift);
|
bgc_fp64_vector3_copy(&affine_map->shift, &position->shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ================= Set Affine ================== //
|
||||||
|
|
||||||
|
inline int bgc_fp32_position3_set_affine(BGC_FP32_Position3* const position, const BGC_FP32_Affine3* const affine_map)
|
||||||
|
{
|
||||||
|
if (bgc_fp32_quaternion_set_rotation_matrix(&position->turn._versor, &affine_map->distortion) == BGC_SUCCESS) {
|
||||||
|
bgc_fp32_vector3_copy(&position->shift, &affine_map->shift);
|
||||||
|
return BGC_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return BGC_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int bgc_fp64_position3_set_affine(BGC_FP64_Position3* const position, const BGC_FP64_Affine3* const affine_map)
|
||||||
|
{
|
||||||
|
if (bgc_fp64_quaternion_set_rotation_matrix(&position->turn._versor, &affine_map->distortion) == BGC_SUCCESS) {
|
||||||
|
bgc_fp64_vector3_copy(&position->shift, &affine_map->shift);
|
||||||
|
return BGC_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return BGC_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
// ============= Get Reverse Affine ============== //
|
// ============= Get Reverse Affine ============== //
|
||||||
|
|
||||||
inline void bgc_fp32_position3_get_reverse_affine(BGC_FP32_Affine3* const affine_map, const BGC_FP32_Position3* const position)
|
inline void bgc_fp32_position3_get_reverse_affine(BGC_FP32_Affine3* const affine_map, const BGC_FP32_Position3* const position)
|
||||||
|
|
@ -186,6 +208,32 @@ inline void bgc_fp64_position3_get_reverse_affine(BGC_FP64_Affine3* const affine
|
||||||
bgc_fp64_vector3_revert(&affine_map->shift);
|
bgc_fp64_vector3_revert(&affine_map->shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ============= Set Reverse Affine ============== //
|
||||||
|
|
||||||
|
inline int bgc_fp32_position3_set_reverse_affine(BGC_FP32_Position3* const position, const BGC_FP32_Affine3* const affine_map)
|
||||||
|
{
|
||||||
|
if (bgc_fp32_quaternion_set_rotation_matrix(&position->turn._versor, &affine_map->distortion) == BGC_SUCCESS) {
|
||||||
|
bgc_fp32_vector3_multiply_by_matrix3x3(&position->shift, &affine_map->shift, &affine_map->distortion);
|
||||||
|
bgc_fp32_quaternion_conjugate(&position->turn._versor);
|
||||||
|
bgc_fp32_vector3_revert(&position->shift);
|
||||||
|
return BGC_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return BGC_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int bgc_fp64_position3_set_reverse_affine(BGC_FP64_Position3* const position, const BGC_FP64_Affine3* const affine_map)
|
||||||
|
{
|
||||||
|
if (bgc_fp64_quaternion_set_rotation_matrix(&position->turn._versor, &affine_map->distortion) == BGC_SUCCESS) {
|
||||||
|
bgc_fp64_vector3_multiply_by_matrix3x3(&position->shift, &affine_map->shift, &affine_map->distortion);
|
||||||
|
bgc_fp64_quaternion_conjugate(&position->turn._versor);
|
||||||
|
bgc_fp64_vector3_revert(&position->shift);
|
||||||
|
return BGC_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return BGC_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
// =============== Transform Point =============== //
|
// =============== Transform Point =============== //
|
||||||
|
|
||||||
inline void bgc_fp32_position3_transform_point(BGC_FP32_Vector3* const transformed_point, const BGC_FP32_Position3* const position, const BGC_FP32_Vector3* const initial_point)
|
inline void bgc_fp32_position3_transform_point(BGC_FP32_Vector3* const transformed_point, const BGC_FP32_Position3* const position, const BGC_FP32_Vector3* const initial_point)
|
||||||
|
|
|
||||||
|
|
@ -303,64 +303,64 @@ int bgc_fp32_quaternion_set_rotation_matrix(BGC_FP32_Quaternion* const quaternio
|
||||||
return BGC_FAILURE;
|
return BGC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float ss_4 = (1 + matrix->r1c1) + (matrix->r2c2 + matrix->r3c3);
|
const float ss4 = (1 + matrix->r1c1) + (matrix->r2c2 + matrix->r3c3);
|
||||||
const float xx_4 = (1 + matrix->r1c1) - (matrix->r2c2 + matrix->r3c3);
|
const float xx4 = (1 + matrix->r1c1) - (matrix->r2c2 + matrix->r3c3);
|
||||||
const float yy_4 = (1 + matrix->r2c2) - (matrix->r1c1 + matrix->r3c3);
|
const float yy4 = (1 + matrix->r2c2) - (matrix->r1c1 + matrix->r3c3);
|
||||||
const float zz_4 = (1 + matrix->r3c3) - (matrix->r1c1 + matrix->r2c2);
|
const float zz4 = (1 + matrix->r3c3) - (matrix->r1c1 + matrix->r2c2);
|
||||||
|
|
||||||
const float sx_4 = matrix->r3c2 - matrix->r2c3;
|
const float sx4 = matrix->r3c2 - matrix->r2c3;
|
||||||
const float sy_4 = matrix->r1c3 - matrix->r3c1;
|
const float sy4 = matrix->r1c3 - matrix->r3c1;
|
||||||
const float sz_4 = matrix->r2c1 - matrix->r1c2;
|
const float sz4 = matrix->r2c1 - matrix->r1c2;
|
||||||
|
|
||||||
const float yz_4 = matrix->r3c2 + matrix->r2c3;
|
const float yz4 = matrix->r3c2 + matrix->r2c3;
|
||||||
const float xz_4 = matrix->r1c3 + matrix->r3c1;
|
const float xz4 = matrix->r1c3 + matrix->r3c1;
|
||||||
const float xy_4 = matrix->r2c1 + matrix->r1c2;
|
const float xy4 = matrix->r2c1 + matrix->r1c2;
|
||||||
|
|
||||||
float max = ss_4;
|
float max = ss4;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
if (xx_4 > max) {
|
if (xx4 > max) {
|
||||||
max = xx_4;
|
max = xx4;
|
||||||
index = 1;
|
index = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yy_4 > max) {
|
if (yy4 > max) {
|
||||||
max = yy_4;
|
max = yy4;
|
||||||
index = 2;
|
index = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zz_4 > max) {
|
if (zz4 > max) {
|
||||||
max = zz_4;
|
max = zz4;
|
||||||
index = 3;
|
index = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
quaternion->s = ss_4;
|
quaternion->s = ss4;
|
||||||
quaternion->x = sx_4;
|
quaternion->x = sx4;
|
||||||
quaternion->y = sy_4;
|
quaternion->y = sy4;
|
||||||
quaternion->z = sz_4;
|
quaternion->z = sz4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
quaternion->s = sx_4;
|
quaternion->s = sx4;
|
||||||
quaternion->x = xx_4;
|
quaternion->x = xx4;
|
||||||
quaternion->y = xy_4;
|
quaternion->y = xy4;
|
||||||
quaternion->z = xz_4;
|
quaternion->z = xz4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
quaternion->s = sy_4;
|
quaternion->s = sy4;
|
||||||
quaternion->x = xy_4;
|
quaternion->x = xy4;
|
||||||
quaternion->y = yy_4;
|
quaternion->y = yy4;
|
||||||
quaternion->z = yz_4;
|
quaternion->z = yz4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
quaternion->s = sz_4;
|
quaternion->s = sz4;
|
||||||
quaternion->x = xz_4;
|
quaternion->x = xz4;
|
||||||
quaternion->y = yz_4;
|
quaternion->y = yz4;
|
||||||
quaternion->z = zz_4;
|
quaternion->z = zz4;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -387,64 +387,64 @@ int bgc_fp64_quaternion_set_rotation_matrix(BGC_FP64_Quaternion* const quaternio
|
||||||
return BGC_FAILURE;
|
return BGC_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const double ss_4 = (1 + matrix->r1c1) + (matrix->r2c2 + matrix->r3c3);
|
const double ss4 = (1 + matrix->r1c1) + (matrix->r2c2 + matrix->r3c3);
|
||||||
const double xx_4 = (1 + matrix->r1c1) - (matrix->r2c2 - matrix->r3c3);
|
const double xx4 = (1 + matrix->r1c1) - (matrix->r2c2 - matrix->r3c3);
|
||||||
const double yy_4 = (1 + matrix->r2c2) - (matrix->r1c1 - matrix->r3c3);
|
const double yy4 = (1 + matrix->r2c2) - (matrix->r1c1 - matrix->r3c3);
|
||||||
const double zz_4 = (1 + matrix->r3c3) - (matrix->r1c1 - matrix->r2c2);
|
const double zz4 = (1 + matrix->r3c3) - (matrix->r1c1 - matrix->r2c2);
|
||||||
|
|
||||||
const double sx_4 = matrix->r3c2 - matrix->r2c3;
|
const double sx4 = matrix->r3c2 - matrix->r2c3;
|
||||||
const double sy_4 = matrix->r1c3 - matrix->r3c1;
|
const double sy4 = matrix->r1c3 - matrix->r3c1;
|
||||||
const double sz_4 = matrix->r2c1 - matrix->r1c2;
|
const double sz4 = matrix->r2c1 - matrix->r1c2;
|
||||||
|
|
||||||
const double yz_4 = matrix->r3c2 + matrix->r2c3;
|
const double yz4 = matrix->r3c2 + matrix->r2c3;
|
||||||
const double xz_4 = matrix->r1c3 + matrix->r3c1;
|
const double xz4 = matrix->r1c3 + matrix->r3c1;
|
||||||
const double xy_4 = matrix->r2c1 + matrix->r1c2;
|
const double xy4 = matrix->r2c1 + matrix->r1c2;
|
||||||
|
|
||||||
double max = ss_4;
|
double max = ss4;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
if (xx_4 > max) {
|
if (xx4 > max) {
|
||||||
max = xx_4;
|
max = xx4;
|
||||||
index = 1;
|
index = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yy_4 > max) {
|
if (yy4 > max) {
|
||||||
max = yy_4;
|
max = yy4;
|
||||||
index = 2;
|
index = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zz_4 > max) {
|
if (zz4 > max) {
|
||||||
max = zz_4;
|
max = zz4;
|
||||||
index = 3;
|
index = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
quaternion->s = ss_4;
|
quaternion->s = ss4;
|
||||||
quaternion->x = sx_4;
|
quaternion->x = sx4;
|
||||||
quaternion->y = sy_4;
|
quaternion->y = sy4;
|
||||||
quaternion->z = sz_4;
|
quaternion->z = sz4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
quaternion->s = sx_4;
|
quaternion->s = sx4;
|
||||||
quaternion->x = xx_4;
|
quaternion->x = xx4;
|
||||||
quaternion->y = xy_4;
|
quaternion->y = xy4;
|
||||||
quaternion->z = xz_4;
|
quaternion->z = xz4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
quaternion->s = sy_4;
|
quaternion->s = sy4;
|
||||||
quaternion->x = xy_4;
|
quaternion->x = xy4;
|
||||||
quaternion->y = yy_4;
|
quaternion->y = yy4;
|
||||||
quaternion->z = yz_4;
|
quaternion->z = yz4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
quaternion->s = sz_4;
|
quaternion->s = sz4;
|
||||||
quaternion->x = xz_4;
|
quaternion->x = xz4;
|
||||||
quaternion->y = yz_4;
|
quaternion->y = yz4;
|
||||||
quaternion->z = zz_4;
|
quaternion->z = zz4;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# Двумерные векторы векторы
|
# Двумерные векторы
|
||||||
|
|
||||||
[English (Английский)](vector2-eng.md)
|
[English (Английский)](vector2-eng.md)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# Трёхмерные векторы векторы
|
# Трёхмерные векторы
|
||||||
|
|
||||||
[English version / Английская версия](vector3-eng.md)
|
[English version / Английская версия](vector3-eng.md)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue