реорганизация функций проекта, уменьшение дублирующегося кода

This commit is contained in:
Andrey Pokidov 2025-02-04 13:20:46 +07:00
parent 6c0ae92ed4
commit 07623b2aa6
10 changed files with 84 additions and 67 deletions

View file

@ -73,11 +73,9 @@ inline void bgc_versor_set_values_fp32(const float s0, const float x1, const flo
const float square_modulus = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
if (1.0f - BGC_TWO_EPSYLON_FP32 <= square_modulus && square_modulus <= 1.0f + BGC_TWO_EPSYLON_FP32) {
return;
if (!bgc_is_sqare_value_unit_fp32(square_modulus)) {
_bgc_versor_normalize_fp32(square_modulus, twin);
}
_bgc_versor_normalize_fp32(square_modulus, twin);
}
inline void bgc_versor_set_values_fp64(const double s0, const double x1, const double x2, const double x3, BgcVersorFP64* versor)
@ -91,11 +89,9 @@ inline void bgc_versor_set_values_fp64(const double s0, const double x1, const d
const double square_modulus = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
if (1.0 - BGC_TWO_EPSYLON_FP64 <= square_modulus && square_modulus <= 1.0 + BGC_TWO_EPSYLON_FP64) {
return;
if (!bgc_is_sqare_value_unit_fp64(square_modulus)) {
_bgc_versor_normalize_fp64(square_modulus, twin);
}
_bgc_versor_normalize_fp64(square_modulus, twin);
}
// ==================== Copy ==================== //
@ -200,12 +196,12 @@ inline void bgc_versor_set_rotation_fp64(const BgcRotation3FP64* rotation, BgcVe
inline int bgc_versor_is_idle_fp32(const BgcVersorFP32* versor)
{
return 1.0f - BGC_EPSYLON_FP32 <= versor->s0 || versor->s0 <= -(1.0 - BGC_EPSYLON_FP32);
return (1.0f - BGC_EPSYLON_FP32 <= versor->s0) | (versor->s0 <= -(1.0 - BGC_EPSYLON_FP32));
}
inline int bgc_versor_is_idle_fp64(const BgcVersorFP64* versor)
{
return 1.0 - BGC_EPSYLON_FP64 <= versor->s0 || versor->s0 <= -(1.0 - BGC_EPSYLON_FP64);
return (1.0 - BGC_EPSYLON_FP64 <= versor->s0) | (versor->s0 <= -(1.0 - BGC_EPSYLON_FP64));
}
// ============= Copy to twin type ============== //
@ -296,7 +292,7 @@ inline void bgc_versor_set_shortened_fp64(const BgcVersorFP64* versor, BgcVersor
twin->x1 = -versor->x1;
twin->x2 = -versor->x2;
twin->x3 = -versor->x3;
}
}
// ================= Inversion ================== //