Добавлены матрицы 2x3 и 3x2, добавлены произведения матриц. Изменения в названиях функций
This commit is contained in:
parent
86486ac9cf
commit
049f09f3d4
31 changed files with 1831 additions and 1314 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
<CodeBlocks_workspace_layout_file>
|
<CodeBlocks_workspace_layout_file>
|
||||||
<FileVersion major="1" minor="0" />
|
<FileVersion major="1" minor="0" />
|
||||||
<ActiveProject path="dev/geometry-dev.cbp" />
|
<ActiveProject path="src/geometry.cbp" />
|
||||||
|
<PreferredTarget name="Debug" />
|
||||||
</CodeBlocks_workspace_layout_file>
|
</CodeBlocks_workspace_layout_file>
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||||
<CodeBlocks_layout_file>
|
<CodeBlocks_layout_file>
|
||||||
<FileVersion major="1" minor="0" />
|
<FileVersion major="1" minor="0" />
|
||||||
<ActiveTarget name="Release" />
|
<ActiveTarget name="Debug" />
|
||||||
<File name="main.c" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="main.c" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="3262" topLine="102" />
|
<Cursor1 position="3793" topLine="116" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
</CodeBlocks_layout_file>
|
</CodeBlocks_layout_file>
|
||||||
|
|
|
||||||
17
dev/main.c
17
dev/main.c
|
|
@ -135,7 +135,7 @@ void print_matrix(const DPMatrix3x3* matrix)
|
||||||
printf("(%lf, %lf, %lf)\n", matrix->r2c1, matrix->r2c2, matrix->r2c3);
|
printf("(%lf, %lf, %lf)\n", matrix->r2c1, matrix->r2c2, matrix->r2c3);
|
||||||
printf("(%lf, %lf, %lf)\n\n", matrix->r3c1, matrix->r3c2, matrix->r3c3);
|
printf("(%lf, %lf, %lf)\n\n", matrix->r3c1, matrix->r3c2, matrix->r3c3);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
DPMatrix3x3 m1, m2, check;
|
DPMatrix3x3 m1, m2, check;
|
||||||
|
|
@ -170,3 +170,18 @@ int main()
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
SPVector2 vector;
|
||||||
|
|
||||||
|
sp_vector2_set(0, 0, &vector);
|
||||||
|
|
||||||
|
printf("SPVector2(%f, %f), module = %d\n",
|
||||||
|
vector.x1,
|
||||||
|
vector.x2,
|
||||||
|
sp_vector2_is_zero(&vector)
|
||||||
|
);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
||||||
BIN
docs/documentation.odt
Normal file
BIN
docs/documentation.odt
Normal file
Binary file not shown.
|
|
@ -58,10 +58,16 @@
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit filename="matrix2x2.h" />
|
<Unit filename="matrix2x2.h" />
|
||||||
|
<Unit filename="matrix2x3.h" />
|
||||||
|
<Unit filename="matrix3x2.h" />
|
||||||
<Unit filename="matrix3x3.c">
|
<Unit filename="matrix3x3.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit filename="matrix3x3.h" />
|
<Unit filename="matrix3x3.h" />
|
||||||
|
<Unit filename="matrixes.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="matrixes.h" />
|
||||||
<Unit filename="quaternion.c">
|
<Unit filename="quaternion.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,9 @@
|
||||||
#include "vector2.h"
|
#include "vector2.h"
|
||||||
#include "vector3.h"
|
#include "vector3.h"
|
||||||
|
|
||||||
|
#include "matrixes.h"
|
||||||
#include "matrix2x2.h"
|
#include "matrix2x2.h"
|
||||||
|
#include "matrix2x3.h"
|
||||||
#include "matrix3x3.h"
|
#include "matrix3x3.h"
|
||||||
|
|
||||||
#include "rotation3.h"
|
#include "rotation3.h"
|
||||||
|
|
|
||||||
|
|
@ -2,59 +2,19 @@
|
||||||
<CodeBlocks_layout_file>
|
<CodeBlocks_layout_file>
|
||||||
<FileVersion major="1" minor="0" />
|
<FileVersion major="1" minor="0" />
|
||||||
<ActiveTarget name="Debug" />
|
<ActiveTarget name="Debug" />
|
||||||
<File name="matrix3x3.c" open="1" top="1" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="quaternion.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="3207" topLine="198" />
|
<Cursor1 position="1849" topLine="67" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="angle.c" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="vector2.h" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="0" topLine="0" />
|
<Cursor1 position="2293" topLine="74" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="matrix3x3.h" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="basis.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="6363" topLine="266" />
|
<Cursor1 position="103" topLine="0" />
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="vector2.c" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="1940" topLine="25" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="vector3.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="0" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="quaternion.c" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="6789" topLine="145" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="rotation3.c" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="154" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="matrix2x2.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="305" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="geometry.h" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="315" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="quaternion.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="3387" topLine="111" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="rotation3.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="305" topLine="29" />
|
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="angle.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="angle.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
|
@ -62,34 +22,34 @@
|
||||||
<Cursor1 position="1082" topLine="0" />
|
<Cursor1 position="1082" topLine="0" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="vector2.h" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="matrix3x3.c" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="0" topLine="0" />
|
<Cursor1 position="23" topLine="72" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="basis.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="matrix3x2.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="103" topLine="8" />
|
<Cursor1 position="897" topLine="36" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="matrix2x3.h" open="1" top="1" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="1596" topLine="54" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="matrix2x2.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="matrix2x2.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="6700" topLine="238" />
|
<Cursor1 position="2885" topLine="183" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="versor.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="vector3.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="3718" topLine="116" />
|
<Cursor1 position="2779" topLine="79" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="basis.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="versor.h" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="20" topLine="0" />
|
<Cursor1 position="27" topLine="0" />
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="vector3.c" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="1436" topLine="15" />
|
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="versor.c" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="versor.c" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
|
@ -97,4 +57,54 @@
|
||||||
<Cursor1 position="504" topLine="0" />
|
<Cursor1 position="504" topLine="0" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
|
<File name="quaternion.c" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="6789" topLine="145" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="vector3.c" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="1436" topLine="15" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="rotation3.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="305" topLine="29" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="matrix2x2.c" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="24" topLine="0" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="matrix3x3.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="3618" topLine="127" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="rotation3.c" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="154" topLine="0" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="geometry.h" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="316" topLine="0" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="vector2.c" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="1940" topLine="25" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="basis.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="20" topLine="0" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="angle.c" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="0" topLine="0" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
</CodeBlocks_layout_file>
|
</CodeBlocks_layout_file>
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1 @@
|
||||||
#include "matrix2x2.h"
|
#include "matrix2x2.h"
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
#include "angle.h"
|
|
||||||
|
|
||||||
const SPMatrix2x2 SP_ZERO_MATRIX2X2 = {
|
|
||||||
0.0f, 0.0f,
|
|
||||||
0.0f, 0.0f
|
|
||||||
};
|
|
||||||
|
|
||||||
const DPMatrix2x2 DP_ZERO_MATRIX2X2 = {
|
|
||||||
0.0, 0.0,
|
|
||||||
0.0, 0.0
|
|
||||||
};
|
|
||||||
|
|
||||||
const SPMatrix2x2 SP_IDENTITY_MATRIX2X2 = {
|
|
||||||
1.0f, 0.0f,
|
|
||||||
0.0f, 1.0f
|
|
||||||
};
|
|
||||||
|
|
||||||
const DPMatrix2x2 DP_IDENTITY_MATRIX2X2 = {
|
|
||||||
1.0, 0.0,
|
|
||||||
0.0, 1.0
|
|
||||||
};
|
|
||||||
|
|
|
||||||
167
src/matrix2x2.h
167
src/matrix2x2.h
|
|
@ -3,24 +3,7 @@
|
||||||
|
|
||||||
#include "angle.h"
|
#include "angle.h"
|
||||||
#include "vector2.h"
|
#include "vector2.h"
|
||||||
|
#include "matrixes.h"
|
||||||
typedef struct {
|
|
||||||
float r1c1, r1c2;
|
|
||||||
float r2c1, r2c2;
|
|
||||||
} SPMatrix2x2;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
double r1c1, r1c2;
|
|
||||||
double r2c1, r2c2;
|
|
||||||
} DPMatrix2x2;
|
|
||||||
|
|
||||||
extern const SPMatrix2x2 SP_ZERO_MATRIX2X2;
|
|
||||||
|
|
||||||
extern const DPMatrix2x2 DP_ZERO_MATRIX2X2;
|
|
||||||
|
|
||||||
extern const SPMatrix2x2 SP_IDENTITY_MATRIX2X2;
|
|
||||||
|
|
||||||
extern const DPMatrix2x2 DP_IDENTITY_MATRIX2X2;
|
|
||||||
|
|
||||||
// =================== Reset ==================== //
|
// =================== Reset ==================== //
|
||||||
|
|
||||||
|
|
@ -124,22 +107,24 @@ static inline void dp_matrix2x2_copy(const DPMatrix2x2* from, DPMatrix2x2* to)
|
||||||
|
|
||||||
// ============= Copy to twin type ============== //
|
// ============= Copy to twin type ============== //
|
||||||
|
|
||||||
static inline void sp_matrix2x2_copy_to_double(const SPMatrix2x2* from, DPMatrix2x2* to)
|
static inline void sp_matrix2x2_set_from_double(const DPMatrix2x2* from, SPMatrix2x2* to)
|
||||||
{
|
|
||||||
to->r1c1 = (double)from->r1c1;
|
|
||||||
to->r1c2 = (double)from->r1c2;
|
|
||||||
to->r2c1 = (double)from->r2c1;
|
|
||||||
to->r2c2 = (double)from->r2c2;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void dp_matrix2x2_copy_to_single(const DPMatrix2x2* from, SPMatrix2x2* to)
|
|
||||||
{
|
{
|
||||||
to->r1c1 = (float)from->r1c1;
|
to->r1c1 = (float)from->r1c1;
|
||||||
to->r1c2 = (float)from->r1c2;
|
to->r1c2 = (float)from->r1c2;
|
||||||
|
|
||||||
to->r2c1 = (float)from->r2c1;
|
to->r2c1 = (float)from->r2c1;
|
||||||
to->r2c2 = (float)from->r2c2;
|
to->r2c2 = (float)from->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void dp_matrix2x2_set_from_single(const SPMatrix2x2* from, DPMatrix2x2* to)
|
||||||
|
{
|
||||||
|
to->r1c1 = from->r1c1;
|
||||||
|
to->r1c2 = from->r1c2;
|
||||||
|
|
||||||
|
to->r2c1 = from->r2c1;
|
||||||
|
to->r2c2 = from->r2c2;
|
||||||
|
}
|
||||||
|
|
||||||
// ================ Determinant ================= //
|
// ================ Determinant ================= //
|
||||||
|
|
||||||
static inline float sp_matrix2x2_get_determinant(const SPMatrix2x2* matrix)
|
static inline float sp_matrix2x2_get_determinant(const SPMatrix2x2* matrix)
|
||||||
|
|
@ -232,98 +217,78 @@ static inline int dp_matrix2x2_invert(DPMatrix2x2* matrix)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============== Make Transposed ============== //
|
// =============== Set Transposed =============== //
|
||||||
|
|
||||||
static inline void sp_matrix2x2_make_transposed(const SPMatrix2x2* matrix, SPMatrix2x2* result)
|
static inline void sp_matrix2x2_set_transposed(const SPMatrix2x2* from, SPMatrix2x2* to)
|
||||||
{
|
{
|
||||||
if (matrix == result) {
|
float tmp = from->r1c2;
|
||||||
sp_matrix2x2_transpose(result);
|
|
||||||
return;
|
to->r1c1 = from->r1c1;
|
||||||
|
to->r1c2 = from->r2c1;
|
||||||
|
|
||||||
|
to->r2c1 = tmp;
|
||||||
|
to->r2c2 = from->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
result->r1c1 = matrix->r1c1;
|
static inline void dp_matrix2x2_set_transposed(const DPMatrix2x2* from, DPMatrix2x2* to)
|
||||||
result->r1c2 = matrix->r2c1;
|
|
||||||
|
|
||||||
result->r2c1 = matrix->r1c2;
|
|
||||||
result->r2c2 = matrix->r2c2;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void dp_matrix2x2_make_transposed(const DPMatrix2x2* matrix, DPMatrix2x2* result)
|
|
||||||
{
|
{
|
||||||
if (matrix == result) {
|
double tmp = from->r1c2;
|
||||||
dp_matrix2x2_transpose(result);
|
|
||||||
return;
|
to->r1c1 = from->r1c1;
|
||||||
|
to->r1c2 = from->r2c1;
|
||||||
|
|
||||||
|
to->r2c1 = tmp;
|
||||||
|
to->r2c2 = from->r2c2;
|
||||||
}
|
}
|
||||||
|
|
||||||
result->r1c1 = matrix->r1c1;
|
// ================ Set Inverted ================ //
|
||||||
result->r1c2 = matrix->r1c2;
|
|
||||||
|
|
||||||
result->r2c1 = matrix->r2c1;
|
static inline int sp_matrix2x2_set_inverted(const SPMatrix2x2* from, SPMatrix2x2* to)
|
||||||
result->r2c2 = matrix->r2c2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================ Make Inverted =============== //
|
|
||||||
|
|
||||||
static inline int sp_matrix2x2_make_inverted(const SPMatrix2x2* matrix, SPMatrix2x2* result)
|
|
||||||
{
|
{
|
||||||
const float determinant = sp_matrix2x2_get_determinant(matrix);
|
const float determinant = sp_matrix2x2_get_determinant(from);
|
||||||
|
|
||||||
if (-SP_EPSYLON <= determinant && determinant <= SP_EPSYLON) {
|
if (-SP_EPSYLON <= determinant && determinant <= SP_EPSYLON) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float r1c1 = matrix->r2c2;
|
const float r1c1 = from->r2c2;
|
||||||
const float r1c2 = -matrix->r1c2;
|
const float r1c2 = -from->r1c2;
|
||||||
|
|
||||||
const float r2c1 = -matrix->r2c1;
|
const float r2c1 = -from->r2c1;
|
||||||
const float r2c2 = matrix->r1c1;
|
const float r2c2 = from->r1c1;
|
||||||
|
|
||||||
result->r1c1 = r1c1 / determinant;
|
to->r1c1 = r1c1 / determinant;
|
||||||
result->r1c2 = r1c2 / determinant;
|
to->r1c2 = r1c2 / determinant;
|
||||||
|
|
||||||
result->r2c1 = r2c1 / determinant;
|
to->r2c1 = r2c1 / determinant;
|
||||||
result->r2c2 = r2c2 / determinant;
|
to->r2c2 = r2c2 / determinant;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||