Переименование Posture в Rigit Pose, изменение внутренней организации Rigid Pose
This commit is contained in:
parent
ce991f0488
commit
614daf8ebd
6 changed files with 174 additions and 159 deletions
|
|
@ -100,6 +100,10 @@
|
|||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="quaternion.h" />
|
||||
<Unit filename="rigid-pose3.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="rigid-pose3.h" />
|
||||
<Unit filename="slerp3.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
#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);
|
||||
}
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
#ifndef _BGC_POSTURE3_H_INCLUDED_
|
||||
#define _BGC_POSTURE3_H_INCLUDED_
|
||||
|
||||
#include "types.h"
|
||||
#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->_versor.real_part.s0 = 1.0f;
|
||||
posture->_versor.real_part.x1 = 0.0f;
|
||||
posture->_versor.real_part.x2 = 0.0f;
|
||||
posture->_versor.real_part.x3 = 0.0f;
|
||||
|
||||
posture->_versor.dual_part.s0 = 0.0f;
|
||||
posture->_versor.dual_part.x1 = 0.0f;
|
||||
posture->_versor.dual_part.x2 = 0.0f;
|
||||
posture->_versor.dual_part.x3 = 0.0f;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_posture3_reset(BGC_FP64_Posture3* posture)
|
||||
{
|
||||
posture->_versor.real_part.s0 = 1.0;
|
||||
posture->_versor.real_part.x1 = 0.0;
|
||||
posture->_versor.real_part.x2 = 0.0;
|
||||
posture->_versor.real_part.x3 = 0.0;
|
||||
|
||||
posture->_versor.dual_part.s0 = 0.0;
|
||||
posture->_versor.dual_part.x1 = 0.0;
|
||||
posture->_versor.dual_part.x2 = 0.0;
|
||||
posture->_versor.dual_part.x3 = 0.0;
|
||||
}
|
||||
|
||||
// ==================== Copy ==================== //
|
||||
|
||||
inline void bgc_fp32_posture3_copy(BGC_FP32_Posture3* destination, const BGC_FP32_Posture3* source)
|
||||
{
|
||||
bgc_fp32_dual_quaternion_copy(&destination->_versor, &source->_versor);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_posture3_copy(BGC_FP64_Posture3* destination, const BGC_FP64_Posture3* source)
|
||||
{
|
||||
bgc_fp64_dual_quaternion_copy(&destination->_versor, &source->_versor);
|
||||
}
|
||||
|
||||
// ==================== Swap ==================== //
|
||||
|
||||
inline void bgc_fp32_posture3_swap(BGC_FP32_Posture3* posture1, BGC_FP32_Posture3* posture2)
|
||||
{
|
||||
bgc_fp32_dual_quaternion_swap(&posture1->_versor, &posture2->_versor);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_posture3_swap(BGC_FP64_Posture3* posture1, BGC_FP64_Posture3* posture2)
|
||||
{
|
||||
bgc_fp64_dual_quaternion_swap(&posture1->_versor, &posture2->_versor);
|
||||
}
|
||||
|
||||
// ================== Convert =================== //
|
||||
|
||||
inline void bgc_fp32_posture3_convert_to_fp64(BGC_FP64_Posture3* destination, const BGC_FP32_Posture3* source)
|
||||
{
|
||||
bgc_fp32_dual_quaternion_convert_to_fp64(&destination->_versor, &source->_versor);
|
||||
|
||||
const double square_magnitude = bgc_fp64_quaternion_get_square_magnitude(&destination->_versor.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_dual_quaternion_convert_to_fp32(&destination->_versor, &source->_versor);
|
||||
|
||||
const float square_magnitude = bgc_fp32_quaternion_get_square_magnitude(&destination->_versor.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_FP32_Posture3* first, const BGC_FP32_Posture3* second)
|
||||
{
|
||||
bgc_fp32_dual_quaternion_multiply_by_dual_quaternion(&combination->_versor, &second->_versor, &first->_versor);
|
||||
|
||||
const float square_magnitude = bgc_fp32_quaternion_get_square_magnitude(&combination->_versor.real_part);
|
||||
|
||||
if (!bgc_fp32_is_square_unit(square_magnitude)) {
|
||||
_bgc_fp32_posture3_normalize(combination, square_magnitude);
|
||||
}
|
||||
}
|
||||
|
||||
inline void bgc_fp64_posture3_combine(BGC_FP64_Posture3* combination, const BGC_FP64_Posture3* first, const BGC_FP64_Posture3* second)
|
||||
{
|
||||
bgc_fp64_dual_quaternion_multiply_by_dual_quaternion(&combination->_versor, &second->_versor, &first->_versor);
|
||||
|
||||
const double square_magnitude = bgc_fp64_quaternion_get_square_magnitude(&combination->_versor.real_part);
|
||||
|
||||
if (!bgc_fp64_is_square_unit(square_magnitude)) {
|
||||
_bgc_fp64_posture3_normalize(combination, square_magnitude);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
42
basic-geometry/rigid-pose3.c
Normal file
42
basic-geometry/rigid-pose3.c
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#include "rigid-pose3.h"
|
||||
|
||||
extern inline void bgc_fp32_rigid_pose3_reset(BGC_FP32_RigidPose3* pose);
|
||||
extern inline void bgc_fp64_rigid_pose3_reset(BGC_FP64_RigidPose3* pose);
|
||||
|
||||
extern inline void bgc_fp32_rigid_pose3_copy(BGC_FP32_RigidPose3* destination, const BGC_FP32_RigidPose3* source);
|
||||
extern inline void bgc_fp64_rigid_pose3_copy(BGC_FP64_RigidPose3* destination, const BGC_FP64_RigidPose3* source);
|
||||
|
||||
extern inline void bgc_fp32_rigid_pose3_swap(BGC_FP32_RigidPose3* pose1, BGC_FP32_RigidPose3* pose2);
|
||||
extern inline void bgc_fp64_rigid_pose3_swap(BGC_FP64_RigidPose3* pose1, BGC_FP64_RigidPose3* pose2);
|
||||
|
||||
extern inline void bgc_fp32_rigid_pose3_convert_to_fp64(BGC_FP64_RigidPose3* destination, const BGC_FP32_RigidPose3* source);
|
||||
extern inline void bgc_fp64_rigid_pose3_convert_to_fp32(BGC_FP32_RigidPose3* destination, const BGC_FP64_RigidPose3* source);
|
||||
|
||||
extern inline void bgc_fp32_rigid_pose3_combine(BGC_FP32_RigidPose3* combination, const BGC_FP32_RigidPose3* first, const BGC_FP32_RigidPose3* second);
|
||||
extern inline void bgc_fp64_rigid_pose3_combine(BGC_FP64_RigidPose3* combination, const BGC_FP64_RigidPose3* first, const BGC_FP64_RigidPose3* second);
|
||||
|
||||
void _bgc_fp32_rigid_pose3_normalize(BGC_FP32_RigidPose3* pose, const float square_magnitude)
|
||||
{
|
||||
if (square_magnitude <= BGC_FP32_SQUARE_EPSILON || isnan(square_magnitude)) {
|
||||
bgc_fp32_rigid_pose3_reset(pose);
|
||||
return;
|
||||
}
|
||||
|
||||
const float multiplier = sqrtf(1.0f / square_magnitude);
|
||||
|
||||
bgc_fp32_quaternion_multiply_by_real(&pose->_real_part, &pose->_real_part, multiplier);
|
||||
bgc_fp32_quaternion_multiply_by_real(&pose->_dual_part, &pose->_dual_part, multiplier);
|
||||
}
|
||||
|
||||
void _bgc_fp64_rigid_pose3_normalize(BGC_FP64_RigidPose3* pose, const double square_magnitude)
|
||||
{
|
||||
if (square_magnitude <= BGC_FP64_SQUARE_EPSILON || isnan(square_magnitude)) {
|
||||
bgc_fp64_rigid_pose3_reset(pose);
|
||||
return;
|
||||
}
|
||||
|
||||