Добавлены функции swap, shorten и exclude для версоров / Functions swap, shorten and exclude have been added for versors
This commit is contained in:
parent
081f794eb1
commit
5d4472150b
3 changed files with 172 additions and 16 deletions
|
|
@ -231,7 +231,7 @@ static inline int bg_fp64_quaternion_normalize(BgFP64Quaternion* quaternion)
|
|||
|
||||
// ============ Make Rotation Matrix ============ //
|
||||
|
||||
void bg_fp32_quaternion_get_rotation_matrix(const BgFP32Quaternion* quaternion, BgFP32Matrix3x3* matrix)
|
||||
static inline void bg_fp32_quaternion_get_rotation_matrix(const BgFP32Quaternion* quaternion, BgFP32Matrix3x3* matrix)
|
||||
{
|
||||
const float s0s0 = quaternion->s0 * quaternion->s0;
|
||||
const float x1x1 = quaternion->x1 * quaternion->x1;
|
||||
|
|
@ -269,7 +269,7 @@ void bg_fp32_quaternion_get_rotation_matrix(const BgFP32Quaternion* quaternion,
|
|||
matrix->r1c3 = corrector2 * (x1x3 + s0x2);
|
||||
}
|
||||
|
||||
void bg_fp64_quaternion_get_rotation_matrix(const BgFP64Quaternion* quaternion, BgFP64Matrix3x3* matrix)
|
||||
static inline void bg_fp64_quaternion_get_rotation_matrix(const BgFP64Quaternion* quaternion, BgFP64Matrix3x3* matrix)
|
||||
{
|
||||
const double s0s0 = quaternion->s0 * quaternion->s0;
|
||||
const double x1x1 = quaternion->x1 * quaternion->x1;
|
||||
|
|
|
|||
|
|
@ -142,6 +142,52 @@ static inline void bg_fp64_versor_copy(const BgFP64Versor* from, BgFP64Versor* t
|
|||
twin->x3 = from->x3;
|
||||
}
|
||||
|
||||
// ==================== Swap ==================== //
|
||||
|
||||
static inline void bg_fp32_versor_swap(BgFP32Versor* versor1, BgFP32Versor* versor2)
|
||||
{
|
||||
const float s0 = versor1->s0;
|
||||
const float x1 = versor1->x1;
|
||||
const float x2 = versor1->x2;
|
||||
const float x3 = versor1->x3;
|
||||
|
||||
__BgFP32DarkTwinVersor* twin1 = (__BgFP32DarkTwinVersor*)versor1;
|
||||
|
||||
twin1->s0 = versor2->s0;
|
||||
twin1->x1 = versor2->x1;
|
||||
twin1->x2 = versor2->x2;
|
||||
twin1->x3 = versor2->x3;
|
||||
|
||||
__BgFP32DarkTwinVersor* twin2 = (__BgFP32DarkTwinVersor*)versor2;
|
||||
|
||||
twin2->s0 = s0;
|
||||
twin2->x1 = x1;
|
||||
twin2->x2 = x2;
|
||||
twin2->x3 = x3;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_versor_swap(BgFP64Versor* versor1, BgFP64Versor* versor2)
|
||||
{
|
||||
const double s0 = versor1->s0;
|
||||
const double x1 = versor1->x1;
|
||||
const double x2 = versor1->x2;
|
||||
const double x3 = versor1->x3;
|
||||
|
||||
__BgFP64DarkTwinVersor* twin1 = (__BgFP64DarkTwinVersor*)versor1;
|
||||
|
||||
twin1->s0 = versor2->s0;
|
||||
twin1->x1 = versor2->x1;
|
||||
twin1->x2 = versor2->x2;
|
||||
twin1->x3 = versor2->x3;
|
||||
|
||||
__BgFP64DarkTwinVersor* twin2 = (__BgFP64DarkTwinVersor*)versor2;
|
||||
|
||||
twin2->s0 = s0;
|
||||
twin2->x1 = x1;
|
||||
twin2->x2 = x2;
|
||||
twin2->x3 = x3;
|
||||
}
|
||||
|
||||
// =============== Set Crude Turn =============== //
|
||||
|
||||
void bg_fp32_versor_set_crude_turn(const float x1, const float x2, const float x3, const float angle, const angle_unit_t unit, BgFP32Versor* result);
|
||||
|
|
@ -232,6 +278,72 @@ static inline void bg_fp64_versor_set_from_fp32(const BgFP32Versor* versor, BgFP
|
|||
);
|
||||
}
|
||||
|
||||
// ================== Shorten =================== //
|
||||
|
||||
static inline void bg_fp32_versor_shorten(BgFP32Versor* versor)
|
||||
{
|
||||
if (versor->s0 >= 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
||||