Переименование типов в соответствии со стилем POSIX, отказ от префикса bg_
This commit is contained in:
parent
d2a25823a5
commit
605afabd94
25 changed files with 1109 additions and 1035 deletions
|
@ -1,5 +1,5 @@
|
|||
#ifndef _GEOMETRY_VERSOR_H_
|
||||
#define _GEOMETRY_VERSOR_H_
|
||||
#ifndef _BASIC_GEOMETRY_VERSOR_H_
|
||||
#define _BASIC_GEOMETRY_VERSOR_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
@ -13,11 +13,11 @@
|
|||
|
||||
typedef struct {
|
||||
const float s0, x1, x2, x3;
|
||||
} BgFP32Versor;
|
||||
} fp32_versor_t;
|
||||
|
||||
typedef struct {
|
||||
const double s0, x1, x2, x3;
|
||||
} BgFP64Versor;
|
||||
} fp64_versor_t;
|
||||
|
||||
// ================= Dark Twins ================= //
|
||||
|
||||
|
@ -31,12 +31,12 @@ typedef struct {
|
|||
|
||||
// ================= Constants ================== //
|
||||
|
||||
extern const BgFP32Versor BG_FP32_IDLE_VERSOR;
|
||||
extern const BgFP64Versor BG_FP64_IDLE_VERSOR;
|
||||
extern const fp32_versor_t FP32_IDLE_VERSOR;
|
||||
extern const fp64_versor_t FP64_IDLE_VERSOR;
|
||||
|
||||
// =================== Reset ==================== //
|
||||
|
||||
static inline void bg_fp32_versor_reset(BgFP32Versor* versor)
|
||||
static inline void fp32_versor_reset(fp32_versor_t* versor)
|
||||
{
|
||||
__BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)versor;
|
||||
|
||||
|
@ -46,7 +46,7 @@ static inline void bg_fp32_versor_reset(BgFP32Versor* versor)
|
|||
twin->x3 = 0.0f;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_versor_reset(BgFP64Versor* versor)
|
||||
static inline void fp64_versor_reset(fp64_versor_t* versor)
|
||||
{
|
||||
__BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)versor;
|
||||
|
||||
|
@ -58,7 +58,7 @@ static inline void bg_fp64_versor_reset(BgFP64Versor* versor)
|
|||
|
||||
// ==================== Set ===================== //
|
||||
|
||||
static inline void bg_fp32_versor_set_values(const float s0, const float x1, const float x2, const float x3, BgFP32Versor* versor)
|
||||
static inline void fp32_versor_set_values(const float s0, const float x1, const float x2, const float x3, fp32_versor_t* versor)
|
||||
{
|
||||
__BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)versor;
|
||||
|
||||
|
@ -69,11 +69,11 @@ static inline void bg_fp32_versor_set_values(const float s0, const float x1, con
|
|||
|
||||
const float square_modulus = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
|
||||
|
||||
if (1.0f - BG_FP32_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0f + BG_FP32_TWO_EPSYLON) {
|
||||
if (1.0f - FP32_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0f + FP32_TWO_EPSYLON) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (square_modulus <= BG_FP32_SQUARE_EPSYLON) {
|
||||
if (square_modulus <= FP32_SQUARE_EPSYLON) {
|
||||
twin->s0 = 1.0f;
|
||||
twin->x1 = 0.0f;
|
||||
twin->x2 = 0.0f;
|
||||
|
@ -89,7 +89,7 @@ static inline void bg_fp32_versor_set_values(const float s0, const float x1, con
|
|||
twin->x3 *= multiplier;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_versor_set_values(const double s0, const double x1, const double x2, const double x3, BgFP64Versor* versor)
|
||||
static inline void fp64_versor_set_values(const double s0, const double x1, const double x2, const double x3, fp64_versor_t* versor)
|
||||
{
|
||||
__BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)versor;
|
||||
|
||||
|
@ -100,11 +100,11 @@ static inline void bg_fp64_versor_set_values(const double s0, const double x1, c
|
|||
|
||||
const double square_modulus = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
|
||||
|
||||
if (1.0 - BG_FP64_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0 + BG_FP64_TWO_EPSYLON) {
|
||||
if (1.0 - FP64_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0 + FP64_TWO_EPSYLON) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (square_modulus <= BG_FP64_SQUARE_EPSYLON) {
|
||||
if (square_modulus <= FP64_SQUARE_EPSYLON) {
|
||||
twin->s0 = 1.0;
|
||||
twin->x1 = 0.0;
|
||||
twin->x2 = 0.0;
|
||||
|
@ -122,7 +122,7 @@ static inline void bg_fp64_versor_set_values(const double s0, const double x1, c
|
|||
|
||||
// ==================== Copy ==================== //
|
||||
|
||||
static inline void bg_fp32_versor_copy(const BgFP32Versor* from, BgFP32Versor* to)
|
||||
static inline void fp32_versor_copy(const fp32_versor_t* from, fp32_versor_t* to)
|
||||
{
|
||||
__BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)to;
|
||||
|
||||
|
@ -132,7 +132,7 @@ static inline void bg_fp32_versor_copy(const BgFP32Versor* from, BgFP32Versor* t
|
|||
twin->x3 = from->x3;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_versor_copy(const BgFP64Versor* from, BgFP64Versor* to)
|
||||
static inline void fp64_versor_copy(const fp64_versor_t* from, fp64_versor_t* to)
|
||||
{
|
||||
__BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)to;
|
||||
|
||||
|
@ -144,7 +144,7 @@ static inline void bg_fp64_versor_copy(const BgFP64Versor* from, BgFP64Versor* t
|
|||
|
||||
// ==================== Swap ==================== //
|
||||
|
||||
static inline void bg_fp32_versor_swap(BgFP32Versor* versor1, BgFP32Versor* versor2)
|
||||
static inline void fp32_versor_swap(fp32_versor_t* versor1, fp32_versor_t* versor2)
|
||||
{
|
||||
const float s0 = versor1->s0;
|
||||
const float x1 = versor1->x1;
|
||||
|
@ -166,7 +166,7 @@ static inline void bg_fp32_versor_swap(BgFP32Versor* versor1, BgFP32Versor* vers
|
|||
twin2->x3 = x3;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_versor_swap(BgFP64Versor* versor1, BgFP64Versor* versor2)
|
||||
static inline void fp64_versor_swap(fp64_versor_t* versor1, fp64_versor_t* versor2)
|
||||
{
|
||||
const double s0 = versor1->s0;
|
||||
const double x1 = versor1->x1;
|
||||
|
@ -190,51 +190,51 @@ static inline void bg_fp64_versor_swap(BgFP64Versor* versor1, BgFP64Versor* vers
|
|||
|
||||
// =============== 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);
|
||||
void fp32_versor_set_crude_turn(const float x1, const float x2, const float x3, const float angle, const angle_unit_t unit, fp32_versor_t* result);
|
||||
|
||||
void bg_fp64_versor_set_crude_turn(const double x1, const double x2, const double x3, const double angle, const angle_unit_t unit, BgFP64Versor* result);
|
||||
void fp64_versor_set_crude_turn(const double x1, const double x2, const double x3, const double angle, const angle_unit_t unit, fp64_versor_t* result);
|
||||
|
||||
// ================== Set Turn ================== //
|
||||
|
||||
static inline void bg_fp32_versor_set_turn(const BgFP32Vector3* axis, const float angle, const angle_unit_t unit, BgFP32Versor* result)
|
||||
static inline void fp32_versor_set_turn(const fp32_vector3_t* axis, const float angle, const angle_unit_t unit, fp32_versor_t* result)
|
||||
{
|
||||
bg_fp32_versor_set_crude_turn(axis->x1, axis->x2, axis->x3, angle, unit, result);
|
||||
fp32_versor_set_crude_turn(axis->x1, axis->x2, axis->x3, angle, unit, result);
|
||||
}
|
||||
|
||||
static inline void bg_fp64_versor_set_turn(const BgFP32Vector3* axis, const double angle, const angle_unit_t unit, BgFP64Versor* result)
|
||||
static inline void fp64_versor_set_turn(const fp32_vector3_t* axis, const double angle, const angle_unit_t unit, fp64_versor_t* result)
|
||||
{
|
||||
bg_fp64_versor_set_crude_turn(axis->x1, axis->x2, axis->x3, angle, unit, result);
|
||||
fp64_versor_set_crude_turn(axis->x1, axis->x2, axis->x3, angle, unit, result);
|
||||
}
|
||||
|
||||
// ================ Set Rotation ================ //
|
||||
|
||||
static inline void bg_fp32_versor_set_rotation(const BgFP32Rotation3* rotation, BgFP32Versor* result)
|
||||
static inline void fp32_versor_set_rotation(const fp32_rotation3_t* rotation, fp32_versor_t* result)
|
||||
{
|
||||
bg_fp32_versor_set_crude_turn(rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BG_ANGLE_UNIT_RADIANS, result);
|
||||
fp32_versor_set_crude_turn(rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BG_ANGLE_UNIT_RADIANS, result);
|
||||
}
|
||||
|
||||
static inline void bg_fp64_versor_set_rotation(const BgFP64Rotation3* rotation, BgFP64Versor* result)
|
||||
static inline void fp64_versor_set_rotation(const fp64_rotation3_t* rotation, fp64_versor_t* result)
|
||||
{
|
||||
bg_fp64_versor_set_crude_turn(rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BG_ANGLE_UNIT_RADIANS, result);
|
||||
fp64_versor_set_crude_turn(rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BG_ANGLE_UNIT_RADIANS, result);
|
||||
}
|
||||
|
||||
// ================= Comparison ================= //
|
||||
|
||||
static inline int bg_fp32_versor_is_idle(const BgFP32Versor* versor)
|
||||
static inline int fp32_versor_is_idle(const fp32_versor_t* versor)
|
||||
{
|
||||
return 1.0f - BG_FP32_EPSYLON <= versor->s0 || versor->s0 <= -(1.0 - BG_FP32_EPSYLON);
|
||||
return 1.0f - FP32_EPSYLON <= versor->s0 || versor->s0 <= -(1.0 - FP32_EPSYLON);
|
||||
}
|
||||
|
||||
static inline int bg_fp64_versor_is_idle(const BgFP64Versor* versor)
|
||||
static inline int fp64_versor_is_idle(const fp64_versor_t* versor)
|
||||
{
|
||||
return 1.0 - BG_FP64_EPSYLON <= versor->s0 || versor->s0 <= -(1.0 - BG_FP64_EPSYLON);
|
||||
return 1.0 - FP64_EPSYLON <= versor->s0 || versor->s0 <= -(1.0 - FP64_EPSYLON);
|
||||
}
|
||||
|
||||
// ============= Copy to twin type ============== //
|
||||
|
||||
static inline void bg_fp32_versor_set_from_fp64(const BgFP64Versor* versor, BgFP32Versor* result)
|
||||
static inline void fp32_versor_set_from_fp64(const fp64_versor_t* versor, fp32_versor_t* result)
|
||||
{
|
||||
bg_fp32_versor_set_values(
|
||||
fp32_versor_set_values(
|
||||
(float) versor->s0,
|
||||
(float) versor->x1,
|
||||
(float) versor->x2,
|
||||
|
@ -243,9 +243,9 @@ static inline void bg_fp32_versor_set_from_fp64(const BgFP64Versor* versor, BgFP
|
|||
);
|
||||
}
|
||||
|
||||
static inline void bg_fp64_versor_set_from_fp32(const BgFP32Versor* versor, BgFP64Versor* result)
|
||||
static inline void fp64_versor_set_from_fp32(const fp32_versor_t* versor, fp64_versor_t* result)
|
||||
{
|
||||
bg_fp64_versor_set_values(
|
||||
fp64_versor_set_values(
|
||||
versor->s0,
|
||||
versor->x1,
|
||||
versor->x2,
|
||||
|
@ -256,7 +256,7 @@ static inline void bg_fp64_versor_set_from_fp32(const BgFP32Versor* versor, BgFP
|
|||
|
||||
// ================== Shorten =================== //
|
||||
|
||||
static inline void bg_fp32_versor_shorten(BgFP32Versor* versor)
|
||||
static inline void fp32_versor_shorten(fp32_versor_t* versor)
|
||||
{
|
||||
if (versor->s0 >= 0.0f) {
|
||||
return;
|
||||
|
@ -269,7 +269,7 @@ static inline void bg_fp32_versor_shorten(BgFP32Versor* versor)
|
|||
twin->x3 = -versor->x3;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_versor_shorten(BgFP64Versor* versor)
|
||||
static inline void fp64_versor_shorten(fp64_versor_t* versor)
|
||||
{
|
||||
if (versor->s0 >= 0.0f) {
|
||||
return;
|
||||
|
@ -284,7 +284,7 @@ static inline void bg_fp64_versor_shorten(BgFP64Versor* versor)
|
|||
|
||||
// ================== Shorten =================== //
|
||||
|
||||
static inline void bg_fp32_versor_set_shortened(const BgFP32Versor* versor, BgFP32Versor* shortened)
|
||||
static inline void fp32_versor_set_shortened(const fp32_versor_t* versor, fp32_versor_t* shortened)
|
||||
{
|
||||
__BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)shortened;
|
||||
|
||||
|
@ -302,7 +302,7 @@ static inline void bg_fp32_versor_set_shortened(const BgFP32Versor* versor, BgFP
|
|||
twin->x3 = -versor->x3;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_versor_set_shortened(const BgFP64Versor* versor, BgFP64Versor* shortened)
|
||||
static inline void fp64_versor_set_shortened(const fp64_versor_t* versor, fp64_versor_t* shortened)
|
||||
{
|
||||
__BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)shortened;
|
||||
|
||||
|
@ -322,7 +322,7 @@ static inline void bg_fp64_versor_set_shortened(const BgFP64Versor* versor, BgFP
|
|||
|
||||
// ================= Inversion ================== //
|
||||
|
||||
static inline void bg_fp32_versor_invert(BgFP32Versor* versor)
|
||||
static inline void fp32_versor_invert(fp32_versor_t* versor)
|
||||
{
|
||||
__BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)versor;
|
||||
twin->x1 = -versor->x1;
|
||||
|
@ -330,7 +330,7 @@ static inline void bg_fp32_versor_invert(BgFP32Versor* versor)
|
|||
twin->x3 = -versor->x3;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_versor_invert(BgFP64Versor* versor)
|
||||
static inline void fp64_versor_invert(fp64_versor_t* versor)
|
||||
{
|
||||
__BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)versor;
|
||||
twin->x1 = -versor->x1;
|
||||
|
@ -340,7 +340,7 @@ static inline void bg_fp64_versor_invert(BgFP64Versor* versor)
|
|||
|
||||
// ================ Set Inverted ================ //
|
||||
|
||||
static inline void bg_fp32_versor_set_inverted(const BgFP32Versor* versor, BgFP32Versor* to)
|
||||
static inline void fp32_versor_set_inverted(const fp32_versor_t* versor, fp32_versor_t* to)
|
||||
{
|
||||
__BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)to;
|
||||
twin->s0 = versor->s0;
|
||||
|
@ -349,7 +349,7 @@ static inline void bg_fp32_versor_set_inverted(const BgFP32Versor* versor, BgFP3
|
|||
twin->x3 = -versor->x3;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_versor_set_inverted(const BgFP64Versor* versor, BgFP64Versor* to)
|
||||
static inline void fp64_versor_set_inverted(const fp64_versor_t* versor, fp64_versor_t* to)
|
||||
{
|
||||
__BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)to;
|
||||
twin->s0 = versor->s0;
|
||||
|
@ -360,9 +360,9 @@ static inline void bg_fp64_versor_set_inverted(const BgFP64Versor* versor, BgFP6
|
|||
|
||||
// ================ Set Inverted ================ //
|
||||
|
||||
static inline void bg_fp32_versor_set_inverted_fp64(const BgFP64Versor* versor, BgFP32Versor* to)
|
||||
static inline void fp32_versor_set_inverted_fp64(const fp64_versor_t* versor, fp32_versor_t* to)
|
||||
{
|
||||
bg_fp32_versor_set_values(
|
||||
fp32_versor_set_values(
|
||||
(float) versor->s0,
|
||||
(float) -versor->x1,
|
||||
(float) -versor->x2,
|
||||
|
@ -371,9 +371,9 @@ static inline void bg_fp32_versor_set_inverted_fp64(const BgFP64Versor* versor,
|
|||
);
|
||||
}
|
||||
|
||||
static inline void bg_fp64_versor_set_inverted_fp32(const BgFP32Versor* versor, BgFP64Versor* to)
|
||||
static inline void fp64_versor_set_inverted_fp32(const fp32_versor_t* versor, fp64_versor_t* to)
|
||||
{
|
||||
bg_fp64_versor_set_values(
|
||||
fp64_versor_set_values(
|
||||
versor->s0,
|
||||
-versor->x1,
|
||||
-versor->x2,
|
||||
|
@ -384,7 +384,7 @@ static inline void bg_fp64_versor_set_inverted_fp32(const BgFP32Versor* versor,
|
|||
|
||||
// ================ Combination ================= //
|
||||
|
||||
static inline void bg_fp32_versor_combine(const BgFP32Versor* second, const BgFP32Versor* first, BgFP32Versor* result)
|
||||
static inline void fp32_versor_combine(const fp32_versor_t* second, const fp32_versor_t* first, fp32_versor_t* result)
|
||||
{
|
||||
const float s0 = (second->s0 * first->s0 - second->x1 * first->x1) - (second->x2 * first->x2 + second->x3 * first->x3);
|
||||
const float x1 = (second->x1 * first->s0 + second->s0 * first->x1) - (second->x3 * first->x2 - second->x2 * first->x3);
|
||||
|
@ -400,7 +400,7 @@ static inline void bg_fp32_versor_combine(const BgFP32Versor* second, const BgFP
|
|||
twin->x2 = x2;
|
||||
twin->x3 = x3;
|
||||
|
||||
if (1.0f - BG_FP32_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0f + BG_FP32_TWO_EPSYLON) {
|
||||
if (1.0f - FP32_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0f + FP32_TWO_EPSYLON) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -412,7 +412,7 @@ static inline void bg_fp32_versor_combine(const BgFP32Versor* second, const BgFP
|
|||
twin->x3 *= multiplier;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_versor_combine(const BgFP64Versor* second, const BgFP64Versor* first, BgFP64Versor* result)
|
||||
static inline void fp64_versor_combine(const fp64_versor_t* second, const fp64_versor_t* first, fp64_versor_t* result)
|
||||
{
|
||||
const double s0 = (second->s0 * first->s0 - second->x1 * first->x1) - (second->x2 * first->x2 + second->x3 * first->x3);
|
||||
const double x1 = (second->x1 * first->s0 + second->s0 * first->x1) - (second->x3 * first->x2 - second->x2 * first->x3);
|
||||
|
@ -428,7 +428,7 @@ static inline void bg_fp64_versor_combine(const BgFP64Versor* second, const BgFP
|
|||
twin->x2 = x2;
|
||||
twin->x3 = x3;
|
||||
|
||||
if (1.0 - BG_FP64_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0 + BG_FP64_TWO_EPSYLON) {
|
||||
if (1.0 - FP64_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0 + FP64_TWO_EPSYLON) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -442,7 +442,7 @@ static inline void bg_fp64_versor_combine(const BgFP64Versor* second, const BgFP
|
|||
|
||||
// ============ Combination of three ============ //
|
||||
|
||||
static inline void bg_fp32_versor_combine3(const BgFP32Versor* third, const BgFP32Versor* second, const BgFP32Versor* first, BgFP32Versor* result)
|
||||
static inline void fp32_versor_combine3(const fp32_versor_t* third, const fp32_versor_t* second, const fp32_versor_t* first, fp32_versor_t* 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);
|
||||
|
@ -463,7 +463,7 @@ static inline void bg_fp32_versor_combine3(const BgFP32Versor* third, const BgFP
|
|||
twin->x2 = x2b;
|
||||
twin->x3 = x3b;
|
||||
|
||||
if (1.0f - BG_FP32_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0f + BG_FP32_TWO_EPSYLON) {
|
||||
if (1.0f - FP32_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0f + FP32_TWO_EPSYLON) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -475,7 +475,7 @@ static inline void bg_fp32_versor_combine3(const BgFP32Versor* third, const BgFP
|
|||
twin->x3 *= multiplier;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_versor_combine3(const BgFP64Versor* third, const BgFP64Versor* second, const BgFP64Versor* first, BgFP64Versor* result)
|
||||
static inline void fp64_versor_combine3(const fp64_versor_t* third, const fp64_versor_t* second, const fp64_versor_t* first, fp64_versor_t* 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);
|
||||
|
@ -496,7 +496,7 @@ static inline void bg_fp64_versor_combine3(const BgFP64Versor* third, const BgFP
|
|||
twin->x2 = x2b;
|
||||
twin->x3 = x3b;
|
||||
|
||||
if (1.0 - BG_FP64_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0 + BG_FP64_TWO_EPSYLON) {
|
||||
if (1.0 - FP64_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0 + FP64_TWO_EPSYLON) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -510,7 +510,7 @@ static inline void bg_fp64_versor_combine3(const BgFP64Versor* third, const BgFP
|
|||
|
||||
// ================= Exclusion ================== //
|
||||
|
||||
static inline void bg_fp32_versor_exclude(const BgFP32Versor* basic, const BgFP32Versor* exclusion, BgFP32Versor* result)
|
||||
static inline void fp32_versor_exclude(const fp32_versor_t* basic, const fp32_versor_t* exclusion, fp32_versor_t* result)
|
||||
{
|
||||
const float s0 = (basic->s0 * exclusion->s0 + basic->x1 * exclusion->x1) + (basic->x2 * exclusion->x2 + basic->x3 * exclusion->x3);
|
||||
const float x1 = (basic->x1 * exclusion->s0 - basic->s0 * exclusion->x1) + (basic->x3 * exclusion->x2 - basic->x2 * exclusion->x3);
|
||||
|
@ -526,7 +526,7 @@ static inline void bg_fp32_versor_exclude(const BgFP32Versor* basic, const BgFP3
|
|||
twin->x2 = x2;
|
||||
twin->x3 = x3;
|
||||
|
||||
if (1.0f - BG_FP32_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0f + BG_FP32_TWO_EPSYLON) {
|
||||
if (1.0f - FP32_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0f + FP32_TWO_EPSYLON) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -538,7 +538,7 @@ static inline void bg_fp32_versor_exclude(const BgFP32Versor* basic, const BgFP3
|
|||
twin->x3 *= multiplier;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_versor_exclude(const BgFP64Versor* basic, const BgFP64Versor* exclusion, BgFP64Versor* result)
|
||||
static inline void fp64_versor_exclude(const fp64_versor_t* basic, const fp64_versor_t* exclusion, fp64_versor_t* result)
|
||||
{
|
||||
const double s0 = (basic->s0 * exclusion->s0 + basic->x1 * exclusion->x1) + (basic->x2 * exclusion->x2 + basic->x3 * exclusion->x3);
|
||||
const double x1 = (basic->x1 * exclusion->s0 - basic->s0 * exclusion->x1) + (basic->x3 * exclusion->x2 - basic->x2 * exclusion->x3);
|
||||
|
@ -554,7 +554,7 @@ static inline void bg_fp64_versor_exclude(const BgFP64Versor* basic, const BgFP6
|
|||
twin->x2 = x2;
|
||||
twin->x3 = x3;
|
||||
|
||||
if (1.0 - BG_FP64_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0 + BG_FP64_TWO_EPSYLON) {
|
||||
if (1.0 - FP64_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0 + FP64_TWO_EPSYLON) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -568,13 +568,13 @@ static inline void bg_fp64_versor_exclude(const BgFP64Versor* basic, const BgFP6
|
|||
|
||||
// ================= Rotation3 ================== //
|
||||
|
||||
void bg_fp32_versor_get_rotation(const BgFP32Versor* versor, BgFP32Rotation3* result);
|
||||
void fp32_versor_get_rotation(const fp32_versor_t* versor, fp32_rotation3_t* result);
|
||||
|
||||
void bg_fp64_versor_get_rotation(const BgFP64Versor* versor, BgFP64Rotation3* result);
|
||||
void fp64_versor_get_rotation(const fp64_versor_t* versor, fp64_rotation3_t* result);
|
||||
|
||||
// =========== Make Rotation Matrix3x3 ========== //
|
||||
|
||||
static inline void bg_fp32_versor_make_rotation_matrix(const BgFP32Versor* versor, BgFP32Matrix3x3* matrix)
|
||||
static inline void fp32_versor_make_rotation_matrix(const fp32_versor_t* versor, fp32_matrix3x3_t* matrix)
|
||||
{
|
||||
const float s0s0 = versor->s0 * versor->s0;
|
||||
const float x1x1 = versor->x1 * versor->x1;
|
||||
|
@ -602,7 +602,7 @@ static inline void bg_fp32_versor_make_rotation_matrix(const BgFP32Versor* verso
|
|||
matrix->r1c3 = x1x3 + s0x2;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_versor_make_rotation_matrix(const BgFP64Versor* versor, BgFP64Matrix3x3* matrix)
|
||||
static inline void fp64_versor_make_rotation_matrix(const fp64_versor_t* versor, fp64_matrix3x3_t* matrix)
|
||||
{
|
||||
const double s0s0 = versor->s0 * versor->s0;
|
||||
const double x1x1 = versor->x1 * versor->x1;
|
||||
|
@ -632,7 +632,7 @@ static inline void bg_fp64_versor_make_rotation_matrix(const BgFP64Versor* verso
|
|||
|
||||
// =========== Make Reverse Matrix3x3 =========== //
|
||||
|
||||
static inline void bg_fp32_versor_make_reverse_matrix(const BgFP32Versor* versor, BgFP32Matrix3x3* matrix)
|
||||
static inline void fp32_versor_make_reverse_matrix(const fp32_versor_t* versor, fp32_matrix3x3_t* matrix)
|
||||
{
|
||||
const float s0s0 = versor->s0 * versor->s0;
|
||||
const float x1x1 = versor->x1 * versor->x1;
|
||||
|
@ -660,7 +660,7 @@ static inline void bg_fp32_versor_make_reverse_matrix(const BgFP32Versor* versor
|
|||
matrix->r1c3 = x1x3 - s0x2;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_versor_make_reverse_matrix(const BgFP64Versor* versor, BgFP64Matrix3x3* matrix)
|
||||
static inline void fp64_versor_make_reverse_matrix(const fp64_versor_t* versor, fp64_matrix3x3_t* matrix)
|
||||
{
|
||||
const double s0s0 = versor->s0 * versor->s0;
|
||||
const double x1x1 = versor->x1 * versor->x1;
|
||||
|
@ -690,7 +690,7 @@ static inline void bg_fp64_versor_make_reverse_matrix(const BgFP64Versor* versor
|
|||
|
||||
// ================ Turn Vector ================= //
|
||||
|
||||
static inline void bg_fp32_versor_turn(const BgFP32Versor* versor, const BgFP32Vector3* vector, BgFP32Vector3* result)
|
||||
static inline void fp32_versor_turn(const fp32_versor_t* versor, const fp32_vector3_t* vector, fp32_vector3_t* result)
|
||||
{
|
||||
const float tx1 = 2.0f * (versor->x2 * vector->x3 - versor->x3 * vector->x2);
|
||||
const float tx2 = 2.0f * (versor->x3 * vector->x1 - versor->x1 * vector->x3);
|
||||
|
@ -705,7 +705,7 @@ static inline void bg_fp32_versor_turn(const BgFP32Versor* versor, const BgFP32V
|
|||
result->x3 = x3;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_versor_turn(const BgFP64Versor* versor, const BgFP64Vector3* vector, BgFP64Vector3* result)
|
||||
static inline void fp64_versor_turn(const fp64_versor_t* versor, const fp64_vector3_t* vector, fp64_vector3_t* result)
|
||||
{
|
||||
const double tx1 = 2.0 * (versor->x2 * vector->x3 - versor->x3 * vector->x2);
|
||||
const double tx2 = 2.0 * (versor->x3 * vector->x1 - versor->x1 * vector->x3);
|
||||
|
@ -722,7 +722,7 @@ static inline void bg_fp64_versor_turn(const BgFP64Versor* versor, const BgFP64V
|
|||
|
||||
// ============== Turn Vector Back ============== //
|
||||
|
||||
static inline void bg_fp32_versor_turn_back(const BgFP32Versor* versor, const BgFP32Vector3* vector, BgFP32Vector3* result)
|
||||
static inline void fp32_versor_turn_back(const fp32_versor_t* versor, const fp32_vector3_t* vector, fp32_vector3_t* result)
|
||||
{
|
||||
const float tx1 = 2.0f * (versor->x2 * vector->x3 - versor->x3 * vector->x2);
|
||||
const float tx2 = 2.0f * (versor->x3 * vector->x1 - versor->x1 * vector->x3);
|
||||
|
@ -737,7 +737,7 @@ static inline void bg_fp32_versor_turn_back(const BgFP32Versor* versor, const Bg
|
|||
result->x3 = x3;
|
||||
}
|
||||
|
||||
static inline void bg_fp64_versor_turn_back(const BgFP64Versor* versor, const BgFP64Vector3* vector, BgFP64Vector3* result)
|
||||
static inline void fp64_versor_turn_back(const fp64_versor_t* versor, const fp64_vector3_t* vector, fp64_vector3_t* result)
|
||||
{
|
||||
const double tx1 = 2.0 * (versor->x2 * vector->x3 - versor->x3 * vector->x2);
|
||||
const double tx2 = 2.0 * (versor->x3 * vector->x1 - versor->x1 * vector->x3);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue