Добавление проверки, является ли матрица 2x2 или 3x3 матрицей поворота

This commit is contained in:
Andrey Pokidov 2025-06-05 00:04:27 +07:00
parent 2a4d5522d3
commit b777560d93
6 changed files with 76 additions and 4 deletions

View file

@ -109,6 +109,32 @@ inline int bgc_matrix2x2_is_singular_fp64(const BgcMatrix2x2FP64* matrix)
return bgc_is_zero_fp64(bgc_matrix2x2_get_determinant_fp64(matrix));
}
// ================ Is Rotation ================= //
inline int bgc_matrix2x2_is_rotation_fp32(const BgcMatrix2x2FP32* matrix)
{
const float product_r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1;
const float product_r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2;
const float product_r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1;
const float product_r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2;
return bgc_is_unit_fp32(product_r1c1) && bgc_is_zero_fp32(product_r1c2)
&& bgc_is_zero_fp32(product_r2c1) && bgc_is_unit_fp32(product_r2c2);
}
inline int bgc_matrix2x2_is_rotation_fp64(const BgcMatrix2x2FP64* matrix)
{
const double product_r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1;
const double product_r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2;
const double product_r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1;
const double product_r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2;
return bgc_is_unit_fp64(product_r1c1) && bgc_is_zero_fp64(product_r1c2)
&& bgc_is_zero_fp64(product_r2c1) && bgc_is_unit_fp64(product_r2c2);
}
// ==================== Copy ==================== //
inline void bgc_matrix2x2_copy_fp32(const BgcMatrix2x2FP32* source, BgcMatrix2x2FP32* destination)