Завершение большого переименования
This commit is contained in:
parent
120e651517
commit
3805354611
31 changed files with 1213 additions and 1255 deletions
|
@ -1,9 +1,9 @@
|
|||
#ifndef _BASIC_GEOMETRY_VERSOR_H_
|
||||
#define _BASIC_GEOMETRY_VERSOR_H_
|
||||
#ifndef _BGC_VERSOR_H_
|
||||
#define _BGC_VERSOR_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "basis.h"
|
||||
#include "utilities.h"
|
||||
#include "angle.h"
|
||||
#include "vector3.h"
|
||||
#include "rotation3.h"
|
||||
|
@ -13,32 +13,32 @@
|
|||
|
||||
typedef struct {
|
||||
const float s0, x1, x2, x3;
|
||||
} versor_fp32_t;
|
||||
} bgc_versor_fp32_t;
|
||||
|
||||
typedef struct {
|
||||
const double s0, x1, x2, x3;
|
||||
} versor_fp64_t;
|
||||
} bgc_versor_fp64_t;
|
||||
|
||||
// ================= Dark Twins ================= //
|
||||
|
||||
typedef struct {
|
||||
float s0, x1, x2, x3;
|
||||
} __BgFP32DarkTwinVersor;
|
||||
} _bgc_dark_twin_versor_fp32_t;
|
||||
|
||||
typedef struct {
|
||||
double s0, x1, x2, x3;
|
||||
} __BgFP64DarkTwinVersor;
|
||||
} _bgc_dark_twin_versor_fp64_t;
|
||||
|
||||
// ================= Constants ================== //
|
||||
|
||||
extern const versor_fp32_t FP32_IDLE_VERSOR;
|
||||
extern const versor_fp64_t FP64_IDLE_VERSOR;
|
||||
extern const bgc_versor_fp32_t BGC_IDLE_VERSOR_FP32;
|
||||
extern const bgc_versor_fp64_t BGC_IDLE_VERSOR_FP64;
|
||||
|
||||
// =================== Reset ==================== //
|
||||
|
||||
inline void versor_reset_fp32(versor_fp32_t* versor)
|
||||
inline void bgc_versor_reset_fp32(bgc_versor_fp32_t* versor)
|
||||
{
|
||||
__BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)versor;
|
||||
_bgc_dark_twin_versor_fp32_t* twin = (_bgc_dark_twin_versor_fp32_t*)versor;
|
||||
|
||||
twin->s0 = 1.0f;
|
||||
twin->x1 = 0.0f;
|
||||
|
@ -46,9 +46,9 @@ inline void versor_reset_fp32(versor_fp32_t* versor)
|
|||
twin->x3 = 0.0f;
|
||||
}
|
||||
|
||||
inline void versor_reset_fp64(versor_fp64_t* versor)
|
||||
inline void bgc_versor_reset_fp64(bgc_versor_fp64_t* versor)
|
||||
{
|
||||
__BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)versor;
|
||||
_bgc_dark_twin_versor_fp64_t* twin = (_bgc_dark_twin_versor_fp64_t*)versor;
|
||||
|
||||
twin->s0 = 1.0;
|
||||
twin->x1 = 0.0;
|
||||
|
@ -58,9 +58,9 @@ inline void versor_reset_fp64(versor_fp64_t* versor)
|
|||
|
||||
// ==================== Set ===================== //
|
||||
|
||||
inline void versor_set_values_fp32(const float s0, const float x1, const float x2, const float x3, versor_fp32_t* versor)
|
||||
inline void bgc_versor_set_values_fp32(const float s0, const float x1, const float x2, const float x3, bgc_versor_fp32_t* versor)
|
||||
{
|
||||
__BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)versor;
|
||||
_bgc_dark_twin_versor_fp32_t* twin = (_bgc_dark_twin_versor_fp32_t*)versor;
|
||||
|
||||
twin->s0 = s0;
|
||||
twin->x1 = x1;
|
||||
|
@ -69,11 +69,11 @@ inline void versor_set_values_fp32(const float s0, const float x1, const float x
|
|||
|
||||
const float square_modulus = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
|
||||
|
||||
if (1.0f - FP32_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0f + FP32_TWO_EPSYLON) {
|
||||
if (1.0f - BGC_TWO_EPSYLON_FP32 <= square_modulus && square_modulus <= 1.0f + BGC_TWO_EPSYLON_FP32) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (square_modulus <= FP32_SQUARE_EPSYLON) {
|
||||
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32) {
|
||||
twin->s0 = 1.0f;
|
||||
twin->x1 = 0.0f;
|
||||
twin->x2 = 0.0f;
|
||||
|
@ -89,9 +89,9 @@ inline void versor_set_values_fp32(const float s0, const float x1, const float x
|
|||
twin->x3 *= multiplier;
|
||||
}
|
||||
|
||||
inline void versor_set_values_fp64(const double s0, const double x1, const double x2, const double x3, versor_fp64_t* versor)
|
||||
inline void bgc_versor_set_values_fp64(const double s0, const double x1, const double x2, const double x3, bgc_versor_fp64_t* versor)
|
||||
{
|
||||
__BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)versor;
|
||||
_bgc_dark_twin_versor_fp64_t* twin = (_bgc_dark_twin_versor_fp64_t*)versor;
|
||||
|
||||
twin->s0 = s0;
|
||||
twin->x1 = x1;
|
||||
|
@ -100,11 +100,11 @@ inline void versor_set_values_fp64(const double s0, const double x1, const doubl
|
|||
|
||||
const double square_modulus = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
|
||||
|
||||
if (1.0 - FP64_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0 + FP64_TWO_EPSYLON) {
|
||||
if (1.0 - BGC_TWO_EPSYLON_FP64 <= square_modulus && square_modulus <= 1.0 + BGC_TWO_EPSYLON_FP64) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (square_modulus <= FP64_SQUARE_EPSYLON) {
|
||||
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64) {
|
||||
twin->s0 = 1.0;
|
||||
twin->x1 = 0.0;
|
||||
twin->x2 = 0.0;
|
||||
|
@ -122,9 +122,9 @@ inline void versor_set_values_fp64(const double s0, const double x1, const doubl
|
|||
|
||||
// ==================== Copy ==================== //
|
||||
|
||||
inline void versor_copy_fp32(const versor_fp32_t* from, versor_fp32_t* to)
|
||||
inline void bgc_versor_copy_fp32(const bgc_versor_fp32_t* from, bgc_versor_fp32_t* to)
|
||||
{
|
||||
__BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)to;
|
||||
_bgc_dark_twin_versor_fp32_t* twin = (_bgc_dark_twin_versor_fp32_t*)to;
|
||||
|
||||
twin->s0 = from->s0;
|
||||
twin->x1 = from->x1;
|
||||
|
@ -132,9 +132,9 @@ inline void versor_copy_fp32(const versor_fp32_t* from, versor_fp32_t* to)
|
|||
twin->x3 = from->x3;
|
||||
}
|
||||
|
||||
inline void versor_copy_fp64(const versor_fp64_t* from, versor_fp64_t* to)
|
||||
inline void bgc_versor_copy_fp64(const bgc_versor_fp64_t* from, bgc_versor_fp64_t* to)
|
||||
{
|
||||
__BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)to;
|
||||
_bgc_dark_twin_versor_fp64_t* twin = (_bgc_dark_twin_versor_fp64_t*)to;
|
||||
|
||||
twin->s0 = from->s0;
|
||||
twin->x1 = from->x1;
|
||||
|
@ -144,21 +144,21 @@ inline void versor_copy_fp64(const versor_fp64_t* from, versor_fp64_t* to)
|
|||
|
||||
// ==================== Swap ==================== //
|
||||
|
||||
inline void versor_swap_fp32(versor_fp32_t* versor1, versor_fp32_t* versor2)
|
||||
inline void bgc_versor_swap_fp32(bgc_versor_fp32_t* versor1, bgc_versor_fp32_t* 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;
|
||||
_bgc_dark_twin_versor_fp32_t* twin1 = (_bgc_dark_twin_versor_fp32_t*)versor1;
|
||||
|
||||
twin1->s0 = versor2->s0;
|
||||
twin1->x1 = versor2->x1;
|
||||
twin1->x2 = versor2->x2;
|
||||
twin1->x3 = versor2->x3;
|
||||
|
||||
__BgFP32DarkTwinVersor* twin2 = (__BgFP32DarkTwinVersor*)versor2;
|
||||
_bgc_dark_twin_versor_fp32_t* twin2 = (_bgc_dark_twin_versor_fp32_t*)versor2;
|
||||
|
||||
twin2->s0 = s0;
|
||||
twin2->x1 = x1;
|
||||
|
@ -166,21 +166,21 @@ inline void versor_swap_fp32(versor_fp32_t* versor1, versor_fp32_t* versor2)
|
|||
twin2->x3 = x3;
|
||||
}
|
||||
|
||||
inline void versor_swap_fp64(versor_fp64_t* versor1, versor_fp64_t* versor2)
|
||||
inline void bgc_versor_swap_fp64(bgc_versor_fp64_t* versor1, bgc_versor_fp64_t* 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;
|
||||
_bgc_dark_twin_versor_fp64_t* twin1 = (_bgc_dark_twin_versor_fp64_t*)versor1;
|
||||
|
||||
twin1->s0 = versor2->s0;
|
||||
twin1->x1 = versor2->x1;
|
||||
twin1->x2 = versor2->x2;
|
||||
twin1->x3 = versor2->x3;
|
||||
|
||||
__BgFP64DarkTwinVersor* twin2 = (__BgFP64DarkTwinVersor*)versor2;
|
||||
_bgc_dark_twin_versor_fp64_t* twin2 = (_bgc_dark_twin_versor_fp64_t*)versor2;
|
||||
|
||||
twin2->s0 = s0;
|
||||
twin2->x1 = x1;
|
||||
|
@ -190,51 +190,51 @@ inline void versor_swap_fp64(versor_fp64_t* versor1, versor_fp64_t* versor2)
|
|||
|
||||
// =============== Set Crude Turn =============== //
|
||||
|
||||
void versor_set_crude_turn_fp32(const float x1, const float x2, const float x3, const float angle, const angle_unit_t unit, versor_fp32_t* result);
|
||||
void bgc_versor_set_crude_turn_fp32(const float x1, const float x2, const float x3, const float angle, const bgc_angle_unit_t unit, bgc_versor_fp32_t* result);
|
||||
|
||||
void versor_set_crude_turn_fp64(const double x1, const double x2, const double x3, const double angle, const angle_unit_t unit, versor_fp64_t* result);
|
||||
void bgc_versor_set_crude_turn_fp64(const double x1, const double x2, const double x3, const double angle, const bgc_angle_unit_t unit, bgc_versor_fp64_t* result);
|
||||
|
||||
// ================== Set Turn ================== //
|
||||
|
||||
inline void versor_set_turn_fp32(const vector3_fp32_t* axis, const float angle, const angle_unit_t unit, versor_fp32_t* result)
|
||||
inline void bgc_versor_set_turn_fp32(const bgc_vector3_fp32_t* axis, const float angle, const bgc_angle_unit_t unit, bgc_versor_fp32_t* result)
|
||||
{
|
||||
versor_set_crude_turn_fp32(axis->x1, axis->x2, axis->x3, angle, unit, result);
|
||||
bgc_versor_set_crude_turn_fp32(axis->x1, axis->x2, axis->x3, angle, unit, result);
|
||||
}
|
||||
|
||||
inline void versor_set_turn_fp64(const vector3_fp32_t* axis, const double angle, const angle_unit_t unit, versor_fp64_t* result)
|
||||
inline void bgc_versor_set_turn_fp64(const bgc_vector3_fp32_t* axis, const double angle, const bgc_angle_unit_t unit, bgc_versor_fp64_t* result)
|
||||
{
|
||||
versor_set_crude_turn_fp64(axis->x1, axis->x2, axis->x3, angle, unit, result);
|
||||
bgc_versor_set_crude_turn_fp64(axis->x1, axis->x2, axis->x3, angle, unit, result);
|
||||
}
|
||||
|
||||
// ================ Set Rotation ================ //
|
||||
|
||||
inline void versor_set_rotation_fp32(const rotation3_fp32_t* rotation, versor_fp32_t* result)
|
||||
inline void bgc_versor_set_rotation_fp32(const bgc_rotation3_fp32_t* rotation, bgc_versor_fp32_t* result)
|
||||
{
|
||||
versor_set_crude_turn_fp32(rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BG_ANGLE_UNIT_RADIANS, result);
|
||||
bgc_versor_set_crude_turn_fp32(rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BGC_ANGLE_UNIT_RADIANS, result);
|
||||
}
|
||||
|
||||
inline void versor_set_rotation_fp64(const rotation3_fp64_t* rotation, versor_fp64_t* result)
|
||||
inline void bgc_versor_set_rotation_fp64(const bgc_rotation3_fp64_t* rotation, bgc_versor_fp64_t* result)
|
||||
{
|
||||
versor_set_crude_turn_fp64(rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BG_ANGLE_UNIT_RADIANS, result);
|
||||
bgc_versor_set_crude_turn_fp64(rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BGC_ANGLE_UNIT_RADIANS, result);
|
||||
}
|
||||
|
||||
// ================= Comparison ================= //
|
||||
|
||||
inline int versor_is_idle_fp32(const versor_fp32_t* versor)
|
||||
inline int bgc_versor_is_idle_fp32(const bgc_versor_fp32_t* versor)
|
||||
{
|
||||
return 1.0f - FP32_EPSYLON <= versor->s0 || versor->s0 <= -(1.0 - FP32_EPSYLON);
|
||||
return 1.0f - BGC_EPSYLON_FP32 <= versor->s0 || versor->s0 <= -(1.0 - BGC_EPSYLON_FP32);
|
||||
}
|
||||
|
||||
inline int versor_is_idle_fp64(const versor_fp64_t* versor)
|
||||
inline int bgc_versor_is_idle_fp64(const bgc_versor_fp64_t* versor)
|
||||
{
|
||||
return 1.0 - FP64_EPSYLON <= versor->s0 || versor->s0 <= -(1.0 - FP64_EPSYLON);
|
||||
return 1.0 - BGC_EPSYLON_FP64 <= versor->s0 || versor->s0 <= -(1.0 - BGC_EPSYLON_FP64);
|
||||
}
|
||||
|
||||
// ============= Copy to twin type ============== //
|
||||
|
||||
inline void versor_convert_fp64_to_fp32(const versor_fp64_t* versor, versor_fp32_t* result)
|
||||
inline void bgc_versor_convert_fp64_to_fp32(const bgc_versor_fp64_t* versor, bgc_versor_fp32_t* result)
|
||||
{
|
||||
versor_set_values_fp32(
|
||||
bgc_versor_set_values_fp32(
|
||||
(float) versor->s0,
|
||||
(float) versor->x1,
|
||||
(float) versor->x2,
|
||||
|
@ -243,9 +243,9 @@ inline void versor_convert_fp64_to_fp32(const versor_fp64_t* versor, versor_fp32
|
|||
);
|
||||
}
|
||||
|
||||
inline void versor_convert_fp32_to_fp64(const versor_fp32_t* versor, versor_fp64_t* result)
|
||||
inline void bgc_versor_convert_fp32_to_fp64(const bgc_versor_fp32_t* versor, bgc_versor_fp64_t* result)
|
||||
{
|
||||
versor_set_values_fp64(
|
||||
bgc_versor_set_values_fp64(
|
||||
versor->s0,
|
||||
versor->x1,
|
||||
versor->x2,
|
||||
|
@ -256,26 +256,26 @@ inline void versor_convert_fp32_to_fp64(const versor_fp32_t* versor, versor_fp64
|
|||
|
||||
// ================== Shorten =================== //
|
||||
|
||||
inline void versor_shorten_fp32(versor_fp32_t* versor)
|
||||
inline void bgc_versor_shorten_fp32(bgc_versor_fp32_t* versor)
|
||||
{
|
||||
if (versor->s0 >= 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
||||
__BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)versor;
|
||||
_bgc_dark_twin_versor_fp32_t* twin = (_bgc_dark_twin_versor_fp32_t*)versor;
|
||||
twin->s0 = -versor->s0;
|
||||
twin->x1 = -versor->x1;
|
||||
twin->x2 = -versor->x2;
|
||||
twin->x3 = -versor->x3;
|
||||
}
|
||||
|
||||
inline void versor_shorten_fp64(versor_fp64_t* versor)
|
||||
inline void bgc_versor_shorten_fp64(bgc_versor_fp64_t* versor)
|
||||
{
|
||||
if (versor->s0 >= 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
||||
__BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)versor;
|
||||
_bgc_dark_twin_versor_fp64_t* twin = (_bgc_dark_twin_versor_fp64_t*)versor;
|
||||
twin->s0 = -versor->s0;
|
||||
twin->x1 = -versor->x1;
|
||||
twin->x2 = -versor->x2;
|
||||
|
@ -284,9 +284,9 @@ inline void versor_shorten_fp64(versor_fp64_t* versor)
|
|||
|
||||
// ================== Shorten =================== //
|
||||
|
||||
inline void versor_set_shortened_fp32(const versor_fp32_t* versor, versor_fp32_t* shortened)
|
||||
inline void bgc_versor_set_shortened_fp32(const bgc_versor_fp32_t* versor, bgc_versor_fp32_t* shortened)
|
||||
{
|
||||
__BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)shortened;
|
||||
_bgc_dark_twin_versor_fp32_t* twin = (_bgc_dark_twin_versor_fp32_t*)shortened;
|
||||
|
||||
if (versor->s0 >= 0.0f) {
|
||||
twin->x1 = versor->s0;
|
||||
|
@ -302,9 +302,9 @@ inline void versor_set_shortened_fp32(const versor_fp32_t* versor, versor_fp32_t
|
|||
twin->x3 = -versor->x3;
|
||||
}
|
||||
|
||||
inline void versor_set_shortened_fp64(const versor_fp64_t* versor, versor_fp64_t* shortened)
|
||||
inline void bgc_versor_set_shortened_fp64(const bgc_versor_fp64_t* versor, bgc_versor_fp64_t* shortened)
|
||||
{
|
||||
__BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)shortened;
|
||||
_bgc_dark_twin_versor_fp64_t* twin = (_bgc_dark_twin_versor_fp64_t*)shortened;
|
||||
|
||||
if (versor->s0 >= 0.0) {
|
||||
twin->x1 = versor->s0;
|
||||
|
@ -322,17 +322,17 @@ inline void versor_set_shortened_fp64(const versor_fp64_t* versor, versor_fp64_t
|
|||
|
||||
// ================= Inversion ================== //
|
||||
|
||||
inline void versor_invert_fp32(versor_fp32_t* versor)
|
||||
inline void bgc_versor_invert_fp32(bgc_versor_fp32_t* versor)
|
||||
{
|
||||
__BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)versor;
|
||||
_bgc_dark_twin_versor_fp32_t* twin = (_bgc_dark_twin_versor_fp32_t*)versor;
|
||||
twin->x1 = -versor->x1;
|
||||
twin->x2 = -versor->x2;
|
||||
twin->x3 = -versor->x3;
|
||||
}
|
||||
|
||||
inline void versor_invert_fp64(versor_fp64_t* versor)
|
||||
inline void bgc_versor_invert_fp64(bgc_versor_fp64_t* versor)
|
||||
{
|
||||
__BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)versor;
|
||||
_bgc_dark_twin_versor_fp64_t* twin = (_bgc_dark_twin_versor_fp64_t*)versor;
|
||||
twin->x1 = -versor->x1;
|
||||
twin->x2 = -versor->x2;
|
||||
twin->x3 = -versor->x3;
|
||||
|
@ -340,18 +340,18 @@ inline void versor_invert_fp64(versor_fp64_t* versor)
|
|||
|
||||
// ================ Set Inverted ================ //
|
||||
|
||||
inline void versor_set_inverted_fp32(const versor_fp32_t* versor, versor_fp32_t* to)
|
||||
inline void bgc_versor_set_inverted_fp32(const bgc_versor_fp32_t* versor, bgc_versor_fp32_t* to)
|
||||
{
|
||||
__BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)to;
|
||||
_bgc_dark_twin_versor_fp32_t* twin = (_bgc_dark_twin_versor_fp32_t*)to;
|
||||
twin->s0 = versor->s0;
|
||||
twin->x1 = -versor->x1;
|
||||
twin->x2 = -versor->x2;
|
||||
twin->x3 = -versor->x3;
|
||||
}
|
||||
|
||||
inline void versor_set_inverted_fp64(const versor_fp64_t* versor, versor_fp64_t* to)
|
||||
inline void bgc_versor_set_inverted_fp64(const bgc_versor_fp64_t* versor, bgc_versor_fp64_t* to)
|
||||
{
|
||||
__BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)to;
|
||||
_bgc_dark_twin_versor_fp64_t* twin = (_bgc_dark_twin_versor_fp64_t*)to;
|
||||
twin->s0 = versor->s0;
|
||||
twin->x1 = -versor->x1;
|
||||
twin->x2 = -versor->x2;
|
||||
|
@ -360,9 +360,9 @@ inline void versor_set_inverted_fp64(const versor_fp64_t* versor, versor_fp64_t*
|
|||
|
||||
// ================ Set Inverted ================ //
|
||||
|
||||
inline void versor_set_inverted_fp64_to_fp32(const versor_fp64_t* versor, versor_fp32_t* to)
|
||||
inline void bgc_versor_set_inverted_fp64_to_fp32(const bgc_versor_fp64_t* versor, bgc_versor_fp32_t* to)
|
||||
{
|
||||
versor_set_values_fp32(
|
||||
bgc_versor_set_values_fp32(
|
||||
(float) versor->s0,
|
||||
(float) -versor->x1,
|
||||
(float) -versor->x2,
|
||||
|
@ -371,9 +371,9 @@ inline void versor_set_inverted_fp64_to_fp32(const versor_fp64_t* versor, versor
|
|||
);
|
||||
}
|
||||
|
||||
inline void versor_set_inverted_fp32_to_fp64(const versor_fp32_t* versor, versor_fp64_t* to)
|
||||
inline void bgc_versor_set_inverted_fp32_to_fp64(const bgc_versor_fp32_t* versor, bgc_versor_fp64_t* to)
|
||||
{
|
||||
versor_set_values_fp64(
|
||||
bgc_versor_set_values_fp64(
|
||||
versor->s0,
|
||||
-versor->x1,
|
||||
-versor->x2,
|
||||
|
@ -384,7 +384,7 @@ inline void versor_set_inverted_fp32_to_fp64(const versor_fp32_t* versor, versor
|
|||
|
||||
// ================ Combination ================= //
|
||||
|
||||
inline void versor_combine_fp32(const versor_fp32_t* second, const versor_fp32_t* first, versor_fp32_t* result)
|
||||
inline void bgc_versor_combine_fp32(const bgc_versor_fp32_t* second, const bgc_versor_fp32_t* first, bgc_versor_fp32_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);
|
||||
|
@ -393,14 +393,14 @@ inline void versor_combine_fp32(const versor_fp32_t* second, const versor_fp32_t
|
|||
|
||||
const float square_modulus = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
|
||||
|
||||
__BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)result;
|
||||
_bgc_dark_twin_versor_fp32_t* twin = (_bgc_dark_twin_versor_fp32_t*)result;
|
||||
|
||||
twin->s0 = s0;
|
||||
twin->x1 = x1;
|
||||
twin->x2 = x2;
|
||||
twin->x3 = x3;
|
||||
|
||||
if (1.0f - FP32_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0f + FP32_TWO_EPSYLON) {
|
||||
if (1.0f - BGC_TWO_EPSYLON_FP32 <= square_modulus && square_modulus <= 1.0f + BGC_TWO_EPSYLON_FP32) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -412,7 +412,7 @@ inline void versor_combine_fp32(const versor_fp32_t* second, const versor_fp32_t
|
|||
twin->x3 *= multiplier;
|
||||
}
|
||||
|
||||
inline void versor_combine_fp64(const versor_fp64_t* second, const versor_fp64_t* first, versor_fp64_t* result)
|
||||
inline void bgc_versor_combine_fp64(const bgc_versor_fp64_t* second, const bgc_versor_fp64_t* first, bgc_versor_fp64_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);
|
||||
|
@ -421,14 +421,14 @@ inline void versor_combine_fp64(const versor_fp64_t* second, const versor_fp64_t
|
|||
|
||||
const double square_modulus = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
|
||||
|
||||
__BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)result;
|
||||
_bgc_dark_twin_versor_fp64_t* twin = (_bgc_dark_twin_versor_fp64_t*)result;
|
||||
|
||||
twin->s0 = s0;
|
||||
twin->x1 = x1;
|
||||
twin->x2 = x2;
|
||||
twin->x3 = x3;
|
||||
|
||||
if (1.0 - FP64_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0 + FP64_TWO_EPSYLON) {
|
||||
if (1.0 - BGC_TWO_EPSYLON_FP64 <= square_modulus && square_modulus <= 1.0 + BGC_TWO_EPSYLON_FP64) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -442,7 +442,7 @@ inline void versor_combine_fp64(const versor_fp64_t* second, const versor_fp64_t
|
|||
|
||||
// ============ Combination of three ============ //
|
||||
|
||||
inline void versor_combine3_fp32(const versor_fp32_t* third, const versor_fp32_t* second, const versor_fp32_t* first, versor_fp32_t* result)
|
||||
inline void bgc_versor_combine3_fp32(const bgc_versor_fp32_t* third, const bgc_versor_fp32_t* second, const bgc_versor_fp32_t* first, bgc_versor_fp32_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);
|
||||
|
@ -456,14 +456,14 @@ inline void versor_combine3_fp32(const versor_fp32_t* third, const versor_fp32_t
|
|||
|
||||
const float square_modulus = (s0b * s0b + x1b * x1b) + (x2b * x2b + x3b * x3b);
|
||||
|
||||
__BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)result;
|
||||
_bgc_dark_twin_versor_fp32_t* twin = (_bgc_dark_twin_versor_fp32_t*)result;
|
||||
|
||||
twin->s0 = s0b;
|
||||
twin->x1 = x1b;
|
||||
twin->x2 = x2b;
|
||||
twin->x3 = x3b;
|
||||
|
||||
if (1.0f - FP32_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0f + FP32_TWO_EPSYLON) {
|
||||
if (1.0f - BGC_TWO_EPSYLON_FP32 <= square_modulus && square_modulus <= 1.0f + BGC_TWO_EPSYLON_FP32) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -475,7 +475,7 @@ inline void versor_combine3_fp32(const versor_fp32_t* third, const versor_fp32_t
|
|||
twin->x3 *= multiplier;
|
||||
}
|
||||
|
||||
inline void versor_combine3_fp64(const versor_fp64_t* third, const versor_fp64_t* second, const versor_fp64_t* first, versor_fp64_t* result)
|
||||
inline void bgc_versor_combine3_fp64(const bgc_versor_fp64_t* third, const bgc_versor_fp64_t* second, const bgc_versor_fp64_t* first, bgc_versor_fp64_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);
|
||||
|
@ -489,14 +489,14 @@ inline void versor_combine3_fp64(const versor_fp64_t* third, const versor_fp64_t
|
|||
|
||||
const double square_modulus = (s0b * s0b + x1b * x1b) + (x2b * x2b + x3b * x3b);
|
||||
|
||||
__BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)result;
|
||||
_bgc_dark_twin_versor_fp64_t* twin = (_bgc_dark_twin_versor_fp64_t*)result;
|
||||
|
||||
twin->s0 = s0b;
|
||||
twin->x1 = x1b;
|
||||
twin->x2 = x2b;
|
||||
twin->x3 = x3b;
|
||||
|
||||
if (1.0 - FP64_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0 + FP64_TWO_EPSYLON) {
|
||||
if (1.0 - BGC_TWO_EPSYLON_FP64 <= square_modulus && square_modulus <= 1.0 + BGC_TWO_EPSYLON_FP64) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -510,7 +510,7 @@ inline void versor_combine3_fp64(const versor_fp64_t* third, const versor_fp64_t
|
|||
|
||||
// ================= Exclusion ================== //
|
||||
|
||||
inline void versor_exclude_fp32(const versor_fp32_t* basic, const versor_fp32_t* exclusion, versor_fp32_t* result)
|
||||
inline void bgc_versor_exclude_fp32(const bgc_versor_fp32_t* basic, const bgc_versor_fp32_t* exclusion, bgc_versor_fp32_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);
|
||||
|
@ -519,14 +519,14 @@ inline void versor_exclude_fp32(const versor_fp32_t* basic, const versor_fp32_t*
|
|||
|
||||
const float square_modulus = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
|
||||
|
||||
__BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)result;
|
||||
_bgc_dark_twin_versor_fp32_t* twin = (_bgc_dark_twin_versor_fp32_t*)result;
|
||||
|
||||
twin->s0 = s0;
|
||||
twin->x1 = x1;
|
||||
twin->x2 = x2;
|
||||
twin->x3 = x3;
|
||||
|
||||
if (1.0f - FP32_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0f + FP32_TWO_EPSYLON) {
|
||||
if (1.0f - BGC_TWO_EPSYLON_FP32 <= square_modulus && square_modulus <= 1.0f + BGC_TWO_EPSYLON_FP32) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -538,7 +538,7 @@ inline void versor_exclude_fp32(const versor_fp32_t* basic, const versor_fp32_t*
|
|||
twin->x3 *= multiplier;
|
||||
}
|
||||
|
||||
inline void versor_exclude_fp64(const versor_fp64_t* basic, const versor_fp64_t* exclusion, versor_fp64_t* result)
|
||||
inline void bgc_versor_exclude_fp64(const bgc_versor_fp64_t* basic, const bgc_versor_fp64_t* exclusion, bgc_versor_fp64_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);
|
||||
|
@ -547,14 +547,14 @@ inline void versor_exclude_fp64(const versor_fp64_t* basic, const versor_fp64_t*
|
|||
|
||||
const double square_modulus = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
|
||||
|
||||
__BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)result;
|
||||
_bgc_dark_twin_versor_fp64_t* twin = (_bgc_dark_twin_versor_fp64_t*)result;
|
||||
|
||||
twin->s0 = s0;
|
||||
twin->x1 = x1;
|
||||
twin->x2 = x2;
|
||||
twin->x3 = x3;
|
||||
|
||||
if (1.0 - FP64_TWO_EPSYLON <= square_modulus && square_modulus <= 1.0 + FP64_TWO_EPSYLON) {
|
||||
if (1.0 - BGC_TWO_EPSYLON_FP64 <= square_modulus && square_modulus <= 1.0 + BGC_TWO_EPSYLON_FP64) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -568,13 +568,13 @@ inline void versor_exclude_fp64(const versor_fp64_t* basic, const versor_fp64_t*
|
|||
|
||||
// ================= Rotation3 ================== //
|
||||
|
||||
void versor_get_rotation_fp32(const versor_fp32_t* versor, rotation3_fp32_t* result);
|
||||
void bgc_versor_get_rotation_fp32(const bgc_versor_fp32_t* versor, bgc_rotation3_fp32_t* result);
|
||||
|
||||
void versor_get_rotation_fp64(const versor_fp64_t* versor, rotation3_fp64_t* result);
|
||||
void bgc_versor_get_rotation_fp64(const bgc_versor_fp64_t* versor, bgc_rotation3_fp64_t* result);
|
||||
|
||||
// =========== Make Rotation Matrix3x3 ========== //
|
||||
|
||||
inline void versor_make_rotation_matrix_fp32(const versor_fp32_t* versor, matrix3x3_fp32_t* matrix)
|
||||
inline void bgc_versor_make_rotation_matrix_fp32(const bgc_versor_fp32_t* versor, bgc_matrix3x3_fp32_t* matrix)
|
||||
{
|
||||
const float s0s0 = versor->s0 * versor->s0;
|
||||
const float x1x1 = versor->x1 * versor->x1;
|
||||
|
@ -602,7 +602,7 @@ inline void versor_make_rotation_matrix_fp32(const versor_fp32_t* versor, matrix
|
|||
matrix->r1c3 = x1x3 + s0x2;
|
||||
}
|
||||
|
||||
inline void versor_make_rotation_matrix_fp64(const versor_fp64_t* versor, matrix3x3_fp64_t* matrix)
|
||||
inline void bgc_versor_make_rotation_matrix_fp64(const bgc_versor_fp64_t* versor, bgc_matrix3x3_fp64_t* matrix)
|
||||
{
|
||||
const double s0s0 = versor->s0 * versor->s0;
|
||||
const double x1x1 = versor->x1 * versor->x1;
|
||||
|
@ -632,7 +632,7 @@ inline void versor_make_rotation_matrix_fp64(const versor_fp64_t* versor, matrix
|
|||
|
||||
// =========== Make Reverse Matrix3x3 =========== //
|
||||
|
||||
inline void versor_make_reverse_matrix_fp32(const versor_fp32_t* versor, matrix3x3_fp32_t* matrix)
|
||||
inline void bgc_versor_make_reverse_matrix_fp32(const bgc_versor_fp32_t* versor, bgc_matrix3x3_fp32_t* matrix)
|
||||
{
|
||||
const float s0s0 = versor->s0 * versor->s0;
|
||||
const float x1x1 = versor->x1 * versor->x1;
|
||||
|
@ -660,7 +660,7 @@ inline void versor_make_reverse_matrix_fp32(const versor_fp32_t* versor, matrix3
|
|||
matrix->r1c3 = x1x3 - s0x2;
|
||||
}
|
||||
|
||||
inline void versor_make_reverse_matrix_fp64(const versor_fp64_t* versor, matrix3x3_fp64_t* matrix)
|
||||
inline void bgc_versor_make_reverse_matrix_fp64(const bgc_versor_fp64_t* versor, bgc_matrix3x3_fp64_t* matrix)
|
||||
{
|
||||
const double s0s0 = versor->s0 * versor->s0;
|
||||
const double x1x1 = versor->x1 * versor->x1;
|
||||
|
@ -690,7 +690,7 @@ inline void versor_make_reverse_matrix_fp64(const versor_fp64_t* versor, matrix3
|
|||
|
||||
// ================ Turn Vector ================= //
|
||||
|
||||
inline void versor_turn_vector_fp32(const versor_fp32_t* versor, const vector3_fp32_t* vector, vector3_fp32_t* result)
|
||||
inline void bgc_versor_turn_vector_fp32(const bgc_versor_fp32_t* versor, const bgc_vector3_fp32_t* vector, bgc_vector3_fp32_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 @@ inline void versor_turn_vector_fp32(const versor_fp32_t* versor, const vector3_f
|
|||
result->x3 = x3;
|
||||
}
|
||||
|
||||
inline void versor_turn_vector_fp64(const versor_fp64_t* versor, const vector3_fp64_t* vector, vector3_fp64_t* result)
|
||||
inline void bgc_versor_turn_vector_fp64(const bgc_versor_fp64_t* versor, const bgc_vector3_fp64_t* vector, bgc_vector3_fp64_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 @@ inline void versor_turn_vector_fp64(const versor_fp64_t* versor, const vector3_f
|
|||
|
||||
// ============== Turn Vector Back ============== //
|
||||
|
||||
inline void versor_turn_vector_back_fp32(const versor_fp32_t* versor, const vector3_fp32_t* vector, vector3_fp32_t* result)
|
||||
inline void bgc_versor_turn_vector_back_fp32(const bgc_versor_fp32_t* versor, const bgc_vector3_fp32_t* vector, bgc_vector3_fp32_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 @@ inline void versor_turn_vector_back_fp32(const versor_fp32_t* versor, const vect
|
|||
result->x3 = x3;
|
||||
}
|
||||
|
||||
inline void versor_turn_vector_back_fp64(const versor_fp64_t* versor, const vector3_fp64_t* vector, vector3_fp64_t* result)
|
||||
inline void bgc_versor_turn_vector_back_fp64(const bgc_versor_fp64_t* versor, const bgc_vector3_fp64_t* vector, bgc_vector3_fp64_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