Добавлена комбинация трёх версоров одной операцией
This commit is contained in:
parent
fcbec62024
commit
d2a25823a5
1 changed files with 68 additions and 0 deletions
|
@ -440,6 +440,74 @@ static inline void bg_fp64_versor_combine(const BgFP64Versor* second, const BgFP
|
||||||
twin->x3 *= multiplier;
|
twin->x3 *= multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ============ Combination of three ============ //
|
||||||
|
|
||||||
|
static inline void bg_fp32_versor_combine3(const BgFP32Versor* third, const BgFP32Versor* second, const BgFP32Versor* first, BgFP32Versor* result)
|
||||||
|
{
|
||||||
|
const float s0a = (second->s0 * first->s0 - second->x1 * first->x1) - (second->x2 * first->x2 + second->x3 * first->x3);
|
||||||
|
const float x1a = (second->x1 * first->s0 + second->s0 * first->x1) - (second->x3 * first->x2 - second->x2 * first->x3);
|
||||||
|
const float x2a = (second->x2 * first->s0 + second->s0 * first->x2) - (second->x1 * first->x3 - second->x3 * first->x1);
|
||||||
|
const float x3a = (second->x3 * first->s0 + second->s0 * first->x3) - (second->x2 * first->x1 - second->x1 * first->x2);
|
||||||
|
|
||||||
|
const float s0b = (third->s0 * s0a - third->x1 * x1a) - (third->x2 * x2a + third->x3 * x3a);
|
||||||
|
const float x1b = (third->x1 * s0a + third->s0 * x1a) - (third->x3 * x2a - third->x2 * x3a);
|
||||||
|
const float x2b = (third->x2 * s0a + third->s0 * x2a) - (third->x1 * x3a - third->x3 * x1a);
|
||||||
|
const float x3b = (third->x3 * s0a + third->s0 * x3a) - (third->x2 * x1a - third->x1 * x2a);
|
||||||
|
|
||||||
|
const float square_modulus = (s0b * s0b + x1b * x1b) + (x2b * x2b + x3b * x3b);
|
||||||
|
|
||||||
|
__BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)result;
|
||||||
|
|
||||||
|
twin->s0 = s0b;
|
||||||
|
twin->x1 = x1b;
|
||||||
|
twin->x2 = x2b;
|
||||||
|
twin->x3 = x3b;
|
||||||
|
|
||||||
|
if (1.0f - BG_FP32_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0f + BG_FP32_TWO_EPSYLON) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const float multiplier = sqrtf(1.0f / square_modulus);
|
||||||
|
|
||||||
|
twin->s0 *= multiplier;
|
||||||
|
twin->x1 *= multiplier;
|
||||||
|
twin->x2 *= multiplier;
|
||||||
|
twin->x3 *= multiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void bg_fp64_versor_combine3(const BgFP64Versor* third, const BgFP64Versor* second, const BgFP64Versor* first, BgFP64Versor* result)
|
||||||
|
{
|
||||||
|
const double s0a = (second->s0 * first->s0 - second->x1 * first->x1) - (second->x2 * first->x2 + second->x3 * first->x3);
|
||||||
|
const double x1a = (second->x1 * first->s0 + second->s0 * first->x1) - (second->x3 * first->x2 - second->x2 * first->x3);
|
||||||
|
const double x2a = (second->x2 * first->s0 + second->s0 * first->x2) - (second->x1 * first->x3 - second->x3 * first->x1);
|
||||||
|
const double x3a = (second->x3 * first->s0 + second->s0 * first->x3) - (second->x2 * first->x1 - second->x1 * first->x2);
|
||||||
|
|
||||||
|
const double s0b = (third->s0 * s0a - third->x1 * x1a) - (third->x2 * x2a + third->x3 * x3a);
|
||||||
|
const double x1b = (third->x1 * s0a + third->s0 * x1a) - (third->x3 * x2a - third->x2 * x3a);
|
||||||
|
const double x2b = (third->x2 * s0a + third->s0 * x2a) - (third->x1 * x3a - third->x3 * x1a);
|
||||||
|
const double x3b = (third->x3 * s0a + third->s0 * x3a) - (third->x2 * x1a - third->x1 * x2a);
|
||||||
|
|
||||||
|
const double square_modulus = (s0b * s0b + x1b * x1b) + (x2b * x2b + x3b * x3b);
|
||||||
|
|
||||||
|
__BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)result;
|
||||||
|
|
||||||
|
twin->s0 = s0b;
|
||||||
|
twin->x1 = x1b;
|
||||||
|
twin->x2 = x2b;
|
||||||
|
twin->x3 = x3b;
|
||||||
|
|
||||||
|
if (1.0 - BG_FP64_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0 + BG_FP64_TWO_EPSYLON) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const double multiplier = sqrt(1.0 / square_modulus);
|
||||||
|
|
||||||
|
twin->s0 *= multiplier;
|
||||||
|
twin->x1 *= multiplier;
|
||||||
|
twin->x2 *= multiplier;
|
||||||
|
twin->x3 *= multiplier;
|
||||||
|
}
|
||||||
|
|
||||||
// ================= Exclusion ================== //
|
// ================= Exclusion ================== //
|
||||||
|
|
||||||
static inline void bg_fp32_versor_exclude(const BgFP32Versor* basic, const BgFP32Versor* exclusion, BgFP32Versor* result)
|
static inline void bg_fp32_versor_exclude(const BgFP32Versor* basic, const BgFP32Versor* exclusion, BgFP32Versor* result)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue