Большое переупорядочивание исходного кода
This commit is contained in:
parent
fffe2be43b
commit
43bf030295
26 changed files with 1225 additions and 1137 deletions
|
@ -73,7 +73,7 @@ inline void bgc_versor_set_values_fp32(const float s0, const float x1, const flo
|
|||
|
||||
const float square_modulus = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
|
||||
|
||||
if (!bgc_is_sqare_value_unit_fp32(square_modulus)) {
|
||||
if (!bgc_is_sqare_unit_fp32(square_modulus)) {
|
||||
_bgc_versor_normalize_fp32(square_modulus, twin);
|
||||
}
|
||||
}
|
||||
|
@ -89,11 +89,29 @@ inline void bgc_versor_set_values_fp64(const double s0, const double x1, const d
|
|||
|
||||
const double square_modulus = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
|
||||
|
||||
if (!bgc_is_sqare_value_unit_fp64(square_modulus)) {
|
||||
if (!bgc_is_sqare_unit_fp64(square_modulus)) {
|
||||
_bgc_versor_normalize_fp64(square_modulus, twin);
|
||||
}
|
||||
}
|
||||
|
||||
// ================== 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_versor_set_turn_fp64(const double x1, const double x2, const double x3, const double angle, const BgcAngleUnitEnum unit, BgcVersorFP64* result);
|
||||
|
||||
// ================ Set Rotation ================ //
|
||||
|
||||
inline void bgc_versor_set_rotation_fp32(const BgcRotation3FP32* rotation, BgcVersorFP32* result)
|
||||
{
|
||||
bgc_versor_set_turn_fp32(rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BGC_ANGLE_UNIT_RADIANS, result);
|
||||
}
|
||||
|
||||
inline void bgc_versor_set_rotation_fp64(const BgcRotation3FP64* rotation, BgcVersorFP64* result)
|
||||
{
|
||||
bgc_versor_set_turn_fp64(rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BGC_ANGLE_UNIT_RADIANS, result);
|
||||
}
|
||||
|
||||
// ==================== Copy ==================== //
|
||||
|
||||
inline void bgc_versor_copy_fp32(const BgcVersorFP32* from, BgcVersorFP32* to)
|
||||
|
@ -162,36 +180,6 @@ inline void bgc_versor_swap_fp64(BgcVersorFP64* versor1, BgcVersorFP64* versor2)
|
|||
twin2->x3 = x3;
|
||||
}
|
||||
|
||||
// =============== Set Crude Turn =============== //
|
||||
|
||||
void bgc_versor_set_crude_turn_fp32(const float x1, const float x2, const float x3, const float angle, const BgcAngleUnitEnum unit, BgcVersorFP32* result);
|
||||
|
||||
void bgc_versor_set_crude_turn_fp64(const double x1, const double x2, const double x3, const double angle, const BgcAngleUnitEnum unit, BgcVersorFP64* result);
|
||||
|
||||
// ================== Set Turn ================== //
|
||||
|
||||
inline void bgc_versor_set_turn_fp32(const BgcVector3FP32* axis, const float angle, const BgcAngleUnitEnum unit, BgcVersorFP32* result)
|
||||
{
|
||||
bgc_versor_set_crude_turn_fp32(axis->x1, axis->x2, axis->x3, angle, unit, result);
|
||||
}
|
||||
|
||||
inline void bgc_versor_set_turn_fp64(const BgcVector3FP32* axis, const double angle, const BgcAngleUnitEnum unit, BgcVersorFP64* result)
|
||||
{
|
||||
bgc_versor_set_crude_turn_fp64(axis->x1, axis->x2, axis->x3, angle, unit, result);
|
||||
}
|
||||
|
||||
// ================ Set Rotation ================ //
|
||||
|
||||
inline void bgc_versor_set_rotation_fp32(const BgcRotation3FP32* rotation, BgcVersorFP32* result)
|
||||
{
|
||||
bgc_versor_set_crude_turn_fp32(rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BGC_ANGLE_UNIT_RADIANS, result);
|
||||
}
|
||||
|
||||
inline void bgc_versor_set_rotation_fp64(const BgcRotation3FP64* rotation, BgcVersorFP64* result)
|
||||
{
|
||||
bgc_versor_set_crude_turn_fp64(rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BGC_ANGLE_UNIT_RADIANS, result);
|
||||
}
|
||||
|
||||
// ================= Comparison ================= //
|
||||
|
||||
inline int bgc_versor_is_identity_fp32(const BgcVersorFP32* versor)
|
||||
|
@ -204,7 +192,7 @@ inline int bgc_versor_is_identity_fp64(const BgcVersorFP64* versor)
|
|||
return 1.0 - BGC_EPSYLON_FP64 <= versor->s0 || versor->s0 <= -(1.0 - BGC_EPSYLON_FP64);
|
||||
}
|
||||
|
||||
// ============= Copy to twin type ============== //
|
||||
// ================== Convert =================== //
|
||||
|
||||
inline void bgc_versor_convert_fp64_to_fp32(const BgcVersorFP64* versor, BgcVersorFP32* result)
|
||||
{
|
||||
|
@ -256,45 +244,7 @@ inline void bgc_versor_shorten_fp64(BgcVersorFP64* versor)
|
|||
twin->x3 = -versor->x3;
|
||||
}
|
||||
|
||||
// ================== Shorten =================== //
|
||||
|
||||
inline void bgc_versor_set_shortened_fp32(const BgcVersorFP32* versor, BgcVersorFP32* shortened)
|
||||
{
|
||||
_BgcDarkTwinVersorFP32* twin = (_BgcDarkTwinVersorFP32*)shortened;
|
||||
|
||||
if (versor->s0 >= 0.0f) {
|
||||
twin->x1 = versor->s0;
|
||||
twin->x1 = versor->x1;
|
||||
twin->x2 = versor->x2;
|
||||
twin->x3 = versor->x3;
|
||||
return;
|
||||
}
|
||||
|
||||
twin->x1 = -versor->s0;
|
||||
twin->x1 = -versor->x1;
|
||||
twin->x2 = -versor->x2;
|
||||
twin->x3 = -versor->x3;
|
||||
}
|
||||
|
||||
inline void bgc_versor_set_shortened_fp64(const BgcVersorFP64* versor, BgcVersorFP64* shortened)
|
||||
{
|
||||
_BgcDarkTwinVersorFP64* twin = (_BgcDarkTwinVersorFP64*)shortened;
|
||||
|
||||
if (versor->s0 >= 0.0) {
|
||||
twin->x1 = versor->s0;
|
||||
twin->x1 = versor->x1;
|
||||
twin->x2 = versor->x2;
|
||||
twin->x3 = versor->x3;
|
||||
return;
|
||||
}
|
||||
|
||||
twin->x1 = -versor->s0;
|
||||
twin->x1 = -versor->x1;
|
||||
twin->x2 = -versor->x2;
|
||||
twin->x3 = -versor->x3;
|
||||
}
|
||||
|
||||
// ================= Inversion ================== //
|
||||
// =================== Invert =================== //
|
||||
|
||||
inline void bgc_versor_invert_fp32(BgcVersorFP32* versor)
|
||||
{
|
||||
|
@ -312,50 +262,6 @@ inline void bgc_versor_invert_fp64(BgcVersorFP64* versor)
|
|||
twin->x3 = -versor->x3;
|
||||
}
|
||||
|
||||
// ================ Set Inverted ================ //
|
||||
|
||||
inline void bgc_versor_set_inverted_fp32(const BgcVersorFP32* versor, BgcVersorFP32* to)
|
||||
{
|
||||
_BgcDarkTwinVersorFP32* twin = (_BgcDarkTwinVersorFP32*)to;
|
||||
twin->s0 = versor->s0;
|
||||
twin->x1 = -versor->x1;
|
||||
twin->x2 = -versor->x2;
|
||||
twin->x3 = -versor->x3;
|
||||
}
|
||||
|
||||
inline void bgc_versor_set_inverted_fp64(const BgcVersorFP64* versor, BgcVersorFP64* to)
|
||||
{
|
||||
_BgcDarkTwinVersorFP64* twin = (_BgcDarkTwinVersorFP64*)to;
|
||||
twin->s0 = versor->s0;
|
||||
twin->x1 = -versor->x1;
|
||||
twin->x2 = -versor->x2;
|
||||
twin->x3 = -versor->x3;
|
||||
}
|
||||
|
||||
// ================ Set Inverted ================ //
|
||||
|
||||
inline void bgc_versor_set_inverted_fp64_to_fp32(const BgcVersorFP64* versor, BgcVersorFP32* to)
|
||||
{
|
||||
bgc_versor_set_values_fp32(
|
||||
(float) versor->s0,
|
||||
(float) -versor->x1,
|
||||
(float) -versor->x2,
|
||||
(float) -versor->x3,
|
||||
to
|
||||
);
|
||||
}
|
||||
|
||||
inline void bgc_versor_set_inverted_fp32_to_fp64(const BgcVersorFP32* versor, BgcVersorFP64* to)
|
||||
{
|
||||
bgc_versor_set_values_fp64(
|
||||
versor->s0,
|
||||
-versor->x1,
|
||||
-versor->x2,
|
||||
-versor->x3,
|
||||
to
|
||||
);
|
||||
}
|
||||
|
||||
// ================ Combination ================= //
|
||||
|
||||
inline void bgc_versor_combine_fp32(const BgcVersorFP32* second, const BgcVersorFP32* first, BgcVersorFP32* result)
|
||||
|
@ -414,11 +320,69 @@ inline void bgc_versor_combine3_fp64(const BgcVersorFP64* third, const BgcVersor
|
|||
);
|
||||
}
|
||||
|
||||
// ================= Rotation3 ================== //
|
||||
// =============== Make Rotation3 =============== //
|
||||
|
||||
void bgc_versor_get_rotation_fp32(const BgcVersorFP32* versor, BgcRotation3FP32* result);
|
||||
void bgc_versor_make_rotation_fp32(const BgcVersorFP32* versor, BgcRotation3FP32* result);
|
||||
|
||||
void bgc_versor_get_rotation_fp64(const BgcVersorFP64* versor, BgcRotation3FP64* result);
|
||||
void bgc_versor_make_rotation_fp64(const BgcVersorFP64* versor, BgcRotation3FP64* result);
|
||||
|
||||
// =============== Make Shortened =============== //
|
||||
|
||||
inline void bgc_versor_make_shortened_fp32(const BgcVersorFP32* versor, BgcVersorFP32* shortened)
|
||||
{
|
||||
_BgcDarkTwinVersorFP32* twin = (_BgcDarkTwinVersorFP32*)shortened;
|
||||
|
||||
if (versor->s0 >= 0.0f) {
|
||||
twin->x1 = versor->s0;
|
||||
twin->x1 = versor->x1;
|
||||
twin->x2 = versor->x2;
|
||||
twin->x3 = versor->x3;
|
||||
return;
|
||||
}
|
||||
|
||||
twin->x1 = -versor->s0;
|
||||
twin->x1 = -versor->x1;
|
||||
twin->x2 = -versor->x2;
|
||||
twin->x3 = -versor->x3;
|
||||
}
|
||||
|
||||
inline void bgc_versor_make_shortened_fp64(const BgcVersorFP64* versor, BgcVersorFP64* shortened)
|
||||
{
|
||||
_BgcDarkTwinVersorFP64* twin = (_BgcDarkTwinVersorFP64*)shortened;
|
||||
|
||||
if (versor->s0 >= 0.0) {
|
||||
twin->x1 = versor->s0;
|
||||
twin->x1 = versor->x1;
|
||||
twin->x2 = versor->x2;
|
||||
twin->x3 = versor->x3;
|
||||
return;
|
||||
}
|
||||
|
||||
twin->x1 = -versor->s0;
|
||||
twin->x1 = -versor->x1;
|
||||
twin->x2 = -versor->x2;
|
||||
twin->x3 = -versor->x3;
|
||||
}
|
||||
|
||||
// =============== Make Inverted ================ //
|
||||
|
||||
inline void bgc_versor_make_inverted_fp32(const BgcVersorFP32* versor, BgcVersorFP32* to)
|
||||
{
|
||||
_BgcDarkTwinVersorFP32* twin = (_BgcDarkTwinVersorFP32*)to;
|
||||
twin->s0 = versor->s0;
|
||||
twin->x1 = -versor->x1;
|
||||
twin->x2 = -versor->x2;
|
||||
twin->x3 = -versor->x3;
|
||||
}
|
||||
|
||||
inline void bgc_versor_make_inverted_fp64(const BgcVersorFP64* versor, BgcVersorFP64* to)
|
||||
{
|
||||
_BgcDarkTwinVersorFP64* twin = (_BgcDarkTwinVersorFP64*)to;
|
||||
twin->s0 = versor->s0;
|
||||
twin->x1 = -versor->x1;
|
||||
twin->x2 = -versor->x2;
|
||||
twin->x3 = -versor->x3;
|
||||
}
|
||||
|
||||
// =========== Make Rotation Matrix3x3 ========== //
|
||||
|
||||
|
@ -536,6 +500,20 @@ inline void bgc_versor_make_reverse_matrix_fp64(const BgcVersorFP64* versor, Bgc
|
|||
matrix->r1c3 = x1x3 - s0x2;
|
||||
}
|
||||
|
||||
// ============= Make Both Matrixes ============= //
|
||||
|
||||
inline void bgc_versor_make_both_matrixes_fp32(const BgcVersorFP32* versor, BgcMatrix3x3FP32* rotation, BgcMatrix3x3FP32* reverse)
|
||||
{
|
||||
bgc_versor_make_reverse_matrix_fp32(versor, reverse);
|
||||
bgc_matrix3x3_make_transposed_fp32(reverse, rotation);
|
||||
}
|
||||
|
||||
inline void bgc_versor_make_both_matrixes_fp64(const BgcVersorFP64* versor, BgcMatrix3x3FP64* rotation, BgcMatrix3x3FP64* reverse)
|
||||
{
|
||||
bgc_versor_make_reverse_matrix_fp64(versor, reverse);
|
||||
bgc_matrix3x3_make_transposed_fp64(reverse, rotation);
|
||||
}
|
||||
|
||||
// ================ Turn Vector ================= //
|
||||
|
||||
inline void bgc_versor_turn_vector_fp32(const BgcVersorFP32* versor, const BgcVector3FP32* vector, BgcVector3FP32* result)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue