Добавлены функции для матриц 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;
|
||||||
|
|
||||||