Переход на версию 0.3: изменение подхода к именованию сущностей, добавление, изменение и удаление ряда функций
This commit is contained in:
parent
d33daf4e2d
commit
f7e41645fe
87 changed files with 4580 additions and 4051 deletions
|
|
@ -27,20 +27,20 @@
|
|||
|
||||
typedef struct {
|
||||
float _s0, _x1, _x2, _x3;
|
||||
} BgcVersorFP32;
|
||||
} BGC_FP32_Versor;
|
||||
|
||||
typedef struct {
|
||||
double _s0, _x1, _x2, _x3;
|
||||
} BgcVersorFP64;
|
||||
} BGC_FP64_Versor;
|
||||
|
||||
// ================= Constants ================== //
|
||||
|
||||
extern const BgcVersorFP32 BGC_IDLE_VERSOR_FP32;
|
||||
extern const BgcVersorFP64 BGC_IDLE_VERSOR_FP64;
|
||||
extern const BGC_FP32_Versor BGC_FP32_IDLE_VERSOR;
|
||||
extern const BGC_FP64_Versor BGC_FP64_IDLE_VERSOR;
|
||||
|
||||
// =================== Reset ==================== //
|
||||
|
||||
inline void bgc_versor_reset_fp32(BgcVersorFP32* versor)
|
||||
inline void bgc_fp32_versor_reset(BGC_FP32_Versor* versor)
|
||||
{
|
||||
versor->_s0 = 1.0f;
|
||||
versor->_x1 = 0.0f;
|
||||
|
|
@ -48,7 +48,7 @@ inline void bgc_versor_reset_fp32(BgcVersorFP32* versor)
|
|||
versor->_x3 = 0.0f;
|
||||
}
|
||||
|
||||
inline void bgc_versor_reset_fp64(BgcVersorFP64* versor)
|
||||
inline void bgc_fp64_versor_reset(BGC_FP64_Versor* versor)
|
||||
{
|
||||
versor->_s0 = 1.0;
|
||||
versor->_x1 = 0.0;
|
||||
|
|
@ -58,11 +58,11 @@ inline void bgc_versor_reset_fp64(BgcVersorFP64* versor)
|
|||
|
||||
// ==================== Set ===================== //
|
||||
|
||||
void _bgc_versor_normalize_fp32(const float square_modulus, BgcVersorFP32* twin);
|
||||
void _bgc_fp32_versor_normalize(BGC_FP32_Versor* twin);
|
||||
|
||||
void _bgc_versor_normalize_fp64(const double square_modulus, BgcVersorFP64* twin);
|
||||
void _bgc_fp64_versor_normalize(BGC_FP64_Versor* twin);
|
||||
|
||||
inline void bgc_versor_set_values_fp32(const float s0, const float x1, const float x2, const float x3, BgcVersorFP32* versor)
|
||||
inline void bgc_fp32_versor_make(const float s0, const float x1, const float x2, const float x3, BGC_FP32_Versor* versor)
|
||||
{
|
||||
versor->_s0 = s0;
|
||||
versor->_x1 = x1;
|
||||
|
|
@ -71,12 +71,12 @@ 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 (!bgc_is_sqare_unit_fp32(square_modulus)) {
|
||||
_bgc_versor_normalize_fp32(square_modulus, versor);
|
||||
if (!bgc_fp32_is_square_unit(square_modulus)) {
|
||||
_bgc_fp32_versor_normalize(versor);
|
||||
}
|
||||
}
|
||||
|
||||
inline void bgc_versor_set_values_fp64(const double s0, const double x1, const double x2, const double x3, BgcVersorFP64* versor)
|
||||
inline void bgc_fp64_versor_make(const double s0, const double x1, const double x2, const double x3, BGC_FP64_Versor* versor)
|
||||
{
|
||||
versor->_s0 = s0;
|
||||
versor->_x1 = x1;
|
||||
|
|
@ -85,56 +85,56 @@ 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 (!bgc_is_sqare_unit_fp64(square_modulus)) {
|
||||
_bgc_versor_normalize_fp64(square_modulus, versor);
|
||||
if (!bgc_fp64_is_square_unit(square_modulus)) {
|
||||
_bgc_fp64_versor_normalize(versor);
|
||||
}
|
||||
}
|
||||
|
||||
// ================== Set Turn ================== //
|
||||
|
||||
void bgc_versor_set_turn_fp32(const float x1, const float x2, const float x3, const float angle, const BgcAngleUnitEnum unit, BgcVersorFP32* result);
|
||||
void bgc_fp32_versor_make_for_turn(const float x1, const float x2, const float x3, const float angle, const int unit, BGC_FP32_Versor* result);
|
||||
|
||||
void bgc_versor_set_turn_fp64(const double x1, const double x2, const double x3, const double angle, const BgcAngleUnitEnum unit, BgcVersorFP64* result);
|
||||
void bgc_fp64_versor_make_for_turn(const double x1, const double x2, const double x3, const double angle, const int unit, BGC_FP64_Versor* result);
|
||||
|
||||
// ================ Set Rotation ================ //
|
||||
|
||||
inline void bgc_versor_set_rotation_fp32(const BgcRotation3FP32* rotation, BgcVersorFP32* result)
|
||||
inline void bgc_fp32_versor_make_for_rotation(const BGC_FP32_Rotation3* rotation, BGC_FP32_Versor* result)
|
||||
{
|
||||
bgc_versor_set_turn_fp32(rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BGC_ANGLE_UNIT_RADIANS, result);
|
||||
bgc_fp32_versor_make_for_turn(rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BGC_ANGLE_UNIT_RADIANS, result);
|
||||
}
|
||||
|
||||
inline void bgc_versor_set_rotation_fp64(const BgcRotation3FP64* rotation, BgcVersorFP64* result)
|
||||
inline void bgc_fp64_versor_make_for_rotation(const BGC_FP64_Rotation3* rotation, BGC_FP64_Versor* result)
|
||||
{
|
||||
bgc_versor_set_turn_fp64(rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BGC_ANGLE_UNIT_RADIANS, result);
|
||||
bgc_fp64_versor_make_for_turn(rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BGC_ANGLE_UNIT_RADIANS, result);
|
||||
}
|
||||
|
||||
// ========= Make Direction Difference ========== //
|
||||
|
||||
int bgc_versor_make_direction_difference_fp32(const BgcVector3FP32* start, const BgcVector3FP32* end, BgcVersorFP32* result);
|
||||
int bgc_fp32_versor_make_direction_difference(const BGC_FP32_Vector3* start, const BGC_FP32_Vector3* end, BGC_FP32_Versor* result);
|
||||
|
||||
int bgc_versor_make_direction_difference_fp64(const BgcVector3FP64* start, const BgcVector3FP64* end, BgcVersorFP64* result);
|
||||
int bgc_fp64_versor_make_direction_difference(const BGC_FP64_Vector3* start, const BGC_FP64_Vector3* end, BGC_FP64_Versor* result);
|
||||
|
||||
// =============== Set Directions =============== //
|
||||
|
||||
int bgc_versor_make_basis_difference_fp32(
|
||||
const BgcVector3FP32* initial_primary_direction,
|
||||
const BgcVector3FP32* initial_auxiliary_direction,
|
||||
const BgcVector3FP32* final_primary_direction,
|
||||
const BgcVector3FP32* final_auxiliary_direction,
|
||||
BgcVersorFP32* result
|
||||
int bgc_fp32_versor_make_basis_difference(
|
||||
const BGC_FP32_Vector3* initial_primary_direction,
|
||||
const BGC_FP32_Vector3* initial_auxiliary_direction,
|
||||
const BGC_FP32_Vector3* final_primary_direction,
|
||||
const BGC_FP32_Vector3* final_auxiliary_direction,
|
||||
BGC_FP32_Versor* result
|
||||
);
|
||||
|
||||
int bgc_versor_make_basis_difference_fp64(
|
||||
const BgcVector3FP64* initial_primary_direction,
|
||||
const BgcVector3FP64* initial_auxiliary_direction,
|
||||
const BgcVector3FP64* final_primary_direction,
|
||||
const BgcVector3FP64* final_auxiliary_direction,
|
||||
BgcVersorFP64* result
|
||||
int bgc_fp64_versor_make_basis_difference(
|
||||
const BGC_FP64_Vector3* initial_primary_direction,
|
||||
const BGC_FP64_Vector3* initial_auxiliary_direction,
|
||||
const BGC_FP64_Vector3* final_primary_direction,
|
||||
const BGC_FP64_Vector3* final_auxiliary_direction,
|
||||
BGC_FP64_Versor* result
|
||||
);
|
||||
|
||||
// ==================== Copy ==================== //
|
||||
|
||||
inline void bgc_versor_copy_fp32(const BgcVersorFP32* source, BgcVersorFP32* destination)
|
||||
inline void bgc_fp32_versor_copy(const BGC_FP32_Versor* source, BGC_FP32_Versor* destination)
|
||||
{
|
||||
destination->_s0 = source->_s0;
|
||||
destination->_x1 = source->_x1;
|
||||
|
|
@ -142,7 +142,7 @@ inline void bgc_versor_copy_fp32(const BgcVersorFP32* source, BgcVersorFP32* des
|
|||
destination->_x3 = source->_x3;
|
||||
}
|
||||
|
||||
inline void bgc_versor_copy_fp64(const BgcVersorFP64* source, BgcVersorFP64* destination)
|
||||
inline void bgc_fp64_versor_copy(const BGC_FP64_Versor* source, BGC_FP64_Versor* destination)
|
||||
{
|
||||
destination->_s0 = source->_s0;
|
||||
destination->_x1 = source->_x1;
|
||||
|
|
@ -152,7 +152,7 @@ inline void bgc_versor_copy_fp64(const BgcVersorFP64* source, BgcVersorFP64* des
|
|||
|
||||
// ==================== Swap ==================== //
|
||||
|
||||
inline void bgc_versor_swap_fp32(BgcVersorFP32* versor1, BgcVersorFP32* versor2)
|
||||
inline void bgc_fp32_versor_swap(BGC_FP32_Versor* versor1, BGC_FP32_Versor* versor2)
|
||||
{
|
||||
const float s0 = versor1->_s0;
|
||||
const float x1 = versor1->_x1;
|
||||
|
|
@ -170,7 +170,7 @@ inline void bgc_versor_swap_fp32(BgcVersorFP32* versor1, BgcVersorFP32* versor2)
|
|||
versor2->_x3 = x3;
|
||||
}
|
||||
|
||||
inline void bgc_versor_swap_fp64(BgcVersorFP64* versor1, BgcVersorFP64* versor2)
|
||||
inline void bgc_fp64_versor_swap(BGC_FP64_Versor* versor1, BGC_FP64_Versor* versor2)
|
||||
{
|
||||
const double s0 = versor1->_s0;
|
||||
const double x1 = versor1->_x1;
|
||||
|
|
@ -190,21 +190,21 @@ inline void bgc_versor_swap_fp64(BgcVersorFP64* versor1, BgcVersorFP64* versor2)
|
|||
|
||||
// ================= Comparison ================= //
|
||||
|
||||
inline int bgc_versor_is_identity_fp32(const BgcVersorFP32* versor)
|
||||
inline int bgc_fp32_versor_is_idle(const BGC_FP32_Versor* versor)
|
||||
{
|
||||
return versor->_x1 * versor->_x1 + versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3 <= BGC_SQUARE_EPSYLON_FP32;
|
||||
return versor->_x1 * versor->_x1 + versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3 <= BGC_FP32_SQUARE_EPSYLON;
|
||||
}
|
||||
|
||||
inline int bgc_versor_is_identity_fp64(const BgcVersorFP64* versor)
|
||||
inline int bgc_fp64_versor_is_idle(const BGC_FP64_Versor* versor)
|
||||
{
|
||||
return versor->_x1 * versor->_x1 + versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3 <= BGC_SQUARE_EPSYLON_FP64;
|
||||
return versor->_x1 * versor->_x1 + versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3 <= BGC_FP64_SQUARE_EPSYLON;
|
||||
}
|
||||
|
||||
// ================== Convert =================== //
|
||||
|
||||
inline void bgc_versor_convert_fp64_to_fp32(const BgcVersorFP64* source, BgcVersorFP32* destination)
|
||||
inline void bgc_fp64_versor_convert_to_fp32(const BGC_FP64_Versor* source, BGC_FP32_Versor* destination)
|
||||
{
|
||||
bgc_versor_set_values_fp32(
|
||||
bgc_fp32_versor_make(
|
||||
(float)source->_s0,
|
||||
(float)source->_x1,
|
||||
(float)source->_x2,
|
||||
|
|
@ -213,9 +213,9 @@ inline void bgc_versor_convert_fp64_to_fp32(const BgcVersorFP64* source, BgcVers
|
|||
);
|
||||
}
|
||||
|
||||
inline void bgc_versor_convert_fp32_to_fp64(const BgcVersorFP32* source, BgcVersorFP64* destination)
|
||||
inline void bgc_fp32_versor_convert_to_fp64(const BGC_FP32_Versor* source, BGC_FP64_Versor* destination)
|
||||
{
|
||||
bgc_versor_set_values_fp64(
|
||||
bgc_fp64_versor_make(
|
||||
source->_s0,
|
||||
source->_x1,
|
||||
source->_x2,
|
||||
|
|
@ -226,7 +226,7 @@ inline void bgc_versor_convert_fp32_to_fp64(const BgcVersorFP32* source, BgcVers
|
|||
|
||||
// ================== Shorten =================== //
|
||||
|
||||
inline void bgc_versor_shorten_fp32(BgcVersorFP32* versor)
|
||||
inline void bgc_fp32_versor_shorten(BGC_FP32_Versor* versor)
|
||||
{
|
||||
if (versor->_s0 < 0.0f) {
|
||||
versor->_s0 = -versor->_s0;
|
||||
|
|
@ -236,7 +236,7 @@ inline void bgc_versor_shorten_fp32(BgcVersorFP32* versor)
|
|||
}
|
||||
}
|
||||
|
||||
inline void bgc_versor_shorten_fp64(BgcVersorFP64* versor)
|
||||
inline void bgc_fp64_versor_shorten(BGC_FP64_Versor* versor)
|
||||
{
|
||||
if (versor->_s0 < 0.0) {
|
||||
versor->_s0 = -versor->_s0;
|
||||
|
|
@ -246,7 +246,7 @@ inline void bgc_versor_shorten_fp64(BgcVersorFP64* versor)
|
|||
}
|
||||
}
|
||||
|
||||
inline void bgc_versor_get_shortened_fp32(const BgcVersorFP32* versor, BgcVersorFP32* shortened)
|
||||
inline void bgc_fp32_versor_get_shortened(const BGC_FP32_Versor* versor, BGC_FP32_Versor* shortened)
|
||||
{
|
||||
if (versor->_s0 >= 0.0f) {
|
||||
shortened->_s0 = versor->_s0;
|
||||
|
|
@ -262,7 +262,7 @@ inline void bgc_versor_get_shortened_fp32(const BgcVersorFP32* versor, BgcVersor
|
|||
shortened->_x3 = -versor->_x3;
|
||||
}
|
||||
|
||||
inline void bgc_versor_get_shortened_fp64(const BgcVersorFP64* versor, BgcVersorFP64* shortened)
|
||||
inline void bgc_fp64_versor_get_shortened(const BGC_FP64_Versor* versor, BGC_FP64_Versor* shortened)
|
||||
{
|
||||
if (versor->_s0 >= 0.0) {
|
||||
shortened->_s0 = versor->_s0;
|
||||
|
|
@ -280,7 +280,7 @@ inline void bgc_versor_get_shortened_fp64(const BgcVersorFP64* versor, BgcVersor
|
|||
|
||||
// ================== Negative ================== //
|
||||
|
||||
inline void bgc_versor_make_opposite_fp32(BgcVersorFP32* versor)
|
||||
inline void bgc_fp32_versor_alternate(BGC_FP32_Versor* versor)
|
||||
{
|
||||
versor->_s0 = -versor->_s0;
|
||||
versor->_x1 = -versor->_x1;
|
||||
|
|
@ -288,7 +288,7 @@ inline void bgc_versor_make_opposite_fp32(BgcVersorFP32* versor)
|
|||
versor->_x3 = -versor->_x3;
|
||||
}
|
||||
|
||||
inline void bgc_versor_make_opposite_fp64(BgcVersorFP64* versor)
|
||||
inline void bgc_fp64_versor_alternate(BGC_FP64_Versor* versor)
|
||||
{
|
||||
versor->_s0 = -versor->_s0;
|
||||
versor->_x1 = -versor->_x1;
|
||||
|
|
@ -296,7 +296,7 @@ inline void bgc_versor_make_opposite_fp64(BgcVersorFP64* versor)
|
|||
versor->_x3 = -versor->_x3;
|
||||
}
|
||||
|
||||
inline void bgc_versor_get_opposite_fp32(const BgcVersorFP32* versor, BgcVersorFP32* opposite)
|
||||
inline void bgc_fp32_versor_get_alternative(const BGC_FP32_Versor* versor, BGC_FP32_Versor* opposite)
|
||||
{
|
||||
opposite->_s0 = -versor->_s0;
|
||||
opposite->_x1 = -versor->_x1;
|
||||
|
|
@ -304,7 +304,7 @@ inline void bgc_versor_get_opposite_fp32(const BgcVersorFP32* versor, BgcVersorF
|
|||
opposite->_x3 = -versor->_x3;
|
||||
}
|
||||
|
||||
inline void bgc_versor_get_opposite_fp64(const BgcVersorFP64* versor, BgcVersorFP64* opposite)
|
||||
inline void bgc_fp64_versor_get_alternative(const BGC_FP64_Versor* versor, BGC_FP64_Versor* opposite)
|
||||
{
|
||||
opposite->_s0 = -versor->_s0;
|
||||
opposite->_x1 = -versor->_x1;
|
||||
|
|
@ -314,21 +314,21 @@ inline void bgc_versor_get_opposite_fp64(const BgcVersorFP64* versor, BgcVersorF
|
|||
|
||||
// =================== Invert =================== //
|
||||
|
||||
inline void bgc_versor_invert_fp32(BgcVersorFP32* versor)
|
||||
inline void bgc_fp32_versor_revert(BGC_FP32_Versor* versor)
|
||||
{
|
||||
versor->_x1 = -versor->_x1;
|
||||
versor->_x2 = -versor->_x2;
|
||||
versor->_x3 = -versor->_x3;
|
||||
}
|
||||
|
||||
inline void bgc_versor_invert_fp64(BgcVersorFP64* versor)
|
||||
inline void bgc_fp64_versor_revert(BGC_FP64_Versor* versor)
|
||||
{
|
||||
versor->_x1 = -versor->_x1;
|
||||
versor->_x2 = -versor->_x2;
|
||||
versor->_x3 = -versor->_x3;
|
||||
}
|
||||
|
||||
inline void bgc_versor_get_inverse_fp32(const BgcVersorFP32* versor, BgcVersorFP32* inverse)
|
||||
inline void bgc_fp32_versor_get_reverse(const BGC_FP32_Versor* versor, BGC_FP32_Versor* inverse)
|
||||
{
|
||||
inverse->_s0 = versor->_s0;
|
||||
inverse->_x1 = -versor->_x1;
|
||||
|
|
@ -336,7 +336,7 @@ inline void bgc_versor_get_inverse_fp32(const BgcVersorFP32* versor, BgcVersorFP
|
|||
inverse->_x3 = -versor->_x3;
|
||||
}
|
||||
|
||||
inline void bgc_versor_get_inverse_fp64(const BgcVersorFP64* versor, BgcVersorFP64* inverse)
|
||||
inline void bgc_fp64_versor_get_reverse(const BGC_FP64_Versor* versor, BGC_FP64_Versor* inverse)
|
||||
{
|
||||
inverse->_s0 = versor->_s0;
|
||||
inverse->_x1 = -versor->_x1;
|
||||
|
|
@ -346,15 +346,15 @@ inline void bgc_versor_get_inverse_fp64(const BgcVersorFP64* versor, BgcVersorFP
|
|||
|
||||
// =============== Get Exponation =============== //
|
||||
|
||||
void bgc_versor_get_exponation_fp32(const BgcVersorFP32* base, const float exponent, BgcVersorFP32* power);
|
||||
void bgc_fp32_versor_get_exponation(const BGC_FP32_Versor* base, const float exponent, BGC_FP32_Versor* power);
|
||||
|
||||
void bgc_versor_get_exponation_fp64(const BgcVersorFP64* base, const double exponent, BgcVersorFP64* power);
|
||||
void bgc_fp64_versor_get_exponation(const BGC_FP64_Versor* base, const double exponent, BGC_FP64_Versor* power);
|
||||
|
||||
// ================ Combination ================= //
|
||||
|
||||
inline void bgc_versor_combine_fp32(const BgcVersorFP32* first, const BgcVersorFP32* second, BgcVersorFP32* result)
|
||||
inline void bgc_fp32_versor_combine(const BGC_FP32_Versor* first, const BGC_FP32_Versor* second, BGC_FP32_Versor* result)
|
||||
{
|
||||
bgc_versor_set_values_fp32(
|
||||
bgc_fp32_versor_make(
|
||||
(second->_s0 * first->_s0 - second->_x1 * first->_x1) - (second->_x2 * first->_x2 + second->_x3 * first->_x3),
|
||||
(second->_x1 * first->_s0 + second->_s0 * first->_x1) - (second->_x3 * first->_x2 - second->_x2 * first->_x3),
|
||||
(second->_x2 * first->_s0 + second->_s0 * first->_x2) - (second->_x1 * first->_x3 - second->_x3 * first->_x1),
|
||||
|
|
@ -363,9 +363,9 @@ inline void bgc_versor_combine_fp32(const BgcVersorFP32* first, const BgcVersorF
|
|||
);
|
||||
}
|
||||
|
||||
inline void bgc_versor_combine_fp64(const BgcVersorFP64* first, const BgcVersorFP64* second, BgcVersorFP64* result)
|
||||
inline void bgc_fp64_versor_combine(const BGC_FP64_Versor* first, const BGC_FP64_Versor* second, BGC_FP64_Versor* result)
|
||||
{
|
||||
bgc_versor_set_values_fp64(
|
||||
bgc_fp64_versor_make(
|
||||
(second->_s0 * first->_s0 - second->_x1 * first->_x1) - (second->_x2 * first->_x2 + second->_x3 * first->_x3),
|
||||
(second->_x1 * first->_s0 + second->_s0 * first->_x1) - (second->_x3 * first->_x2 - second->_x2 * first->_x3),
|
||||
(second->_x2 * first->_s0 + second->_s0 * first->_x2) - (second->_x1 * first->_x3 - second->_x3 * first->_x1),
|
||||
|
|
@ -376,14 +376,14 @@ inline void bgc_versor_combine_fp64(const BgcVersorFP64* first, const BgcVersorF
|
|||
|
||||
// ============ Combination of three ============ //
|
||||
|
||||
inline void bgc_versor_combine3_fp32(const BgcVersorFP32* first, const BgcVersorFP32* second, const BgcVersorFP32* third, BgcVersorFP32* result)
|
||||
inline void bgc_fp32_versor_combine3(const BGC_FP32_Versor* first, const BGC_FP32_Versor* second, const BGC_FP32_Versor* third, BGC_FP32_Versor* 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);
|
||||
const float x2 = (second->_x2 * first->_s0 + second->_s0 * first->_x2) - (second->_x1 * first->_x3 - second->_x3 * first->_x1);
|
||||
const float x3 = (second->_x3 * first->_s0 + second->_s0 * first->_x3) - (second->_x2 * first->_x1 - second->_x1 * first->_x2);
|
||||
|
||||
bgc_versor_set_values_fp32(
|
||||
bgc_fp32_versor_make(
|
||||
(third->_s0 * s0 - third->_x1 * x1) - (third->_x2 * x2 + third->_x3 * x3),
|
||||
(third->_x1 * s0 + third->_s0 * x1) - (third->_x3 * x2 - third->_x2 * x3),
|
||||
(third->_x2 * s0 + third->_s0 * x2) - (third->_x1 * x3 - third->_x3 * x1),
|
||||
|
|
@ -392,14 +392,14 @@ inline void bgc_versor_combine3_fp32(const BgcVersorFP32* first, const BgcVersor
|
|||
);
|
||||
}
|
||||
|
||||
inline void bgc_versor_combine3_fp64(const BgcVersorFP64* first, const BgcVersorFP64* second, const BgcVersorFP64* third, BgcVersorFP64* result)
|
||||
inline void bgc_fp64_versor_combine3(const BGC_FP64_Versor* first, const BGC_FP64_Versor* second, const BGC_FP64_Versor* third, BGC_FP64_Versor* 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);
|
||||
const double x2 = (second->_x2 * first->_s0 + second->_s0 * first->_x2) - (second->_x1 * first->_x3 - second->_x3 * first->_x1);
|
||||
const double x3 = (second->_x3 * first->_s0 + second->_s0 * first->_x3) - (second->_x2 * first->_x1 - second->_x1 * first->_x2);
|
||||
|
||||
bgc_versor_set_values_fp64(
|
||||
bgc_fp64_versor_make(
|
||||
(third->_s0 * s0 - third->_x1 * x1) - (third->_x2 * x2 + third->_x3 * x3),
|
||||
(third->_x1 * s0 + third->_s0 * x1) - (third->_x3 * x2 - third->_x2 * x3),
|
||||
(third->_x2 * s0 + third->_s0 * x2) - (third->_x1 * x3 - third->_x3 * x1),
|
||||
|
|
@ -410,9 +410,9 @@ inline void bgc_versor_combine3_fp64(const BgcVersorFP64* first, const BgcVersor
|
|||
|
||||
// ================= Exclusion ================== //
|
||||
|
||||
inline void bgc_versor_exclude_fp32(const BgcVersorFP32* base, const BgcVersorFP32* excludant, BgcVersorFP32* difference)
|
||||
inline void bgc_fp32_versor_exclude(const BGC_FP32_Versor* base, const BGC_FP32_Versor* excludant, BGC_FP32_Versor* difference)
|
||||
{
|
||||
bgc_versor_set_values_fp32(
|
||||
bgc_fp32_versor_make(
|
||||
(base->_s0 * excludant->_s0 + base->_x1 * excludant->_x1) + (base->_x2 * excludant->_x2 + base->_x3 * excludant->_x3),
|
||||
(base->_x1 * excludant->_s0 + base->_x3 * excludant->_x2) - (base->_s0 * excludant->_x1 + base->_x2 * excludant->_x3),
|
||||
(base->_x2 * excludant->_s0 + base->_x1 * excludant->_x3) - (base->_s0 * excludant->_x2 + base->_x3 * excludant->_x1),
|
||||
|
|
@ -421,9 +421,9 @@ inline void bgc_versor_exclude_fp32(const BgcVersorFP32* base, const BgcVersorFP
|
|||
);
|
||||
}
|
||||
|
||||
inline void bgc_versor_exclude_fp64(const BgcVersorFP64* base, const BgcVersorFP64* excludant, BgcVersorFP64* difference)
|
||||
inline void bgc_fp64_versor_exclude(const BGC_FP64_Versor* base, const BGC_FP64_Versor* excludant, BGC_FP64_Versor* difference)
|
||||
{
|
||||
bgc_versor_set_values_fp64(
|
||||
bgc_fp64_versor_make(
|
||||
(base->_s0 * excludant->_s0 + base->_x1 * excludant->_x1) + (base->_x2 * excludant->_x2 + base->_x3 * excludant->_x3),
|
||||
(base->_x1 * excludant->_s0 + base->_x3 * excludant->_x2) - (base->_s0 * excludant->_x1 + base->_x2 * excludant->_x3),
|
||||
(base->_x2 * excludant->_s0 + base->_x1 * excludant->_x3) - (base->_s0 * excludant->_x2 + base->_x3 * excludant->_x1),
|
||||
|
|
@ -434,19 +434,19 @@ inline void bgc_versor_exclude_fp64(const BgcVersorFP64* base, const BgcVersorFP
|
|||
|
||||
// ============ Sphere Interpolation ============ //
|
||||
|
||||
void bgc_versor_spherically_interpolate_fp32(const BgcVersorFP32* start, const BgcVersorFP32* end, const float phase, BgcVersorFP32* result);
|
||||
void bgc_fp32_versor_spherically_interpolate(const BGC_FP32_Versor* start, const BGC_FP32_Versor* end, const float phase, BGC_FP32_Versor* result);
|
||||
|
||||
void bgc_versor_spherically_interpolate_fp64(const BgcVersorFP64* start, const BgcVersorFP64* end, const double phase, BgcVersorFP64* result);
|
||||
void bgc_fp64_versor_spherically_interpolate(const BGC_FP64_Versor* start, const BGC_FP64_Versor* end, const double phase, BGC_FP64_Versor* result);
|
||||
|
||||
// ================ Get Rotation ================ //
|
||||
|
||||
void bgc_versor_get_rotation_fp32(const BgcVersorFP32* versor, BgcRotation3FP32* result);
|
||||
void bgc_fp32_versor_get_rotation(const BGC_FP32_Versor* versor, BGC_FP32_Rotation3* result);
|
||||
|
||||
void bgc_versor_get_rotation_fp64(const BgcVersorFP64* versor, BgcRotation3FP64* result);
|
||||
void bgc_fp64_versor_get_rotation(const BGC_FP64_Versor* versor, BGC_FP64_Rotation3* result);
|
||||
|
||||
// ============ Get Rotation Matrix ============= //
|
||||
|
||||
inline void bgc_versor_get_rotation_matrix_fp32(const BgcVersorFP32* versor, BgcMatrix3x3FP32* matrix)
|
||||
inline void bgc_fp32_versor_get_rotation_matrix(const BGC_FP32_Versor* versor, BGC_FP32_Matrix3x3* matrix)
|
||||
{
|
||||
const float s0s0 = versor->_s0 * versor->_s0;
|
||||
const float x1x1 = versor->_x1 * versor->_x1;
|
||||
|
|
@ -473,7 +473,7 @@ inline void bgc_versor_get_rotation_matrix_fp32(const BgcVersorFP32* versor, Bgc
|
|||
matrix->r1c3 = 2.0f * (x1x3 + s0x2);
|
||||
}
|
||||
|
||||
inline void bgc_versor_get_rotation_matrix_fp64(const BgcVersorFP64* versor, BgcMatrix3x3FP64* matrix)
|
||||
inline void bgc_fp64_versor_get_rotation_matrix(const BGC_FP64_Versor* versor, BGC_FP64_Matrix3x3* matrix)
|
||||
{
|
||||
const double s0s0 = versor->_s0 * versor->_s0;
|
||||
const double x1x1 = versor->_x1 * versor->_x1;
|
||||
|
|
@ -502,7 +502,7 @@ inline void bgc_versor_get_rotation_matrix_fp64(const BgcVersorFP64* versor, Bgc
|
|||
|
||||
// ============= Get Reverse Matrix ============= //
|
||||
|
||||
inline void bgc_versor_get_reverse_matrix_fp32(const BgcVersorFP32* versor, BgcMatrix3x3FP32* matrix)
|
||||
inline void bgc_fp32_versor_get_reverse_matrix(const BGC_FP32_Versor* versor, BGC_FP32_Matrix3x3* matrix)
|
||||
{
|
||||
const float s0s0 = versor->_s0 * versor->_s0;
|
||||
const float x1x1 = versor->_x1 * versor->_x1;
|
||||
|
|
@ -529,7 +529,7 @@ inline void bgc_versor_get_reverse_matrix_fp32(const BgcVersorFP32* versor, BgcM
|
|||
matrix->r1c3 = 2.0f * (x1x3 - s0x2);
|
||||
}
|
||||
|
||||
inline void bgc_versor_get_reverse_matrix_fp64(const BgcVersorFP64* versor, BgcMatrix3x3FP64* matrix)
|
||||
inline void bgc_fp64_versor_get_reverse_matrix(const BGC_FP64_Versor* versor, BGC_FP64_Matrix3x3* matrix)
|
||||
{
|
||||
const double s0s0 = versor->_s0 * versor->_s0;
|
||||
const double x1x1 = versor->_x1 * versor->_x1;
|
||||
|
|
@ -558,21 +558,21 @@ inline void bgc_versor_get_reverse_matrix_fp64(const BgcVersorFP64* versor, BgcM
|
|||
|
||||
// ============= Get Both Matrixes ============== //
|
||||
|
||||
inline void bgc_versor_get_both_matrices_fp32(const BgcVersorFP32* versor, BgcMatrix3x3FP32* rotation, BgcMatrix3x3FP32* reverse)
|
||||
inline void bgc_fp32_versor_get_both_matrices(const BGC_FP32_Versor* versor, BGC_FP32_Matrix3x3* rotation, BGC_FP32_Matrix3x3* reverse)
|
||||
{
|
||||
bgc_versor_get_reverse_matrix_fp32(versor, reverse);
|
||||
bgc_matrix3x3_transpose_fp32(reverse, rotation);
|
||||
bgc_fp32_versor_get_reverse_matrix(versor, reverse);
|
||||
bgc_fp32_matrix3x3_get_transposed(reverse, rotation);
|
||||
}
|
||||
|
||||
inline void bgc_versor_get_both_matrices_fp64(const BgcVersorFP64* versor, BgcMatrix3x3FP64* rotation, BgcMatrix3x3FP64* reverse)
|
||||
inline void bgc_fp64_versor_get_both_matrices(const BGC_FP64_Versor* versor, BGC_FP64_Matrix3x3* rotation, BGC_FP64_Matrix3x3* reverse)
|
||||
{
|
||||
bgc_versor_get_reverse_matrix_fp64(versor, reverse);
|
||||
bgc_matrix3x3_transpose_fp64(reverse, rotation);
|
||||
bgc_fp64_versor_get_reverse_matrix(versor, reverse);
|
||||
bgc_fp64_matrix3x3_get_transposed(reverse, rotation);
|
||||
}
|
||||
|
||||
// ================ Turn Vector ================= //
|
||||
|
||||
inline void bgc_versor_turn_vector_fp32(const BgcVersorFP32* versor, const BgcVector3FP32* vector, BgcVector3FP32* result)
|
||||
inline void bgc_fp32_versor_turn_vector(const BGC_FP32_Versor* versor, const BGC_FP32_Vector3* vector, BGC_FP32_Vector3* 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);
|
||||
|
|
@ -587,7 +587,7 @@ inline void bgc_versor_turn_vector_fp32(const BgcVersorFP32* versor, const BgcVe
|
|||
result->x3 = x3;
|
||||
}
|
||||
|
||||
inline void bgc_versor_turn_vector_fp64(const BgcVersorFP64* versor, const BgcVector3FP64* vector, BgcVector3FP64* result)
|
||||
inline void bgc_fp64_versor_turn_vector(const BGC_FP64_Versor* versor, const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* 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);
|
||||
|
|
@ -604,7 +604,7 @@ inline void bgc_versor_turn_vector_fp64(const BgcVersorFP64* versor, const BgcVe
|
|||
|
||||
// ============== Turn Vector Back ============== //
|
||||
|
||||
inline void bgc_versor_turn_vector_back_fp32(const BgcVersorFP32* versor, const BgcVector3FP32* vector, BgcVector3FP32* result)
|
||||
inline void bgc_fp32_versor_turn_vector_back(const BGC_FP32_Versor* versor, const BGC_FP32_Vector3* vector, BGC_FP32_Vector3* 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);
|
||||
|
|
@ -619,7 +619,7 @@ inline void bgc_versor_turn_vector_back_fp32(const BgcVersorFP32* versor, const
|
|||
result->x3 = x3;
|
||||
}
|
||||
|
||||
inline void bgc_versor_turn_vector_back_fp64(const BgcVersorFP64* versor, const BgcVector3FP64* vector, BgcVector3FP64* result)
|
||||
inline void bgc_fp64_versor_turn_vector_back(const BGC_FP64_Versor* versor, const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* 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);
|
||||
|
|
@ -636,24 +636,24 @@ inline void bgc_versor_turn_vector_back_fp64(const BgcVersorFP64* versor, const
|
|||
|
||||
// ================== Are Close ================= //
|
||||
|
||||
inline int bgc_versor_are_close_fp32(const BgcVersorFP32* versor1, const BgcVersorFP32* versor2)
|
||||
inline int bgc_fp32_versor_are_close(const BGC_FP32_Versor* versor1, const BGC_FP32_Versor* versor2)
|
||||
{
|
||||
const float ds0 = versor1->_s0 - versor2->_s0;
|
||||
const float dx1 = versor1->_x1 - versor2->_x1;
|
||||
const float dx2 = versor1->_x2 - versor2->_x2;
|
||||
const float dx3 = versor1->_x3 - versor2->_x3;
|
||||
|
||||
return (ds0 * ds0 + dx1 * dx1) + (dx2 * dx2 + dx3 * dx3) <= BGC_SQUARE_EPSYLON_FP32;
|
||||
return (ds0 * ds0 + dx1 * dx1) + (dx2 * dx2 + dx3 * dx3) <= BGC_FP32_SQUARE_EPSYLON;
|
||||
}
|
||||
|
||||
inline int bgc_versor_are_close_fp64(const BgcVersorFP64* versor1, const BgcVersorFP64* versor2)
|
||||
inline int bgc_fp64_versor_are_close(const BGC_FP64_Versor* versor1, const BGC_FP64_Versor* versor2)
|
||||
{
|
||||
const double ds0 = versor1->_s0 - versor2->_s0;
|
||||
const double dx1 = versor1->_x1 - versor2->_x1;
|
||||
const double dx2 = versor1->_x2 - versor2->_x2;
|
||||
const double dx3 = versor1->_x3 - versor2->_x3;
|
||||
|
||||
return (ds0 * ds0 + dx1 * dx1) + (dx2 * dx2 + dx3 * dx3) <= BGC_SQUARE_EPSYLON_FP64;
|
||||
return (ds0 * ds0 + dx1 * dx1) + (dx2 * dx2 + dx3 * dx3) <= BGC_FP64_SQUARE_EPSYLON;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue