Добавлены функции модуля для версоров и кватернионо / Functions of modulus have been added for versors and quaternions
This commit is contained in:
parent
bef7ab98f4
commit
03e390c1d0
12 changed files with 246 additions and 211 deletions
|
@ -7,9 +7,9 @@ const BgFP32Versor BG_FP32_IDLE_VERSOR = { 1.0f, 0.0f, 0.0f, 0.0f };
|
|||
|
||||
const BgFP64Versor BG_FP64_IDLE_VERSOR = { 1.0, 0.0, 0.0, 0.0 };
|
||||
|
||||
void __bg_fp32_versor_normalize(const float square_module, __BgFP32DarkTwinVersor* twin)
|
||||
void __bg_fp32_versor_normalize(const float square_modulus, __BgFP32DarkTwinVersor* twin)
|
||||
{
|
||||
if (square_module <= BG_FP32_SQUARE_EPSYLON || (twin->s0 * twin->s0) >= (1.0f - BG_FP32_TWO_EPSYLON) * square_module) {
|
||||
if (square_modulus <= BG_FP32_SQUARE_EPSYLON || (twin->s0 * twin->s0) >= (1.0f - BG_FP32_TWO_EPSYLON) * square_modulus) {
|
||||
twin->s0 = 1.0f;
|
||||
twin->x1 = 0.0f;
|
||||
twin->x2 = 0.0f;
|
||||
|
@ -17,17 +17,17 @@ void __bg_fp32_versor_normalize(const float square_module, __BgFP32DarkTwinVerso
|
|||
return;
|
||||
}
|
||||
|
||||
const float module = sqrtf(square_module);
|
||||
const float modulus = sqrtf(square_modulus);
|
||||
|
||||
twin->s0 /= module;
|
||||
twin->x1 /= module;
|
||||
twin->x2 /= module;
|
||||
twin->x3 /= module;
|
||||
twin->s0 /= modulus;
|
||||
twin->x1 /= modulus;
|
||||
twin->x2 /= modulus;
|
||||
twin->x3 /= modulus;
|
||||
}
|
||||
|
||||
void __bg_fp64_versor_normalize(const double square_module, __BgFP64DarkTwinVersor* twin)
|
||||
void __bg_fp64_versor_normalize(const double square_modulus, __BgFP64DarkTwinVersor* twin)
|
||||
{
|
||||
if (square_module <= BG_FP64_SQUARE_EPSYLON || (twin->s0 * twin->s0) >= (1.0 - BG_FP64_TWO_EPSYLON) * square_module) {
|
||||
if (square_modulus <= BG_FP64_SQUARE_EPSYLON || (twin->s0 * twin->s0) >= (1.0 - BG_FP64_TWO_EPSYLON) * square_modulus) {
|
||||
twin->s0 = 1.0;
|
||||
twin->x1 = 0.0;
|
||||
twin->x2 = 0.0;
|
||||
|
@ -35,12 +35,12 @@ void __bg_fp64_versor_normalize(const double square_module, __BgFP64DarkTwinVers
|
|||
return;
|
||||
}
|
||||
|
||||
const double module = sqrt(square_module);
|
||||
const double modulus = sqrt(square_modulus);
|
||||
|
||||
twin->s0 /= module;
|
||||
twin->x1 /= module;
|
||||
twin->x2 /= module;
|
||||
twin->x3 /= module;
|
||||
twin->s0 /= modulus;
|
||||
twin->x1 /= modulus;
|
||||
twin->x2 /= modulus;
|
||||
twin->x3 /= modulus;
|
||||
}
|
||||
|
||||
// =============== Set Crude Turn =============== //
|
||||
|
@ -108,11 +108,11 @@ void bg_fp32_versor_get_rotation(const BgFP32Versor* versor, BgFP32Rotation3* re
|
|||
|
||||
result->radians = 2.0f * acosf(versor->s0 / sqrtf(versor->s0 * versor->s0 + square_vector));
|
||||
|
||||
const float vector_module = sqrtf(square_vector);
|
||||
const float vector_modulus = sqrtf(square_vector);
|
||||
|
||||
result->axis.x1 = versor->x1 / vector_module;
|
||||
result->axis.x2 = versor->x2 / vector_module;
|
||||
result->axis.x3 = versor->x3 / vector_module;
|
||||
result->axis.x1 = versor->x1 / vector_modulus;
|
||||
result->axis.x2 = versor->x2 / vector_modulus;
|
||||
result->axis.x3 = versor->x3 / vector_modulus;
|
||||
}
|
||||
|
||||
void bg_fp64_versor_get_rotation(const BgFP64Versor* versor, BgFP64Rotation3* result)
|
||||
|
@ -130,9 +130,9 @@ void bg_fp64_versor_get_rotation(const BgFP64Versor* versor, BgFP64Rotation3* re
|
|||
|
||||
result->radians = 2.0 * acos(versor->s0 / sqrt(versor->s0 * versor->s0 + square_vector));
|
||||
|
||||
const double vector_module = sqrt(square_vector);
|
||||
const double vector_modulus = sqrt(square_vector);
|
||||
|
||||
result->axis.x1 = versor->x1 / vector_module;
|
||||
result->axis.x2 = versor->x2 / vector_module;
|
||||
result->axis.x3 = versor->x3 / vector_module;
|
||||
result->axis.x1 = versor->x1 / vector_modulus;
|
||||
result->axis.x2 = versor->x2 / vector_modulus;
|
||||
result->axis.x3 = versor->x3 / vector_modulus;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue