40 lines
1.9 KiB
C
40 lines
1.9 KiB
C
#include "posture3.h"
|
|
|
|
extern inline void bgc_fp32_posture3_reset(BGC_FP32_Posture3* posture);
|
|
extern inline void bgc_fp64_posture3_reset(BGC_FP64_Posture3* posture);
|
|
|
|
extern inline void bgc_fp32_posture3_copy(BGC_FP32_Posture3* destination, const BGC_FP32_Posture3* source);
|
|
extern inline void bgc_fp64_posture3_copy(BGC_FP64_Posture3* destination, const BGC_FP64_Posture3* source);
|
|
|
|
extern inline void bgc_fp32_posture3_swap(BGC_FP32_Posture3* posture1, BGC_FP32_Posture3* posture2);
|
|
extern inline void bgc_fp64_posture3_swap(BGC_FP64_Posture3* posture1, BGC_FP64_Posture3* posture2);
|
|
|
|
extern inline void bgc_fp32_posture3_convert_to_fp64(BGC_FP64_Posture3* destination, const BGC_FP32_Posture3* source);
|
|
extern inline void bgc_fp64_posture3_convert_to_fp32(BGC_FP32_Posture3* destination, const BGC_FP64_Posture3* source);
|
|
|
|
extern inline void bgc_fp32_posture3_combine(BGC_FP32_Posture3* combination, const BGC_FP32_Posture3* first, const BGC_FP32_Posture3* second);
|
|
extern inline void bgc_fp64_posture3_combine(BGC_FP64_Posture3* combination, const BGC_FP64_Posture3* first, const BGC_FP64_Posture3* second);
|
|
|
|
void _bgc_fp32_posture3_normalize(BGC_FP32_Posture3* posture, const float square_magnitude)
|
|
{
|
|
if (square_magnitude <= BGC_FP32_SQUARE_EPSILON || isnan(square_magnitude)) {
|
|
bgc_fp32_posture3_reset(posture);
|
|
return;
|
|
}
|
|
|
|
const float multiplier = sqrtf(1.0f / square_magnitude);
|
|
|
|
bgc_fp32_dual_quaternion_multiply_by_real_number(&posture->_versor, &posture->_versor, multiplier);
|
|
}
|
|
|
|
void _bgc_fp64_posture3_normalize(BGC_FP64_Posture3* posture, const double square_magnitude)
|
|
{
|
|
if (square_magnitude <= BGC_FP64_SQUARE_EPSILON || isnan(square_magnitude)) {
|
|
bgc_fp64_posture3_reset(posture);
|
|
return;
|
|
}
|
|
|
|
const double multiplier = sqrt(1.0 / square_magnitude);
|
|
|
|
bgc_fp64_dual_quaternion_multiply_by_real_number(&posture->_versor, &posture->_versor, multiplier);
|
|
}
|