Удаление избыточных функций и небольшие исправления / Removing of extra methods and small fixes
This commit is contained in:
parent
049f09f3d4
commit
67f66e2127
6 changed files with 176 additions and 602 deletions
184
src/matrix2x2.h
184
src/matrix2x2.h
|
|
@ -365,102 +365,6 @@ static inline void dp_matrix2x2_add(const DPMatrix2x2* matrix1, const DPMatrix2x
|
|||
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
|
||||
}
|
||||
|
||||
// ==================== Add3 ==================== //
|
||||
|
||||
static inline void sp_matrix2x2_add3(
|
||||
const SPMatrix2x2* matrix1,
|
||||
const SPMatrix2x2* matrix2,
|
||||
const SPMatrix2x2* matrix3,
|
||||
SPMatrix2x2* sum
|
||||
)
|
||||
{
|
||||
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1 + matrix3->r1c1;
|
||||
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2 + matrix3->r1c2;
|
||||
|
||||
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1 + matrix3->r2c1;
|
||||
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2 + matrix3->r2c2;
|
||||
}
|
||||
|
||||
static inline void dp_matrix2x2_add3(
|
||||
const DPMatrix2x2* matrix1,
|
||||
const DPMatrix2x2* matrix2,
|
||||
const DPMatrix2x2* matrix3,
|
||||
DPMatrix2x2* sum
|
||||
)
|
||||
{
|
||||
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1 + matrix3->r1c1;
|
||||
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2 + matrix3->r1c2;
|
||||
|
||||
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1 + matrix3->r2c1;
|
||||
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2 + matrix3->r2c2;
|
||||
}
|
||||
|
||||
// ==================== Add4 ==================== //
|
||||
|
||||
static inline void sp_matrix2x2_add4(
|
||||
const SPMatrix2x2* matrix1,
|
||||
const SPMatrix2x2* matrix2,
|
||||
const SPMatrix2x2* matrix3,
|
||||
const SPMatrix2x2* matrix4,
|
||||
SPMatrix2x2* sum
|
||||
)
|
||||
{
|
||||
sum->r1c1 = (matrix1->r1c1 + matrix2->r1c1) + (matrix3->r1c1 + matrix4->r1c1);
|
||||
sum->r1c2 = (matrix1->r1c2 + matrix2->r1c2) + (matrix3->r1c2 + matrix4->r1c2);
|
||||
|
||||
sum->r2c1 = (matrix1->r2c1 + matrix2->r2c1) + (matrix3->r2c1 + matrix4->r2c1);
|
||||
sum->r2c2 = (matrix1->r2c2 + matrix2->r2c2) + (matrix3->r2c2 + matrix4->r2c2);
|
||||
}
|
||||
|
||||
static inline void dp_matrix2x2_add4(
|
||||
const DPMatrix2x2* matrix1,
|
||||
const DPMatrix2x2* matrix2,
|
||||
const DPMatrix2x2* matrix3,
|
||||
const DPMatrix2x2* matrix4,
|
||||
DPMatrix2x2* sum
|
||||
)
|
||||
{
|
||||
sum->r1c1 = (matrix1->r1c1 + matrix2->r1c1) + (matrix3->r1c1 + matrix4->r1c1);
|
||||
sum->r1c2 = (matrix1->r1c2 + matrix2->r1c2) + (matrix3->r1c2 + matrix4->r1c2);
|
||||
|
||||
sum->r2c1 = (matrix1->r2c1 + matrix2->r2c1) + (matrix3->r2c1 + matrix4->r2c1);
|
||||
sum->r2c2 = (matrix1->r2c2 + matrix2->r2c2) + (matrix3->r2c2 + matrix4->r2c2);
|
||||
}
|
||||
|
||||
// ==================== Add5 ==================== //
|
||||
|
||||
static inline void sp_matrix2x2_add5(
|
||||
const SPMatrix2x2* matrix1,
|
||||
const SPMatrix2x2* matrix2,
|
||||
const SPMatrix2x2* matrix3,
|
||||
const SPMatrix2x2* matrix4,
|
||||
const SPMatrix2x2* matrix5,
|
||||
SPMatrix2x2* sum
|
||||
)
|
||||
{
|
||||
sum->r1c1 = (matrix1->r1c1 + matrix2->r1c1) + (matrix3->r1c1 + matrix4->r1c1) + matrix5->r1c1;
|
||||
sum->r1c2 = (matrix1->r1c2 + matrix2->r1c2) + (matrix3->r1c2 + matrix4->r1c2) + matrix5->r1c2;
|
||||
|
||||
sum->r2c1 = (matrix1->r2c1 + matrix2->r2c1) + (matrix3->r2c1 + matrix4->r2c1) + matrix5->r2c1;
|
||||
sum->r2c2 = (matrix1->r2c2 + matrix2->r2c2) + (matrix3->r2c2 + matrix4->r2c2) + matrix5->r2c2;
|
||||
}
|
||||
|
||||
static inline void dp_matrix2x2_add5(
|
||||
const DPMatrix2x2* matrix1,
|
||||
const DPMatrix2x2* matrix2,
|
||||
const DPMatrix2x2* matrix3,
|
||||
const DPMatrix2x2* matrix4,
|
||||
const DPMatrix2x2* matrix5,
|
||||
DPMatrix2x2* sum
|
||||
)
|
||||
{
|
||||
sum->r1c1 = (matrix1->r1c1 + matrix2->r1c1) + (matrix3->r1c1 + matrix4->r1c1) + matrix5->r1c1;
|
||||
sum->r1c2 = (matrix1->r1c2 + matrix2->r1c2) + (matrix3->r1c2 + matrix4->r1c2) + matrix5->r1c2;
|
||||
|
||||
sum->r2c1 = (matrix1->r2c1 + matrix2->r2c1) + (matrix3->r2c1 + matrix4->r2c1) + matrix5->r2c1;
|
||||
sum->r2c2 = (matrix1->r2c2 + matrix2->r2c2) + (matrix3->r2c2 + matrix4->r2c2) + matrix5->r2c2;
|
||||
}
|
||||
|
||||
// ================ Subtraction ================= //
|
||||
|
||||
static inline void sp_matrix2x2_subtract(const SPMatrix2x2* minuend, const SPMatrix2x2* subtrahend, SPMatrix2x2* difference)
|
||||
|
|
@ -481,6 +385,46 @@ static inline void dp_matrix2x2_subtract(const DPMatrix2x2* minuend, const DPMat
|
|||
difference->r2c2 = minuend->r2c2 - subtrahend->r2c2;
|
||||
}
|
||||
|
||||
// =============== Multiplication =============== //
|
||||
|
||||
static inline void sp_matrix2x2_multiply(const SPMatrix2x2* multiplicand, const float multiplier, SPMatrix2x2* product)
|
||||
{
|
||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||
|
||||
product->r2c1 = multiplicand->r2c1 * multiplier;
|
||||
product->r2c2 = multiplicand->r2c2 * multiplier;
|
||||
}
|
||||
|
||||
static inline void dp_matrix2x2_multiply(const DPMatrix2x2* multiplicand, const double multiplier, DPMatrix2x2* product)
|
||||
{
|
||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||
|
||||
product->r2c1 = multiplicand->r2c1 * multiplier;
|
||||
product->r2c2 = multiplicand->r2c2 * multiplier;
|
||||
}
|
||||
|
||||
// ================== Division ================== //
|
||||
|
||||
static inline void sp_matrix2x2_divide(const SPMatrix2x2* dividend, const float divisor, SPMatrix2x2* quotient)
|
||||
{
|
||||
quotient->r1c1 = dividend->r1c1 / divisor;
|
||||
quotient->r1c2 = dividend->r1c2 / divisor;
|
||||
|
||||
quotient->r2c1 = dividend->r2c1 / divisor;
|
||||
quotient->r2c2 = dividend->r2c2 / divisor;
|
||||
}
|
||||
|
||||
static inline void dp_matrix2x2_divide(const DPMatrix2x2* dividend, const double divisor, DPMatrix2x2* quotient)
|
||||
{
|
||||
quotient->r1c1 = dividend->r1c1 / divisor;
|
||||
quotient->r1c2 = dividend->r1c2 / divisor;
|
||||
|
||||
quotient->r2c1 = dividend->r2c1 / divisor;
|
||||
quotient->r2c2 = dividend->r2c2 / divisor;
|
||||
}
|
||||
|
||||
// ============= Weighed Sum of two ============= //
|
||||
|
||||
static inline void sp_matrix2x2_get_weighted_sum2(
|
||||
|
|
@ -605,51 +549,11 @@ static inline void dp_matrix2x2_get_weighted_sum5(
|
|||
sum->r2c2 = (matrix1->r2c2 * weight1 + matrix2->r2c2 * weight2) + (matrix3->r2c2 * weight3 + matrix4->r2c2 * weight4) + matrix5->r2c2 * weight5;
|
||||
}
|
||||
|
||||
// =============== Multiplication =============== //
|
||||
|
||||
static inline void sp_matrix2x2_multiply(const SPMatrix2x2* multiplicand, const float multiplier, SPMatrix2x2* product)
|
||||
{
|
||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||
|
||||
product->r2c1 = multiplicand->r2c1 * multiplier;
|
||||
product->r2c2 = multiplicand->r2c2 * multiplier;
|
||||
}
|
||||
|
||||
static inline void dp_matrix2x2_multiply(const DPMatrix2x2* multiplicand, const double multiplier, DPMatrix2x2* product)
|
||||
{
|
||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||
|
||||
product->r2c1 = multiplicand->r2c1 * multiplier;
|
||||
product->r2c2 = multiplicand->r2c2 * multiplier;
|
||||
}
|
||||
|
||||
// ================== Division ================== //
|
||||
|
||||
static inline void sp_matrix2x2_divide(const SPMatrix2x2* dividend, const float divisor, SPMatrix2x2* quotient)
|
||||
{
|
||||
quotient->r1c1 = dividend->r1c1 / divisor;
|
||||
quotient->r1c2 = dividend->r1c2 / divisor;
|
||||
|
||||
quotient->r2c1 = dividend->r2c1 / divisor;
|
||||
quotient->r2c2 = dividend->r2c2 / divisor;
|
||||
}
|
||||
|
||||
static inline void dp_matrix2x2_divide(const DPMatrix2x2* dividend, const double divisor, DPMatrix2x2* quotient)
|
||||
{
|
||||
quotient->r1c1 = dividend->r1c1 / divisor;
|
||||
quotient->r1c2 = dividend->r1c2 / divisor;
|
||||
|
||||
quotient->r2c1 = dividend->r2c1 / divisor;
|
||||
quotient->r2c2 = dividend->r2c2 / divisor;
|
||||
}
|
||||
|
||||
// ============ Left Vector Product ============= //
|
||||
|
||||
static inline void sp_matrix2x2_left_product(const SPVector2* vector, const SPMatrix2x2* matrix, SPVector2* result)
|
||||
{
|
||||
sp_vector2_set(
|
||||
sp_vector2_set_values(
|
||||
vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1,
|
||||
vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2,
|
||||
result
|
||||
|
|
@ -658,7 +562,7 @@ static inline void sp_matrix2x2_left_product(const SPVector2* vector, const SPMa
|
|||
|
||||
static inline void dp_matrix2x2_left_product(const DPVector2* vector, const DPMatrix2x2* matrix, DPVector2* result)
|
||||
{
|
||||
dp_vector2_set(
|
||||
dp_vector2_set_values(
|
||||
vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1,
|
||||
vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2,
|
||||
result
|
||||
|
|
@ -669,7 +573,7 @@ static inline void dp_matrix2x2_left_product(const DPVector2* vector, const DPMa
|
|||
|
||||
static inline void sp_matrix2x2_right_product(const SPMatrix2x2* matrix, const SPVector2* vector, SPVector2* result)
|
||||
{
|
||||
sp_vector2_set(
|
||||
sp_vector2_set_values(
|
||||
matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2,
|
||||
matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2,
|
||||
result
|
||||
|
|
@ -678,7 +582,7 @@ static inline void sp_matrix2x2_right_product(const SPMatrix2x2* matrix, const S
|
|||
|
||||
static inline void dp_matrix2x2_right_product(const DPMatrix2x2* matrix, const DPVector2* vector, DPVector2* result)
|
||||
{
|
||||
dp_vector2_set(
|
||||
dp_vector2_set_values(
|
||||
matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2,
|
||||
matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2,
|
||||
result
|
||||
|
|
|
|||
272
src/matrix3x3.h
272
src/matrix3x3.h
|
|
@ -236,9 +236,9 @@ static inline void dp_matrix3x3_transpose(DPMatrix3x3* matrix)
|
|||
|
||||
// ================ Make Inverted =============== //
|
||||
|
||||
int sp_matrix3x3_make_inverted(const SPMatrix3x3* matrix, SPMatrix3x3* result);
|
||||
int sp_matrix3x3_set_inverted(const SPMatrix3x3* matrix, SPMatrix3x3* result);
|
||||
|
||||
int dp_matrix3x3_make_inverted(const DPMatrix3x3* matrix, DPMatrix3x3* result);
|
||||
int dp_matrix3x3_set_inverted(const DPMatrix3x3* matrix, DPMatrix3x3* result);
|
||||
|
||||
// =============== Make Transposed ============== //
|
||||
|
||||
|
|
@ -426,138 +426,6 @@ static inline void dp_matrix3x3_add(const DPMatrix3x3* matrix1, const DPMatrix3x
|
|||
sum->r3c3 = matrix1->r3c3 + matrix2->r3c3;
|
||||
}
|
||||
|
||||
// ==================== Add3 ==================== //
|
||||
|
||||
static inline void sp_matrix3x3_add3(
|
||||
const SPMatrix3x3* matrix1,
|
||||
const SPMatrix3x3* matrix2,
|
||||
const SPMatrix3x3* matrix3,
|
||||
SPMatrix3x3* sum
|
||||
)
|
||||
{
|
||||
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1 + matrix3->r1c1;
|
||||
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2 + matrix3->r1c2;
|
||||
sum->r1c3 = matrix1->r1c3 + matrix2->r1c3 + matrix3->r1c3;
|
||||
|
||||
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1 + matrix3->r2c1;
|
||||
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2 + matrix3->r2c2;
|
||||
sum->r2c3 = matrix1->r2c3 + matrix2->r2c3 + matrix3->r2c3;
|
||||
|
||||
sum->r3c1 = matrix1->r3c1 + matrix2->r3c1 + matrix3->r3c1;
|
||||
sum->r3c2 = matrix1->r3c2 + matrix2->r3c2 + matrix3->r3c2;
|
||||
sum->r3c3 = matrix1->r3c3 + matrix2->r3c3 + matrix3->r3c3;
|
||||
}
|
||||
|
||||
static inline void dp_matrix3x3_add3(
|
||||
const DPMatrix3x3* matrix1,
|
||||
const DPMatrix3x3* matrix2,
|
||||
const DPMatrix3x3* matrix3,
|
||||
DPMatrix3x3* sum
|
||||
)
|
||||
{
|
||||
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1 + matrix3->r1c1;
|
||||
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2 + matrix3->r1c2;
|
||||
sum->r1c3 = matrix1->r1c3 + matrix2->r1c3 + matrix3->r1c3;
|
||||
|
||||
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1 + matrix3->r2c1;
|
||||
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2 + matrix3->r2c2;
|
||||
sum->r2c3 = matrix1->r2c3 + matrix2->r2c3 + matrix3->r2c3;
|
||||
|
||||
sum->r3c1 = matrix1->r3c1 + matrix2->r3c1 + matrix3->r3c1;
|
||||
sum->r3c2 = matrix1->r3c2 + matrix2->r3c2 + matrix3->r3c2;
|
||||
sum->r3c3 = matrix1->r3c3 + matrix2->r3c3 + matrix3->r3c3;
|
||||
}
|
||||
|
||||
// ==================== Add4 ==================== //
|
||||
|
||||
static inline void sp_matrix3x3_add4(
|
||||
const SPMatrix3x3* matrix1,
|
||||
const SPMatrix3x3* matrix2,
|
||||
const SPMatrix3x3* matrix3,
|
||||
const SPMatrix3x3* matrix4,
|
||||
SPMatrix3x3* sum
|
||||
)
|
||||
{
|
||||
sum->r1c1 = (matrix1->r1c1 + matrix2->r1c1) + (matrix3->r1c1 + matrix4->r1c1);
|
||||
sum->r1c2 = (matrix1->r1c2 + matrix2->r1c2) + (matrix3->r1c2 + matrix4->r1c2);
|
||||
sum->r1c2 = (matrix1->r1c3 + matrix2->r1c3) + (matrix3->r1c3 + matrix4->r1c3);
|
||||
|
||||
sum->r2c1 = (matrix1->r2c1 + matrix2->r2c1) + (matrix3->r2c1 + matrix4->r2c1);
|
||||
sum->r2c2 = (matrix1->r2c2 + matrix2->r2c2) + (matrix3->r2c2 + matrix4->r2c2);
|
||||
sum->r2c3 = (matrix1->r2c3 + matrix2->r2c3) + (matrix3->r2c3 + matrix4->r2c3);
|
||||
|
||||
sum->r3c1 = (matrix1->r3c1 + matrix2->r3c1) + (matrix3->r3c1 + matrix4->r3c1);
|
||||
sum->r3c2 = (matrix1->r3c2 + matrix2->r3c2) + (matrix3->r3c2 + matrix4->r3c2);
|
||||
sum->r3c3 = (matrix1->r3c3 + matrix2->r3c3) + (matrix3->r3c3 + matrix4->r3c3);
|
||||
}
|
||||
|
||||
static inline void dp_matrix3x3_add4(
|
||||
const DPMatrix3x3* matrix1,
|
||||
const DPMatrix3x3* matrix2,
|
||||
const DPMatrix3x3* matrix3,
|
||||
const DPMatrix3x3* matrix4,
|
||||
DPMatrix3x3* sum
|
||||
)
|
||||
{
|
||||
sum->r1c1 = (matrix1->r1c1 + matrix2->r1c1) + (matrix3->r1c1 + matrix4->r1c1);
|
||||
sum->r1c2 = (matrix1->r1c2 + matrix2->r1c2) + (matrix3->r1c2 + matrix4->r1c2);
|
||||
sum->r1c2 = (matrix1->r1c3 + matrix2->r1c3) + (matrix3->r1c3 + matrix4->r1c3);
|
||||
|
||||
sum->r2c1 = (matrix1->r2c1 + matrix2->r2c1) + (matrix3->r2c1 + matrix4->r2c1);
|
||||
sum->r2c2 = (matrix1->r2c2 + matrix2->r2c2) + (matrix3->r2c2 + matrix4->r2c2);
|
||||
sum->r2c3 = (matrix1->r2c3 + matrix2->r2c3) + (matrix3->r2c3 + matrix4->r2c3);
|
||||
|
||||
sum->r3c1 = (matrix1->r3c1 + matrix2->r3c1) + (matrix3->r3c1 + matrix4->r3c1);
|
||||
sum->r3c2 = (matrix1->r3c2 + matrix2->r3c2) + (matrix3->r3c2 + matrix4->r3c2);
|
||||
sum->r3c3 = (matrix1->r3c3 + matrix2->r3c3) + (matrix3->r3c3 + matrix4->r3c3);
|
||||
}
|
||||
|
||||
// ==================== Add5 ==================== //
|
||||
|
||||
static inline void sp_matrix3x3_add5(
|
||||
const SPMatrix3x3* matrix1,
|
||||
const SPMatrix3x3* matrix2,
|
||||
const SPMatrix3x3* matrix3,
|
||||
const SPMatrix3x3* matrix4,
|
||||
const SPMatrix3x3* matrix5,
|
||||
SPMatrix3x3* sum
|
||||
)
|
||||
{
|
||||
sum->r1c1 = (matrix1->r1c1 + matrix2->r1c1) + (matrix3->r1c1 + matrix4->r1c1) + matrix5->r1c1;
|
||||
sum->r1c2 = (matrix1->r1c2 + matrix2->r1c2) + (matrix3->r1c2 + matrix4->r1c2) + matrix5->r1c2;
|
||||
sum->r1c3 = (matrix1->r1c3 + matrix2->r1c3) + (matrix3->r1c3 + matrix4->r1c3) + matrix5->r1c3;
|
||||
|
||||
sum->r2c1 = (matrix1->r2c1 + matrix2->r2c1) + (matrix3->r2c1 + matrix4->r2c1) + matrix5->r2c1;
|
||||
sum->r2c2 = (matrix1->r2c2 + matrix2->r2c2) + (matrix3->r2c2 + matrix4->r2c2) + matrix5->r2c2;
|
||||
sum->r2c3 = (matrix1->r2c3 + matrix2->r2c3) + (matrix3->r2c3 + matrix4->r2c3) + matrix5->r2c3;
|
||||
|
||||
sum->r3c1 = (matrix1->r3c1 + matrix2->r3c1) + (matrix3->r3c1 + matrix4->r3c1) + matrix5->r3c1;
|
||||
sum->r3c2 = (matrix1->r3c2 + matrix2->r3c2) + (matrix3->r3c2 + matrix4->r3c2) + matrix5->r3c2;
|
||||
sum->r3c3 = (matrix1->r3c3 + matrix2->r3c3) + (matrix3->r3c3 + matrix4->r3c3) + matrix5->r3c3;
|
||||
}
|
||||
|
||||
static inline void dp_matrix3x3_add5(
|
||||
const DPMatrix3x3* matrix1,
|
||||
const DPMatrix3x3* matrix2,
|
||||
const DPMatrix3x3* matrix3,
|
||||
const DPMatrix3x3* matrix4,
|
||||
const DPMatrix3x3* matrix5,
|
||||
DPMatrix3x3* sum
|
||||
)
|
||||
{
|
||||
sum->r1c1 = (matrix1->r1c1 + matrix2->r1c1) + (matrix3->r1c1 + matrix4->r1c1) + matrix5->r1c1;
|
||||
sum->r1c2 = (matrix1->r1c2 + matrix2->r1c2) + (matrix3->r1c2 + matrix4->r1c2) + matrix5->r1c2;
|
||||
sum->r1c3 = (matrix1->r1c3 + matrix2->r1c3) + (matrix3->r1c3 + matrix4->r1c3) + matrix5->r1c3;
|
||||
|
||||
sum->r2c1 = (matrix1->r2c1 + matrix2->r2c1) + (matrix3->r2c1 + matrix4->r2c1) + matrix5->r2c1;
|
||||
sum->r2c2 = (matrix1->r2c2 + matrix2->r2c2) + (matrix3->r2c2 + matrix4->r2c2) + matrix5->r2c2;
|
||||
sum->r2c3 = (matrix1->r2c3 + matrix2->r2c3) + (matrix3->r2c3 + matrix4->r2c3) + matrix5->r2c3;
|
||||
|
||||
sum->r3c1 = (matrix1->r3c1 + matrix2->r3c1) + (matrix3->r3c1 + matrix4->r3c1) + matrix5->r3c1;
|
||||
sum->r3c2 = (matrix1->r3c2 + matrix2->r3c2) + (matrix3->r3c2 + matrix4->r3c2) + matrix5->r3c2;
|
||||
sum->r3c3 = (matrix1->r3c3 + matrix2->r3c3) + (matrix3->r3c3 + matrix4->r3c3) + matrix5->r3c3;
|
||||
}
|
||||
|
||||
// ================ Subtraction ================= //
|
||||
|
||||
static inline void sp_matrix3x3_subtract(const SPMatrix3x3* minuend, const SPMatrix3x3* subtrahend, SPMatrix3x3* difference)
|
||||
|
|
@ -590,6 +458,70 @@ static inline void dp_matrix3x3_subtract(const DPMatrix3x3* minuend, const DPMat
|
|||
difference->r3c3 = minuend->r3c3 - subtrahend->r3c3;
|
||||
}
|
||||
|
||||
// =============== Multiplication =============== //
|
||||
|
||||
static inline void sp_matrix3x3_multiply(const SPMatrix3x3* multiplicand, const float multiplier, SPMatrix3x3* product)
|
||||
{
|
||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||
product->r1c3 = multiplicand->r1c3 * multiplier;
|
||||
|
||||
product->r2c1 = multiplicand->r2c1 * multiplier;
|
||||
product->r2c2 = multiplicand->r2c2 * multiplier;
|
||||
product->r2c3 = multiplicand->r2c3 * multiplier;
|
||||
|
||||
product->r3c1 = multiplicand->r3c1 * multiplier;
|
||||
product->r3c2 = multiplicand->r3c2 * multiplier;
|
||||
product->r3c3 = multiplicand->r3c3 * multiplier;
|
||||
}
|
||||
|
||||
static inline void dp_matrix3x3_multiply(const DPMatrix3x3* multiplicand, const double multiplier, DPMatrix3x3* product)
|
||||
{
|
||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||
product->r1c3 = multiplicand->r1c3 * multiplier;
|
||||
|
||||
product->r2c1 = multiplicand->r2c1 * multiplier;
|
||||
product->r2c2 = multiplicand->r2c2 * multiplier;
|
||||
product->r2c3 = multiplicand->r2c3 * multiplier;
|
||||
|
||||
product->r3c1 = multiplicand->r3c1 * multiplier;
|
||||
product->r3c2 = multiplicand->r3c2 * multiplier;
|
||||
product->r3c3 = multiplicand->r3c3 * multiplier;
|
||||
}
|
||||
|
||||
// ================== Division ================== //
|
||||
|
||||
static inline void sp_matrix3x3_divide(const SPMatrix3x3* dividend, const float divisor, SPMatrix3x3* quotient)
|
||||
{
|
||||
quotient->r1c1 = dividend->r1c1 / divisor;
|
||||
quotient->r1c2 = dividend->r1c2 / divisor;
|
||||
quotient->r1c3 = dividend->r1c3 / divisor;
|
||||
|
||||
quotient->r2c1 = dividend->r2c1 / divisor;
|
||||
quotient->r2c2 = dividend->r2c2 / divisor;
|
||||
quotient->r2c3 = dividend->r2c3 / divisor;
|
||||
|
||||
quotient->r3c1 = dividend->r3c1 / divisor;
|
||||
quotient->r3c2 = dividend->r3c2 / divisor;
|
||||
quotient->r3c3 = dividend->r3c3 / divisor;
|
||||
}
|
||||
|
||||
static inline void dp_matrix3x3_divide(const DPMatrix3x3* dividend, const double divisor, DPMatrix3x3* quotient)
|
||||
{
|
||||
quotient->r1c1 = dividend->r1c1 / divisor;
|
||||
quotient->r1c2 = dividend->r1c2 / divisor;
|
||||
quotient->r1c3 = dividend->r1c3 / divisor;
|
||||
|
||||
quotient->r2c1 = dividend->r2c1 / divisor;
|
||||
quotient->r2c2 = dividend->r2c2 / divisor;
|
||||
quotient->r2c3 = dividend->r2c3 / divisor;
|
||||
|
||||
quotient->r3c1 = dividend->r3c1 / divisor;
|
||||
quotient->r3c2 = dividend->r3c2 / divisor;
|
||||
quotient->r3c3 = dividend->r3c3 / divisor;
|
||||
}
|
||||
|
||||
// ============= Weighed Sum of two ============= //
|
||||
|
||||
void sp_matrix3x3_get_weighted_sum2(
|
||||
|
|
@ -658,75 +590,11 @@ void dp_matrix3x3_get_weighted_sum5(
|
|||
DPMatrix3x3* sum
|
||||
);
|
||||
|
||||
// =============== Multiplication =============== //
|
||||
|
||||
static inline void sp_matrix3x3_multiply(const SPMatrix3x3* multiplicand, const float multiplier, SPMatrix3x3* product)
|
||||
{
|
||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||
product->r1c3 = multiplicand->r1c3 * multiplier;
|
||||
|
||||
product->r2c1 = multiplicand->r2c1 * multiplier;
|
||||
product->r2c2 = multiplicand->r2c2 * multiplier;
|
||||
product->r2c3 = multiplicand->r2c3 * multiplier;
|
||||
|
||||
product->r3c1 = multiplicand->r3c1 * multiplier;
|
||||
product->r3c2 = multiplicand->r3c2 * multiplier;
|
||||
product->r3c3 = multiplicand->r3c3 * multiplier;
|
||||
}
|
||||
|
||||
static inline void dp_matrix3x3_multiply(const DPMatrix3x3* multiplicand, const double multiplier, DPMatrix3x3* product)
|
||||
{
|
||||
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||
product->r1c3 = multiplicand->r1c3 * multiplier;
|
||||
|
||||
product->r2c1 = multiplicand->r2c1 * multiplier;
|
||||
product->r2c2 = multiplicand->r2c2 * multiplier;
|
||||
product->r2c3 = multiplicand->r2c3 * multiplier;
|
||||
|
||||
product->r3c1 = multiplicand->r3c1 * multiplier;
|
||||
product->r3c2 = multiplicand->r3c2 * multiplier;
|
||||
product->r3c3 = multiplicand->r3c3 * multiplier;
|
||||
}
|
||||
|
||||
// ================== Division ================== //
|
||||
|
||||
static inline void sp_matrix3x3_divide(const SPMatrix3x3* dividend, const float divisor, SPMatrix3x3* quotient)
|
||||
{
|
||||
quotient->r1c1 = dividend->r1c1 / divisor;
|
||||
quotient->r1c2 = dividend->r1c2 / divisor;
|
||||
quotient->r1c3 = dividend->r1c3 / divisor;
|
||||
|
||||
quotient->r2c1 = dividend->r2c1 / divisor;
|
||||
quotient->r2c2 = dividend->r2c2 / divisor;
|
||||
quotient->r2c3 = dividend->r2c3 / divisor;
|
||||
|
||||
quotient->r3c1 = dividend->r3c1 / divisor;
|
||||
quotient->r3c2 = dividend->r3c2 / divisor;
|
||||
quotient->r3c3 = dividend->r3c3 / divisor;
|
||||
}
|
||||
|
||||
static inline void dp_matrix3x3_divide(const DPMatrix3x3* dividend, const double divisor, DPMatrix3x3* quotient)
|
||||
{
|
||||
quotient->r1c1 = dividend->r1c1 / divisor;
|
||||
quotient->r1c2 = dividend->r1c2 / divisor;
|
||||
quotient->r1c3 = dividend->r1c3 / divisor;
|
||||
|
||||
quotient->r2c1 = dividend->r2c1 / divisor;
|
||||
quotient->r2c2 = dividend->r2c2 / divisor;
|
||||
quotient->r2c3 = dividend->r2c3 / divisor;
|
||||
|
||||
quotient->r3c1 = dividend->r3c1 / divisor;
|
||||
quotient->r3c2 = dividend->r3c2 / divisor;
|
||||
quotient->r3c3 = dividend->r3c3 / divisor;
|
||||
}
|
||||
|
||||
// ============ Left Vector Product ============= //
|
||||
|
||||
static inline void sp_matrix3x3_left_product(const SPVector3* vector, const SPMatrix3x3* matrix, SPVector3* result)
|
||||
{
|
||||
sp_vector3_set(
|
||||
sp_vector3_set_values(
|
||||
vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1,
|
||||
vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2,
|
||||
vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3 + vector->x3 * matrix->r3c3,
|
||||
|
|
@ -736,7 +604,7 @@ static inline void sp_matrix3x3_left_product(const SPVector3* vector, const SPMa
|
|||
|
||||
static inline void dp_matrix3x3_left_product(const DPVector3* vector, const DPMatrix3x3* matrix, DPVector3* result)
|
||||
{
|
||||
dp_vector3_set(
|
||||
dp_vector3_set_values(
|
||||
vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1,
|
||||
vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2,
|
||||
vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3 + vector->x3 * matrix->r3c3,
|
||||
|
|
@ -748,7 +616,7 @@ static inline void dp_matrix3x3_left_product(const DPVector3* vector, const DPMa
|
|||
|
||||
static inline void sp_matrix3x3_right_product(const SPMatrix3x3* matrix, const SPVector3* vector, SPVector3* result)
|
||||
{
|
||||
sp_vector3_set(
|
||||
sp_vector3_set_values(
|
||||
matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3,
|
||||
matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3,
|
||||
matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3,
|
||||
|
|
@ -758,7 +626,7 @@ static inline void sp_matrix3x3_right_product(const SPMatrix3x3* matrix, const S
|
|||
|
||||
static inline void dp_matrix3x3_right_product(const DPMatrix3x3* matrix, const DPVector3* vector, DPVector3* result)
|
||||
{
|
||||
dp_vector3_set(
|
||||
dp_vector3_set_values(
|
||||
matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3,
|
||||
matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3,
|
||||
matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3,
|
||||
|
|
|
|||
|
|
@ -1,13 +1,5 @@
|
|||
#include "vector2.h"
|
||||
|
||||