Небольшие исправления, а также добавление гомогенного трёхмерного вектора
This commit is contained in:
parent
03627f4401
commit
043cc72c81
25 changed files with 1686 additions and 1644 deletions
|
|
@ -97,12 +97,12 @@ inline double bgc_fp64_quaternion_get_modulus(const BGC_FP64_Quaternion* quatern
|
|||
|
||||
inline int bgc_fp32_quaternion_is_zero(const BGC_FP32_Quaternion* quaternion)
|
||||
{
|
||||
return bgc_fp32_quaternion_get_square_modulus(quaternion) <= BGC_FP32_SQUARE_EPSYLON;
|
||||
return bgc_fp32_quaternion_get_square_modulus(quaternion) <= BGC_FP32_SQUARE_EPSILON;
|
||||
}
|
||||
|
||||
inline int bgc_fp64_quaternion_is_zero(const BGC_FP64_Quaternion* quaternion)
|
||||
{
|
||||
return bgc_fp64_quaternion_get_square_modulus(quaternion) <= BGC_FP64_SQUARE_EPSYLON;
|
||||
return bgc_fp64_quaternion_get_square_modulus(quaternion) <= BGC_FP64_SQUARE_EPSILON;
|
||||
}
|
||||
|
||||
// ================== Is Unit =================== //
|
||||
|
|
@ -295,7 +295,7 @@ inline int bgc_fp32_quaternion_get_ratio(BGC_FP32_Quaternion* quotient, const BG
|
|||
{
|
||||
const float square_modulus = bgc_fp32_quaternion_get_square_modulus(divisor);
|
||||
|
||||
if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
|
||||
if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -318,7 +318,7 @@ inline int bgc_fp64_quaternion_get_ratio(BGC_FP64_Quaternion* quotient, const BG
|
|||
{
|
||||
const double square_modulus = bgc_fp64_quaternion_get_square_modulus(divisor);
|
||||
|
||||
if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
|
||||
if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -477,7 +477,7 @@ inline int bgc_fp32_quaternion_get_inverse(BGC_FP32_Quaternion* inverse, const B
|
|||
{
|
||||
const float square_modulus = bgc_fp32_quaternion_get_square_modulus(quaternion);
|
||||
|
||||
if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
|
||||
if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -495,7 +495,7 @@ inline int bgc_fp64_quaternion_get_inverse(BGC_FP64_Quaternion* inverse, const B
|
|||
{
|
||||
const double square_modulus = bgc_fp64_quaternion_get_square_modulus(quaternion);
|
||||
|
||||
if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
|
||||
if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -529,7 +529,7 @@ inline int bgc_fp32_quaternion_normalize(BGC_FP32_Quaternion* quaternion)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
|
||||
if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -551,7 +551,7 @@ inline int bgc_fp64_quaternion_normalize(BGC_FP64_Quaternion* quaternion)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
|
||||
if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -574,7 +574,7 @@ inline int bgc_fp32_quaternion_get_normalized(BGC_FP32_Quaternion* normalized, c
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
|
||||
if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) {
|
||||
bgc_fp32_quaternion_reset(normalized);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -592,7 +592,7 @@ inline int bgc_fp64_quaternion_get_normalized(BGC_FP64_Quaternion* normalized, c
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
|
||||
if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) {
|
||||
bgc_fp64_quaternion_reset(normalized);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -618,7 +618,7 @@ inline int bgc_fp32_quaternion_get_rotation_matrix(BGC_FP32_Matrix3x3* rotation,
|
|||
|
||||
const float square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
|
||||
|
||||
if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus))
|
||||
if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus))
|
||||
{
|
||||
bgc_fp32_matrix3x3_make_identity(rotation);
|
||||
return 0;
|
||||
|
|
@ -635,17 +635,17 @@ inline int bgc_fp32_quaternion_get_rotation_matrix(BGC_FP32_Matrix3x3* rotation,
|
|||
|
||||
const float corrector2 = 2.0f * corrector1;
|
||||
|
||||
rotation->r1c1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3));
|
||||
rotation->r2c2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3));
|
||||
rotation->r3c3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2));
|
||||
rotation->row1_col1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3));
|
||||
rotation->row2_col2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3));
|
||||
rotation->row3_col3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2));
|
||||
|
||||
rotation->r1c2 = corrector2 * (x1x2 - s0x3);
|
||||
rotation->r2c3 = corrector2 * (x2x3 - s0x1);
|
||||
rotation->r3c1 = corrector2 * (x1x3 - s0x2);
|
||||
rotation->row1_col2 = corrector2 * (x1x2 - s0x3);
|
||||
rotation->row2_col3 = corrector2 * (x2x3 - s0x1);
|
||||
rotation->row3_col1 = corrector2 * (x1x3 - s0x2);
|
||||
|
||||
rotation->r2c1 = corrector2 * (x1x2 + s0x3);
|
||||
rotation->r3c2 = corrector2 * (x2x3 + s0x1);
|
||||
rotation->r1c3 = corrector2 * (x1x3 + s0x2);
|
||||
rotation->row2_col1 = corrector2 * (x1x2 + s0x3);
|
||||
rotation->row3_col2 = corrector2 * (x2x3 + s0x1);
|
||||
rotation->row1_col3 = corrector2 * (x1x3 + s0x2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -659,7 +659,7 @@ inline int bgc_fp64_quaternion_get_rotation_matrix(BGC_FP64_Matrix3x3* rotation,
|
|||
|
||||
const double square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
|
||||
|
||||
if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus))
|
||||
if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus))
|
||||
{
|
||||
bgc_fp64_matrix3x3_make_identity(rotation);
|
||||
return 0;
|
||||
|
|
@ -676,17 +676,17 @@ inline int bgc_fp64_quaternion_get_rotation_matrix(BGC_FP64_Matrix3x3* rotation,
|
|||
|
||||
const double corrector2 = 2.0f * corrector1;
|
||||
|
||||
rotation->r1c1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3));
|
||||
rotation->r2c2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3));
|
||||
rotation->r3c3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2));
|
||||
rotation->row1_col1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3));
|
||||
rotation->row2_col2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3));
|
||||
rotation->row3_col3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2));
|
||||
|
||||
rotation->r1c2 = corrector2 * (x1x2 - s0x3);
|
||||
rotation->r2c3 = corrector2 * (x2x3 - s0x1);
|
||||
rotation->r3c1 = corrector2 * (x1x3 - s0x2);
|
||||
rotation->row1_col2 = corrector2 * (x1x2 - s0x3);
|
||||
rotation->row2_col3 = corrector2 * (x2x3 - s0x1);
|
||||
rotation->row3_col1 = corrector2 * (x1x3 - s0x2);
|
||||
|
||||
rotation->r2c1 = corrector2 * (x1x2 + s0x3);
|
||||
rotation->r3c2 = corrector2 * (x2x3 + s0x1);
|
||||
rotation->r1c3 = corrector2 * (x1x3 + s0x2);
|
||||
rotation->row2_col1 = corrector2 * (x1x2 + s0x3);
|
||||
rotation->row3_col2 = corrector2 * (x2x3 + s0x1);
|
||||
rotation->row1_col3 = corrector2 * (x1x3 + s0x2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -702,7 +702,7 @@ inline int bgc_fp32_quaternion_get_reverse_matrix(BGC_FP32_Matrix3x3* reverse, c
|
|||
|
||||
const float square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
|
||||
|
||||
if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus))
|
||||
if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus))
|
||||
{
|
||||
bgc_fp32_matrix3x3_make_identity(reverse);
|
||||
return 0;
|
||||
|
|
@ -719,17 +719,17 @@ inline int bgc_fp32_quaternion_get_reverse_matrix(BGC_FP32_Matrix3x3* reverse, c
|
|||
|
||||
const float corrector2 = 2.0f * corrector1;
|
||||
|
||||
reverse->r1c1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3));
|
||||
reverse->r2c2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3));
|
||||
reverse->r3c3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2));
|
||||
reverse->row1_col1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3));
|
||||
reverse->row2_col2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3));
|
||||
reverse->row3_col3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2));
|
||||
|
||||
reverse->r1c2 = corrector2 * (x1x2 + s0x3);
|
||||
reverse->r2c3 = corrector2 * (x2x3 + s0x1);
|
||||
reverse->r3c1 = corrector2 * (x1x3 + s0x2);
|
||||
reverse->row1_col2 = corrector2 * (x1x2 + s0x3);
|
||||
reverse->row2_col3 = corrector2 * (x2x3 + s0x1);
|
||||
reverse->row3_col1 = corrector2 * (x1x3 + s0x2);
|
||||
|
||||
reverse->r2c1 = corrector2 * (x1x2 - s0x3);
|
||||
reverse->r3c2 = corrector2 * (x2x3 - s0x1);
|
||||
reverse->r1c3 = corrector2 * (x1x3 - s0x2);
|
||||
reverse->row2_col1 = corrector2 * (x1x2 - s0x3);
|
||||
reverse->row3_col2 = corrector2 * (x2x3 - s0x1);
|
||||
reverse->row1_col3 = corrector2 * (x1x3 - s0x2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -743,7 +743,7 @@ inline int bgc_fp64_quaternion_get_reverse_matrix(BGC_FP64_Matrix3x3* reverse, c
|
|||
|
||||
const double square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
|
||||
|
||||
if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus))
|
||||
if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus))
|
||||
{
|
||||
bgc_fp64_matrix3x3_make_identity(reverse);
|
||||
return 0;
|
||||
|
|
@ -760,17 +760,17 @@ inline int bgc_fp64_quaternion_get_reverse_matrix(BGC_FP64_Matrix3x3* reverse, c
|
|||
|
||||
const double corrector2 = 2.0f * corrector1;
|
||||
|
||||
reverse->r1c1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3));
|
||||
reverse->r2c2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3));
|
||||
reverse->r3c3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2));
|
||||
reverse->row1_col1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3));
|
||||
reverse->row2_col2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3));
|
||||
reverse->row3_col3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2));
|
||||
|
||||
reverse->r1c2 = corrector2 * (x1x2 + s0x3);
|
||||
reverse->r2c3 = corrector2 * (x2x3 + s0x1);
|
||||
reverse->r3c1 = corrector2 * (x1x3 + s0x2);
|
||||
reverse->row1_col2 = corrector2 * (x1x2 + s0x3);
|
||||
reverse->row2_col3 = corrector2 * (x2x3 + s0x1);
|
||||
reverse->row3_col1 = corrector2 * (x1x3 + s0x2);
|
||||
|
||||
reverse->r2c1 = corrector2 * (x1x2 - s0x3);
|
||||
reverse->r3c2 = corrector2 * (x2x3 - s0x1);
|
||||
reverse->r1c3 = corrector2 * (x1x3 - s0x2);
|
||||
reverse->row2_col1 = corrector2 * (x1x2 - s0x3);
|
||||
reverse->row3_col2 = corrector2 * (x2x3 - s0x1);
|
||||
reverse->row1_col3 = corrector2 * (x1x3 - s0x2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -810,11 +810,11 @@ inline int bgc_fp32_quaternion_are_close(const BGC_FP32_Quaternion* quaternion1,
|
|||
const float square_modulus2 = bgc_fp32_quaternion_get_square_modulus(quaternion2);
|
||||
const float square_distance = (ds0 * ds0 + dx1 * dx1) + (dx2 * dx2 + dx3 * dx3);
|
||||
|
||||
if (square_modulus1 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT) {
|
||||
return square_distance <= BGC_FP32_SQUARE_EPSYLON;
|
||||
if (square_modulus1 <= BGC_FP32_EPSILON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP32_EPSILON_EFFECTIVENESS_LIMIT) {
|
||||
return square_distance <= BGC_FP32_SQUARE_EPSILON;
|
||||
}
|
||||
|
||||
return square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus2;
|
||||
return square_distance <= BGC_FP32_SQUARE_EPSILON * square_modulus1 && square_distance <= BGC_FP32_SQUARE_EPSILON * square_modulus2;
|
||||
}
|
||||
|
||||
inline int bgc_fp64_quaternion_are_close(const BGC_FP64_Quaternion* quaternion1, const BGC_FP64_Quaternion* quaternion2)
|
||||
|
|
@ -828,11 +828,11 @@ inline int bgc_fp64_quaternion_are_close(const BGC_FP64_Quaternion* quaternion1,
|
|||
const double square_modulus2 = bgc_fp64_quaternion_get_square_modulus(quaternion2);
|
||||
const double square_distance = (ds0 * ds0 + dx1 * dx1) + (dx2 * dx2 + dx3 * dx3);
|
||||
|
||||
if (square_modulus1 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT) {
|
||||
return square_distance <= BGC_FP64_SQUARE_EPSYLON;
|
||||
if (square_modulus1 <= BGC_FP64_EPSILON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP64_EPSILON_EFFECTIVENESS_LIMIT) {
|
||||
return square_distance <= BGC_FP64_SQUARE_EPSILON;
|
||||
}
|
||||
|
||||
return square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus2;
|
||||
return square_distance <= BGC_FP64_SQUARE_EPSILON * square_modulus1 && square_distance <= BGC_FP64_SQUARE_EPSILON * square_modulus2;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue