Переход на версию 0.3: изменение подхода к именованию сущностей, добавление, изменение и удаление ряда функций
This commit is contained in:
parent
d33daf4e2d
commit
f7e41645fe
87 changed files with 4580 additions and 4051 deletions
|
|
@ -3,83 +3,83 @@
|
|||
#include "angle.h"
|
||||
#include "versor.h"
|
||||
|
||||
const BgcVersorFP32 BGC_IDLE_VERSOR_FP32 = { 1.0f, 0.0f, 0.0f, 0.0f };
|
||||
const BGC_FP32_Versor BGC_FP32_IDLE_VERSOR = { 1.0f, 0.0f, 0.0f, 0.0f };
|
||||
|
||||
const BgcVersorFP64 BGC_IDLE_VERSOR_FP64 = { 1.0, 0.0, 0.0, 0.0 };
|
||||
const BGC_FP64_Versor BGC_FP64_IDLE_VERSOR = { 1.0, 0.0, 0.0, 0.0 };
|
||||
|
||||
extern inline void bgc_versor_reset_fp32(BgcVersorFP32* versor);
|
||||
extern inline void bgc_versor_reset_fp64(BgcVersorFP64* versor);
|
||||
extern inline void bgc_fp32_versor_reset(BGC_FP32_Versor* versor);
|
||||
extern inline void bgc_fp64_versor_reset(BGC_FP64_Versor* versor);
|
||||
|
||||
extern inline void bgc_versor_set_values_fp32(const float s0, const float x1, const float x2, const float x3, BgcVersorFP32* versor);
|
||||
extern inline void bgc_versor_set_values_fp64(const double s0, const double x1, const double x2, const double x3, BgcVersorFP64* versor);
|
||||
extern inline void bgc_fp32_versor_make(const float s0, const float x1, const float x2, const float x3, BGC_FP32_Versor* versor);
|
||||
extern inline void bgc_fp64_versor_make(const double s0, const double x1, const double x2, const double x3, BGC_FP64_Versor* versor);
|
||||
|
||||
extern inline void bgc_versor_set_rotation_fp32(const BgcRotation3FP32* rotation, BgcVersorFP32* result);
|
||||
extern inline void bgc_versor_set_rotation_fp64(const BgcRotation3FP64* rotation, BgcVersorFP64* result);
|
||||
extern inline void bgc_fp32_versor_make_for_rotation(const BGC_FP32_Rotation3* rotation, BGC_FP32_Versor* result);
|
||||
extern inline void bgc_fp64_versor_make_for_rotation(const BGC_FP64_Rotation3* rotation, BGC_FP64_Versor* result);
|
||||
|
||||
extern inline void bgc_versor_copy_fp32(const BgcVersorFP32* source, BgcVersorFP32* destination);
|
||||
extern inline void bgc_versor_copy_fp64(const BgcVersorFP64* source, BgcVersorFP64* destination);
|
||||
extern inline void bgc_fp32_versor_copy(const BGC_FP32_Versor* source, BGC_FP32_Versor* destination);
|
||||
extern inline void bgc_fp64_versor_copy(const BGC_FP64_Versor* source, BGC_FP64_Versor* destination);
|
||||
|
||||
extern inline void bgc_versor_swap_fp32(BgcVersorFP32* versor1, BgcVersorFP32* versor2);
|
||||
extern inline void bgc_versor_swap_fp64(BgcVersorFP64* versor1, BgcVersorFP64* versor2);
|
||||
extern inline void bgc_fp32_versor_swap(BGC_FP32_Versor* versor1, BGC_FP32_Versor* versor2);
|
||||
extern inline void bgc_fp64_versor_swap(BGC_FP64_Versor* versor1, BGC_FP64_Versor* versor2);
|
||||
|
||||
extern inline int bgc_versor_is_identity_fp32(const BgcVersorFP32* versor);
|
||||
extern inline int bgc_versor_is_identity_fp64(const BgcVersorFP64* versor);
|
||||
extern inline int bgc_fp32_versor_is_idle(const BGC_FP32_Versor* versor);
|
||||
extern inline int bgc_fp64_versor_is_idle(const BGC_FP64_Versor* versor);
|
||||
|
||||
extern inline void bgc_versor_convert_fp64_to_fp32(const BgcVersorFP64* source, BgcVersorFP32* destination);
|
||||
extern inline void bgc_versor_convert_fp32_to_fp64(const BgcVersorFP32* source, BgcVersorFP64* destination);
|
||||
extern inline void bgc_fp64_versor_convert_to_fp32(const BGC_FP64_Versor* source, BGC_FP32_Versor* destination);
|
||||
extern inline void bgc_fp32_versor_convert_to_fp64(const BGC_FP32_Versor* source, BGC_FP64_Versor* destination);
|
||||
|
||||
extern inline void bgc_versor_shorten_fp32(BgcVersorFP32* versor);
|
||||
extern inline void bgc_versor_shorten_fp64(BgcVersorFP64* versor);
|
||||
extern inline void bgc_fp32_versor_shorten(BGC_FP32_Versor* versor);
|
||||
extern inline void bgc_fp64_versor_shorten(BGC_FP64_Versor* versor);
|
||||
|
||||
extern inline void bgc_versor_get_shortened_fp32(const BgcVersorFP32* versor, BgcVersorFP32* shortened);
|
||||
extern inline void bgc_versor_get_shortened_fp64(const BgcVersorFP64* versor, BgcVersorFP64* shortened);
|
||||
extern inline void bgc_fp32_versor_get_shortened(const BGC_FP32_Versor* versor, BGC_FP32_Versor* shortened);
|
||||
extern inline void bgc_fp64_versor_get_shortened(const BGC_FP64_Versor* versor, BGC_FP64_Versor* shortened);
|
||||
|
||||
extern inline void bgc_versor_make_opposite_fp32(BgcVersorFP32* versor);
|
||||
extern inline void bgc_versor_make_opposite_fp64(BgcVersorFP64* versor);
|
||||
extern inline void bgc_fp32_versor_alternate(BGC_FP32_Versor* versor);
|
||||
extern inline void bgc_fp64_versor_alternate(BGC_FP64_Versor* versor);
|
||||
|
||||
extern inline void bgc_versor_get_opposite_fp32(const BgcVersorFP32* versor, BgcVersorFP32* opposite);
|
||||
extern inline void bgc_versor_get_opposite_fp64(const BgcVersorFP64* versor, BgcVersorFP64* opposite);
|
||||
extern inline void bgc_fp32_versor_get_alternative(const BGC_FP32_Versor* versor, BGC_FP32_Versor* opposite);
|
||||
extern inline void bgc_fp64_versor_get_alternative(const BGC_FP64_Versor* versor, BGC_FP64_Versor* opposite);
|
||||
|
||||
extern inline void bgc_versor_invert_fp32(BgcVersorFP32* versor);
|
||||
extern inline void bgc_versor_invert_fp64(BgcVersorFP64* versor);
|
||||
extern inline void bgc_fp32_versor_revert(BGC_FP32_Versor* versor);
|
||||
extern inline void bgc_fp64_versor_revert(BGC_FP64_Versor* versor);
|
||||
|
||||
extern inline void bgc_versor_get_inverse_fp32(const BgcVersorFP32* versor, BgcVersorFP32* inverse);
|
||||
extern inline void bgc_versor_get_inverse_fp64(const BgcVersorFP64* versor, BgcVersorFP64* inverse);
|
||||
extern inline void bgc_fp32_versor_get_reverse(const BGC_FP32_Versor* versor, BGC_FP32_Versor* inverse);
|
||||
extern inline void bgc_fp64_versor_get_reverse(const BGC_FP64_Versor* versor, BGC_FP64_Versor* inverse);
|
||||
|
||||
extern inline void bgc_versor_combine_fp32(const BgcVersorFP32* first, const BgcVersorFP32* second, BgcVersorFP32* result);
|
||||
extern inline void bgc_versor_combine_fp64(const BgcVersorFP64* first, const BgcVersorFP64* second, BgcVersorFP64* result);
|
||||
extern inline void bgc_fp32_versor_combine(const BGC_FP32_Versor* first, const BGC_FP32_Versor* second, BGC_FP32_Versor* result);
|
||||
extern inline void bgc_fp64_versor_combine(const BGC_FP64_Versor* first, const BGC_FP64_Versor* second, BGC_FP64_Versor* result);
|
||||
|
||||
extern inline void bgc_versor_combine3_fp32(const BgcVersorFP32* first, const BgcVersorFP32* second, const BgcVersorFP32* third, BgcVersorFP32* result);
|
||||
extern inline void bgc_versor_combine3_fp64(const BgcVersorFP64* first, const BgcVersorFP64* second, const BgcVersorFP64* third, BgcVersorFP64* result);
|
||||
extern 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);
|
||||
extern 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);
|
||||
|
||||
extern inline void bgc_versor_exclude_fp32(const BgcVersorFP32* base, const BgcVersorFP32* excludant, BgcVersorFP32* difference);
|
||||
extern inline void bgc_versor_exclude_fp64(const BgcVersorFP64* base, const BgcVersorFP64* excludant, BgcVersorFP64* difference);
|
||||
extern inline void bgc_fp32_versor_exclude(const BGC_FP32_Versor* base, const BGC_FP32_Versor* excludant, BGC_FP32_Versor* difference);
|
||||
extern inline void bgc_fp64_versor_exclude(const BGC_FP64_Versor* base, const BGC_FP64_Versor* excludant, BGC_FP64_Versor* difference);
|
||||
|
||||
extern inline void bgc_versor_get_rotation_matrix_fp32(const BgcVersorFP32* versor, BgcMatrix3x3FP32* matrix);
|
||||
extern inline void bgc_versor_get_rotation_matrix_fp64(const BgcVersorFP64* versor, BgcMatrix3x3FP64* matrix);
|
||||
extern inline void bgc_fp32_versor_get_rotation_matrix(const BGC_FP32_Versor* versor, BGC_FP32_Matrix3x3* matrix);
|
||||
extern inline void bgc_fp64_versor_get_rotation_matrix(const BGC_FP64_Versor* versor, BGC_FP64_Matrix3x3* matrix);
|
||||
|
||||
extern inline void bgc_versor_get_reverse_matrix_fp32(const BgcVersorFP32* versor, BgcMatrix3x3FP32* matrix);
|
||||
extern inline void bgc_versor_get_reverse_matrix_fp64(const BgcVersorFP64* versor, BgcMatrix3x3FP64* matrix);
|
||||
extern inline void bgc_fp32_versor_get_reverse_matrix(const BGC_FP32_Versor* versor, BGC_FP32_Matrix3x3* matrix);
|
||||
extern inline void bgc_fp64_versor_get_reverse_matrix(const BGC_FP64_Versor* versor, BGC_FP64_Matrix3x3* matrix);
|
||||
|
||||
extern inline void bgc_versor_get_both_matrices_fp32(const BgcVersorFP32* versor, BgcMatrix3x3FP32* rotation, BgcMatrix3x3FP32* reverse);
|
||||
extern inline void bgc_versor_get_both_matrices_fp64(const BgcVersorFP64* versor, BgcMatrix3x3FP64* rotation, BgcMatrix3x3FP64* reverse);
|
||||
extern inline void bgc_fp32_versor_get_both_matrices(const BGC_FP32_Versor* versor, BGC_FP32_Matrix3x3* rotation, BGC_FP32_Matrix3x3* reverse);
|
||||
extern inline void bgc_fp64_versor_get_both_matrices(const BGC_FP64_Versor* versor, BGC_FP64_Matrix3x3* rotation, BGC_FP64_Matrix3x3* reverse);
|
||||
|
||||
extern inline void bgc_versor_turn_vector_fp32(const BgcVersorFP32* versor, const BgcVector3FP32* vector, BgcVector3FP32* result);
|
||||
extern inline void bgc_versor_turn_vector_fp64(const BgcVersorFP64* versor, const BgcVector3FP64* vector, BgcVector3FP64* result);
|
||||
extern inline void bgc_fp32_versor_turn_vector(const BGC_FP32_Versor* versor, const BGC_FP32_Vector3* vector, BGC_FP32_Vector3* result);
|
||||
extern inline void bgc_fp64_versor_turn_vector(const BGC_FP64_Versor* versor, const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* result);
|
||||
|
||||
extern inline void bgc_versor_turn_vector_back_fp32(const BgcVersorFP32* versor, const BgcVector3FP32* vector, BgcVector3FP32* result);
|
||||
extern inline void bgc_versor_turn_vector_back_fp64(const BgcVersorFP64* versor, const BgcVector3FP64* vector, BgcVector3FP64* result);
|
||||
extern inline void bgc_fp32_versor_turn_vector_back(const BGC_FP32_Versor* versor, const BGC_FP32_Vector3* vector, BGC_FP32_Vector3* result);
|
||||
extern inline void bgc_fp64_versor_turn_vector_back(const BGC_FP64_Versor* versor, const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* result);
|
||||
|
||||
extern inline int bgc_versor_are_close_fp32(const BgcVersorFP32* versor1, const BgcVersorFP32* versor2);
|
||||
extern inline int bgc_versor_are_close_fp64(const BgcVersorFP64* versor1, const BgcVersorFP64* versor2);
|
||||
extern inline int bgc_fp32_versor_are_close(const BGC_FP32_Versor* versor1, const BGC_FP32_Versor* versor2);
|
||||
extern inline int bgc_fp64_versor_are_close(const BGC_FP64_Versor* versor1, const BGC_FP64_Versor* versor2);
|
||||
|
||||
// ================= Normalize ================== //
|
||||
|
||||
void _bgc_versor_normalize_fp32(const float square_modulus, BgcVersorFP32* versor)
|
||||
void _bgc_fp32_versor_normalize(BGC_FP32_Versor* versor)
|
||||
{
|
||||
// (square_modulus != square_modulus) is true when square_modulus is NaN
|
||||
const float square_modulus = (versor->_s0 * versor->_s0 + versor->_x1 * versor->_x1) + (versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3);
|
||||
|
||||
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) {
|
||||
if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
|
||||
versor->_s0 = 1.0f;
|
||||
versor->_x1 = 0.0f;
|
||||
versor->_x2 = 0.0f;
|
||||
|
|
@ -95,11 +95,11 @@ void _bgc_versor_normalize_fp32(const float square_modulus, BgcVersorFP32* verso
|
|||
versor->_x3 *= multiplier;
|
||||
}
|
||||
|
||||
void _bgc_versor_normalize_fp64(const double square_modulus, BgcVersorFP64* versor)
|
||||
void _bgc_fp64_versor_normalize(BGC_FP64_Versor* versor)
|
||||
{
|
||||
// (square_modulus != square_modulus) is true when square_modulus is NaN
|
||||
const double square_modulus = (versor->_s0 * versor->_s0 + versor->_x1 * versor->_x1) + (versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3);
|
||||
|
||||
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) {
|
||||
if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
|
||||
versor->_s0 = 1.0;
|
||||
versor->_x1 = 0.0;
|
||||
versor->_x2 = 0.0;
|
||||
|
|
@ -117,71 +117,71 @@ void _bgc_versor_normalize_fp64(const double square_modulus, BgcVersorFP64* vers
|
|||
|
||||
// ================== 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)
|
||||
{
|
||||
const float square_vector = x1 * x1 + x2 * x2 + x3 * x3;
|
||||
|
||||
if (square_vector <= BGC_SQUARE_EPSYLON_FP32) {
|
||||
bgc_versor_reset_fp32(result);
|
||||
if (square_vector <= BGC_FP32_SQUARE_EPSYLON) {
|
||||
bgc_fp32_versor_reset(result);
|
||||
return;
|
||||
}
|
||||
|
||||
const float half_angle = bgc_angle_to_radians_fp32(0.5f * angle, unit);
|
||||
const float half_angle = bgc_fp32_angle_to_radians(0.5f * angle, unit);
|
||||
|
||||
const float sine = sinf(half_angle);
|
||||
|
||||
if (bgc_is_zero_fp32(sine)) {
|
||||
bgc_versor_reset_fp32(result);
|
||||
if (bgc_fp32_is_zero(sine)) {
|
||||
bgc_fp32_versor_reset(result);
|
||||
return;
|
||||
}
|
||||
|
||||
const float multiplier = sine / sqrtf(square_vector);
|
||||
|
||||
bgc_versor_set_values_fp32(cosf(half_angle), x1 * multiplier, x2 * multiplier, x3 * multiplier, result);
|
||||
bgc_fp32_versor_make(cosf(half_angle), x1 * multiplier, x2 * multiplier, x3 * multiplier, 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)
|
||||
{
|
||||
const double square_vector = x1 * x1 + x2 * x2 + x3 * x3;
|
||||
|
||||
if (square_vector <= BGC_SQUARE_EPSYLON_FP64) {
|
||||
bgc_versor_reset_fp64(result);
|
||||
if (square_vector <= BGC_FP64_SQUARE_EPSYLON) {
|
||||
bgc_fp64_versor_reset(result);
|
||||
return;
|
||||
}
|
||||
|
||||
const double half_angle = bgc_angle_to_radians_fp64(0.5 * angle, unit);
|
||||
const double half_angle = bgc_fp64_angle_to_radians(0.5 * angle, unit);
|
||||
|
||||
const double sine = sin(half_angle);
|
||||
|
||||
if (bgc_is_zero_fp64(sine)) {
|
||||
bgc_versor_reset_fp64(result);
|
||||
if (bgc_fp64_is_zero(sine)) {
|
||||
bgc_fp64_versor_reset(result);
|
||||
return;
|
||||
}
|
||||
|
||||
const double multiplier = sine / sqrt(square_vector);
|
||||
|
||||
bgc_versor_set_values_fp64(cos(half_angle), x1 * multiplier, x2 * multiplier, x3 * multiplier, result);
|
||||
bgc_fp64_versor_make(cos(half_angle), x1 * multiplier, x2 * multiplier, x3 * multiplier, result);
|
||||
}
|
||||
|
||||
// ========= Make Direction Difference ========== //
|
||||
|
||||
static int _bgc_versor_make_direction_turn_fp32(const BgcVector3FP32* start, const BgcVector3FP32* end, const float square_modulus_product, BgcVersorFP32* result)
|
||||
static int _bgc_fp32_versor_make_direction_turn(const BGC_FP32_Vector3* start, const BGC_FP32_Vector3* end, const float square_modulus_product, BGC_FP32_Versor* result)
|
||||
{
|
||||
BgcVector3FP32 orthogonal_axis;
|
||||
BGC_FP32_Vector3 orthogonal_axis;
|
||||
|
||||
bgc_vector3_get_cross_product_fp32(start, end, &orthogonal_axis);
|
||||
bgc_fp32_vector3_get_cross_product(start, end, &orthogonal_axis);
|
||||
|
||||
const float scalar_product = bgc_vector3_get_scalar_product_fp32(start, end);
|
||||
const float square_modulus = bgc_vector3_get_square_modulus_fp32(&orthogonal_axis);
|
||||
const float scalar_product = bgc_fp32_vector3_get_dot_product(start, end);
|
||||
const float square_modulus = bgc_fp32_vector3_get_square_modulus(&orthogonal_axis);
|
||||
const float square_sine = square_modulus / square_modulus_product;
|
||||
|
||||
if (square_sine > BGC_SQUARE_EPSYLON_FP32) {
|
||||
if (square_sine > BGC_FP32_SQUARE_EPSYLON) {
|
||||
const float cosine = scalar_product / sqrtf(square_modulus_product);
|
||||
const float angle = 0.5f * atan2f(sqrtf(square_sine), cosine);
|
||||
|
||||
const float multiplier = sinf(angle) * sqrtf(1.0f / square_modulus);
|
||||
|
||||
bgc_versor_set_values_fp32(cosf(angle), orthogonal_axis.x1 * multiplier, orthogonal_axis.x2 * multiplier, orthogonal_axis.x3 * multiplier, result);
|
||||
bgc_fp32_versor_make(cosf(angle), orthogonal_axis.x1 * multiplier, orthogonal_axis.x2 * multiplier, orthogonal_axis.x3 * multiplier, result);
|
||||
return BGC_SOME_TURN;
|
||||
}
|
||||
|
||||
|
|
@ -189,27 +189,27 @@ static int _bgc_versor_make_direction_turn_fp32(const BgcVector3FP32* start, con
|
|||
return BGC_OPPOSITE;
|
||||
}
|
||||
|
||||
bgc_versor_reset_fp32(result);
|
||||
bgc_fp32_versor_reset(result);
|
||||
return BGC_ZERO_TURN;
|
||||
}
|
||||
|
||||
static int _bgc_versor_make_direction_turn_fp64(const BgcVector3FP64* start, const BgcVector3FP64* end, const double square_modulus_product, BgcVersorFP64* result)
|
||||
static int _bgc_fp64_versor_make_direction_turn(const BGC_FP64_Vector3* start, const BGC_FP64_Vector3* end, const double square_modulus_product, BGC_FP64_Versor* result)
|
||||
{
|
||||
BgcVector3FP64 orthogonal_axis;
|
||||
BGC_FP64_Vector3 orthogonal_axis;
|
||||
|
||||
bgc_vector3_get_cross_product_fp64(start, end, &orthogonal_axis);
|
||||
bgc_fp64_vector3_get_cross_product(start, end, &orthogonal_axis);
|
||||
|
||||
const double scalar_product = bgc_vector3_get_scalar_product_fp64(start, end);
|
||||
const double square_modulus = bgc_vector3_get_square_modulus_fp64(&orthogonal_axis);
|
||||
const double scalar_product = bgc_fp64_vector3_get_dot_product(start, end);
|
||||
const double square_modulus = bgc_fp64_vector3_get_square_modulus(&orthogonal_axis);
|
||||
const double square_sine = square_modulus / square_modulus_product;
|
||||
|
||||
if (square_sine > BGC_SQUARE_EPSYLON_FP64) {
|
||||
if (square_sine > BGC_FP64_SQUARE_EPSYLON) {
|
||||
const double cosine = scalar_product / sqrt(square_modulus_product);
|
||||
const double angle = 0.5 * atan2(sqrt(square_sine), cosine);
|
||||
|
||||
const double multiplier = sin(angle) * sqrt(1.0f / square_modulus);
|
||||
|
||||
bgc_versor_set_values_fp64(cos(angle), orthogonal_axis.x1 * multiplier, orthogonal_axis.x2 * multiplier, orthogonal_axis.x3 * multiplier, result);
|
||||
bgc_fp64_versor_make(cos(angle), orthogonal_axis.x1 * multiplier, orthogonal_axis.x2 * multiplier, orthogonal_axis.x3 * multiplier, result);
|
||||
return BGC_SOME_TURN;
|
||||
}
|
||||
|
||||
|
|
@ -217,51 +217,51 @@ static int _bgc_versor_make_direction_turn_fp64(const BgcVector3FP64* start, con
|
|||
return BGC_OPPOSITE;
|
||||
}
|
||||
|
||||
bgc_versor_reset_fp64(result);
|
||||
bgc_fp64_versor_reset(result);
|
||||
return BGC_ZERO_TURN;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
const float start_square_modulus = bgc_vector3_get_square_modulus_fp32(start);
|
||||
const float end_square_modulus = bgc_vector3_get_square_modulus_fp32(end);
|
||||
const float start_square_modulus = bgc_fp32_vector3_get_square_modulus(start);
|
||||
const float end_square_modulus = bgc_fp32_vector3_get_square_modulus(end);
|
||||
|
||||
if (start_square_modulus <= BGC_SQUARE_EPSYLON_FP32 || end_square_modulus <= BGC_SQUARE_EPSYLON_FP32) {
|
||||
bgc_versor_reset_fp32(result);
|
||||
if (start_square_modulus <= BGC_FP32_SQUARE_EPSYLON || end_square_modulus <= BGC_FP32_SQUARE_EPSYLON) {
|
||||
bgc_fp32_versor_reset(result);
|
||||
return BGC_ZERO_TURN;
|
||||
}
|
||||
|
||||
return _bgc_versor_make_direction_turn_fp32(start, end, start_square_modulus * end_square_modulus, result);
|
||||
return _bgc_fp32_versor_make_direction_turn(start, end, start_square_modulus * end_square_modulus, 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)
|
||||
{
|
||||
const double start_square_modulus = bgc_vector3_get_square_modulus_fp64(start);
|
||||
const double end_square_modulus = bgc_vector3_get_square_modulus_fp64(end);
|
||||
const double start_square_modulus = bgc_fp64_vector3_get_square_modulus(start);
|
||||
const double end_square_modulus = bgc_fp64_vector3_get_square_modulus(end);
|
||||
|
||||
if (start_square_modulus <= BGC_SQUARE_EPSYLON_FP64 || end_square_modulus <= BGC_SQUARE_EPSYLON_FP64) {
|
||||
bgc_versor_reset_fp64(result);
|
||||
if (start_square_modulus <= BGC_FP64_SQUARE_EPSYLON || end_square_modulus <= BGC_FP64_SQUARE_EPSYLON) {
|
||||
bgc_fp64_versor_reset(result);
|
||||
return BGC_ZERO_TURN;
|
||||
}
|
||||
|
||||
return _bgc_versor_make_direction_turn_fp64(start, end, start_square_modulus * end_square_modulus, result);
|
||||
return _bgc_fp64_versor_make_direction_turn(start, end, start_square_modulus * end_square_modulus, result);
|
||||
}
|
||||
|
||||
// =============== Set Directions =============== //
|
||||
|
||||
static int _bgc_versor_validate_basis_fp32(const float primary_square_modulus, const float auxiliary_square_modulus, const float orthogonal_square_modulus)
|
||||
static int _bgc_fp32_versor_validate_basis(const float primary_square_modulus, const float auxiliary_square_modulus, const float orthogonal_square_modulus)
|
||||
{
|
||||
if (primary_square_modulus <= BGC_SQUARE_EPSYLON_FP32) {
|
||||
if (primary_square_modulus <= BGC_FP32_SQUARE_EPSYLON) {
|
||||
//TODO: add error code for: primary_vector is zero
|
||||
return BGC_FAILED;
|
||||
}
|
||||
|
||||
if (auxiliary_square_modulus <= BGC_SQUARE_EPSYLON_FP32) {
|
||||
if (auxiliary_square_modulus <= BGC_FP32_SQUARE_EPSYLON) {
|
||||
//TODO: add error code for: auxiliary_vector is zero
|
||||
return BGC_FAILED;
|
||||
}
|
||||
|
||||
if (orthogonal_square_modulus <= BGC_SQUARE_EPSYLON_FP32 * primary_square_modulus * auxiliary_square_modulus) {
|
||||
if (orthogonal_square_modulus <= BGC_FP32_SQUARE_EPSYLON * primary_square_modulus * auxiliary_square_modulus) {
|
||||
//TODO: add error code for: primary_vector and auxiliary_vector are parallel
|
||||
return BGC_FAILED;
|
||||
}
|
||||
|
|
@ -269,19 +269,19 @@ static int _bgc_versor_validate_basis_fp32(const float primary_square_modulus, c
|
|||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
static int _bgc_versor_validate_basis_fp64(const double primary_square_modulus, const double auxiliary_square_modulus, const double orthogonal_square_modulus)
|
||||
static int _bgc_fp64_versor_validate_basis(const double primary_square_modulus, const double auxiliary_square_modulus, const double orthogonal_square_modulus)
|
||||
{
|
||||
if (primary_square_modulus <= BGC_SQUARE_EPSYLON_FP64) {
|
||||
if (primary_square_modulus <= BGC_FP64_SQUARE_EPSYLON) {
|
||||
//TODO: add error code for: primary_vector is zero
|
||||
return BGC_FAILED;
|
||||
}
|
||||
|
||||
if (auxiliary_square_modulus <= BGC_SQUARE_EPSYLON_FP64) {
|
||||
if (auxiliary_square_modulus <= BGC_FP64_SQUARE_EPSYLON) {
|
||||
//TODO: add error code for: auxiliary_vector is zero
|
||||
return BGC_FAILED;
|
||||
}
|
||||
|
||||
if (orthogonal_square_modulus <= BGC_SQUARE_EPSYLON_FP64 * primary_square_modulus * auxiliary_square_modulus) {
|
||||
if (orthogonal_square_modulus <= BGC_FP64_SQUARE_EPSYLON * primary_square_modulus * auxiliary_square_modulus) {
|
||||
//TODO: add error code for: primary_vector and auxiliary_vector are parallel
|
||||
return BGC_FAILED;
|
||||
}
|
||||
|
|
@ -289,64 +289,64 @@ static int _bgc_versor_validate_basis_fp64(const double primary_square_modulus,
|
|||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
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
|
||||
)
|
||||
{
|
||||
BgcVector3FP32 initial_orthogonal_direction, turned_orthogonal_direction, final_orthogonal_direction;
|
||||
BGC_FP32_Vector3 initial_orthogonal_direction, turned_orthogonal_direction, final_orthogonal_direction;
|
||||
|
||||
// Step 1: Validate initial basis:
|
||||
bgc_vector3_get_cross_product_fp32(initial_primary_direction, initial_auxiliary_direction, &initial_orthogonal_direction);
|
||||
bgc_fp32_vector3_get_cross_product(initial_primary_direction, initial_auxiliary_direction, &initial_orthogonal_direction);
|
||||
|
||||
const float initial_primary_square_modulus = bgc_vector3_get_square_modulus_fp32(initial_primary_direction);
|
||||
const float initial_auxiliary_square_modulus = bgc_vector3_get_square_modulus_fp32(initial_auxiliary_direction);
|
||||
const float initial_orthogonal_square_modulus = bgc_vector3_get_square_modulus_fp32(&initial_orthogonal_direction);
|
||||
const float initial_primary_square_modulus = bgc_fp32_vector3_get_square_modulus(initial_primary_direction);
|
||||
const float initial_auxiliary_square_modulus = bgc_fp32_vector3_get_square_modulus(initial_auxiliary_direction);
|
||||
const float initial_orthogonal_square_modulus = bgc_fp32_vector3_get_square_modulus(&initial_orthogonal_direction);
|
||||
|
||||
const int initial_basis_valudation = _bgc_versor_validate_basis_fp32(initial_primary_square_modulus, initial_auxiliary_square_modulus, initial_orthogonal_square_modulus);
|
||||
const int initial_basis_valudation = _bgc_fp32_versor_validate_basis(initial_primary_square_modulus, initial_auxiliary_square_modulus, initial_orthogonal_square_modulus);
|
||||
|
||||
if (initial_basis_valudation != BGC_SUCCESS) {
|
||||
return initial_basis_valudation;
|
||||
}
|
||||
|
||||
// Step 1: Validate final basis:
|
||||
bgc_vector3_get_cross_product_fp32(final_primary_direction, final_auxiliary_direction, &final_orthogonal_direction);
|
||||
bgc_fp32_vector3_get_cross_product(final_primary_direction, final_auxiliary_direction, &final_orthogonal_direction);
|
||||
|
||||
const float final_primary_square_modulus = bgc_vector3_get_square_modulus_fp32(final_primary_direction);
|
||||
const float final_auxiliary_square_modulus = bgc_vector3_get_square_modulus_fp32(final_auxiliary_direction);
|
||||
const float final_orthogonal_square_modulus = bgc_vector3_get_square_modulus_fp32(&final_orthogonal_direction);
|
||||
const float final_primary_square_modulus = bgc_fp32_vector3_get_square_modulus(final_primary_direction);
|
||||
const float final_auxiliary_square_modulus = bgc_fp32_vector3_get_square_modulus(final_auxiliary_direction);
|
||||
const float final_orthogonal_square_modulus = bgc_fp32_vector3_get_square_modulus(&final_orthogonal_direction);
|
||||
|
||||
const int final_basis_valudation = _bgc_versor_validate_basis_fp32(final_primary_square_modulus, final_auxiliary_square_modulus, final_orthogonal_square_modulus);
|
||||
const int final_basis_valudation = _bgc_fp32_versor_validate_basis(final_primary_square_modulus, final_auxiliary_square_modulus, final_orthogonal_square_modulus);
|
||||
|
||||
if (final_basis_valudation != BGC_SUCCESS) {
|
||||
return final_basis_valudation;
|
||||
}
|
||||
|
||||
// Step 3: Validate normalize orthogonal vectors:
|
||||
bgc_vector3_divide_fp32(&initial_orthogonal_direction, sqrtf(initial_orthogonal_square_modulus), &initial_orthogonal_direction);
|
||||
bgc_vector3_divide_fp32(&final_orthogonal_direction, sqrtf(final_orthogonal_square_modulus), &final_orthogonal_direction);
|
||||
bgc_fp32_vector3_divide(&initial_orthogonal_direction, sqrtf(initial_orthogonal_square_modulus), &initial_orthogonal_direction);
|
||||
bgc_fp32_vector3_divide(&final_orthogonal_direction, sqrtf(final_orthogonal_square_modulus), &final_orthogonal_direction);
|
||||
|
||||
BgcVersorFP32 turn1, turn2;
|
||||
BGC_FP32_Versor turn1, turn2;
|
||||
|
||||
// Step 4: Find turn1
|
||||
int turn1_code = _bgc_versor_make_direction_turn_fp32(initial_primary_direction, final_primary_direction, initial_primary_square_modulus * final_primary_square_modulus, &turn1);
|
||||
int turn1_code = _bgc_fp32_versor_make_direction_turn(initial_primary_direction, final_primary_direction, initial_primary_square_modulus * final_primary_square_modulus, &turn1);
|
||||
|
||||
if (turn1_code == BGC_OPPOSITE) {
|
||||
bgc_versor_set_values_fp32(0.0f, initial_orthogonal_direction.x1, initial_orthogonal_direction.x2, initial_orthogonal_direction.x3, &turn1);
|
||||
bgc_fp32_versor_make(0.0f, initial_orthogonal_direction.x1, initial_orthogonal_direction.x2, initial_orthogonal_direction.x3, &turn1);
|
||||
}
|
||||
|
||||
bgc_versor_turn_vector_fp32(&turn1, &initial_orthogonal_direction, &turned_orthogonal_direction);
|
||||
bgc_fp32_versor_turn_vector(&turn1, &initial_orthogonal_direction, &turned_orthogonal_direction);
|
||||
|
||||
// Step 5: Find turn2:
|
||||
int turn2_code = _bgc_versor_make_direction_turn_fp32(&turned_orthogonal_direction, &final_orthogonal_direction, 1.0f, &turn2);
|
||||
int turn2_code = _bgc_fp32_versor_make_direction_turn(&turned_orthogonal_direction, &final_orthogonal_direction, 1.0f, &turn2);
|
||||
|
||||
if (turn2_code == BGC_OPPOSITE) {
|
||||
const float turn2_multiplier = sqrtf(1.0f / final_primary_square_modulus);
|
||||
|
||||
bgc_versor_set_values_fp32(0.0f,
|
||||
bgc_fp32_versor_make(0.0f,
|
||||
final_primary_direction->x1 * turn2_multiplier,
|
||||
final_primary_direction->x2 * turn2_multiplier,
|
||||
final_primary_direction->x3 * turn2_multiplier,
|
||||
|
|
@ -355,69 +355,69 @@ int bgc_versor_make_basis_difference_fp32(
|
|||
}
|
||||
|
||||
// Step 6: Combine turn1 and turn2:
|
||||
bgc_versor_combine_fp32(&turn1, &turn2, result);
|
||||
bgc_fp32_versor_combine(&turn1, &turn2, result);
|
||||
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
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
|
||||
)
|
||||
{
|
||||
BgcVector3FP64 initial_orthogonal_direction, turned_orthogonal_direction, final_orthogonal_direction;
|
||||
BGC_FP64_Vector3 initial_orthogonal_direction, turned_orthogonal_direction, final_orthogonal_direction;
|
||||
|
||||
// Step 1: Validate initial basis:
|
||||
bgc_vector3_get_cross_product_fp64(initial_primary_direction, initial_auxiliary_direction, &initial_orthogonal_direction);
|
||||
bgc_fp64_vector3_get_cross_product(initial_primary_direction, initial_auxiliary_direction, &initial_orthogonal_direction);
|
||||
|
||||
const double initial_primary_square_modulus = bgc_vector3_get_square_modulus_fp64(initial_primary_direction);
|
||||
const double initial_auxiliary_square_modulus = bgc_vector3_get_square_modulus_fp64(initial_auxiliary_direction);
|
||||
const double initial_orthogonal_square_modulus = bgc_vector3_get_square_modulus_fp64(&initial_orthogonal_direction);
|
||||
const double initial_primary_square_modulus = bgc_fp64_vector3_get_square_modulus(initial_primary_direction);
|
||||
const double initial_auxiliary_square_modulus = bgc_fp64_vector3_get_square_modulus(initial_auxiliary_direction);
|
||||
const double initial_orthogonal_square_modulus = bgc_fp64_vector3_get_square_modulus(&initial_orthogonal_direction);
|
||||
|
||||
const int initial_basis_valudation = _bgc_versor_validate_basis_fp64(initial_primary_square_modulus, initial_auxiliary_square_modulus, initial_orthogonal_square_modulus);
|
||||
const int initial_basis_valudation = _bgc_fp64_versor_validate_basis(initial_primary_square_modulus, initial_auxiliary_square_modulus, initial_orthogonal_square_modulus);
|
||||
|
||||
if (initial_basis_valudation != BGC_SUCCESS) {
|
||||
return initial_basis_valudation;
|
||||
}
|
||||
|
||||
// Step 1: Validate final basis:
|
||||
bgc_vector3_get_cross_product_fp64(final_primary_direction, final_auxiliary_direction, &final_orthogonal_direction);
|
||||
bgc_fp64_vector3_get_cross_product(final_primary_direction, final_auxiliary_direction, &final_orthogonal_direction);
|
||||
|
||||
const double final_primary_square_modulus = bgc_vector3_get_square_modulus_fp64(final_primary_direction);
|
||||
const double final_auxiliary_square_modulus = bgc_vector3_get_square_modulus_fp64(final_auxiliary_direction);
|
||||
const double final_orthogonal_square_modulus = bgc_vector3_get_square_modulus_fp64(&final_orthogonal_direction);
|
||||
const double final_primary_square_modulus = bgc_fp64_vector3_get_square_modulus(final_primary_direction);
|
||||
const double final_auxiliary_square_modulus = bgc_fp64_vector3_get_square_modulus(final_auxiliary_direction);
|
||||
const double final_orthogonal_square_modulus = bgc_fp64_vector3_get_square_modulus(&final_orthogonal_direction);
|
||||
|
||||
const int final_basis_valudation = _bgc_versor_validate_basis_fp64(final_primary_square_modulus, final_auxiliary_square_modulus, final_orthogonal_square_modulus);
|
||||
const int final_basis_valudation = _bgc_fp64_versor_validate_basis(final_primary_square_modulus, final_auxiliary_square_modulus, final_orthogonal_square_modulus);
|
||||
|
||||
if (final_basis_valudation != BGC_SUCCESS) {
|
||||
return final_basis_valudation;
|
||||
}
|
||||
|
||||
// Step 3: Validate normalize orthogonal vectors:
|
||||
bgc_vector3_divide_fp64(&initial_orthogonal_direction, sqrt(initial_orthogonal_square_modulus), &initial_orthogonal_direction);
|
||||
bgc_vector3_divide_fp64(&final_orthogonal_direction, sqrt(final_orthogonal_square_modulus), &final_orthogonal_direction);
|
||||
bgc_fp64_vector3_divide(&initial_orthogonal_direction, sqrt(initial_orthogonal_square_modulus), &initial_orthogonal_direction);
|
||||
bgc_fp64_vector3_divide(&final_orthogonal_direction, sqrt(final_orthogonal_square_modulus), &final_orthogonal_direction);
|
||||
|
||||
BgcVersorFP64 turn1, turn2;
|
||||
BGC_FP64_Versor turn1, turn2;
|
||||
|
||||
// Step 4: Find turn1
|
||||
int turn1_code = _bgc_versor_make_direction_turn_fp64(initial_primary_direction, final_primary_direction, initial_primary_square_modulus * final_primary_square_modulus, &turn1);
|
||||
int turn1_code = _bgc_fp64_versor_make_direction_turn(initial_primary_direction, final_primary_direction, initial_primary_square_modulus * final_primary_square_modulus, &turn1);
|
||||
|
||||
if (turn1_code == BGC_OPPOSITE) {
|
||||
bgc_versor_set_values_fp64(0.0, initial_orthogonal_direction.x1, initial_orthogonal_direction.x2, initial_orthogonal_direction.x3, &turn1);
|
||||
bgc_fp64_versor_make(0.0, initial_orthogonal_direction.x1, initial_orthogonal_direction.x2, initial_orthogonal_direction.x3, &turn1);
|
||||
}
|
||||
|
||||
bgc_versor_turn_vector_fp64(&turn1, &initial_orthogonal_direction, &turned_orthogonal_direction);
|
||||
bgc_fp64_versor_turn_vector(&turn1, &initial_orthogonal_direction, &turned_orthogonal_direction);
|
||||
|
||||
// Step 5: Find turn2:
|
||||
int turn2_code = _bgc_versor_make_direction_turn_fp64(&turned_orthogonal_direction, &final_orthogonal_direction, 1.0f, &turn2);
|
||||
int turn2_code = _bgc_fp64_versor_make_direction_turn(&turned_orthogonal_direction, &final_orthogonal_direction, 1.0f, &turn2);
|
||||
|
||||
if (turn2_code == BGC_OPPOSITE) {
|
||||
const double turn2_multiplier = sqrt(1.0 / final_primary_square_modulus);
|
||||
|
||||
bgc_versor_set_values_fp64(0.0,
|
||||
bgc_fp64_versor_make(0.0,
|
||||
final_primary_direction->x1 * turn2_multiplier,
|
||||
final_primary_direction->x2 * turn2_multiplier,
|
||||
final_primary_direction->x3 * turn2_multiplier,
|
||||
|
|
@ -426,19 +426,19 @@ int bgc_versor_make_basis_difference_fp64(
|
|||
}
|
||||
|
||||
// Step 6: Combine turn1 and turn2:
|
||||
bgc_versor_combine_fp64(&turn1, &turn2, result);
|
||||
bgc_fp64_versor_combine(&turn1, &turn2, result);
|
||||
|
||||
return BGC_SUCCESS;
|
||||
}
|
||||
|
||||
// =============== 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)
|
||||
{
|
||||
const float square_vector = base->_x1 * base->_x1 + base->_x2 * base->_x2 + base->_x3 * base->_x3;
|
||||
|
||||
if (square_vector <= BGC_SQUARE_EPSYLON_FP32 || square_vector != square_vector) {
|
||||
bgc_versor_reset_fp32(power);
|
||||
if (square_vector <= BGC_FP32_SQUARE_EPSYLON || square_vector != square_vector) {
|
||||
bgc_fp32_versor_reset(power);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -448,15 +448,15 @@ void bgc_versor_get_exponation_fp32(const BgcVersorFP32* base, const float expon
|
|||
|
||||
const float multiplier = sinf(angle) / vector_modulus;
|
||||
|
||||
bgc_versor_set_values_fp32(cosf(angle), base->_x1 * multiplier, base->_x2 * multiplier, base->_x3 * multiplier, power);
|
||||
bgc_fp32_versor_make(cosf(angle), base->_x1 * multiplier, base->_x2 * multiplier, base->_x3 * multiplier, 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)
|
||||
{
|
||||
const double square_vector = base->_x1 * base->_x1 + base->_x2 * base->_x2 + base->_x3 * base->_x3;
|
||||
|
||||
if (square_vector <= BGC_SQUARE_EPSYLON_FP64 || square_vector != square_vector) {
|
||||
bgc_versor_reset_fp64(power);
|
||||
if (square_vector <= BGC_FP64_SQUARE_EPSYLON || square_vector != square_vector) {
|
||||
bgc_fp64_versor_reset(power);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -466,12 +466,12 @@ void bgc_versor_get_exponation_fp64(const BgcVersorFP64* base, const double expo
|
|||
|
||||
const double multiplier = sin(angle) / vector_modulus;
|
||||
|
||||
bgc_versor_set_values_fp64(cos(angle), base->_x1 * multiplier, base->_x2 * multiplier, base->_x3 * multiplier, power);
|
||||
bgc_fp64_versor_make(cos(angle), base->_x1 * multiplier, base->_x2 * multiplier, base->_x3 * multiplier, power);
|
||||
}
|
||||
|
||||
// ============ 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)
|
||||
{
|
||||
const float delta_s0 = (end->_s0 * start->_s0 + end->_x1 * start->_x1) + (end->_x2 * start->_x2 + end->_x3 * start->_x3);
|
||||
const float delta_x1 = (end->_x1 * start->_s0 + end->_x3 * start->_x2) - (end->_s0 * start->_x1 + end->_x2 * start->_x3);
|
||||
|
|
@ -481,8 +481,8 @@ void bgc_versor_spherically_interpolate_fp32(const BgcVersorFP32* start, const B
|
|||
const float square_vector = delta_x1 * delta_x1 + delta_x2 * delta_x2 + delta_x3 * delta_x3;
|
||||
|
||||
// square_vector != square_vector means checking for NaN value at square_vector
|
||||
if (square_vector <= BGC_SQUARE_EPSYLON_FP32 || square_vector != square_vector) {
|
||||
bgc_versor_copy_fp32(end, result);
|
||||
if (square_vector <= BGC_FP32_SQUARE_EPSYLON || square_vector != square_vector) {
|
||||
bgc_fp32_versor_copy(end, result);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -497,7 +497,7 @@ void bgc_versor_spherically_interpolate_fp32(const BgcVersorFP32* start, const B
|
|||
const float turn_x3 = delta_x3 * multiplier;
|
||||
|
||||
// Combining of starting orientation with the turning
|
||||
bgc_versor_set_values_fp32(
|
||||
bgc_fp32_versor_make(
|
||||
(turn_s0 * start->_s0 - turn_x1 * start->_x1) - (turn_x2 * start->_x2 + turn_x3 * start->_x3),
|
||||
(turn_x1 * start->_s0 + turn_s0 * start->_x1) - (turn_x3 * start->_x2 - turn_x2 * start->_x3),
|
||||
(turn_x2 * start->_s0 + turn_s0 * start->_x2) - (turn_x1 * start->_x3 - turn_x3 * start->_x1),
|
||||
|
|
@ -506,7 +506,7 @@ void bgc_versor_spherically_interpolate_fp32(const BgcVersorFP32* start, const B
|
|||
);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
const double delta_s0 = (end->_s0 * start->_s0 + end->_x1 * start->_x1) + (end->_x2 * start->_x2 + end->_x3 * start->_x3);
|
||||
const double delta_x1 = (end->_x1 * start->_s0 + end->_x3 * start->_x2) - (end->_s0 * start->_x1 + end->_x2 * start->_x3);
|
||||
|
|
@ -516,8 +516,8 @@ void bgc_versor_spherically_interpolate_fp64(const BgcVersorFP64* start, const B
|
|||
const double square_vector = delta_x1 * delta_x1 + delta_x2 * delta_x2 + delta_x3 * delta_x3;
|
||||
|
||||
// square_vector != square_vector means checking for NaN value at square_vector
|
||||
if (square_vector <= BGC_SQUARE_EPSYLON_FP64 || square_vector != square_vector) {
|
||||
bgc_versor_copy_fp64(end, result);
|
||||
if (square_vector <= BGC_FP64_SQUARE_EPSYLON || square_vector != square_vector) {
|
||||
bgc_fp64_versor_copy(end, result);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -532,7 +532,7 @@ void bgc_versor_spherically_interpolate_fp64(const BgcVersorFP64* start, const B
|
|||
const double turn_x3 = delta_x3 * multiplier;
|
||||
|
||||
// Combining of starting orientation with the turning
|
||||
bgc_versor_set_values_fp64(
|
||||
bgc_fp64_versor_make(
|
||||
(turn_s0 * start->_s0 - turn_x1 * start->_x1) - (turn_x2 * start->_x2 + turn_x3 * start->_x3),
|
||||
(turn_x1 * start->_s0 + turn_s0 * start->_x1) - (turn_x3 * start->_x2 - turn_x2 * start->_x3),
|
||||
(turn_x2 * start->_s0 + turn_s0 * start->_x2) - (turn_x1 * start->_x3 - turn_x3 * start->_x1),
|
||||
|
|
@ -543,12 +543,12 @@ void bgc_versor_spherically_interpolate_fp64(const BgcVersorFP64* start, const B
|
|||
|
||||
// ================ 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)
|
||||
{
|
||||
const float square_modulus = versor->_x1 * versor->_x1 + versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3;
|
||||
|
||||
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32) {
|
||||
bgc_rotation3_reset_fp32(result);
|
||||
if (square_modulus <= BGC_FP32_SQUARE_EPSYLON) {
|
||||
bgc_fp32_rotation3_reset(result);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -563,12 +563,12 @@ void bgc_versor_get_rotation_fp32(const BgcVersorFP32* versor, BgcRotation3FP32*
|
|||
result->axis.x3 = versor->_x3 * multiplier;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
const double square_modulus = versor->_x1 * versor->_x1 + versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3;
|
||||
|
||||
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64) {
|
||||
bgc_rotation3_reset_fp64(result);
|
||||
if (square_modulus <= BGC_FP64_SQUARE_EPSYLON) {
|
||||
bgc_fp64_rotation3_reset(result);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue