Добавлены матрицы 2x3 и 3x2, добавлены произведения матриц. Изменения в названиях функций
This commit is contained in:
parent
86486ac9cf
commit
049f09f3d4
31 changed files with 1831 additions and 1314 deletions
|
@ -1,29 +1,5 @@
|
|||
#include "matrix3x3.h"
|
||||
|
||||
const SPMatrix3x3 SP_ZERO_MATRIX3X3 = {
|
||||
0.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f
|
||||
};
|
||||
|
||||
const DPMatrix3x3 DP_ZERO_MATRIX3X3 = {
|
||||
0.0, 0.0, 0.0,
|
||||
0.0, 0.0, 0.0,
|
||||
0.0, 0.0, 0.0
|
||||
};
|
||||
|
||||
const SPMatrix3x3 SP_IDENTITY_MATRIX3X3 = {
|
||||
1.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f,
|
||||
0.0f, 0.0f, 1.0f
|
||||
};
|
||||
|
||||
const DPMatrix3x3 DP_IDENTITY_MATRIX3X3 = {
|
||||
1.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 1.0
|
||||
};
|
||||
|
||||
// ================= Inversion ================== //
|
||||
|
||||
int sp_matrix3x3_invert(SPMatrix3x3* matrix)
|
||||
|
@ -339,59 +315,3 @@ void dp_matrix3x3_get_weighted_sum5(
|
|||
sum->r3c2 = (matrix1->r3c2 * weight1 + matrix2->r3c2 * weight2) + (matrix3->r3c2 * weight3 + matrix4->r3c2 * weight4) + matrix5->r3c2 * weight5;
|
||||
sum->r3c3 = (matrix1->r3c3 * weight1 + matrix2->r3c3 * weight2) + (matrix3->r3c3 * weight3 + matrix4->r3c3 * weight4) + matrix5->r3c3 * weight5;
|
||||
}
|
||||
|
||||
// =============== Matrix Product =============== //
|
||||
|
||||
void sp_matrix3x3_matrix_product(const SPMatrix3x3* matrix1, const SPMatrix3x3* matrix2, SPMatrix3x3* result)
|
||||
{
|
||||
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
|
||||
|
||||
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
|
||||
|
||||
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
|
||||
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
|
||||
const float r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3 + matrix1->r3c3 * matrix2->r3c3;
|
||||
|
||||
result->r1c1 = r1c1;
|
||||
result->r1c2 = r1c2;
|
||||
result->r1c3 = r1c3;
|
||||
|
||||
result->r2c1 = r2c1;
|
||||
result->r2c2 = r2c2;
|
||||
result->r2c3 = r2c3;
|
||||
|
||||
result->r3c1 = r3c1;
|
||||
result->r3c2 = r3c2;
|
||||
result->r3c3 = r3c3;
|
||||
}
|
||||
|
||||
void dp_matrix3x3_matrix_product(const DPMatrix3x3* matrix1, const DPMatrix3x3* matrix2, DPMatrix3x3* result)
|
||||
{
|
||||
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
|
||||
|
||||
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
|
||||
|
||||
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
|
||||
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
|
||||
const double r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3 + matrix1->r3c3 * matrix2->r3c3;
|
||||
|
||||
result->r1c1 = r1c1;
|
||||
result->r1c2 = r1c2;
|
||||
result->r1c3 = r1c3;
|
||||
|
||||
result->r2c1 = r2c1;
|
||||
result->r2c2 = r2c2;
|
||||
result->r2c3 = r2c3;
|
||||
|
||||
result->r3c1 = r3c1;
|
||||
result->r3c2 = r3c2;
|
||||
result->r3c3 = r3c3;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue