Переименование s0 -> s, x1 -> x, x2 -> y, x3 -> z, что должно упростить читаемость кода. Также обновление документации
This commit is contained in:
parent
d83ab7160d
commit
b8d383da33
38 changed files with 2104 additions and 2070 deletions
|
|
@ -36,18 +36,18 @@ extern const BGC_FP64_Turn3 BGC_FP64_IDLE_TURN3;
|
|||
|
||||
inline void bgc_fp32_turn3_reset(BGC_FP32_Turn3* const turn)
|
||||
{
|
||||
turn->_versor.s0 = 1.0f;
|
||||
turn->_versor.x1 = 0.0f;
|
||||
turn->_versor.x2 = 0.0f;
|
||||
turn->_versor.x3 = 0.0f;
|
||||
turn->_versor.s = 1.0f;
|
||||
turn->_versor.x = 0.0f;
|
||||
turn->_versor.y = 0.0f;
|
||||
turn->_versor.z = 0.0f;
|
||||
}
|
||||
|
||||
inline void bgc_fp64_turn3_reset(BGC_FP64_Turn3* const turn)
|
||||
{
|
||||
turn->_versor.s0 = 1.0;
|
||||
turn->_versor.x1 = 0.0;
|
||||
turn->_versor.x2 = 0.0;
|
||||
turn->_versor.x3 = 0.0;
|
||||
turn->_versor.s = 1.0;
|
||||
turn->_versor.x = 0.0;
|
||||
turn->_versor.y = 0.0;
|
||||
turn->_versor.z = 0.0;
|
||||
}
|
||||
|
||||
// ============= Private: Normalize ============= //
|
||||
|
|
@ -61,19 +61,19 @@ inline void _bgc_fp32_turn3_normalize(BGC_FP32_Turn3* const turn)
|
|||
}
|
||||
|
||||
if (square_magnitude <= BGC_FP32_SQUARE_EPSILON || isnan(square_magnitude)) {
|
||||
turn->_versor.s0 = 1.0f;
|
||||
turn->_versor.x1 = 0.0f;
|
||||
turn->_versor.x2 = 0.0f;
|
||||
turn->_versor.x3 = 0.0f;
|
||||
turn->_versor.s = 1.0f;
|
||||
turn->_versor.x = 0.0f;
|
||||
turn->_versor.y = 0.0f;
|
||||
turn->_versor.z = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
const float multiplier = sqrtf(1.0f / square_magnitude);
|
||||
|
||||
turn->_versor.s0 *= multiplier;
|
||||
turn->_versor.x1 *= multiplier;
|
||||
turn->_versor.x2 *= multiplier;
|
||||
turn->_versor.x3 *= multiplier;
|
||||
turn->_versor.s *= multiplier;
|
||||
turn->_versor.x *= multiplier;
|
||||
turn->_versor.y *= multiplier;
|
||||
turn->_versor.z *= multiplier;
|
||||
}
|
||||
|
||||
inline void _bgc_fp64_turn3_normalize(BGC_FP64_Turn3* const turn)
|
||||
|
|
@ -85,32 +85,32 @@ inline void _bgc_fp64_turn3_normalize(BGC_FP64_Turn3* const turn)
|
|||
}
|
||||
|
||||
if (square_magnitude <= BGC_FP64_SQUARE_EPSILON || isnan(square_magnitude)) {
|
||||
turn->_versor.s0 = 1.0;
|
||||
turn->_versor.x1 = 0.0;
|
||||
turn->_versor.x2 = 0.0;
|
||||
turn->_versor.x3 = 0.0;
|
||||
turn->_versor.s = 1.0;
|
||||
turn->_versor.x = 0.0;
|
||||
turn->_versor.y = 0.0;
|
||||
turn->_versor.z = 0.0;
|
||||
return;
|
||||
}
|
||||
|
||||
const double multiplier = sqrt(1.0 / square_magnitude);
|
||||
|
||||
turn->_versor.s0 *= multiplier;
|
||||
turn->_versor.x1 *= multiplier;
|
||||
turn->_versor.x2 *= multiplier;
|
||||
turn->_versor.x3 *= multiplier;
|
||||
turn->_versor.s *= multiplier;
|
||||
turn->_versor.x *= multiplier;
|
||||
turn->_versor.y *= multiplier;
|
||||
turn->_versor.z *= multiplier;
|
||||
}
|
||||
|
||||
// ================= Set Values ================= //
|
||||
|
||||
inline void bgc_fp32_turn3_set_values(BGC_FP32_Turn3* const turn, const float s0, const float x1, const float x2, const float x3)
|
||||
inline void bgc_fp32_turn3_set_values(BGC_FP32_Turn3* const turn, const float s, const float x, const float y, const float z)
|
||||
{
|
||||
bgc_fp32_quaternion_set_values(&turn->_versor, s0, x1, x2, x3);
|
||||
bgc_fp32_quaternion_set_values(&turn->_versor, s, x, y, z);
|
||||
_bgc_fp32_turn3_normalize(turn);
|
||||
}
|
||||
|
||||
inline void bgc_fp64_turn3_set_values(BGC_FP64_Turn3* const turn, const double s0, const double x1, const double x2, const double x3)
|
||||
inline void bgc_fp64_turn3_set_values(BGC_FP64_Turn3* const turn, const double s, const double x, const double y, const double z)
|
||||
{
|
||||
bgc_fp64_quaternion_set_values(&turn->_versor, s0, x1, x2, x3);
|
||||
bgc_fp64_quaternion_set_values(&turn->_versor, s, x, y, z);
|
||||
_bgc_fp64_turn3_normalize(turn);
|
||||
}
|
||||
|
||||
|
|
@ -148,9 +148,9 @@ double bgc_fp64_turn3_get_rotation(BGC_FP64_Vector3* const axis, const BGC_FP64_
|
|||
|
||||
// ================ Set Rotation ================ //
|
||||
|
||||
void bgc_fp32_turn3_set_rotation(BGC_FP32_Turn3* const turn, const float x1, const float x2, const float x3, const float angle, const int angle_unit);
|
||||
void bgc_fp32_turn3_set_rotation(BGC_FP32_Turn3* const turn, const float x, const float y, const float z, const float angle, const int angle_unit);
|
||||
|
||||
void bgc_fp64_turn3_set_rotation(BGC_FP64_Turn3* const turn, const double x1, const double x2, const double x3, const double angle, const int angle_unit);
|
||||
void bgc_fp64_turn3_set_rotation(BGC_FP64_Turn3* const turn, const double x, const double y, const double z, const double angle, const int angle_unit);
|
||||
|
||||
// ========= Find Direction Difference ========== //
|
||||
|
||||
|
|
@ -231,21 +231,21 @@ inline void bgc_fp64_turn3_convert_to_fp32(BGC_FP32_Turn3* const destination, co
|
|||
|
||||
inline void bgc_fp32_turn3_shorten(BGC_FP32_Turn3* const turn)
|
||||
{
|
||||
if (turn->_versor.s0 < 0.0f) {
|
||||
if (turn->_versor.s < 0.0f) {
|
||||
bgc_fp32_quaternion_revert(&turn->_versor);
|
||||
}
|
||||
}
|
||||
|
||||
inline void bgc_fp64_turn3_shorten(BGC_FP64_Turn3* const turn)
|
||||
{
|
||||
if (turn->_versor.s0 < 0.0) {
|
||||
if (turn->_versor.s < 0.0) {
|
||||
bgc_fp64_quaternion_revert(&turn->_versor);
|
||||
}
|
||||
}
|
||||
|
||||
inline void bgc_fp32_turn3_get_shortened(BGC_FP32_Turn3* const shortened, const BGC_FP32_Turn3* const turn)
|
||||
{
|
||||
if (turn->_versor.s0 >= 0.0f) {
|
||||
if (turn->_versor.s >= 0.0f) {
|
||||
bgc_fp32_quaternion_copy(&shortened->_versor, &turn->_versor);
|
||||
}
|
||||
else {
|
||||
|
|
@ -255,7 +255,7 @@ inline void bgc_fp32_turn3_get_shortened(BGC_FP32_Turn3* const shortened, const
|
|||
|
||||
inline void bgc_fp64_turn3_get_shortened(BGC_FP64_Turn3* const shortened, const BGC_FP64_Turn3* const turn)
|
||||
{
|
||||
if (turn->_versor.s0 >= 0.0) {
|
||||
if (turn->_versor.s >= 0.0) {
|
||||
bgc_fp64_quaternion_copy(&shortened->_versor, &turn->_versor);
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue