Добавлены функции для матриц 2x3 и 3x2 / New functions for matrixes 2x3 and 3x2 have been added
This commit is contained in:
parent
67f66e2127
commit
07c1330858
11 changed files with 902 additions and 52 deletions
|
@ -176,7 +176,7 @@ int main()
|
||||||
{
|
{
|
||||||
SPVector2 vector;
|
SPVector2 vector;
|
||||||
|
|
||||||
sp_vector2_set(0, 0, &vector);
|
sp_vector2_set_values(0, 0, &vector);
|
||||||
|
|
||||||
printf("SPVector2(%f, %f), module = %d\n",
|
printf("SPVector2(%f, %f), module = %d\n",
|
||||||
vector.x1,
|
vector.x1,
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "matrixes.h"
|
#include "matrixes.h"
|
||||||
#include "matrix2x2.h"
|
#include "matrix2x2.h"
|
||||||
#include "matrix2x3.h"
|
#include "matrix2x3.h"
|
||||||
|
#include "matrix3x2.h"
|
||||||
#include "matrix3x3.h"
|
#include "matrix3x3.h"
|
||||||
|
|
||||||
#include "rotation3.h"
|
#include "rotation3.h"
|
||||||
|
|
|
@ -23,7 +23,10 @@
|
||||||
<ClInclude Include="basis.h" />
|
<ClInclude Include="basis.h" />
|
||||||
<ClInclude Include="geometry.h" />
|
<ClInclude Include="geometry.h" />
|
||||||
<ClInclude Include="matrix2x2.h" />
|
<ClInclude Include="matrix2x2.h" />
|
||||||
|
<ClInclude Include="matrix2x3.h" />
|
||||||
|
<ClInclude Include="matrix3x2.h" />
|
||||||
<ClInclude Include="matrix3x3.h" />
|
<ClInclude Include="matrix3x3.h" />
|
||||||
|
<ClInclude Include="matrixes.h" />
|
||||||
<ClInclude Include="quaternion.h" />
|
<ClInclude Include="quaternion.h" />
|
||||||
<ClInclude Include="rotation3.h" />
|
<ClInclude Include="rotation3.h" />
|
||||||
<ClInclude Include="versor.h" />
|
<ClInclude Include="versor.h" />
|
||||||
|
@ -34,7 +37,10 @@
|
||||||
<ClCompile Include="angle.c" />
|
<ClCompile Include="angle.c" />
|
||||||
<ClCompile Include="basis.c" />
|
<ClCompile Include="basis.c" />
|
||||||
<ClCompile Include="matrix2x2.c" />
|
<ClCompile Include="matrix2x2.c" />
|
||||||
|
<ClCompile Include="matrix2x3.c" />
|
||||||
|
<ClCompile Include="matrix3x2.c" />
|
||||||
<ClCompile Include="matrix3x3.c" />
|
<ClCompile Include="matrix3x3.c" />
|
||||||
|
<ClCompile Include="matrixes.c" />
|
||||||
<ClCompile Include="quaternion.c" />
|
<ClCompile Include="quaternion.c" />
|
||||||
<ClCompile Include="rotation3.c" />
|
<ClCompile Include="rotation3.c" />
|
||||||
<ClCompile Include="versor.c" />
|
<ClCompile Include="versor.c" />
|
||||||
|
|
|
@ -45,6 +45,15 @@
|
||||||
<ClInclude Include="quaternion.h">
|
<ClInclude Include="quaternion.h">
|
||||||
<Filter>Файлы заголовков</Filter>
|
<Filter>Файлы заголовков</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="matrix2x3.h">
|
||||||
|
<Filter>Файлы заголовков</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="matrix3x2.h">
|
||||||
|
<Filter>Файлы заголовков</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="matrixes.h">
|
||||||
|
<Filter>Файлы заголовков</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="angle.c">
|
<ClCompile Include="angle.c">
|
||||||
|
@ -74,5 +83,14 @@
|
||||||
<ClCompile Include="quaternion.c">
|
<ClCompile Include="quaternion.c">
|
||||||
<Filter>Исходные файлы</Filter>
|
<Filter>Исходные файлы</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="matrixes.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="matrix2x3.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="matrix3x2.c">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
149
src/matrix2x3.c
Normal file
149
src/matrix2x3.c
Normal file
|
@ -0,0 +1,149 @@
|
||||||
|
#include "matrix2x3.h"
|
||||||
|
|
||||||
|
// ============= Weighed Sum of two ============= //
|
||||||
|
|
||||||
|
void sp_matrix2x3_get_weighted_sum2(
|
||||||
|
const float weight1, const SPMatrix2x3* matrix1,
|
||||||
|
const float weight2, const SPMatrix2x3* matrix2,
|
||||||
|
SPMatrix2x3* 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;
|
||||||
|
|
||||||
|
sum->r3c1 = matrix1->r3c1 * weight1 + matrix2->r3c1 * weight2;
|
||||||
|
sum->r3c2 = matrix1->r3c2 * weight1 + matrix2->r3c2 * weight2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dp_matrix2x3_get_weighted_sum2(
|
||||||
|
const double weight1, const DPMatrix2x3* matrix1,
|
||||||
|
const double weight2, const DPMatrix2x3* matrix2,
|
||||||
|
DPMatrix2x3* 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;
|
||||||
|
|
||||||
|
sum->r3c1 = matrix1->r3c1 * weight1 + matrix2->r3c1 * weight2;
|
||||||
|
sum->r3c2 = matrix1->r3c2 * weight1 + matrix2->r3c2 * weight2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============ Weighed Sum of three ============ //
|
||||||
|
|
||||||
|
void sp_matrix2x3_get_weighted_sum3(
|
||||||
|
const float weight1, const SPMatrix2x3* matrix1,
|
||||||
|
const float weight2, const SPMatrix2x3* matrix2,
|
||||||
|
const float weight3, const SPMatrix2x3* matrix3,
|
||||||
|
SPMatrix2x3* 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;
|
||||||
|
|
||||||
|
sum->r3c1 = matrix1->r3c1 * weight1 + matrix2->r3c1 * weight2 + matrix3->r3c1 * weight3;
|
||||||
|
sum->r3c2 = matrix1->r3c2 * weight1 + matrix2->r3c2 * weight2 + matrix3->r3c2 * weight3;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dp_matrix2x3_get_weighted_sum3(
|
||||||
|
const double weight1, const DPMatrix2x3* matrix1,
|
||||||
|
const double weight2, const DPMatrix2x3* matrix2,
|
||||||
|
const double weight3, const DPMatrix2x3* matrix3,
|
||||||
|
DPMatrix2x3* 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;
|
||||||
|
|
||||||
|
sum->r3c1 = matrix1->r3c1 * weight1 + matrix2->r3c1 * weight2 + matrix3->r3c1 * weight3;
|
||||||
|
sum->r3c2 = matrix1->r3c2 * weight1 + matrix2->r3c2 * weight2 + matrix3->r3c2 * weight3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============ Weighed Sum of four ============= //
|
||||||
|
|
||||||
|
void sp_matrix2x3_get_weighted_sum4(
|
||||||
|
const float weight1, const SPMatrix2x3* matrix1,
|
||||||
|
const float weight2, const SPMatrix2x3* matrix2,
|
||||||
|
const float weight3, const SPMatrix2x3* matrix3,
|
||||||
|
const float weight4, const SPMatrix2x3* matrix4,
|
||||||
|
SPMatrix2x3* 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);
|
||||||
|
|
||||||
|
sum->r3c1 = (matrix1->r3c1 * weight1 + matrix2->r3c1 * weight2) + (matrix3->r3c1 * weight3 + matrix4->r3c1 * weight4);
|
||||||
|
sum->r3c2 = (matrix1->r3c2 * weight1 + matrix2->r3c2 * weight2) + (matrix3->r3c2 * weight3 + matrix4->r3c2 * weight4);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dp_matrix2x3_get_weighted_sum4(
|
||||||
|
const double weight1, const DPMatrix2x3* matrix1,
|
||||||
|
const double weight2, const DPMatrix2x3* matrix2,
|
||||||
|
const double weight3, const DPMatrix2x3* matrix3,
|
||||||
|
const double weight4, const DPMatrix2x3* matrix4,
|
||||||
|
DPMatrix2x3* 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);
|
||||||
|
|
||||||
|
sum->r3c1 = (matrix1->r3c1 * weight1 + matrix2->r3c1 * weight2) + (matrix3->r3c1 * weight3 + matrix4->r3c1 * weight4);
|
||||||
|
sum->r3c2 = (matrix1->r3c2 * weight1 + matrix2->r3c2 * weight2) + (matrix3->r3c2 * weight3 + matrix4->r3c2 * weight4);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============ Weighed Sum of five ============= //
|
||||||
|
|
||||||
|
void sp_matrix2x3_get_weighted_sum5(
|
||||||
|
const float weight1, const SPMatrix2x3* matrix1,
|
||||||
|
const float weight2, const SPMatrix2x3* matrix2,
|
||||||
|
const float weight3, const SPMatrix2x3* matrix3,
|
||||||
|
const float weight4, const SPMatrix2x3* matrix4,
|
||||||
|
const float weight5, const SPMatrix2x3* matrix5,
|
||||||
|
SPMatrix2x3* sum
|
||||||
|
)
|
||||||
|
{
|
||||||
|
sum->r1c1 = (matrix1->r1c1 * weight1 + matrix2->r1c1 * weight2) + (matrix3->r1c1 * weight3 + matrix4->r1c1 * weight4) + matrix5->r1c1 * weight5;
|
||||||
|
sum->r1c2 = (matrix1->r1c2 * weight1 + matrix2->r1c2 * weight2) + (matrix3->r1c2 * weight3 + matrix4->r1c2 * weight4) + matrix5->r1c2 * weight5;
|
||||||
|
|
||||||
|
sum->r2c1 = (matrix1->r2c1 * weight1 + matrix2->r2c1 * weight2) + (matrix3->r2c1 * weight3 + matrix4->r2c1 * weight4) + matrix5->r2c1 * weight5;
|
||||||
|
sum->r2c2 = (matrix1->r2c2 * weight1 + matrix2->r2c2 * weight2) + (matrix3->r2c2 * weight3 + matrix4->r2c2 * weight4) + matrix5->r2c2 * weight5;
|
||||||
|
|
||||||
|
sum->r3c1 = (matrix1->r3c1 * weight1 + matrix2->r3c1 * weight2) + (matrix3->r3c1 * weight3 + matrix4->r3c1 * weight4) + matrix5->r3c1 * weight5;
|
||||||
|
sum->r3c2 = (matrix1->r3c2 * weight1 + matrix2->r3c2 * weight2) + (matrix3->r3c2 * weight3 + matrix4->r3c2 * weight4) + matrix5->r3c2 * weight5;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dp_matrix2x3_get_weighted_sum5(
|
||||||
|
const double weight1, const DPMatrix2x3* matrix1,
|
||||||
|
const double weight2, const DPMatrix2x3* matrix2,
|
||||||
|
const double weight3, const DPMatrix2x3* matrix3,
|
||||||
|
const double weight4, const DPMatrix2x3* matrix4,
|
||||||
|
const double weight5, const DPMatrix2x3* matrix5,
|
||||||
|
DPMatrix2x3* sum
|
||||||
|
)
|
||||||
|
{
|
||||||
|
sum->r1c1 = (matrix1->r1c1 * weight1 + matrix2->r1c1 * weight2) + (matrix3->r1c1 * weight3 + matrix4->r1c1 * weight4) + matrix5->r1c1 * weight5;
|
||||||
|
sum->r1c2 = (matrix1->r1c2 * weight1 + matrix2->r1c2 * weight2) + (matrix3->r1c2 * weight3 + matrix4->r1c2 * weight4) + matrix5->r1c2 * weight5;
|
||||||
|
|
||||||
|
sum->r2c1 = (matrix1->r2c1 * weight1 + matrix2->r2c1 * weight2) + (matrix3->r2c1 * weight3 + matrix4->r2c1 * weight4) + matrix5->r2c1 * weight5;
|
||||||
|
sum->r2c2 = (matrix1->r2c2 * weight1 + matrix2->r2c2 * weight2) + (matrix3->r2c2 * weight3 + matrix4->r2c2 * weight4) + matrix5->r2c2 * weight5;
|
||||||
|
|
||||||
|
sum->r3c1 = (matrix1->r3c1 * weight1 + matrix2->r3c1 * weight2) + (matrix3->r3c1 * weight3 + matrix4->r3c1 * weight4) + matrix5->r3c1 * weight5;
|
||||||
|
sum->r3c2 = (matrix1->r3c2 * weight1 + matrix2->r3c2 * weight2) + (matrix3->r3c2 * weight3 + matrix4->r3c2 * weight4) + matrix5->r3c2 * weight5;
|
||||||
|
}
|
279
src/matrix2x3.h
279
src/matrix2x3.h
|
@ -37,15 +37,12 @@ static inline void sp_matrix2x3_copy(const SPMatrix2x3* from, SPMatrix2x3* to)
|
||||||
{
|
{
|
||||||
to->r1c1 = from->r1c1;
|
to->r1c1 = from->r1c1;
|
||||||
to->r1c2 = from->r1c2;
|
to->r1c2 = from->r1c2;
|
||||||
to->r1c3 = from->r1c3;
|
|
||||||
|
|
||||||
to->r2c1 = from->r2c1;
|
to->r2c1 = from->r2c1;
|
||||||
to->r2c2 = from->r2c2;
|
to->r2c2 = from->r2c2;
|
||||||
to->r2c3 = from->r2c3;
|
|
||||||
|
|
||||||
to->r3c1 = from->r3c1;
|
to->r3c1 = from->r3c1;
|
||||||
to->r3c2 = from->r3c2;
|
to->r3c2 = from->r3c2;
|
||||||
to->r3c3 = from->r3c3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dp_matrix2x3_copy(const DPMatrix2x3* from, DPMatrix2x3* to)
|
static inline void dp_matrix2x3_copy(const DPMatrix2x3* from, DPMatrix2x3* to)
|
||||||
|
@ -138,4 +135,280 @@ static inline void dp_matrix2x3_transpose_single(const SPMatrix3x2* from, DPMatr
|
||||||
to->r3c2 = from->r2c3;
|
to->r3c2 = from->r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ================= Set Row 1 ================== //
|
||||||
|
|
||||||
|
static inline void sp_matrix2x3_set_row1(const float c1, const float c2, SPMatrix2x3* matrix)
|
||||||
|
{
|
||||||
|
matrix->r1c1 = c1;
|
||||||
|
matrix->r1c2 = c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix2x3_set_row1(const double c1, const double c2, DPMatrix2x3* matrix)
|
||||||
|
{
|
||||||
|
matrix->r1c1 = c1;
|
||||||
|
matrix->r1c2 = c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================= Set Row 2 ================== //
|
||||||
|
|
||||||
|
static inline void sp_matrix2x3_set_row2(const float c1, const float c2, SPMatrix2x3* matrix)
|
||||||
|
{
|
||||||
|
matrix->r2c1 = c1;
|
||||||
|
matrix->r2c2 = c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix2x3_set_row2(const double c1, const double c2, DPMatrix2x3* matrix)
|
||||||
|
{
|
||||||
|
matrix->r2c1 = c1;
|
||||||
|
matrix->r2c2 = c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================= Set Row 3 ================== //
|
||||||
|
|
||||||
|
static inline void sp_matrix2x3_set_row3(const float c1, const float c2, SPMatrix2x3* matrix)
|
||||||
|
{
|
||||||
|
matrix->r3c1 = c1;
|
||||||
|
matrix->r3c2 = c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix2x3_set_row3(const double c1, const double c2, DPMatrix2x3* matrix)
|
||||||
|
{
|
||||||
|
matrix->r3c1 = c1;
|
||||||
|
matrix->r3c2 = c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================ Set Column 1 ================ //
|
||||||
|
|
||||||
|
static inline void sp_matrix2x3_set_column1(const float r1, const float r2, const float r3, SPMatrix2x3* matrix)
|
||||||
|
{
|
||||||
|
matrix->r1c1 = r1;
|
||||||
|
matrix->r2c1 = r2;
|
||||||
|
matrix->r3c1 = r3;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix2x3_set_column1(const double r1, const double r2, const double r3, DPMatrix2x3* matrix)
|
||||||
|
{
|
||||||
|
matrix->r1c1 = r1;
|
||||||
|
matrix->r2c1 = r2;
|
||||||
|
matrix->r3c1 = r3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================ Set Column 2 ================ //
|
||||||
|
|
||||||
|
static inline void sp_matrix2x3_set_column2(const float r1, const float r2, const float r3, SPMatrix2x3* matrix)
|
||||||
|
{
|
||||||
|
matrix->r1c2 = r1;
|
||||||
|
matrix->r2c2 = r2;
|
||||||
|
matrix->r3c2 = r3;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix2x3_set_column2(const double r1, const double r2, const double r3, DPMatrix2x3* matrix)
|
||||||
|
{
|
||||||
|
matrix->r1c2 = r1;
|
||||||
|
matrix->r2c2 = r2;
|
||||||
|
matrix->r3c2 = r3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================== Addition ================== //
|
||||||
|
|
||||||
|
static inline void sp_matrix2x3_add(const SPMatrix2x3* matrix1, const SPMatrix2x3* matrix2, SPMatrix2x3* sum)
|
||||||
|
{
|
||||||
|
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
||||||
|
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
||||||
|
|
||||||
|
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
|
||||||
|
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
|
||||||
|
|
||||||
|
sum->r3c1 = matrix1->r3c1 + matrix2->r3c1;
|
||||||
|
sum->r3c2 = matrix1->r3c2 + matrix2->r3c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix2x3_add(const DPMatrix2x3* matrix1, const DPMatrix2x3* matrix2, DPMatrix2x3* sum)
|
||||||
|
{
|
||||||
|
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
||||||
|
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
||||||
|
|
||||||
|
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
|
||||||
|
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
|
||||||
|
|
||||||
|
sum->r3c1 = matrix1->r3c1 + matrix2->r3c1;
|
||||||
|
sum->r3c2 = matrix1->r3c2 + matrix2->r3c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================ Subtraction ================= //
|
||||||
|
|
||||||
|
static inline void sp_matrix2x3_subtract(const SPMatrix2x3* minuend, const SPMatrix2x3* subtrahend, SPMatrix2x3* difference)
|
||||||
|
{
|
||||||
|
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
|
||||||
|
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
|
||||||
|
|
||||||
|
difference->r2c1 = minuend->r2c1 - subtrahend->r2c1;
|
||||||
|
difference->r2c2 = minuend->r2c2 - subtrahend->r2c2;
|
||||||
|
|
||||||
|
difference->r3c1 = minuend->r3c1 - subtrahend->r3c1;
|
||||||
|
difference->r3c2 = minuend->r3c2 - subtrahend->r3c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix2x3_subtract(const DPMatrix2x3* minuend, const DPMatrix2x3* subtrahend, DPMatrix2x3* difference)
|
||||||
|
{
|
||||||
|
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
|
||||||
|
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
|
||||||
|
|
||||||
|
difference->r2c1 = minuend->r2c1 - subtrahend->r2c1;
|
||||||
|
difference->r2c2 = minuend->r2c2 - subtrahend->r2c2;
|
||||||
|
|
||||||
|
difference->r3c1 = minuend->r3c1 - subtrahend->r3c1;
|
||||||
|
difference->r3c2 = minuend->r3c2 - subtrahend->r3c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =============== Multiplication =============== //
|
||||||
|
|
||||||
|
static inline void sp_matrix2x3_multiply(const SPMatrix2x3* multiplicand, const float multiplier, SPMatrix2x3* product)
|
||||||
|
{
|
||||||
|
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||||
|
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||||
|
|
||||||
|
product->r2c1 = multiplicand->r2c1 * multiplier;
|
||||||
|
product->r2c2 = multiplicand->r2c2 * multiplier;
|
||||||
|
|
||||||
|
product->r3c1 = multiplicand->r3c1 * multiplier;
|
||||||
|
product->r3c2 = multiplicand->r3c2 * multiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix2x3_multiply(const DPMatrix2x3* multiplicand, const double multiplier, DPMatrix2x3* product)
|
||||||
|
{
|
||||||
|
product->r1c1 = multiplicand->r1c1 * multiplier;
|
||||||
|
product->r1c2 = multiplicand->r1c2 * multiplier;
|
||||||
|
|
||||||
|
product->r2c1 = multiplicand->r2c1 * multiplier;
|
||||||
|
product->r2c2 = multiplicand->r2c2 * multiplier;
|
||||||
|
|
||||||
|
product->r3c1 = multiplicand->r3c1 * multiplier;
|
||||||
|
product->r3c2 = multiplicand->r3c2 * multiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================== Division ================== //
|
||||||
|
|
||||||
|
static inline void sp_matrix2x3_divide(const SPMatrix2x3* dividend, const float divisor, SPMatrix2x3* quotient)
|
||||||
|
{
|
||||||
|
quotient->r1c1 = dividend->r1c1 / divisor;
|
||||||
|
quotient->r1c2 = dividend->r1c2 / divisor;
|
||||||
|
|
||||||
|
quotient->r2c1 = dividend->r2c1 / divisor;
|
||||||
|
quotient->r2c2 = dividend->r2c2 / divisor;
|
||||||
|
|
||||||
|
quotient->r3c1 = dividend->r3c1 / divisor;
|
||||||
|
quotient->r3c2 = dividend->r3c2 / divisor;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix2x3_divide(const DPMatrix2x3* dividend, const double divisor, DPMatrix2x3* quotient)
|
||||||
|
{
|
||||||
|
quotient->r1c1 = dividend->r1c1 / divisor;
|
||||||
|
quotient->r1c2 = dividend->r1c2 / divisor;
|
||||||
|
|
||||||
|
quotient->r2c1 = dividend->r2c1 / divisor;
|
||||||
|
quotient->r2c2 = dividend->r2c2 / divisor;
|
||||||
|
|
||||||
|
quotient->r3c1 = dividend->r3c1 / divisor;
|
||||||
|
quotient->r3c2 = dividend->r3c2 / divisor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============= Weighed Sum of two ============= //
|
||||||
|
|
||||||
|
void sp_matrix2x3_get_weighted_sum2(
|
||||||
|
const float weight1, const SPMatrix2x3* matrix1,
|
||||||
|
const float weight2, const SPMatrix2x3* matrix2,
|
||||||
|
SPMatrix2x3* sum
|
||||||
|
);
|
||||||
|
|
||||||
|
void dp_matrix2x3_get_weighted_sum2(
|
||||||
|
const double weight1, const DPMatrix2x3* matrix1,
|
||||||
|
const double weight2, const DPMatrix2x3* matrix2,
|
||||||
|
DPMatrix2x3* sum
|
||||||
|
);
|
||||||
|
|
||||||
|
// ============ Weighed Sum of three ============ //
|
||||||
|
|
||||||
|
void sp_matrix2x3_get_weighted_sum3(
|
||||||
|
const float weight1, const SPMatrix2x3* matrix1,
|
||||||
|
const float weight2, const SPMatrix2x3* matrix2,
|
||||||
|
const float weight3, const SPMatrix2x3* matrix3,
|
||||||
|
SPMatrix2x3* sum
|
||||||
|
);
|
||||||
|
|
||||||
|
void dp_matrix2x3_get_weighted_sum3(
|
||||||
|
const double weight1, const DPMatrix2x3* matrix1,
|
||||||
|
const double weight2, const DPMatrix2x3* matrix2,
|
||||||
|
const double weight3, const DPMatrix2x3* matrix3,
|
||||||
|
DPMatrix2x3* sum
|
||||||
|
);
|
||||||
|
|
||||||
|
// ============ Weighed Sum of four ============= //
|
||||||
|
|
||||||
|
void sp_matrix2x3_get_weighted_sum4(
|
||||||
|
const float weight1, const SPMatrix2x3* matrix1,
|
||||||
|
const float weight2, const SPMatrix2x3* matrix2,
|
||||||
|
const float weight3, const SPMatrix2x3* matrix3,
|
||||||
|
const float weight4, const SPMatrix2x3* matrix4,
|
||||||
|
SPMatrix2x3* sum
|
||||||
|
);
|
||||||
|
|
||||||
|
void dp_matrix2x3_get_weighted_sum4(
|
||||||
|
const double weight1, const DPMatrix2x3* matrix1,
|
||||||
|
const double weight2, const DPMatrix2x3* matrix2,
|
||||||
|
const double weight3, const DPMatrix2x3* matrix3,
|
||||||
|
const double weight4, const DPMatrix2x3* matrix4,
|
||||||
|
DPMatrix2x3* sum
|
||||||
|
);
|
||||||
|
|
||||||
|
// ============ Weighed Sum of five ============= //
|
||||||
|
|
||||||
|
void sp_matrix2x3_get_weighted_sum5(
|
||||||
|
const float weight1, const SPMatrix2x3* matrix1,
|
||||||
|
const float weight2, const SPMatrix2x3* matrix2,
|
||||||
|
const float weight3, const SPMatrix2x3* matrix3,
|
||||||
|
const float weight4, const SPMatrix2x3* matrix4,
|
||||||
|
const float weight5, const SPMatrix2x3* matrix5,
|
||||||
|
SPMatrix2x3* sum
|
||||||
|
);
|
||||||
|
|
||||||
|
void dp_matrix2x3_get_weighted_sum5(
|
||||||
|
const double weight1, const DPMatrix2x3* matrix1,
|
||||||
|
const double weight2, const DPMatrix2x3* matrix2,
|
||||||
|
const double weight3, const DPMatrix2x3* matrix3,
|
||||||
|
const double weight4, const DPMatrix2x3* matrix4,
|
||||||
|
const double weight5, const DPMatrix2x3* matrix5,
|
||||||
|
DPMatrix2x3* sum
|
||||||
|
);
|
||||||
|
|
||||||
|
// ============ Left Vector Product ============= //
|
||||||
|
|
||||||
|
static inline void sp_matrix2x3_left_product(const SPVector3* vector, const SPMatrix2x3* matrix, SPVector2* result)
|
||||||
|
{
|
||||||
|
result->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
||||||
|
result->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix2x3_left_product(const DPVector3* vector, const DPMatrix2x3* matrix, DPVector2* result)
|
||||||
|
{
|
||||||
|
result->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
|
||||||
|
result->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============ Right Vector Product ============ //
|
||||||
|
|
||||||
|
static inline void sp_matrix2x3_right_product(const SPMatrix2x3* matrix, const SPVector2* vector, SPVector3* result)
|
||||||
|
{
|
||||||
|
result->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
||||||
|
result->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
||||||
|
result->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix2x3_right_product(const DPMatrix2x3* matrix, const DPVector2* vector, DPVector3* result)
|
||||||
|
{
|
||||||
|
result->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
|
||||||
|
result->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
|
||||||
|
result->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
141
src/matrix3x2.c
Normal file
141
src/matrix3x2.c
Normal file
|
@ -0,0 +1,141 @@
|
||||||
|
#include "matrix3x2.h"
|
||||||
|
|
||||||
|
// ============= Weighed Sum of two ============= //
|
||||||
|
|
||||||
|
void sp_matrix3x2_get_weighted_sum2(
|
||||||
|
const float weight1, const SPMatrix3x2* matrix1,
|
||||||
|
const float weight2, const SPMatrix3x2* matrix2,
|
||||||
|
SPMatrix3x2* sum
|
||||||
|
)
|
||||||
|
{
|
||||||
|
sum->r1c1 = matrix1->r1c1 * weight1 + matrix2->r1c1 * weight2;
|
||||||
|
sum->r1c2 = matrix1->r1c2 * weight1 + matrix2->r1c2 * weight2;
|
||||||
|
sum->r1c3 = matrix1->r1c3 * weight1 + matrix2->r1c3 * weight2;
|
||||||
|
|
||||||
|
sum->r2c1 = matrix1->r2c1 * weight1 + matrix2->r2c1 * weight2;
|
||||||
|
sum->r2c2 = matrix1->r2c2 * weight1 + matrix2->r2c2 * weight2;
|
||||||
|
sum->r2c3 = matrix1->r2c3 * weight1 + matrix2->r2c3 * weight2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dp_matrix3x2_get_weighted_sum2(
|
||||||
|
const double weight1, const DPMatrix3x2* matrix1,
|
||||||
|
const double weight2, const DPMatrix3x2* matrix2,
|
||||||
|
DPMatrix3x2* sum
|
||||||
|
)
|
||||||
|
{
|
||||||
|
sum->r1c1 = matrix1->r1c1 * weight1 + matrix2->r1c1 * weight2;
|
||||||
|
sum->r1c2 = matrix1->r1c2 * weight1 + matrix2->r1c2 * weight2;
|
||||||
|
sum->r1c3 = matrix1->r1c3 * weight1 + matrix2->r1c3 * weight2;
|
||||||
|
|
||||||
|
sum->r2c1 = matrix1->r2c1 * weight1 + matrix2->r2c1 * weight2;
|
||||||
|
sum->r2c2 = matrix1->r2c2 * weight1 + matrix2->r2c2 * weight2;
|
||||||
|
sum->r2c3 = matrix1->r2c3 * weight1 + matrix2->r2c3 * weight2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============ Weighed Sum of three ============ //
|
||||||
|
|
||||||
|
void sp_matrix3x2_get_weighted_sum3(
|
||||||
|
const float weight1, const SPMatrix3x2* matrix1,
|
||||||
|
const float weight2, const SPMatrix3x2* matrix2,
|
||||||
|
const float weight3, const SPMatrix3x2* matrix3,
|
||||||
|
SPMatrix3x2* sum
|
||||||
|
)
|
||||||
|
{
|
||||||
|
sum->r1c1 = matrix1->r1c1 * weight1 + matrix2->r1c1 * weight2 + matrix3->r1c1 * weight3;
|
||||||
|
sum->r1c2 = matrix1->r1c2 * weight1 + matrix2->r1c2 * weight2 + matrix3->r1c2 * weight3;
|
||||||
|
sum->r1c3 = matrix1->r1c3 * weight1 + matrix2->r1c3 * weight2 + matrix3->r1c3 * weight3;
|
||||||
|
|
||||||
|
sum->r2c1 = matrix1->r2c1 * weight1 + matrix2->r2c1 * weight2 + matrix3->r2c1 * weight3;
|
||||||
|
sum->r2c2 = matrix1->r2c2 * weight1 + matrix2->r2c2 * weight2 + matrix3->r2c2 * weight3;
|
||||||
|
sum->r2c3 = matrix1->r2c3 * weight1 + matrix2->r2c3 * weight2 + matrix3->r2c3 * weight3;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dp_matrix3x2_get_weighted_sum3(
|
||||||
|
const double weight1, const DPMatrix3x2* matrix1,
|
||||||
|
const double weight2, const DPMatrix3x2* matrix2,
|
||||||
|
const double weight3, const DPMatrix3x2* matrix3,
|
||||||
|
DPMatrix3x2* sum
|
||||||
|
)
|
||||||
|
{
|
||||||
|
sum->r1c1 = matrix1->r1c1 * weight1 + matrix2->r1c1 * weight2 + matrix3->r1c1 * weight3;
|
||||||
|
sum->r1c2 = matrix1->r1c2 * weight1 + matrix2->r1c2 * weight2 + matrix3->r1c2 * weight3;
|
||||||
|
sum->r1c3 = matrix1->r1c3 * weight1 + matrix2->r1c3 * weight2 + matrix3->r1c3 * weight3;
|
||||||
|
|
||||||
|
sum->r2c1 = matrix1->r2c1 * weight1 + matrix2->r2c1 * weight2 + matrix3->r2c1 * weight3;
|
||||||
|
sum->r2c2 = matrix1->r2c2 * weight1 + matrix2->r2c2 * weight2 + matrix3->r2c2 * weight3;
|
||||||
|
sum->r2c3 = matrix1->r2c3 * weight1 + matrix2->r2c3 * weight2 + matrix3->r2c3 * weight3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============ Weighed Sum of four ============= //
|
||||||
|
|
||||||
|
void sp_matrix3x2_get_weighted_sum4(
|
||||||
|
const float weight1, const SPMatrix3x2* matrix1,
|
||||||
|
const float weight2, const SPMatrix3x2* matrix2,
|
||||||
|
const float weight3, const SPMatrix3x2* matrix3,
|
||||||
|
const float weight4, const SPMatrix3x2* matrix4,
|
||||||
|
SPMatrix3x2* 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->r1c3 = (matrix1->r1c3 * weight1 + matrix2->r1c3 * weight2) + (matrix3->r1c3 * weight3 + matrix4->r1c3 * 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);
|
||||||
|
sum->r2c3 = (matrix1->r2c3 * weight1 + matrix2->r2c3 * weight2) + (matrix3->r2c3 * weight3 + matrix4->r2c3 * weight4);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dp_matrix3x2_get_weighted_sum4(
|
||||||
|
const double weight1, const DPMatrix3x2* matrix1,
|
||||||
|
const double weight2, const DPMatrix3x2* matrix2,
|
||||||
|
const double weight3, const DPMatrix3x2* matrix3,
|
||||||
|
const double weight4, const DPMatrix3x2* matrix4,
|
||||||
|
DPMatrix3x2* 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->r1c3 = (matrix1->r1c3 * weight1 + matrix2->r1c3 * weight2) + (matrix3->r1c3 * weight3 + matrix4->r1c3 * 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);
|
||||||
|
sum->r2c3 = (matrix1->r2c3 * weight1 + matrix2->r2c3 * weight2) + (matrix3->r2c3 * weight3 + matrix4->r2c3 * weight4);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============ Weighed Sum of five ============= //
|
||||||
|
|
||||||
|
void sp_matrix3x2_get_weighted_sum5(
|
||||||
|
const float weight1, const SPMatrix3x2* matrix1,
|
||||||
|
const float weight2, const SPMatrix3x2* matrix2,
|
||||||
|
const float weight3, const SPMatrix3x2* matrix3,
|
||||||
|
const float weight4, const SPMatrix3x2* matrix4,
|
||||||
|
const float weight5, const SPMatrix3x2* matrix5,
|
||||||
|
SPMatrix3x2* sum
|
||||||
|
)
|
||||||
|
{
|
||||||
|
sum->r1c1 = (matrix1->r1c1 * weight1 + matrix2->r1c1 * weight2) + (matrix3->r1c1 * weight3 + matrix4->r1c1 * weight4) + matrix5->r1c1 * weight5;
|
||||||
|
sum->r1c2 = (matrix1->r1c2 * weight1 + matrix2->r1c2 * weight2) + (matrix3->r1c2 * weight3 + matrix4->r1c2 * weight4) + matrix5->r1c2 * weight5;
|
||||||
|
sum->r1c3 = (matrix1->r1c3 * weight1 + matrix2->r1c3 * weight2) + (matrix3->r1c3 * weight3 + matrix4->r1c3 * weight4) + matrix5->r1c3 * weight5;
|
||||||
|
|
||||||
|
sum->r2c1 = (matrix1->r2c1 * weight1 + matrix2->r2c1 * weight2) + (matrix3->r2c1 * weight3 + matrix4->r2c1 * weight4) + matrix5->r2c1 * weight5;
|
||||||
|
sum->r2c2 = (matrix1->r2c2 * weight1 + matrix2->r2c2 * weight2) + (matrix3->r2c2 * weight3 + matrix4->r2c2 * weight4) + matrix5->r2c2 * weight5;
|
||||||
|
sum->r2c3 = (matrix1->r2c3 * weight1 + matrix2->r2c3 * weight2) + (matrix3->r2c3 * weight3 + matrix4->r2c3 * weight4) + matrix5->r2c3 * weight5;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dp_matrix3x2_get_weighted_sum5(
|
||||||
|
const double weight1, const DPMatrix3x2* matrix1,
|
||||||
|
const double weight2, const DPMatrix3x2* matrix2,
|
||||||
|
const double weight3, const DPMatrix3x2* matrix3,
|
||||||
|
const double weight4, const DPMatrix3x2* matrix4,
|
||||||
|
const double weight5, const DPMatrix3x2* matrix5,
|
||||||
|
DPMatrix3x2* sum
|
||||||
|
)
|
||||||
|
{
|
||||||
|
sum->r1c1 = (matrix1->r1c1 * weight1 + matrix2->r1c1 * weight2) + (matrix3->r1c1 * weight3 + matrix4->r1c1 * weight4) + matrix5->r1c1 * weight5;
|
||||||
|
sum->r1c2 = (matrix1->r1c2 * weight1 + matrix2->r1c2 * weight2) + (matrix3->r1c2 * weight3 + matrix4->r1c2 * weight4) + matrix5->r1c2 * weight5;
|
||||||
|
sum->r1c3 = (matrix1->r1c3 * weight1 + matrix2->r1c3 * weight2) + (matrix3->r1c3 * weight3 + matrix4->r1c3 * weight4) + matrix5->r1c3 * weight5;
|
||||||
|
|
||||||
|
sum->r2c1 = (matrix1->r2c1 * weight1 + matrix2->r2c1 * weight2) + (matrix3->r2c1 * weight3 + matrix4->r2c1 * weight4) + matrix5->r2c1 * weight5;
|
||||||
|
sum->r2c2 = (matrix1->r2c2 * weight1 + matrix2->r2c2 * weight2) + (matrix3->r2c2 * weight3 + matrix4->r2c2 * weight4) + matrix5->r2c2 * weight5;
|
||||||
|
sum->r2c3 = (matrix1->r2c3 * weight1 + matrix2->r2c3 * weight2) + (matrix3->r2c3 * weight3 + matrix4->r2c3 * weight4) + matrix5->r2c3 * weight5;
|
||||||
|
}
|
272
src/matrix3x2.h
272
src/matrix3x2.h
|
@ -1,6 +1,10 @@
|
||||||
#ifndef _GEOMETRY_MATRIX3X2_H_
|
#ifndef _GEOMETRY_MATRIX3X2_H_
|
||||||
#define _GEOMETRY_MATRIX3X2_H_
|
#define _GEOMETRY_MATRIX3X2_H_
|
||||||
|
|
||||||
|
#include "vector2.h"
|
||||||
|
#include "vector3.h"
|
||||||
|
#include "matrixes.h"
|
||||||
|
|
||||||
// =================== Reset ==================== //
|
// =================== Reset ==================== //
|
||||||
|
|
||||||
static inline void sp_matrix3x2_reset(SPMatrix3x2* matrix)
|
static inline void sp_matrix3x2_reset(SPMatrix3x2* matrix)
|
||||||
|
@ -97,4 +101,272 @@ static inline void dp_matrix3x2_transpose_single(const SPMatrix2x3* from, DPMatr
|
||||||
to->r2c3 = from->r3c2;
|
to->r2c3 = from->r3c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ================= Set Row 1 ================== //
|
||||||
|
|
||||||
|
static inline void sp_matrix3x2_set_row1(const float c1, const float c2, const float c3, SPMatrix3x2* matrix)
|
||||||
|
{
|
||||||
|
matrix->r1c1 = c1;
|
||||||
|
matrix->r1c2 = c2;
|
||||||
|
matrix->r1c3 = c3;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix3x2_set_row1(const double c1, const double c2, const double c3, DPMatrix3x2* matrix)
|
||||||
|
{
|
||||||
|
matrix->r1c1 = c1;
|
||||||
|
matrix->r1c2 = c2;
|
||||||
|
matrix->r1c3 = c3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================= Set Row 2 ================== //
|
||||||
|
|
||||||
|
static inline void sp_matrix3x2_set_row2(const float c1, const float c2, const float c3, SPMatrix3x2* matrix)
|
||||||
|
{
|
||||||
|
matrix->r2c1 = c1;
|
||||||
|
matrix->r2c2 = c2;
|
||||||
|
matrix->r2c3 = c3;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix3x2_set_row2(const double c1, const double c2, const double c3, DPMatrix3x2* matrix)
|
||||||
|
{
|
||||||
|
matrix->r2c1 = c1;
|
||||||
|
matrix->r2c2 = c2;
|
||||||
|
matrix->r2c3 = c3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================ Set Column 1 ================ //
|
||||||
|
|
||||||
|
static inline void sp_matrix3x2_set_column1(const float r1, const float r2, SPMatrix3x2* matrix)
|
||||||
|
{
|
||||||
|
matrix->r1c1 = r1;
|
||||||
|
matrix->r2c1 = r2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix3x2_set_column1(const double r1, const double r2, DPMatrix3x2* matrix)
|
||||||
|
{
|
||||||
|
matrix->r1c1 = r1;
|
||||||
|
matrix->r2c1 = r2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================ Set Column 2 ================ //
|
||||||
|
|
||||||
|
static inline void sp_matrix3x2_set_column2(const float r1, const float r2, SPMatrix3x2* matrix)
|
||||||
|
{
|
||||||
|
matrix->r1c2 = r1;
|
||||||
|
matrix->r2c2 = r2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix3x2_set_column2(const double r1, const double r2, DPMatrix3x2* matrix)
|
||||||
|
{
|
||||||
|
matrix->r1c2 = r1;
|
||||||
|
matrix->r2c2 = r2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================ Set Column 3 ================ //
|
||||||
|
|
||||||
|
static inline void sp_matrix3x2_set_column3(const float r1, const float r2, SPMatrix3x2* matrix)
|
||||||
|
{
|
||||||
|
matrix->r1c3 = r1;
|
||||||
|
matrix->r2c3 = r2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix3x2_set_column3(const double r1, const double r2, DPMatrix3x2* matrix)
|
||||||
|
{
|
||||||
|
matrix->r1c3 = r1;
|
||||||
|
matrix->r2c3 = r2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================== Addition ================== //
|
||||||
|
|
||||||
|
static inline void sp_matrix3x2_add(const SPMatrix3x2* matrix1, const SPMatrix3x2* matrix2, SPMatrix3x2* sum)
|
||||||
|
{
|
||||||
|
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
||||||
|
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
||||||
|
sum->r1c3 = matrix1->r1c3 + matrix2->r1c3;
|
||||||
|
|
||||||
|
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
|
||||||
|
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
|
||||||
|
sum->r2c3 = matrix1->r2c3 + matrix2->r2c3;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix3x2_add(const DPMatrix3x2* matrix1, const DPMatrix3x2* matrix2, DPMatrix3x2* sum)
|
||||||
|
{
|
||||||
|
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
|
||||||
|
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
|
||||||
|
sum->r1c3 = matrix1->r1c3 + matrix2->r1c3;
|
||||||
|
|
||||||
|
sum->r2c1 = matrix1->r2c1 + matrix2->r2c1;
|
||||||
|
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
|
||||||
|
sum->r2c3 = matrix1->r2c3 + matrix2->r2c3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================ Subtraction ================= //
|
||||||
|
|
||||||
|
static inline void sp_matrix3x2_subtract(const SPMatrix3x2* minuend, const SPMatrix3x2* subtrahend, SPMatrix3x2* difference)
|
||||||
|
{
|
||||||
|
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
|
||||||
|
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
|
||||||
|
difference->r1c3 = minuend->r1c3 - subtrahend->r1c3;
|
||||||
|
|
||||||
|
difference->r2c1 = minuend->r2c1 - subtrahend->r2c1;
|
||||||
|
difference->r2c2 = minuend->r2c2 - subtrahend->r2c2;
|
||||||
|
difference->r2c3 = minuend->r2c3 - subtrahend->r2c3;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix3x2_subtract(const DPMatrix3x2* minuend, const DPMatrix3x2* subtrahend, DPMatrix3x2* difference)
|
||||||
|
{
|
||||||
|
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
|
||||||
|
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
|
||||||
|
difference->r1c3 = minuend->r1c3 - subtrahend->r1c3;
|
||||||
|
|
||||||
|
difference->r2c1 = minuend->r2c1 - subtrahend->r2c1;
|
||||||
|
difference->r2c2 = minuend->r2c2 - subtrahend->r2c2;
|
||||||
|
difference->r2c3 = minuend->r2c3 - subtrahend->r2c3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =============== Multiplication =============== //
|
||||||
|
|
||||||
|
static inline void sp_matrix3x2_multiply(const SPMatrix3x2* multiplicand, const float multiplier, SPMatrix3x2* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix3x2_multiply(const DPMatrix3x2* multiplicand, const double multiplier, DPMatrix3x2* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================== Division ================== //
|
||||||
|
|
||||||
|
static inline void sp_matrix3x2_divide(const SPMatrix3x2* dividend, const float divisor, SPMatrix3x2* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix3x2_divide(const DPMatrix3x2* dividend, const double divisor, DPMatrix3x2* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============= Weighed Sum of two ============= //
|
||||||
|
|
||||||
|
void sp_matrix3x2_get_weighted_sum2(
|
||||||
|
const float weight1, const SPMatrix3x2* matrix1,
|
||||||
|
const float weight2, const SPMatrix3x2* matrix2,
|
||||||
|
SPMatrix3x2* sum
|
||||||
|
);
|
||||||
|
|
||||||
|
void dp_matrix3x2_get_weighted_sum2(
|
||||||
|
const double weight1, const DPMatrix3x2* matrix1,
|
||||||
|
const double weight2, const DPMatrix3x2* matrix2,
|
||||||
|
DPMatrix3x2* sum
|
||||||
|
);
|
||||||
|
|
||||||
|
// ============ Weighed Sum of three ============ //
|
||||||
|
|
||||||
|
void sp_matrix3x2_get_weighted_sum3(
|
||||||
|
const float weight1, const SPMatrix3x2* matrix1,
|
||||||
|
const float weight2, const SPMatrix3x2* matrix2,
|
||||||
|
const float weight3, const SPMatrix3x2* matrix3,
|
||||||
|
SPMatrix3x2* sum
|
||||||
|
);
|
||||||
|
|
||||||
|
void dp_matrix3x2_get_weighted_sum3(
|
||||||
|
const double weight1, const DPMatrix3x2* matrix1,
|
||||||
|
const double weight2, const DPMatrix3x2* matrix2,
|
||||||
|
const double weight3, const DPMatrix3x2* matrix3,
|
||||||
|
DPMatrix3x2* sum
|
||||||
|
);
|
||||||
|
|
||||||
|
// ============ Weighed Sum of four ============= //
|
||||||
|
|
||||||
|
void sp_matrix3x2_get_weighted_sum4(
|
||||||
|
const float weight1, const SPMatrix3x2* matrix1,
|
||||||
|
const float weight2, const SPMatrix3x2* matrix2,
|
||||||
|
const float weight3, const SPMatrix3x2* matrix3,
|
||||||
|
const float weight4, const SPMatrix3x2* matrix4,
|
||||||
|
SPMatrix3x2* sum
|
||||||
|
);
|
||||||
|
|
||||||
|
void dp_matrix3x2_get_weighted_sum4(
|
||||||
|
const double weight1, const DPMatrix3x2* matrix1,
|
||||||
|
const double weight2, const DPMatrix3x2* matrix2,
|
||||||
|
const double weight3, const DPMatrix3x2* matrix3,
|
||||||
|
const double weight4, const DPMatrix3x2* matrix4,
|
||||||
|
DPMatrix3x2* sum
|
||||||
|
);
|
||||||
|
|
||||||
|
// ============ Weighed Sum of five ============= //
|
||||||
|
|
||||||
|
void sp_matrix3x2_get_weighted_sum5(
|
||||||
|
const float weight1, const SPMatrix3x2* matrix1,
|
||||||
|
const float weight2, const SPMatrix3x2* matrix2,
|
||||||
|
const float weight3, const SPMatrix3x2* matrix3,
|
||||||
|
const float weight4, const SPMatrix3x2* matrix4,
|
||||||
|
const float weight5, const SPMatrix3x2* matrix5,
|
||||||
|
SPMatrix3x2* sum
|
||||||
|
);
|
||||||
|
|
||||||
|
void dp_matrix3x2_get_weighted_sum5(
|
||||||
|
const double weight1, const DPMatrix3x2* matrix1,
|
||||||
|
const double weight2, const DPMatrix3x2* matrix2,
|
||||||
|
const double weight3, const DPMatrix3x2* matrix3,
|
||||||
|
const double weight4, const DPMatrix3x2* matrix4,
|
||||||
|
const double weight5, const DPMatrix3x2* matrix5,
|
||||||
|
DPMatrix3x2* sum
|
||||||
|
);
|
||||||
|
|
||||||
|
// ============ Left Vector Product ============= //
|
||||||
|
|
||||||
|
static inline void sp_matrix3x2_left_product(const SPVector2* vector, const SPMatrix3x2* matrix, SPVector3* result)
|
||||||
|
{
|
||||||
|
result->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
||||||
|
result->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
||||||
|
result->x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix3x2_left_product(const DPVector2* vector, const DPMatrix3x2* matrix, DPVector3* result)
|
||||||
|
{
|
||||||
|
result->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
|
||||||
|
result->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
|
||||||
|
result->x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============ Right Vector Product ============ //
|
||||||
|
|
||||||
|
static inline void sp_matrix3x2_right_product(const SPMatrix3x2* matrix, const SPVector3* vector, SPVector2* result)
|
||||||
|
{
|
||||||
|
result->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
||||||
|
result->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix3x2_right_product(const DPMatrix3x2* matrix, const DPVector3* vector, DPVector2* result)
|
||||||
|
{
|
||||||
|
result->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
|
||||||
|
result->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -282,22 +282,6 @@ static inline void dp_matrix3x3_make_transposed(const DPMatrix3x3* matrix, DPMat
|
||||||
result->r3c3 = matrix->r3c3;
|
result->r3c3 = matrix->r3c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================ Set Diagonal ================ //
|
|
||||||
|
|
||||||
static inline void sp_matrix3x3_set_main_diagonal(const float d1, const float d2, const float d3, SPMatrix3x3* matrix)
|
|
||||||
{
|
|
||||||
matrix->r1c1 = d1;
|
|
||||||
matrix->r2c2 = d2;
|
|
||||||
matrix->r3c3 = d3;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void dp_matrix3x3_set_main_diagonal(const double d1, const double d2, const double d3, DPMatrix3x3* matrix)
|
|
||||||
{
|
|
||||||
matrix->r1c1 = d1;
|
|
||||||
matrix->r2c2 = d2;
|
|
||||||
matrix->r3c3 = d3;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================= Set Row 1 ================== //
|
// ================= Set Row 1 ================== //
|
||||||
|
|
||||||
static inline void sp_matrix3x3_set_row1(const float c1, const float c2, const float c3, SPMatrix3x3* matrix)
|
static inline void sp_matrix3x3_set_row1(const float c1, const float c2, const float c3, SPMatrix3x3* matrix)
|
||||||
|
|
|
@ -116,6 +116,26 @@ void dp_matrix_product_2x3_at_3x2(const DPMatrix2x3* matrix1, const DPMatrix3x2*
|
||||||
result->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3;
|
result->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ========== Matrix Product 3x2 at 2x3 ========= //
|
||||||
|
|
||||||
|
static inline void sp_matrix_product_3x2_at_2x3(const SPMatrix3x2* matrix1, const SPMatrix2x3* matrix2, SPMatrix2x2* result)
|
||||||
|
{
|
||||||
|
result->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||||
|
result->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||||
|
|
||||||
|
result->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||||
|
result->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dp_matrix_product_3x2_at_2x3(const DPMatrix3x2* matrix1, const DPMatrix2x3* matrix2, DPMatrix2x2* result)
|
||||||
|
{
|
||||||
|
result->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
||||||
|
result->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||||
|
|
||||||
|
result->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
||||||
|
result->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||||
|
}
|
||||||
|
|
||||||
// ========== Matrix Product 3x2 at 3x3 ========= //
|
// ========== Matrix Product 3x2 at 3x3 ========= //
|
||||||
|
|
||||||
void sp_matrix_product_3x2_at_3x3(const SPMatrix3x2* matrix1, const SPMatrix3x3* matrix2, SPMatrix3x2* result)
|
void sp_matrix_product_3x2_at_3x3(const SPMatrix3x2* matrix1, const SPMatrix3x3* matrix2, SPMatrix3x2* result)
|
||||||
|
@ -139,13 +159,13 @@ void sp_matrix_product_3x2_at_3x3(const SPMatrix3x2* matrix1, const SPMatrix3x3*
|
||||||
|
|
||||||
void dp_matrix_product_3x2_at_3x3(const DPMatrix3x2* matrix1, const DPMatrix3x3* matrix2, DPMatrix3x2* result)
|
void dp_matrix_product_3x2_at_3x3(const DPMatrix3x2* matrix1, const DPMatrix3x3* matrix2, DPMatrix3x2* result)
|
||||||
{
|
{
|
||||||
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
const double 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 double 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 double 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 double 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 double 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 double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
|
||||||
|
|
||||||
result->r1c1 = r1c1;
|
result->r1c1 = r1c1;
|
||||||
result->r1c2 = r1c2;
|
result->r1c2 = r1c2;
|
||||||
|
@ -160,14 +180,14 @@ void dp_matrix_product_3x2_at_3x3(const DPMatrix3x2* matrix1, const DPMatrix3x3*
|
||||||
|
|
||||||
void sp_matrix_product_3x3_at_2x3(const SPMatrix3x3* matrix1, const SPMatrix2x3* matrix2, SPMatrix2x3* result)
|
void sp_matrix_product_3x3_at_2x3(const SPMatrix3x3* matrix1, const SPMatrix2x3* matrix2, SPMatrix2x3* result)
|
||||||
{
|
{
|
||||||
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
const float 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 float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||||
|
|
||||||
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
const float 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 float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
||||||
|
|
||||||
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
|
const float 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 float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
|
||||||
|
|
||||||
result->r1c1 = r1c1;
|
result->r1c1 = r1c1;
|
||||||
result->r1c2 = r1c2;
|
result->r1c2 = r1c2;
|
||||||
|
|
|
@ -105,23 +105,9 @@ void dp_matrix_product_2x3_at_3x2(const DPMatrix2x3* matrix1, const DPMatrix3x2*
|
||||||
|
|
||||||
// ========== Matrix Product 3x2 at 2x3 ========= //
|
// ========== Matrix Product 3x2 at 2x3 ========= //
|
||||||
|
|
||||||
void sp_matrix_product_3x2_at_2x3(const SPMatrix3x2* matrix1, const SPMatrix2x3* matrix2, SPMatrix2x2* result)
|
void sp_matrix_product_3x2_at_2x3(const SPMatrix3x2* matrix1, const SPMatrix2x3* matrix2, SPMatrix2x2* result);
|
||||||
{
|
|
||||||
result->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
|
||||||
result->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
|
||||||
|
|
||||||
result->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
void dp_matrix_product_3x2_at_2x3(const DPMatrix3x2* matrix1, const DPMatrix2x3* matrix2, DPMatrix2x2* result);
|
||||||
result->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
|
||||||
}
|
|
||||||
|
|
||||||
void dp_matrix_product_3x2_at_2x3(const DPMatrix3x2* matrix1, const DPMatrix2x3* matrix2, DPMatrix2x2* result)
|
|
||||||
{
|
|
||||||
result->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
|
|
||||||
result->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
|
||||||
|
|
||||||
result->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
|
|
||||||
result->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== Matrix Product 3x2 at 3x3 ========= //
|
// ========== Matrix Product 3x2 at 3x3 ========= //
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue