реорганизация функций проекта, уменьшение дублирующегося кода
This commit is contained in:
parent
6c0ae92ed4
commit
07623b2aa6
10 changed files with 84 additions and 67 deletions
|
|
@ -185,16 +185,12 @@ inline double bgc_matrix2x2_get_determinant_fp64(const BgcMatrix2x2FP64* matrix)
|
|||
|
||||
inline int bgc_matrix2x2_is_singular_fp32(const BgcMatrix2x2FP32* matrix)
|
||||
{
|
||||
const float determinant = bgc_matrix2x2_get_determinant_fp32(matrix);
|
||||
|
||||
return -BGC_EPSYLON_FP32 <= determinant && determinant <= BGC_EPSYLON_FP32;
|
||||
return bgc_is_zero_fp32(bgc_matrix2x2_get_determinant_fp32(matrix));
|
||||
}
|
||||
|
||||
inline int bgc_matrix2x2_is_singular_fp64(const BgcMatrix2x2FP64* matrix)
|
||||
{
|
||||
const double determinant = bgc_matrix2x2_get_determinant_fp64(matrix);
|
||||
|
||||
return -BGC_EPSYLON_FP64 <= determinant && determinant <= BGC_EPSYLON_FP64;
|
||||
return bgc_is_zero_fp64(bgc_matrix2x2_get_determinant_fp64(matrix));
|
||||
}
|
||||
|
||||
// =============== Transposition ================ //
|
||||
|
|
@ -219,7 +215,7 @@ inline int bgc_matrix2x2_invert_fp32(BgcMatrix2x2FP32* matrix)
|
|||
{
|
||||
const float determinant = bgc_matrix2x2_get_determinant_fp32(matrix);
|
||||
|
||||
if (-BGC_EPSYLON_FP32 <= determinant && determinant <= BGC_EPSYLON_FP32) {
|
||||
if (bgc_is_zero_fp32(determinant)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -244,7 +240,7 @@ inline int bgc_matrix2x2_invert_fp64(BgcMatrix2x2FP64* matrix)
|
|||
{
|
||||
const double determinant = bgc_matrix2x2_get_determinant_fp64(matrix);
|
||||
|
||||
if (-BGC_EPSYLON_FP64 <= determinant && determinant <= BGC_EPSYLON_FP64) {
|
||||
if (bgc_is_zero_fp64(determinant)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -295,7 +291,7 @@ inline int bgc_matrix2x2_set_inverted_fp32(const BgcMatrix2x2FP32* from, BgcMatr
|
|||
{
|
||||
const float determinant = bgc_matrix2x2_get_determinant_fp32(from);
|
||||
|
||||
if (-BGC_EPSYLON_FP32 <= determinant && determinant <= BGC_EPSYLON_FP32) {
|
||||
if (bgc_is_zero_fp32(determinant)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -320,7 +316,7 @@ inline int bgc_matrix2x2_set_inverted_fp64(const BgcMatrix2x2FP64* from, BgcMatr
|
|||
{
|
||||
const double determinant = bgc_matrix2x2_get_determinant_fp64(from);
|
||||
|
||||
if (-BGC_EPSYLON_FP64 <= determinant && determinant <= BGC_EPSYLON_FP64) {
|
||||
if (bgc_is_zero_fp64(determinant)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -264,16 +264,12 @@ inline double bgc_matrix3x3_get_determinant_fp64(const BgcMatrix3x3FP64* matrix)
|
|||
|
||||
inline int bgc_matrix3x3_is_singular_fp32(const BgcMatrix3x3FP32* matrix)
|
||||
{
|
||||
const float determinant = bgc_matrix3x3_get_determinant_fp32(matrix);
|
||||
|
||||
return -BGC_EPSYLON_FP32 <= determinant && determinant <= BGC_EPSYLON_FP32;
|
||||
return bgc_is_zero_fp32(bgc_matrix3x3_get_determinant_fp32(matrix));
|
||||
}
|
||||
|
||||
inline int bgc_matrix3x3_is_singular_fp64(const BgcMatrix3x3FP64* matrix)
|
||||
{
|
||||
const double determinant = bgc_matrix3x3_get_determinant_fp64(matrix);
|
||||
|
||||
return -BGC_EPSYLON_FP64 <= determinant && determinant <= BGC_EPSYLON_FP64;
|
||||
return bgc_is_zero_fp64(bgc_matrix3x3_get_determinant_fp64(matrix));
|
||||
}
|
||||
|
||||
// ================= Inversion ================== //
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ inline int bgc_quaternion_normalize_fp32(BgcQuaternionFP32* quaternion)
|
|||
{
|
||||
const float square_modulus = bgc_quaternion_get_square_modulus_fp32(quaternion);
|
||||
|
||||
if (1.0f - BGC_TWO_EPSYLON_FP32 <= square_modulus && square_modulus <= 1.0f + BGC_TWO_EPSYLON_FP32) {
|
||||
if (bgc_is_sqare_value_unit_fp32(square_modulus)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -248,7 +248,7 @@ inline int bgc_quaternion_normalize_fp64(BgcQuaternionFP64* quaternion)
|
|||
{
|
||||
const double square_modulus = bgc_quaternion_get_square_modulus_fp64(quaternion);
|
||||
|
||||
if (1.0 - BGC_TWO_EPSYLON_FP64 <= square_modulus && square_modulus <= 1.0 + BGC_TWO_EPSYLON_FP64) {
|
||||
if (bgc_is_sqare_value_unit_fp64(square_modulus)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -278,7 +278,7 @@ inline void bgc_quaternion_get_rotation_matrix_fp32(const BgcQuaternionFP32* qua
|
|||
|
||||
const float square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
|
||||
|
||||
if (-BGC_EPSYLON_FP32 <= square_modulus && square_modulus <= BGC_EPSYLON_FP32)
|
||||
if (bgc_is_zero_fp32(square_modulus))
|
||||
{
|
||||
bgc_matrix3x3_set_to_identity_fp32(matrix);
|
||||
return;
|
||||
|
|
@ -316,7 +316,7 @@ inline void bgc_quaternion_get_rotation_matrix_fp64(const BgcQuaternionFP64* qua
|
|||
|
||||
const double square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
|
||||
|
||||
if (-BGC_EPSYLON_FP64 <= square_modulus && square_modulus <= BGC_EPSYLON_FP64)
|
||||
if (bgc_is_zero_fp64(square_modulus))
|
||||
{
|
||||
bgc_matrix3x3_set_to_identity_fp64(matrix);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -68,11 +68,9 @@ inline void bgc_tangent_set_values_fp32(const float x1, const float x2, BgcTange
|
|||
twin->cos = x1;
|
||||
twin->sin = x2;
|
||||
|
||||
if (1.0f - BGC_TWO_EPSYLON_FP32 <= square_modulus && square_modulus <= 1.0f + BGC_TWO_EPSYLON_FP32) {
|
||||
return;
|
||||
if (!bgc_is_sqare_value_unit_fp32(square_modulus)) {
|
||||