реорганизация функций проекта, уменьшение дублирующегося кода

This commit is contained in:
Andrey Pokidov 2025-02-04 13:20:46 +07:00
parent 6c0ae92ed4
commit 07623b2aa6
10 changed files with 84 additions and 67 deletions

View file

@ -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;
}