Отказ от функций getWeightedSum в пользу appendScaled; оптимизация версоров / Replacing of getWeightedSum onto appendScaled; versor optimization
This commit is contained in:
parent
7bd9c07f17
commit
e354b2425c
13 changed files with 331 additions and 835 deletions
144
src/matrix2x2.h
144
src/matrix2x2.h
|
|
@ -345,6 +345,26 @@ static inline void dp_matrix2x2_set_column2(const double r1, const double r2, DP
|
||||||
matrix->r2c2 = r2;
|
matrix->r2c2 = r2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ================ Append scaled =============== //
|
||||||
|
|
||||||
|
static inline void sp_matrix2x2_append_scaled(SPMatrix2x2* basic_vector, const SPMatrix2x2* scalable_vector, const float scale)
|
||||||
|
{
|
||||||
|
basic_vector->r1c1 += scalable_vector->r1c1 * scale;
|
||||||
|
basic_vector->r1c2 += scalable_vector->r1c2 * scale;
|
||||||
|
|
||||||
|
basic_vector->r2c1 += scalable_vector->r2c1 * scale;
|
||||||
|
basic_vector->r2c2 += scalable_vector->r2c2 * scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix2x2_append_scaled(DPMatrix2x2* basic_vector, const DPMatrix2x2* scalable_vector, const double scale)
|
||||||
|
{
|
||||||
|
basic_vector->r1c1 += scalable_vector->r1c1 * scale;
|
||||||
|
basic_vector->r1c2 += scalable_vector->r1c2 * scale;
|
||||||
|
|
||||||
|
basic_vector->r2c1 += scalable_vector->r2c1 * scale;
|
||||||
|
basic_vector->r2c2 += scalable_vector->r2c2 * scale;
|
||||||
|
}
|
||||||
|
|
||||||
// ================== Addition ================== //
|
// ================== Addition ================== //
|
||||||
|
|
||||||
static inline void sp_matrix2x2_add(const SPMatrix2x2* matrix1, const SPMatrix2x2* matrix2, SPMatrix2x2* sum)
|
static inline void sp_matrix2x2_add(const SPMatrix2x2* matrix1, const SPMatrix2x2* matrix2, SPMatrix2x2* sum)
|
||||||
|
|
@ -425,130 +445,6 @@ static inline void dp_matrix2x2_divide(const DPMatrix2x2* dividend, const double
|
||||||
quotient->r2c2 = dividend->r2c2 / divisor;
|
quotient->r2c2 = dividend->r2c2 / divisor;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============= Weighed Sum of two ============= //
|
|
||||||
|
|
||||||
static inline void sp_matrix2x2_get_weighted_sum2(
|
|
||||||
const float weight1, const SPMatrix2x2* matrix1,
|
|
||||||
const float weight2, const SPMatrix2x2* matrix2,
|
|
||||||
SPMatrix2x2* sum
|
|
||||||
)
|
|
||||||
{
|
|
||||||
sum->r1c1 = matrix1->r1c1 * weight1 + matrix2->r1c1 * weight2;
|
|
||||||
sum->r1c2 = matrix1->r1c2 * weight1 + matrix2->r1c2 * weight2;
|
|
||||||
|
|
||||||
sum->r2c1 = matrix1->r2c1 * weight1 + matrix2->r2c1 * weight2;
|
|
||||||
sum->r2c2 = matrix1->r2c2 * weight1 + matrix2->r2c2 * weight2;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void dp_matrix2x2_get_weighted_sum2(
|
|
||||||
const double weight1, const DPMatrix2x2* matrix1,
|
|
||||||
const double weight2, const DPMatrix2x2* matrix2,
|
|
||||||
DPMatrix2x2* sum
|
|
||||||
)
|
|
||||||
{
|
|
||||||
sum->r1c1 = matrix1->r1c1 * weight1 + matrix2->r1c1 * weight2;
|
|
||||||
sum->r1c2 = matrix1->r1c2 * weight1 + matrix2->r1c2 * weight2;
|
|
||||||
|
|
||||||
sum->r2c1 = matrix1->r2c1 * weight1 + matrix2->r2c1 * weight2;
|
|
||||||
sum->r2c2 = matrix1->r2c2 * weight1 + matrix2->r2c2 * weight2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ============ Weighed Sum of three ============ //
|
|
||||||
|
|
||||||
static inline void sp_matrix2x2_get_weighted_sum3(
|
|
||||||
const float weight1, const SPMatrix2x2* matrix1,
|
|
||||||
const float weight2, const SPMatrix2x2* matrix2,
|
|
||||||
const float weight3, const SPMatrix2x2* matrix3,
|
|
||||||
SPMatrix2x2* sum
|
|
||||||
)
|
|
||||||
{
|
|
||||||
sum->r1c1 = matrix1->r1c1 * weight1 + matrix2->r1c1 * weight2 + matrix3->r1c1 * weight3;
|
|
||||||
sum->r1c2 = matrix1->r1c2 * weight1 + matrix2->r1c2 * weight2 + matrix3->r1c2 * weight3;
|
|
||||||
|
|
||||||
sum->r2c1 = matrix1->r2c1 * weight1 + matrix2->r2c1 * weight2 + matrix3->r2c1 * weight3;
|
|
||||||
sum->r2c2 = matrix1->r2c2 * weight1 + matrix2->r2c2 * weight2 + matrix3->r2c2 * weight3;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void dp_matrix2x2_get_weighted_sum3(
|
|
||||||
const double weight1, const DPMatrix2x2* matrix1,
|
|
||||||
const double weight2, const DPMatrix2x2* matrix2,
|
|
||||||
const double weight3, const DPMatrix2x2* matrix3,
|
|
||||||
DPMatrix2x2* sum
|
|
||||||
)
|
|
||||||
{
|
|
||||||
sum->r1c1 = matrix1->r1c1 * weight1 + matrix2->r1c1 * weight2 + matrix3->r1c1 * weight3;
|
|
||||||
sum->r1c2 = matrix1->r1c2 * weight1 + matrix2->r1c2 * weight2 + matrix3->r1c2 * weight3;
|
|
||||||
|
|
||||||
sum->r2c1 = matrix1->r2c1 * weight1 + matrix2->r2c1 * weight2 + matrix3->r2c1 * weight3;
|
|
||||||
sum->r2c2 = matrix1->r2c2 * weight1 + matrix2->r2c2 * weight2 + matrix3->r2c2 * weight3;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ============ Weighed Sum of four ============= //
|
|
||||||
|
|
||||||
static inline void sp_matrix2x2_get_weighted_sum4(
|
|
||||||
const float weight1, const SPMatrix2x2* matrix1,
|
|
||||||
const float weight2, const SPMatrix2x2* matrix2,
|
|
||||||
const float weight3, const SPMatrix2x2* matrix3,
|
|
||||||
const float weight4, const SPMatrix2x2* matrix4,
|
|
||||||
SPMatrix2x2* sum
|
|
||||||
)
|
|
||||||
{
|
|
||||||
sum->r1c1 = (matrix1->r1c1 * weight1 + matrix2->r1c1 * weight2) + (matrix3->r1c1 * weight3 + matrix4->r1c1 * weight4);
|
|
||||||
sum->r1c2 = (matrix1->r1c2 * weight1 + matrix2->r1c2 * weight2) + (matrix3->r1c2 * weight3 + matrix4->r1c2 * weight4);
|
|
||||||
|
|
||||||
sum->r2c1 = (matrix1->r2c1 * weight1 + matrix2->r2c1 * weight2) + (matrix3->r2c1 * weight3 + matrix4->r2c1 * weight4);
|
|
||||||
sum->r2c2 = (matrix1->r2c2 * weight1 + matrix2->r2c2 * weight2) + (matrix3->r2c2 * weight3 + matrix4->r2c2 * weight4);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void dp_matrix2x2_get_weighted_sum4(
|
|
||||||
const double weight1, const DPMatrix2x2* matrix1,
|
|
||||||
const double weight2, const DPMatrix2x2* matrix2,
|
|
||||||
const double weight3, const DPMatrix2x2* matrix3,
|
|
||||||
const double weight4, const DPMatrix2x2* matrix4,
|
|
||||||
DPMatrix2x2* sum
|
|
||||||
)
|
|
||||||
{
|
|
||||||
sum->r1c1 = (matrix1->r1c1 * weight1 + matrix2->r1c1 * weight2) + (matrix3->r1c1 * weight3 + matrix4->r1c1 * weight4);
|
|
||||||
sum->r1c2 = (matrix1->r1c2 * weight1 + matrix2->r1c2 * weight2) + (matrix3->r1c2 * weight3 + matrix4->r1c2 * weight4);
|
|
||||||
|
|
||||||
sum->r2c1 = (matrix1->r2c1 * weight1 + matrix2->r2c1 * weight2) + (matrix3->r2c1 * weight3 + matrix4->r2c1 * weight4);
|
|
||||||