Добавлены функции модуля для версоров и кватернионо / Functions of modulus have been added for versors and quaternions

This commit is contained in:
Andrey Pokidov 2024-11-25 19:47:45 +07:00
parent bef7ab98f4
commit 03e390c1d0
12 changed files with 246 additions and 211 deletions

View file

@ -9,15 +9,15 @@ void bg_fp32_quaternion_get_rotation_matrix(const BgFP32Quaternion* quaternion,
const float x2x2 = quaternion->x2 * quaternion->x2;
const float x3x3 = quaternion->x3 * quaternion->x3;
const float square_module = (s0s0 + x1x1) + (x2x2 + x3x3);
const float square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
if (-BG_FP32_EPSYLON <= square_module && square_module <= BG_FP32_EPSYLON)
if (-BG_FP32_EPSYLON <= square_modulus && square_modulus <= BG_FP32_EPSYLON)
{
bg_fp32_matrix3x3_set_to_identity(matrix);
return;
}
const float corrector1 = 1.0f / square_module;
const float corrector1 = 1.0f / square_modulus;
const float corrector2 = 2.0f * corrector1;
const float s0x1 = quaternion->s0 * quaternion->x1;
@ -47,15 +47,15 @@ void bg_fp64_quaternion_get_rotation_matrix(const BgFP64Quaternion* quaternion,
const double x2x2 = quaternion->x2 * quaternion->x2;
const double x3x3 = quaternion->x3 * quaternion->x3;
const double square_module = (s0s0 + x1x1) + (x2x2 + x3x3);
const double square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
if (-BG_FP64_EPSYLON <= square_module && square_module <= BG_FP64_EPSYLON)
if (-BG_FP64_EPSYLON <= square_modulus && square_modulus <= BG_FP64_EPSYLON)
{
bg_fp64_matrix3x3_set_to_identity(matrix);
return;
}
const double corrector1 = 1.0f / square_module;
const double corrector1 = 1.0f / square_modulus;
const double corrector2 = 2.0f * corrector1;
const double s0x1 = quaternion->s0 * quaternion->x1;
@ -87,15 +87,15 @@ void bg_fp32_quaternion_get_reverse_matrix(const BgFP32Quaternion* quaternion, B
const float x2x2 = quaternion->x2 * quaternion->x2;
const float x3x3 = quaternion->x3 * quaternion->x3;
const float square_module = (s0s0 + x1x1) + (x2x2 + x3x3);
const float square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
if (-BG_FP32_EPSYLON <= square_module && square_module <= BG_FP32_EPSYLON)
if (-BG_FP32_EPSYLON <= square_modulus && square_modulus <= BG_FP32_EPSYLON)
{
bg_fp32_matrix3x3_set_to_identity(matrix);
return;
}
const float corrector1 = 1.0f / square_module;
const float corrector1 = 1.0f / square_modulus;
const float corrector2 = 2.0f * corrector1;
const float s0x1 = quaternion->s0 * quaternion->x1;
@ -125,15 +125,15 @@ void bg_fp64_quaternion_get_reverse_matrix(const BgFP64Quaternion* quaternion, B
const double x2x2 = quaternion->x2 * quaternion->x2;
const double x3x3 = quaternion->x3 * quaternion->x3;
const double square_module = (s0s0 + x1x1) + (x2x2 + x3x3);
const double square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
if (-BG_FP64_EPSYLON <= square_module && square_module <= BG_FP64_EPSYLON)
if (-BG_FP64_EPSYLON <= square_modulus && square_modulus <= BG_FP64_EPSYLON)
{
bg_fp64_matrix3x3_set_to_identity(matrix);
return;
}
const double corrector1 = 1.0f / square_module;
const double corrector1 = 1.0f / square_modulus;
const double corrector2 = 2.0f * corrector1;
const double s0x1 = quaternion->s0 * quaternion->x1;