Удаление избыточных функций, добавление функций для комплексных чисел и кватернионов
This commit is contained in:
parent
fa9ecda57b
commit
34ee460873
21 changed files with 976 additions and 1158 deletions
|
|
@ -21,7 +21,7 @@ static const BgcVector2FP32 _TEST_FP32_NONZERO_VECTOR2_LIST[] = {
|
|||
{ -1.25f * BGC_EPSYLON_FP32, 0.0f },
|
||||
{ 0.0f, 1.25f * BGC_EPSYLON_FP32 },
|
||||
{ 0.0f, -1.25f * BGC_EPSYLON_FP32 },
|
||||
{ 1.25f * BGC_EPSYLON_FP32, 1.25 * BGC_EPSYLON_FP32 },
|
||||
{ 1.25f * BGC_EPSYLON_FP32, 1.25f * BGC_EPSYLON_FP32 },
|
||||
{ -1.25f * BGC_EPSYLON_FP32, -1.25f * BGC_EPSYLON_FP32 }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -18,20 +18,20 @@ 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_fp64(const BgcMatrix2x2FP64* matrix);
|
||||
|
||||
extern inline void bgc_matrix2x2_copy_fp32(const BgcMatrix2x2FP32* from, BgcMatrix2x2FP32* to);
|
||||
extern inline void bgc_matrix2x2_copy_fp64(const BgcMatrix2x2FP64* from, BgcMatrix2x2FP64* to);
|
||||
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_swap_fp32(BgcMatrix2x2FP32* matrix1, BgcMatrix2x2FP32* matrix2);
|
||||
extern inline void bgc_matrix2x2_swap_fp64(BgcMatrix2x2FP64* matrix1, BgcMatrix2x2FP64* matrix2);
|
||||
|
||||
extern inline void bgc_matrix2x2_convert_fp64_to_fp32(const BgcMatrix2x2FP64* from, BgcMatrix2x2FP32* to);
|
||||
extern inline void bgc_matrix2x2_convert_fp32_to_fp64(const BgcMatrix2x2FP32* from, BgcMatrix2x2FP64* to);
|
||||
extern inline void bgc_matrix2x2_convert_fp64_to_fp32(const BgcMatrix2x2FP64* source, BgcMatrix2x2FP32* destination);
|
||||
extern inline void bgc_matrix2x2_convert_fp32_to_fp64(const BgcMatrix2x2FP32* source, BgcMatrix2x2FP64* destination);
|
||||
|
||||
extern inline int bgc_matrix2x2_invert_fp32(BgcMatrix2x2FP32* matrix);
|
||||
extern inline int bgc_matrix2x2_invert_fp64(BgcMatrix2x2FP64* matrix);
|
||||
extern inline int bgc_matrix2x2_invert_fp32(const BgcMatrix2x2FP32* matrix, BgcMatrix2x2FP32* inverted);
|
||||
extern inline int bgc_matrix2x2_invert_fp64(const BgcMatrix2x2FP64* matrix, BgcMatrix2x2FP64* inverted);
|
||||
|
||||
extern inline void bgc_matrix2x2_transpose_fp32(BgcMatrix2x2FP32* matrix);
|
||||
extern inline void bgc_matrix2x2_transpose_fp64(BgcMatrix2x2FP64* matrix);
|
||||
extern inline void bgc_matrix2x2_transpose_fp32(const BgcMatrix2x2FP32* matrix, BgcMatrix2x2FP32* transposed);
|
||||
extern inline void bgc_matrix2x2_transpose_fp64(const BgcMatrix2x2FP64* matrix, BgcMatrix2x2FP64* transposed);
|
||||
|
||||
extern inline void bgc_matrix2x2_set_row1_fp32(const float c1, const float c2, BgcMatrix2x2FP32* matrix);
|
||||
extern inline void bgc_matrix2x2_set_row1_fp64(const double c1, const double c2, BgcMatrix2x2FP64* matrix);
|
||||
|
|
@ -45,12 +45,6 @@ extern inline void bgc_matrix2x2_set_column1_fp64(const double r1, const double
|
|||
extern inline void bgc_matrix2x2_set_column2_fp32(const float r1, const float r2, BgcMatrix2x2FP32* matrix);
|
||||
extern inline void bgc_matrix2x2_set_column2_fp64(const double r1, const double r2, BgcMatrix2x2FP64* matrix);
|
||||
|
||||
extern inline int bgc_matrix2x2_get_inverted_fp32(const BgcMatrix2x2FP32* from, BgcMatrix2x2FP32* to);
|
||||
extern inline int bgc_matrix2x2_get_inverted_fp64(const BgcMatrix2x2FP64* from, BgcMatrix2x2FP64* to);
|
||||
|
||||
extern inline void bgc_matrix2x2_get_transposed_fp32(const BgcMatrix2x2FP32* from, BgcMatrix2x2FP32* to);
|
||||
extern inline void bgc_matrix2x2_get_transposed_fp64(const BgcMatrix2x2FP64* from, BgcMatrix2x2FP64* to);
|
||||
|
||||
extern inline void bgc_matrix2x2_add_fp32(const BgcMatrix2x2FP32* matrix1, const BgcMatrix2x2FP32* matrix2, BgcMatrix2x2FP32* sum);
|
||||
extern inline void bgc_matrix2x2_add_fp64(const BgcMatrix2x2FP64* matrix1, const BgcMatrix2x2FP64* matrix2, BgcMatrix2x2FP64* sum);
|
||||
|
||||
|
|
@ -74,4 +68,3 @@ extern inline void bgc_matrix2x2_get_left_product_fp64(const BgcVector2FP64* vec
|
|||
|
||||
extern inline void bgc_matrix2x2_get_right_product_fp32(const BgcMatrix2x2FP32* matrix, const BgcVector2FP32* vector, BgcVector2FP32* product);
|
||||
extern inline void bgc_matrix2x2_get_right_product_fp64(const BgcMatrix2x2FP64* matrix, const BgcVector2FP64* vector, BgcVector2FP64* product);
|
||||
|
||||
|
|
|
|||
|
|
@ -111,22 +111,22 @@ inline int bgc_matrix2x2_is_singular_fp64(const BgcMatrix2x2FP64* matrix)
|
|||
|
||||
// ==================== Copy ==================== //
|
||||
|
||||
inline void bgc_matrix2x2_copy_fp32(const BgcMatrix2x2FP32* from, BgcMatrix2x2FP32* to)
|
||||
inline void bgc_matrix2x2_copy_fp32(const BgcMatrix2x2FP32* source, BgcMatrix2x2FP32* destination)
|
||||
{
|
||||
to->r1c1 = from->r1c1;
|
||||
to->r1c2 = from->r1c2;
|
||||
destination->r1c1 = source->r1c1;
|
||||
destination->r1c2 = source->r1c2;
|
||||
|
||||
to->r2c1 = from->r2c1;
|
||||
to->r2c2 = from->r2c2;
|
||||
destination->r2c1 = source->r2c1;
|
||||
destination->r2c2 = source->r2c2;
|
||||
}
|
||||
|
||||
inline void bgc_matrix2x2_copy_fp64(const BgcMatrix2x2FP64* from, BgcMatrix2x2FP64* to)
|
||||
inline void bgc_matrix2x2_copy_fp64(const BgcMatrix2x2FP64* source, BgcMatrix2x2FP64* destination)
|
||||
{
|
||||
to->r1c1 = from->r1c1;
|
||||
to->r1c2 = from->r1c2;
|
||||
destination->r1c1 = source->r1c1;
|
||||
destination->r1c2 = source->r1c2;
|
||||
|
||||
to->r2c1 = from->r2c1;
|
||||
to->r2c2 = from->r2c2;
|
||||
destination->r2c1 = source->r2c1;
|
||||
destination->r2c2 = source->r2c2;
|
||||
}
|
||||
|
||||
// ==================== Swap ==================== //
|
||||
|
|
@ -175,27 +175,27 @@ inline void bgc_matrix2x2_swap_fp64(BgcMatrix2x2FP64* matrix1, BgcMatrix2x2FP64*
|
|||
|
||||
// ================== Convert =================== //
|
||||
|
||||
inline void bgc_matrix2x2_convert_fp64_to_fp32(const BgcMatrix2x2FP64* from, BgcMatrix2x2FP32* to)
|
||||
inline void bgc_matrix2x2_convert_fp64_to_fp32(const BgcMatrix2x2FP64* source, BgcMatrix2x2FP32* destination)
|
||||
{
|
||||
to->r1c1 = (float)from->r1c1;
|
||||
to->r1c2 = (float)from->r1c2;
|
||||
destination->r1c1 = (float)source->r1c1;
|
||||
destination->r1c2 = (float)source->r1c2;
|
||||
|
||||
to->r2c1 = (float)from->r2c1;
|
||||
to->r2c2 = (float)from->r2c2;
|
||||
destination->r2c1 = (float)source->r2c1;
|
||||
destination->r2c2 = (float)source->r2c2;
|
||||
}
|
||||
|
||||
inline void bgc_matrix2x2_convert_fp32_to_fp64(const BgcMatrix2x2FP32* from, BgcMatrix2x2FP64* to)
|
||||
inline void bgc_matrix2x2_convert_fp32_to_fp64(const BgcMatrix2x2FP32* source, BgcMatrix2x2FP64* destination)
|
||||
{
|
||||
to->r1c1 = from->r1c1;
|
||||
to->r1c2 = from->r1c2;
|
||||
destination->r1c1 = source->r1c1;
|
||||
destination->r1c2 = source->r1c2;
|
||||
|
||||
to->r2c1 = from->r2c1;
|
||||
to->r2c2 = from->r2c2;
|
||||
destination->r2c1 = source->r2c1;
|
||||
destination->r2c2 = source->r2c2;
|
||||
}
|
||||
|
||||
// =================== Invert =================== //
|
||||
|
||||
inline int bgc_matrix2x2_invert_fp32(BgcMatrix2x2FP32* matrix)
|
||||
inline int bgc_matrix2x2_invert_fp32(const BgcMatrix2x2FP32* matrix, BgcMatrix2x2FP32* inverted)
|
||||
{
|
||||
const float determinant = bgc_matrix2x2_get_determinant_fp32(matrix);
|
||||
|
||||
|
|
@ -211,16 +211,16 @@ inline int bgc_matrix2x2_invert_fp32(BgcMatrix2x2FP32* matrix)
|
|||
|
||||
const float multiplier = 1.0f / determinant;
|
||||
|
||||
matrix->r1c1 = r1c1 * multiplier;
|
||||
matrix->r1c2 = r1c2 * multiplier;
|
||||
inverted->r1c1 = r1c1 * multiplier;
|
||||
inverted->r1c2 = r1c2 * multiplier;
|
||||
|
||||
matrix->r2c1 = r2c1 * multiplier;
|
||||
matrix->r2c2 = r2c2 * multiplier;
|
||||
inverted->r2c1 = r2c1 * multiplier;
|
||||
inverted->r2c2 = r2c2 * multiplier;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int bgc_matrix2x2_invert_fp64(BgcMatrix2x2FP64* matrix)
|
||||
inline int bgc_matrix2x2_invert_fp64(const BgcMatrix2x2FP64* matrix, BgcMatrix2x2FP64* inverted)
|
||||
{
|
||||
const double determinant = bgc_matrix2x2_get_determinant_fp64(matrix);
|
||||
|
||||
|
|
@ -236,29 +236,37 @@ inline int bgc_matrix2x2_invert_fp64(BgcMatrix2x2FP64* matrix)
|
|||
|
||||
const double multiplier = 1.0 / determinant;
|
||||
|
||||
matrix->r1c1 = r1c1 * multiplier;
|
||||
matrix->r1c2 = r1c2 * multiplier;
|
||||
inverted->r1c1 = r1c1 * multiplier;
|
||||
inverted->r1c2 = r1c2 * multiplier;
|
||||
|
||||
matrix->r2c1 = r2c1 * multiplier;
|
||||
matrix->r2c2 = r2c2 * multiplier;
|
||||
inverted->r2c1 = r2c1 * multiplier;
|
||||
inverted->r2c2 = r2c2 * multiplier;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ================= Transpose ================== //
|
||||
|
||||
inline void bgc_matrix2x2_transpose_fp32(BgcMatrix2x2FP32* matrix)
|
||||
inline void bgc_matrix2x2_transpose_fp32(const BgcMatrix2x2FP32* matrix, BgcMatrix2x2FP32* transposed)
|
||||
{
|
||||
const float tmp = matrix->r1c2;
|
||||
matrix->r1c2 = matrix->r2c1;
|
||||
matrix->r2c1 = tmp;
|
||||
const float r1c2 = matrix->r1c2;
|
||||
|
||||
transposed->r1c1 = matrix->r1c1;
|
||||
transposed->r1c2 = matrix->r2c1;
|
||||
|
||||
transposed->r2c1 = r1c2;
|
||||
transposed->r2c2 = matrix->r2c2;
|
||||
}
|
||||
|
||||
inline void bgc_matrix2x2_transpose_fp64(BgcMatrix2x2FP64* matrix)
|
||||
inline void bgc_matrix2x2_transpose_fp64(const BgcMatrix2x2FP64* matrix, BgcMatrix2x2FP64* transposed)
|
||||
{
|
||||
const double tmp = matrix->r1c2;
|
||||
matrix->r1c2 = matrix->r2c1;
|
||||
matrix->r2c1 = tmp;
|
||||
const double r1c2 = matrix->r1c2;
|
||||
|
||||
transposed->r1c1 = matrix->r1c1;
|
||||
transposed->r1c2 = matrix->r2c1;
|
||||
|
||||
transposed->r2c1 = r1c2;
|
||||
transposed->r2c2 = matrix->r2c2;
|
||||
}
|
||||
|
||||
// ================= Set Row 1 ================== //
|
||||
|
|
@ -317,82 +325,6 @@ inline void bgc_matrix2x2_set_column2_fp64(const double r1, const double r2, Bgc
|
|||
matrix->r2c2 = r2;
|
||||
}
|
||||
|
||||
// ================ Get Inverted ================ //
|
||||
|
||||
inline int bgc_matrix2x2_get_inverted_fp32(const BgcMatrix2x2FP32* matrix, BgcMatrix2x2FP32* inverted)
|
||||
{
|
||||
const float determinant = bgc_matrix2x2_get_determinant_fp32(matrix);
|
||||
|
||||
if (bgc_is_zero_fp32(determinant)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const float r1c1 = matrix->r2c2;
|
||||
const float r1c2 = -matrix->r1c2;
|
||||
|
||||
const float r2c1 = -matrix->r2c1;
|
||||
const float r2c2 = matrix->r1c1;
|
||||
|
||||
const float multiplier = 1.0f / determinant;
|
||||
|
||||
inverted->r1c1 = r1c1 * multiplier;
|
||||
inverted->r1c2 = r1c2 * multiplier;
|
||||
|
||||
inverted->r2c1 = r2c1 * multiplier;
|
||||
inverted->r2c2 = r2c2 * multiplier;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
inline int bgc_matrix2x2_get_inverted_fp64(const BgcMatrix2x2FP64* matrix, BgcMatrix2x2FP64* inverted)
|
||||
{
|
||||
const double determinant = bgc_matrix2x2_get_determinant_fp64(matrix);
|
||||
|
||||
if (bgc_is_zero_fp64(determinant)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const double r1c1 = matrix->r2c2;
|
||||
const double r1c2 = -matrix->r1c2;
|
||||
|
||||
const double r2c1 = -matrix->r2c1;
|
||||
const double r2c2 = matrix->r1c1;
|
||||
|
||||
const double multiplier = 1.0 / determinant;
|
||||
|
||||
inverted->r1c1 = r1c1 * multiplier;
|
||||
inverted->r1c2 = r1c2 * multiplier;
|
||||
|
||||
inverted->r2c1 = r2c1 * multiplier;
|
||||
inverted->r2c2 = r2c2 * multiplier;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// =============== Get Transposed =============== //
|
||||
|
||||
inline void bgc_matrix2x2_get_transposed_fp32(const BgcMatrix2x2FP32* matrix, BgcMatrix2x2FP32* transposed)
|
||||
{
|
||||
float tmp = matrix->r1c2;
|
||||
|
||||
transposed->r1c1 = matrix->r1c1;
|
||||
transposed->r1c2 = matrix->r2c1;
|
||||
|
||||
transposed->r2c1 = tmp;
|
||||
transposed->r2c2 = matrix->r2c2;
|
||||
}
|
||||
|
||||
inline void bgc_matrix2x2_get_transposed_fp64(const BgcMatrix2x2FP64* matrix, BgcMatrix2x2FP64* transposed)
|
||||
{
|
||||
double tmp = matrix->r1c2;
|
||||
|
||||
transposed->r1c1 = matrix->r1c1;
|
||||
transposed->r1c2 = matrix->r2c1;
|
||||
|
||||
transposed->r2c1 = tmp;
|
||||
transposed->r2c2 = matrix->r2c2;
|
||||
}
|
||||
|
||||
// ==================== Add ===================== //
|
||||
|
||||
inline void bgc_matrix2x2_add_fp32(const BgcMatrix2x2FP32* matrix1, const BgcMatrix2x2FP32* matrix2, BgcMatrix2x2FP32* sum)
|
||||
|
|
|
|||
|
|
@ -3,14 +3,17 @@
|
|||
extern inline void bgc_matrix2x3_reset_fp32(BgcMatrix2x3FP32* matrix);
|
||||
extern inline void bgc_matrix2x3_reset_fp64(BgcMatrix2x3FP64* matrix);
|
||||
|
||||
extern inline void bgc_matrix2x3_copy_fp32(const BgcMatrix2x3FP32* from, BgcMatrix2x3FP32* to);
|
||||
extern inline void bgc_matrix2x3_copy_fp64(const BgcMatrix2x3FP64* from, BgcMatrix2x3FP64* to);
|
||||
extern inline void bgc_matrix2x3_copy_fp32(const BgcMatrix2x3FP32* source, BgcMatrix2x3FP32* destination);
|
||||
extern inline void bgc_matrix2x3_copy_fp64(const BgcMatrix2x3FP64* source, BgcMatrix2x3FP64* destination);
|
||||
|
||||
extern inline void bgc_matrix2x3_swap_fp32(BgcMatrix2x3FP32* matrix1, BgcMatrix2x3FP32* matrix2);
|
||||
extern inline void bgc_matrix2x3_swap_fp64(BgcMatrix2x3FP64* matrix1, BgcMatrix2x3FP64* matrix2);
|
||||
|
||||
extern inline void bgc_matrix2x3_convert_fp64_to_fp32(const BgcMatrix2x3FP64* from, BgcMatrix2x3FP32* to);
|
||||
extern inline void bgc_matrix2x3_convert_fp32_to_fp64(const BgcMatrix2x3FP32* from, BgcMatrix2x3FP64* to);
|
||||
extern inline void bgc_matrix2x3_convert_fp64_to_fp32(const BgcMatrix2x3FP64* source, BgcMatrix2x3FP32* destination);
|
||||
extern inline void bgc_matrix2x3_convert_fp32_to_fp64(const BgcMatrix2x3FP32* source, BgcMatrix2x3FP64* destination);
|
||||
|
||||
extern inline void bgc_matrix2x3_transpose_fp32(const BgcMatrix3x2FP32* matrix, BgcMatrix2x3FP32* transposed);
|
||||
extern inline void bgc_matrix2x3_transpose_fp64(const BgcMatrix3x2FP64* matrix, BgcMatrix2x3FP64* transposed);
|
||||
|
||||
extern inline void bgc_matrix2x3_set_row1_fp32(const float c1, const float c2, BgcMatrix2x3FP32* matrix);
|
||||
extern inline void bgc_matrix2x3_set_row1_fp64(const double c1, const double c2, BgcMatrix2x3FP64* matrix);
|
||||
|
|
@ -27,9 +30,6 @@ extern inline void bgc_matrix2x3_set_column1_fp64(const double r1, const double
|
|||
extern inline void bgc_matrix2x3_set_column2_fp32(const float r1, const float r2, const float r3, BgcMatrix2x3FP32* matrix);
|
||||
extern inline void bgc_matrix2x3_set_column2_fp64(const double r1, const double r2, const double r3, BgcMatrix2x3FP64* matrix);
|
||||
|
||||
extern inline void bgc_matrix2x3_get_transposed_fp32(const BgcMatrix3x2FP32* from, BgcMatrix2x3FP32* to);
|
||||
extern inline void bgc_matrix2x3_get_transposed_fp64(const BgcMatrix3x2FP64* from, BgcMatrix2x3FP64* to);
|
||||
|
||||
extern inline void bgc_matrix2x3_add_fp32(const BgcMatrix2x3FP32* matrix1, const BgcMatrix2x3FP32* matrix2, BgcMatrix2x3FP32* sum);
|
||||
extern inline void bgc_matrix2x3_add_fp64(const BgcMatrix2x3FP64* matrix1, const BgcMatrix2x3FP64* matrix2, BgcMatrix2x3FP64* sum);
|
||||
|
||||
|
|
|
|||
|
|
@ -33,28 +33,28 @@ inline void bgc_matrix2x3_reset_fp64(BgcMatrix2x3FP64* matrix)
|
|||
|
||||
// ==================== Copy ==================== //
|
||||
|
||||
inline void bgc_matrix2x3_copy_fp32(const BgcMatrix2x3FP32* from, BgcMatrix2x3FP32* to)
|
||||
inline void bgc_matrix2x3_copy_fp32(const BgcMatrix2x3FP32* source, BgcMatrix2x3FP32* destination)
|
||||
{
|
||||
to->r1c1 = from->r1c1;
|
||||
to->r1c2 = from->r1c2;
|
||||
destination->r1c1 = source->r1c1;
|
||||
destination->r1c2 = source->r1c2;
|
||||
|
||||
to->r2c1 = from->r2c1;
|
||||
to->r2c2 = from->r2c2;
|
||||
destination->r2c1 = source->r2c1;
|
||||
destination->r2c2 = source->r2c2;
|
||||
|
||||
to->r3c1 = from->r3c1;
|
||||
to->r3c2 = from->r3c2;
|
||||
destination->r3c1 = source->r3c1;
|
||||
destination->r3c2 = source->r3c2;
|
||||
}
|
||||
|
||||
inline void bgc_matrix2x3_copy_fp64(const BgcMatrix2x3FP64* from, BgcMatrix2x3FP64* to)
|
||||
inline void bgc_matrix2x3_copy_fp64(const BgcMatrix2x3FP64* source, BgcMatrix2x3FP64* destination)
|
||||
{
|
||||
to->r1c1 = from->r1c1;
|
||||
to->r1c2 = from->r1c2;
|
||||
destination->r1c1 = source->r1c1;
|
||||
destination->r1c2 = source->r1c2;
|
||||
|
||||
to->r2c1 = from->r2c1;
|
||||
to->r2c2 = from->r2c2;
|
||||
destination->r2c1 = source->r2c1;
|
||||
destination->r2c2 = source->r2c2;
|
||||
|
||||
to->r3c1 = from->r3c1;
|
||||
to->r3c2 = from->r3c2;
|
||||
destination->r3c1 = source->r3c1;
|
||||
destination->r3c2 = source->r3c2;
|
||||
}
|
||||
|
||||
// ==================== Swap ==================== //
|
||||
|
|
@ -121,28 +121,54 @@ inline void bgc_matrix2x3_swap_fp64(BgcMatrix2x3FP64* matrix1, BgcMatrix2x3FP64*
|
|||
|
||||
// ================== Convert =================== //
|
||||
|
||||
inline void bgc_matrix2x3_convert_fp64_to_fp32(const BgcMatrix2x3FP64* from, BgcMatrix2x3FP32* to)
|
||||
inline void bgc_matrix2x3_convert_fp64_to_fp32(const BgcMatrix2x3FP64* source, BgcMatrix2x3FP32* destination)
|
||||
{
|
||||
to->r1c1 = (float) from->r1c1;
|
||||
to->r1c2 = (float) from->r1c2;
|
||||
destination->r1c1 = (float)source->r1c1;
|
||||
destination->r1c2 = (float)source->r1c2;
|
||||
|
||||
to->r2c1 = (float) from->r2c1;
|
||||
to->r2c2 = (float) from->r2c2;
|
||||
destination->r2c1 = (float)source->r2c1;
|
||||
destination->r2c2 = (float)source->r2c2;
|
||||
|
||||
to->r3c1 = (float) from->r3c1;
|
||||
to->r3c2 = (float) from->r3c2;
|
||||
destination->r3c1 = (float)source->r3c1;
|
||||
destination->r3c2 = (float)source->r3c2;
|
||||
}
|
||||
|
||||
inline void bgc_matrix2x3_convert_fp32_to_fp64(const BgcMatrix2x3FP32* from, BgcMatrix2x3FP64* to)
|
||||
inline void bgc_matrix2x3_convert_fp32_to_fp64(const BgcMatrix2x3FP32* source, BgcMatrix2x3FP64* destination)
|
||||
{
|
||||
to->r1c1 = from->r1c1;
|
||||
to->r1c2 = from->r1c2;
|
||||
destination->r1c1 = source->r1c1;
|
||||
destination->r1c2 = source->r1c2;
|
||||
|
||||
to->r2c1 = from->r2c1;
|
||||
to->r2c2 = from->r2c2;
|
||||
destination->r2c1 = source->r2c1;
|
||||
destination->r2c2 = source->r2c2;
|
||||
|
||||
to->r3c1 = from->r3c1;
|
||||
to->r3c2 = from->r3c2;
|
||||
destination->r3c1 = source->r3c1;
|
||||
destination->r3c2 = source->r3c2;
|
||||
}
|
||||
|
||||
// ================= Transpose ================== //
|
||||
|
||||
inline void bgc_matrix2x3_transpose_fp32(const BgcMatrix3x2FP32* matrix, BgcMatrix2x3FP32* transposed)
|
||||
{
|
||||
transposed->r1c1 = matrix->r1c1;
|
||||
transposed->r1c2 = matrix->r2c1;
|
||||
|
||||
transposed->r2c1 = matrix->r1c2;
|
||||
transposed->r2c2 = matrix->r2c2;
|
||||
|
||||
transposed->r3c1 = matrix->r1c3;
|
||||
transposed->r3c2 = matrix->r2c3;
|
||||
}
|
||||
|
||||
inline void bgc_matrix2x3_transpose_fp64(const BgcMatrix3x2FP64* matrix, BgcMatrix2x3FP64* transposed)
|
||||
{
|
||||
transposed->r1c1 = matrix->r1c1;
|
||||
transposed->r1c2 = matrix->r2c1;
|
||||
|
||||
transposed->r2c1 = matrix->r1c2;
|
||||
transposed->r2c2 = matrix->r2c2;
|
||||
|
||||
transposed->r3c1 = matrix->r1c3;
|
||||
transposed->r3c2 = matrix->r2c3;
|
||||
}
|
||||
|
||||
// ================= Set Row 1 ================== //
|
||||
|
|
@ -219,33 +245,6 @@ inline void bgc_matrix2x3_set_column2_fp64(const double r1, const double r2, con
|
|||
matrix->r3c2 = r3;
|
||||
}
|
||||
|
||||
// =============== Get transposed =============== //
|
||||
|
||||
inline void bgc_matrix2x3_get_transposed_fp32(const BgcMatrix3x2FP32* matrix, BgcMatrix2x3FP32* transposed)
|
||||
{
|
||||
transposed->r1c1 = matrix->r1c1;
|
||||
transposed->r1c2 = matrix->r2c1;
|
||||
|
||||
transposed->r2c1 = matrix->r1c2;
|
||||
transposed->r2c2 = matrix->r2c2;
|
||||
|
||||
transposed->r3c1 = matrix->r1c3;
|
||||
transposed->r3c2 = matrix->r2c3;
|
||||
}
|
||||
|
||||
inline void bgc_matrix2x3_get_transposed_fp64(const BgcMatrix3x2FP64* matrix, BgcMatrix2x3FP64* transposed)
|
||||
{
|
||||
transposed->r1c1 = matrix->r1c1;
|
||||
transposed->r1c2 = matrix->r2c1;
|
||||
|
||||
transposed->r2c1 = matrix->r1c2;
|
||||
transposed->r2c2 = matrix->r2c2;
|
||||
|
||||
transposed->r3c1 = matrix->r1c3;
|
||||
transposed->r3c2 = matrix->r2c3;
|
||||
}
|
||||
|
||||
|
||||
// ==================== Add ===================== //
|
||||
|
||||
inline void bgc_matrix2x3_add_fp32(const BgcMatrix2x3FP32* matrix1, const BgcMatrix2x3FP32* matrix2, BgcMatrix2x3FP32* sum)
|
||||
|
|
|
|||
|
|
@ -3,14 +3,17 @@
|
|||
extern inline void bgc_matrix3x2_reset_fp32(BgcMatrix3x2FP32* matrix);
|
||||
extern inline void bgc_matrix3x2_reset_fp64(BgcMatrix3x2FP64* matrix);
|
||||
|
||||
extern inline void bgc_matrix3x2_copy_fp32(const BgcMatrix3x2FP32* from, BgcMatrix3x2FP32* to);
|
||||
extern inline void bgc_matrix3x2_copy_fp64(const BgcMatrix3x2FP64* from, BgcMatrix3x2FP64* to);
|
||||
extern inline void bgc_matrix3x2_copy_fp32(const BgcMatrix3x2FP32* source, BgcMatrix3x2FP32* destination);
|
||||
extern inline void bgc_matrix3x2_copy_fp64(const BgcMatrix3x2FP64* source, BgcMatrix3x2FP64* destination);
|
||||
|
||||
extern inline void bgc_matrix3x2_swap_fp32(BgcMatrix3x2FP32* matrix1, BgcMatrix3x2FP32* matrix2);
|
||||
extern inline void bgc_matrix3x2_swap_fp64(BgcMatrix3x2FP64* matrix1, BgcMatrix3x2FP64* matrix2);
|
||||
|
||||
extern inline void bgc_matrix3x2_convert_fp64_to_fp32(const BgcMatrix3x2FP64* from, BgcMatrix3x2FP32* to);
|
||||
extern inline void bgc_matrix3x2_convert_fp32_to_fp64(const BgcMatrix3x2FP32* from, BgcMatrix3x2FP64* to);
|
||||
extern inline void bgc_matrix3x2_convert_fp64_to_fp32(const BgcMatrix3x2FP64* source, BgcMatrix3x2FP32* destination);
|
||||
extern inline void bgc_matrix3x2_convert_fp32_to_fp64(const BgcMatrix3x2FP32* source, BgcMatrix3x2FP64* destination);
|
||||
|
||||
extern inline void bgc_matrix3x2_transpose_fp32(const BgcMatrix2x3FP32* matrix, BgcMatrix3x2FP32* transposed);
|
||||
extern inline void bgc_matrix3x2_transpose_fp64(const BgcMatrix2x3FP64* matrix, BgcMatrix3x2FP64* transposed);
|
||||
|
||||
extern inline void bgc_matrix3x2_set_row1_fp32(const float c1, const float c2, const float c3, BgcMatrix3x2FP32* matrix);
|
||||
extern inline void bgc_matrix3x2_set_row1_fp64(const double c1, const double c2, const double c3, BgcMatrix3x2FP64* matrix);
|
||||
|
|
@ -27,9 +30,6 @@ extern inline void bgc_matrix3x2_set_column2_fp64(const double r1, const double
|
|||
extern inline void bgc_matrix3x2_set_column3_fp32(const float r1, const float r2, BgcMatrix3x2FP32* matrix);
|
||||
extern inline void bgc_matrix3x2_set_column3_fp64(const double r1, const double r2, BgcMatrix3x2FP64* matrix);
|
||||
|
||||
extern inline void bgc_matrix3x2_get_transposed_fp32(const BgcMatrix2x3FP32* from, BgcMatrix3x2FP32* to);
|
||||
extern inline void bgc_matrix3x2_get_transposed_fp64(const BgcMatrix2x3FP64* from, BgcMatrix3x2FP64* to);
|
||||
|
||||
extern inline void bgc_matrix3x2_add_fp32(const BgcMatrix3x2FP32* matrix1, const BgcMatrix3x2FP32* matrix2, BgcMatrix3x2FP32* sum);
|
||||
extern inline void bgc_matrix3x2_add_fp64(const BgcMatrix3x2FP64* matrix1, const BgcMatrix3x2FP64* matrix2, BgcMatrix3x2FP64* sum);
|
||||
|
||||
|
|
|
|||
|
|
@ -31,26 +31,26 @@ inline void bgc_matrix3x2_reset_fp64(BgcMatrix3x2FP64* matrix)
|
|||
|
||||
// ==================== Copy ==================== //
|
||||
|
||||
inline void bgc_matrix3x2_copy_fp32(const BgcMatrix3x2FP32* from, BgcMatrix3x2FP32* to)
|
||||
inline void bgc_matrix3x2_copy_fp32(const BgcMatrix3x2FP32* source, BgcMatrix3x2FP32* destination)
|
||||
{
|
||||
to->r1c1 = from->r1c1;
|
||||
to->r1c2 = from->r1c2;
|
||||
to->r1c3 = from->r1c3;
|
||||
destination->r1c1 = source->r1c1;
|
||||
destination->r1c2 = source->r1c2;
|
||||
destination->r1c3 = source->r1c3;
|
||||
|
||||
to->r2c1 = from->r2c1;
|
||||
to->r2c2 = from->r2c2;
|
||||
to->r2c3 = from->r2c3;
|
||||
destination->r2c1 = source->r2c1;
|
||||
destination->r2c2 = source->r2c2;
|
||||
destination->r2c3 = source->r2c3;
|
||||
}
|
||||
|
||||
inline void bgc_matrix3x2_copy_fp64(const BgcMatrix3x2FP64* from, BgcMatrix3x2FP64* to)
|
||||
inline void bgc_matrix3x2_copy_fp64(const BgcMatrix3x2FP64* source, BgcMatrix3x2FP64* destination)
|
||||
{
|
||||
to->r1c1 = from->r1c1;
|
||||
to->r1c2 = from->r1c2;
|
||||
to->r1c3 = from->r1c3;
|
||||
destination->r1c1 = source->r1c1;
|
||||
destination->r1c2 = source->r1c2;
|
||||
destination->r1c3 = source->r1c3;
|
||||
|
||||
to->r2c1 = from->r2c1;
|
||||
to->r2c2 = from->r2c2;
|
||||
to->r2c3 = from->r2c3;
|
||||
destination->r2c1 = source->r2c1;
|
||||
destination->r2c2 = source->r2c2;
|
||||
destination->r2c3 = source->r2c3;
|
||||
}
|
||||
|
||||
// ==================== Swap ==================== //
|
||||
|
|
@ -111,26 +111,50 @@ inline void bgc_matrix3x2_swap_fp64(BgcMatrix3x2FP64* matrix1, BgcMatrix3x2FP64*
|
|||
|
||||
// ================== Convert =================== //
|
||||
|
||||
inline void bgc_matrix3x2_convert_fp64_to_fp32(const BgcMatrix3x2FP64* from, BgcMatrix3x2FP32* to)
|
||||
inline void bgc_matrix3x2_convert_fp64_to_fp32(const BgcMatrix3x2FP64* source, BgcMatrix3x2FP32* destination)
|
||||
{
|
||||
to->r1c1 = (float) from->r1c1;
|
||||
to->r1c2 = (float) from->r1c2;
|
||||
to->r1c3 = (float) from->r1c3;
|
||||
destination->r1c1 = (float)source->r1c1;
|
||||
destination->r1c2 = (float)source->r1c2;
|
||||
destination->r1c3 = (float)source->r1c3;
|
||||
|
||||
to->r2c1 = (float) from->r2c1;
|
||||
to->r2c2 = (float) from->r2c2;
|
||||
to->r2c3 = (float) from->r2c3;
|
||||
destination->r2c1 = (float)source->r2c1;
|
||||
destination->r2c2 = (float)source->r2c2;
|
||||
destination->r2c3 = (float)source->r2c3;
|
||||
}
|
||||
|
||||
inline void bgc_matrix3x2_convert_fp32_to_fp64(const BgcMatrix3x2FP32* from, BgcMatrix3x2FP64* to)
|
||||
inline void bgc_matrix3x2_convert_fp32_to_fp64(const BgcMatrix3x2FP32* source, BgcMatrix3x2FP64* destination)
|
||||
{
|
||||
to->r1c1 = from->r1c1;
|
||||
to->r1c2 = from->r1c2;
|
||||
to->r1c3 = from->r1c3;
|
||||
destination->r1c1 = source->r1c1;
|
||||
destination->r1c2 = source->r1c2;
|
||||
destination->r1c3 = source->r1c3;
|
||||
|
||||
to->r2c1 = from->r2c1;
|
||||
to->r2c2 = from->r2c2;
|
||||
to->r2c3 = from->r2c3;
|
||||
destination->r2c1 = source->r2c1;
|
||||
destination->r2c2 = source->r2c2;
|
||||
destination->r2c3 = source->r2c3;
|
||||
}
|
||||
|
||||
// ================= Transpose ================== //
|
||||
|
||||
inline void bgc_matrix3x2_transpose_fp32(const BgcMatrix2x3FP32* matrix, BgcMatrix3x2FP32* transposed)
|
||||
{
|
||||
transposed->r1c1 = matrix->r1c1;
|
||||
transposed->r1c2 = matrix->r2c1;
|
||||
transposed->r1c3 = matrix->r3c1;
|
||||
|
||||
transposed->r2c1 = matrix->r1c2;
|
||||
transposed->r2c2 = matrix->r2c2;
|
||||
transposed->r2c3 = matrix->r3c2;
|
||||
}
|
||||
|
||||
inline void bgc_matrix3x2_transpose_fp64(const BgcMatrix2x3FP64* matrix, BgcMatrix3x2FP64* transposed)
|
||||
{
|
||||
transposed->r1c1 = matrix->r1c1;
|
||||
transposed->r1c2 = matrix->r2c1;
|
||||
transposed->r1c3 = matrix->r3c1;
|
||||
|
||||
transposed->r2c1 = matrix->r1c2;
|
||||
transposed->r2c2 = matrix->r2c2;
|
||||
transposed->r2c3 = matrix->r3c2;
|
||||
}
|
||||
|
||||
// ================= Set Row 1 ================== //
|
||||
|
|
@ -207,30 +231,6 @@ inline void bgc_matrix3x2_set_column3_fp64(const double r1, const double r2, Bgc
|
|||
matrix->r2c3 = r2;
|
||||
}
|
||||
|
||||
// =============== Get transposed =============== //
|
||||
|
||||
inline void bgc_matrix3x2_get_transposed_fp32(const BgcMatrix2x3FP32* from, BgcMatrix3x2FP32* to)
|
||||
{
|
||||
to->r1c1 = from->r1c1;
|
||||
to->r1c2 = from->r2c1;
|
||||
to->r1c3 = from->r3c1;
|
||||
|
||||
to->r2c1 = from->r1c2;
|
||||
to->r2c2 = from->r2c2;
|
||||
to->r2c3 = from->r3c2;
|
||||
}
|
||||
|
||||
inline void bgc_matrix3x2_get_transposed_fp64(const BgcMatrix2x3FP64* from, BgcMatrix3x2FP64* to)
|
||||
{
|
||||
to->r1c1 = from->r1c1;
|
||||
to->r1c2 = from->r2c1;
|
||||
to->r1c3 = from->r3c1;
|
||||
|
||||
to->r2c1 = from->r1c2;
|
||||
to->r2c2 = from->r2c2;
|
||||
to->r2c3 = from->r3c2;
|
||||
}
|
||||
|
||||
// ==================== Add ===================== //
|
||||
|
||||
inline void bgc_matrix3x2_add_fp32(const BgcMatrix3x2FP32* matrix1, const BgcMatrix3x2FP32* matrix2, BgcMatrix3x2FP32* sum)
|
||||
|
|
|
|||
|
|
@ -9,14 +9,14 @@ extern inline void bgc_matrix3x3_set_to_identity_fp64(BgcMatrix3x3FP64* matrix);
|
|||
extern inline void bgc_matrix3x3_set_to_diagonal_fp32(const float d1, const float d2, const float d3, BgcMatrix3x3FP32* matrix);
|
||||
extern inline void bgc_matrix3x3_set_to_diagonal_fp64(const double d1, const double d2, const double d3, BgcMatrix3x3FP64* matrix);
|
||||
|
||||
extern inline void bgc_matrix3x3_copy_fp32(const BgcMatrix3x3FP32* from, BgcMatrix3x3FP32* to);
|
||||
extern inline void bgc_matrix3x3_copy_fp64(const BgcMatrix3x3FP64* from, BgcMatrix3x3FP64* to);
|
||||
extern inline void bgc_matrix3x3_copy_fp32(const BgcMatrix3x3FP32* source, BgcMatrix3x3FP32* destination);
|
||||
extern inline void bgc_matrix3x3_copy_fp64(const BgcMatrix3x3FP64* source, BgcMatrix3x3FP64* destination);
|
||||
|
||||
extern inline void bgc_matrix3x3_swap_fp32(BgcMatrix3x3FP32* matrix1, BgcMatrix3x3FP32* matrix2);
|
||||
extern inline void bgc_matrix3x3_swap_fp64(BgcMatrix3x3FP64* matrix1, BgcMatrix3x3FP64* matrix2);
|
||||
|
||||
extern inline void bgc_matrix3x3_convert_fp64_to_fp32(const BgcMatrix3x3FP64* from, BgcMatrix3x3FP32* to);
|
||||
extern inline void bgc_matrix3x3_convert_fp32_to_fp64(const BgcMatrix3x3FP32* from, BgcMatrix3x3FP64* to);
|
||||
extern inline void bgc_matrix3x3_convert_fp64_to_fp32(const BgcMatrix3x3FP64* source, BgcMatrix3x3FP32* destination);
|
||||
extern inline void bgc_matrix3x3_convert_fp32_to_fp64(const BgcMatrix3x3FP32* source, BgcMatrix3x3FP64* destination);
|
||||
|
||||
extern inline float bgc_matrix3x3_get_determinant_fp32(const BgcMatrix3x3FP32* matrix);
|
||||
extern inline double bgc_matrix3x3_get_determinant_fp64(const BgcMatrix3x3FP64* matrix);
|
||||
|
|
@ -24,8 +24,8 @@ 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_fp64(const BgcMatrix3x3FP64* matrix);
|
||||
|
||||
extern inline void bgc_matrix3x3_transpose_fp32(BgcMatrix3x3FP32* matrix);
|
||||
extern inline void bgc_matrix3x3_transpose_fp64(BgcMatrix3x3FP64* matrix);
|
||||
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_set_row1_fp32(const float c1, const float c2, const float c3, BgcMatrix3x3FP32* matrix);
|
||||
extern inline void bgc_matrix3x3_set_row1_fp64(const double c1, const double c2, const double c3, BgcMatrix3x3FP64* matrix);
|
||||
|
|
@ -45,9 +45,6 @@ extern inline void bgc_matrix3x3_set_column2_fp64(const double r1, const double
|
|||
extern inline void bgc_matrix3x3_set_column3_fp32(const float r1, const float r2, const float r3, BgcMatrix3x3FP32* matrix);
|
||||
extern inline void bgc_matrix3x3_set_column3_fp64(const double r1, const double r2, const double r3, BgcMatrix3x3FP64* matrix);
|
||||
|
||||
extern inline void bgc_matrix3x3_get_transposed_fp32(const BgcMatrix3x3FP32* matrix, BgcMatrix3x3FP32* result);
|
||||
extern inline void bgc_matrix3x3_get_transposed_fp64(const BgcMatrix3x3FP64* matrix, BgcMatrix3x3FP64* result);
|
||||
|
||||
extern inline void bgc_matrix3x3_add_fp32(const BgcMatrix3x3FP32* matrix1, const BgcMatrix3x3FP32* matrix2, BgcMatrix3x3FP32* sum);
|
||||
extern inline void bgc_matrix3x3_add_fp64(const BgcMatrix3x3FP64* matrix1, const BgcMatrix3x3FP64* matrix2, BgcMatrix3x3FP64* sum);
|
||||
|
||||
|
|
@ -74,11 +71,11 @@ extern inline void bgc_matrix3x3_get_right_product_fp64(const BgcMatrix3x3FP64*
|
|||
|
||||
// =================== Invert =================== //
|
||||
|
||||
int bgc_matrix3x3_invert_fp32(BgcMatrix3x3FP32* matrix)
|
||||
int bgc_matrix3x3_invert_fp32(const BgcMatrix3x3FP32* matrix, BgcMatrix3x3FP32* inverted)
|
||||
{
|
||||
const float determinant = bgc_matrix3x3_get_determinant_fp32(matrix);
|
||||
|
||||
if (-BGC_EPSYLON_FP32 <= determinant && determinant <= BGC_EPSYLON_FP32) {
|
||||
if (bgc_is_zero_fp32(determinant)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -96,26 +93,26 @@ int bgc_matrix3x3_invert_fp32(BgcMatrix3x3FP32* matrix)
|
|||
|
||||
const float multiplier = 1.0f / determinant;
|
||||
|
||||
matrix->r1c1 = r1c1 * multiplier;
|
||||
matrix->r1c2 = r1c2 * multiplier;
|
||||
matrix->r1c3 = r1c3 * multiplier;
|
||||
inverted->r1c1 = r1c1 * multiplier;
|
||||
inverted->r1c2 = r1c2 * multiplier;
|
||||
inverted->r1c3 = r1c3 * multiplier;
|
||||
|
||||
matrix->r2c1 = r2c1 * multiplier;
|
||||
matrix->r2c2 = r2c2 * multiplier;
|
||||
matrix->r2c3 = r2c3 * multiplier;
|
||||
inverted->r2c1 = r2c1 * multiplier;
|
||||
inverted->r2c2 = r2c2 * multiplier;
|
||||
inverted->r2c3 = r2c3 * multiplier;
|
||||
|
||||
matrix->r3c1 = r3c1 * multiplier;
|
||||
matrix->r3c2 = r3c2 * multiplier;
|
||||
matrix->r3c3 = r3c3 * multiplier;
|
||||
inverted->r3c1 = r3c1 * multiplier;
|
||||
inverted->r3c2 = r3c2 * multiplier;
|
||||
inverted->r3c3 = r3c3 * multiplier;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int bgc_matrix3x3_invert_fp64(BgcMatrix3x3FP64* matrix)
|
||||
int bgc_matrix3x3_invert_fp64(const BgcMatrix3x3FP64* matrix, BgcMatrix3x3FP64* inverted)
|
||||
{
|
||||
const double determinant = bgc_matrix3x3_get_determinant_fp64(matrix);
|
||||
|
||||
if (-BGC_EPSYLON_FP64 <= determinant && determinant <= BGC_EPSYLON_FP64) {
|
||||
if (bgc_is_zero_fp64(determinant)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -133,93 +130,17 @@ int bgc_matrix3x3_invert_fp64(BgcMatrix3x3FP64* matrix)
|
|||
|
||||
const double multiplier = 1.0 / determinant;
|
||||
|
||||
matrix->r1c1 = r1c1 * multiplier;
|
||||
matrix->r1c2 = r1c2 * multiplier;
|
||||
matrix->r1c3 = r1c3 * multiplier;
|
||||
inverted->r1c1 = r1c1 * multiplier;
|
||||
inverted->r1c2 = r1c2 * multiplier;
|
||||
inverted->r1c3 = r1c3 * multiplier;
|
||||
|
||||
matrix->r2c1 = r2c1 * multiplier;
|
||||
matrix->r2c2 = r2c2 * multiplier;
|
||||
matrix->r2c3 = r2c3 * multiplier;
|
||||
inverted->r2c1 = r2c1 * multiplier;
|
||||
inverted->r2c2 = r2c2 * multiplier;
|
||||
inverted->r2c3 = r2c3 * multiplier;
|
||||
|
||||
matrix->r3c1 = r3c1 * multiplier;
|
||||
matrix->r3c2 = r3c2 * multiplier;
|
||||
matrix->r3c3 = r3c3 * multiplier;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ================ Get Inverted ================ //
|
||||
|
||||
int bgc_matrix3x3_get_inverted_fp32(const BgcMatrix3x3FP32* matrix, BgcMatrix3x3FP32* result)
|
||||
{
|
||||
const float determinant = bgc_matrix3x3_get_determinant_fp32(matrix);
|
||||
|
||||
if (-BGC_EPSYLON_FP32 <= determinant && determinant <= BGC_EPSYLON_FP32) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const float r1c1 = matrix->r2c2 * matrix->r3c3 - matrix->r2c3 * matrix->r3c2;
|
||||
const float r1c2 = matrix->r1c3 * matrix->r3c2 - matrix->r1c2 * matrix->r3c3;
|
||||
const float r1c3 = matrix->r1c2 * matrix->r2c3 - matrix->r1c3 * matrix->r2c2;
|
||||
|
||||
const float r2c1 = matrix->r2c3 * matrix->r3c1 - matrix->r2c1 * matrix->r3c3;
|
||||
const float r2c2 = matrix->r1c1 * matrix->r3c3 - matrix->r1c3 * matrix->r3c1;
|
||||
const float r2c3 = matrix->r1c3 * matrix->r2c1 - matrix->r1c1 * matrix->r2c3;
|
||||
|
||||
const float r3c1 = matrix->r2c1 * matrix->r3c2 - matrix->r2c2 * matrix->r3c1;
|
||||
const float r3c2 = matrix->r1c2 * matrix->r3c1 - matrix->r1c1 * matrix->r3c2;
|
||||
const float r3c3 = matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
|
||||
|
||||
const float multiplier = 1.0f / determinant;
|
||||
|
||||
result->r1c1 = r1c1 * multiplier;
|
||||
result->r1c2 = r1c2 * multiplier;
|
||||
result->r1c3 = r1c3 * multiplier;
|
||||
|
||||
result->r2c1 = r2c1 * multiplier;
|
||||
result->r2c2 = r2c2 * multiplier;
|
||||
result->r2c3 = r2c3 * multiplier;
|
||||
|
||||
result->r3c1 = r3c1 * multiplier;
|
||||
result->r3c2 = r3c2 * multiplier;
|
||||
result->r3c3 = r3c3 * multiplier;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int bgc_matrix3x3_get_inverted_fp64(const BgcMatrix3x3FP64* matrix, BgcMatrix3x3FP64* result)
|
||||
{
|
||||
const double determinant = bgc_matrix3x3_get_determinant_fp64(matrix);
|
||||
|
||||
if (-BGC_EPSYLON_FP64 <= determinant && determinant <= BGC_EPSYLON_FP64) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const double r1c1 = matrix->r2c2 * matrix->r3c3 - matrix->r2c3 * matrix->r3c2;
|
||||
const double r1c2 = matrix->r1c3 * matrix->r3c2 - matrix->r1c2 * matrix->r3c3;
|
||||
const double r1c3 = matrix->r1c2 * matrix->r2c3 - matrix->r1c3 * matrix->r2c2;
|
||||
|
||||
const double r2c1 = matrix->r2c3 * matrix->r3c1 - matrix->r2c1 * matrix->r3c3;
|
||||
const double r2c2 = matrix->r1c1 * matrix->r3c3 - matrix->r1c3 * matrix->r3c1;
|
||||
const double r2c3 = matrix->r1c3 * matrix->r2c1 - matrix->r1c1 * matrix->r2c3;
|
||||
|
||||