Развитие структуры Posture3 для хранения пложения тела в виде нормализованного дуального кватерниона
This commit is contained in:
parent
0c27a6e59b
commit
add4d89c80
3 changed files with 109 additions and 24 deletions
|
|
@ -5,35 +5,99 @@
|
|||
#include "quaternion.h"
|
||||
#include "dual-quaternion.h"
|
||||
|
||||
// ================= Normalize ================== //
|
||||
|
||||
void _bgc_fp32_posture3_normalize(BGC_FP32_Posture3* posture, const float square_magnitude);
|
||||
|
||||
void _bgc_fp64_posture3_normalize(BGC_FP64_Posture3* posture, const double square_magnitude);
|
||||
|
||||
// ==================== Reset =================== //
|
||||
|
||||
inline void bgc_fp32_posture3_reset(BGC_FP32_Posture3* posture)
|
||||
{
|
||||
posture->_dual_versor.real_part.s0 = 1.0f;
|
||||
posture->_dual_versor.real_part.x1 = 0.0f;
|
||||
posture->_dual_versor.real_part.x2 = 0.0f;
|
||||
posture->_dual_versor.real_part.x3 = 0.0f;
|
||||
posture->_real_part.s0 = 1.0f;
|
||||
posture->_real_part.x1 = 0.0f;
|
||||
posture->_real_part.x2 = 0.0f;
|
||||
posture->_real_part.x3 = 0.0f;
|
||||
|
||||
posture->_dual_versor.dual_part.s0 = 0.0f;
|
||||
posture->_dual_versor.dual_part.x1 = 0.0f;
|
||||
posture->_dual_versor.dual_part.x2 = 0.0f;
|
||||
posture->_dual_versor.dual_part.x3 = 0.0f;
|
||||
posture->_dual_part.s0 = 0.0f;
|
||||
posture->_dual_part.x1 = 0.0f;
|
||||
posture->_dual_part.x2 = 0.0f;
|
||||
posture->_dual_part.x3 = 0.0f;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_posture3_reset(BGC_FP64_Posture3* posture)
|
||||
{
|
||||
posture->_dual_versor.real_part.s0 = 1.0;
|
||||
posture->_dual_versor.real_part.x1 = 0.0;
|
||||
posture->_dual_versor.real_part.x2 = 0.0;
|
||||
posture->_dual_versor.real_part.x3 = 0.0;
|
||||
posture->_real_part.s0 = 1.0;
|
||||
posture->_real_part.x1 = 0.0;
|
||||
posture->_real_part.x2 = 0.0;
|
||||
posture->_real_part.x3 = 0.0;
|
||||
|
||||
posture->_dual_versor.dual_part.s0 = 0.0;
|
||||
posture->_dual_versor.dual_part.x1 = 0.0;
|
||||
posture->_dual_versor.dual_part.x2 = 0.0;
|
||||
posture->_dual_versor.dual_part.x3 = 0.0;
|
||||
posture->_dual_part.s0 = 0.0;
|
||||
posture->_dual_part.x1 = 0.0;
|
||||
posture->_dual_part.x2 = 0.0;
|
||||
posture->_dual_part.x3 = 0.0;
|
||||
}
|
||||
|
||||
void _bgc_fp32_posture3_normalize(BGC_FP32_Posture3* posture);
|
||||
// ==================== Copy ==================== //
|
||||
|
||||
inline void bgc_fp32_posture3_copy(BGC_FP32_Posture3* destination, const BGC_FP32_Posture3* source)
|
||||
{
|
||||
bgc_fp32_quaternion_copy(&destination->_real_part, &source->_real_part);
|
||||
bgc_fp32_quaternion_copy(&destination->_dual_part, &source->_dual_part);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_posture3_copy(BGC_FP64_Posture3* destination, const BGC_FP64_Posture3* source)
|
||||
{
|
||||
bgc_fp64_quaternion_copy(&destination->_real_part, &source->_real_part);
|
||||
bgc_fp64_quaternion_copy(&destination->_dual_part, &source->_dual_part);
|
||||
}
|
||||
|
||||
// ==================== Swap ==================== //
|
||||
|
||||
inline void bgc_fp32_posture3_swap(BGC_FP32_Posture3* posture1, BGC_FP32_Posture3* posture2)
|
||||
{
|
||||
bgc_fp32_quaternion_swap(&posture1->_real_part, &posture2->_real_part);
|
||||
bgc_fp32_quaternion_swap(&posture1->_dual_part, &posture2->_dual_part);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_posture3_swap(BGC_FP64_Posture3* posture1, BGC_FP64_Posture3* posture2)
|
||||
{
|
||||
bgc_fp64_quaternion_swap(&posture1->_real_part, &posture2->_real_part);
|
||||
bgc_fp64_quaternion_swap(&posture1->_dual_part, &posture2->_dual_part);
|
||||
}
|
||||
|
||||
// ================== Convert =================== //
|
||||
|
||||
inline void bgc_fp32_posture3_convert_to_fp64(BGC_FP64_Posture3* destination, const BGC_FP32_Posture3* source)
|
||||
{
|
||||
bgc_fp32_quaternion_convert_to_fp64(&destination->_real_part, &source->_real_part);
|
||||
bgc_fp32_quaternion_convert_to_fp64(&destination->_dual_part, &source->_dual_part);
|
||||
|
||||
const double square_magnitude = bgc_fp64_quaternion_get_square_magnitude(&destination->_real_part);
|
||||
|
||||
if (!bgc_fp64_is_square_unit(square_magnitude)) {
|
||||
_bgc_fp64_posture3_normalize(destination, square_magnitude);
|
||||
}
|
||||
}
|
||||
|
||||
inline void bgc_fp64_posture3_convert_to_fp32(BGC_FP32_Posture3* destination, const BGC_FP64_Posture3* source)
|
||||
{
|
||||
bgc_fp64_quaternion_convert_to_fp32(&destination->_real_part, &source->_real_part);
|
||||
bgc_fp64_quaternion_convert_to_fp32(&destination->_dual_part, &source->_dual_part);
|
||||
|
||||
const float square_magnitude = bgc_fp32_quaternion_get_square_magnitude(&destination->_real_part);
|
||||
|
||||
if (!bgc_fp32_is_square_unit(square_magnitude)) {
|
||||
_bgc_fp32_posture3_normalize(destination, square_magnitude);
|
||||
}
|
||||
}
|
||||
|
||||
// ================== Combine =================== //
|
||||
|
||||
inline void bgc_fp32_posture3_combine(BGC_FP32_Posture3* combination, const BGC_FP64_Posture3* first, const BGC_FP64_Posture3* second)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue