Добавление проверки, является ли матрица 2x2 или 3x3 матрицей поворота
This commit is contained in:
parent
2a4d5522d3
commit
b777560d93
6 changed files with 76 additions and 4 deletions
|
|
@ -18,6 +18,9 @@ extern inline double bgc_matrix2x2_get_determinant_fp64(const BgcMatrix2x2FP64*
|
||||||
extern inline int bgc_matrix2x2_is_singular_fp32(const BgcMatrix2x2FP32* matrix);
|
extern inline int bgc_matrix2x2_is_singular_fp32(const BgcMatrix2x2FP32* matrix);
|
||||||
extern inline int bgc_matrix2x2_is_singular_fp64(const BgcMatrix2x2FP64* matrix);
|
extern inline int bgc_matrix2x2_is_singular_fp64(const BgcMatrix2x2FP64* matrix);
|
||||||
|
|
||||||
|
extern inline int bgc_matrix2x2_is_rotation_fp32(const BgcMatrix2x2FP32* matrix);
|
||||||
|
extern inline int bgc_matrix2x2_is_rotation_fp64(const BgcMatrix2x2FP64* matrix);
|
||||||
|
|
||||||
extern inline void bgc_matrix2x2_copy_fp32(const BgcMatrix2x2FP32* source, BgcMatrix2x2FP32* destination);
|
extern inline void bgc_matrix2x2_copy_fp32(const BgcMatrix2x2FP32* source, BgcMatrix2x2FP32* destination);
|
||||||
extern inline void bgc_matrix2x2_copy_fp64(const BgcMatrix2x2FP64* source, BgcMatrix2x2FP64* destination);
|
extern inline void bgc_matrix2x2_copy_fp64(const BgcMatrix2x2FP64* source, BgcMatrix2x2FP64* destination);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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));
|
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 ==================== //
|
// ==================== Copy ==================== //
|
||||||
|
|
||||||
inline void bgc_matrix2x2_copy_fp32(const BgcMatrix2x2FP32* source, BgcMatrix2x2FP32* destination)
|
inline void bgc_matrix2x2_copy_fp32(const BgcMatrix2x2FP32* source, BgcMatrix2x2FP32* destination)
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,9 @@ extern inline double bgc_matrix3x3_get_determinant_fp64(const BgcMatrix3x3FP64*
|
||||||
extern inline int bgc_matrix3x3_is_singular_fp32(const BgcMatrix3x3FP32* matrix);
|
extern inline int bgc_matrix3x3_is_singular_fp32(const BgcMatrix3x3FP32* matrix);
|
||||||
extern inline int bgc_matrix3x3_is_singular_fp64(const BgcMatrix3x3FP64* matrix);
|
extern inline int bgc_matrix3x3_is_singular_fp64(const BgcMatrix3x3FP64* matrix);
|
||||||
|
|
||||||
|
extern inline int bgc_matrix3x3_is_rotation_fp32(const BgcMatrix3x3FP32* matrix);
|
||||||
|
extern inline int bgc_matrix3x3_is_rotation_fp64(const BgcMatrix3x3FP64* matrix);
|
||||||
|
|
||||||
extern inline void bgc_matrix3x3_transpose_fp32(const BgcMatrix3x3FP32* matrix, BgcMatrix3x3FP32* transposed);
|
extern inline void bgc_matrix3x3_transpose_fp32(const BgcMatrix3x3FP32* matrix, BgcMatrix3x3FP32* transposed);
|
||||||
extern inline void bgc_matrix3x3_transpose_fp64(const BgcMatrix3x3FP64* matrix, BgcMatrix3x3FP64* transposed);
|
extern inline void bgc_matrix3x3_transpose_fp64(const BgcMatrix3x3FP64* matrix, BgcMatrix3x3FP64* transposed);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -272,6 +272,46 @@ inline int bgc_matrix3x3_is_singular_fp64(const BgcMatrix3x3FP64* matrix)
|
||||||
return bgc_is_zero_fp64(bgc_matrix3x3_get_determinant_fp64(matrix));
|
return bgc_is_zero_fp64(bgc_matrix3x3_get_determinant_fp64(matrix));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ================ Is Rotation ================= //
|
||||||
|
|
||||||
|
inline int bgc_matrix3x3_is_rotation_fp32(const BgcMatrix3x3FP32* matrix)
|
||||||
|
{
|
||||||
|
const float product_r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1 + matrix->r1c3 * matrix->r3c1;
|
||||||
|
const float product_r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2 + matrix->r1c3 * matrix->r3c2;
|
||||||
|
const float product_r1c3 = matrix->r1c1 * matrix->r1c3 + matrix->r1c2 * matrix->r2c3 + matrix->r1c3 * matrix->r3c3;
|
||||||
|
|
||||||
|
const float product_r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1 + matrix->r2c3 * matrix->r3c1;
|
||||||
|
const float product_r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2 + matrix->r2c3 * matrix->r3c2;
|
||||||