Задача 0000001: отказ от использования корректоров в версорах / Task 0000001: declining of usage of correctors in versors
This commit is contained in:
parent
07c1330858
commit
791557fb94
9 changed files with 421 additions and 364 deletions
|
@ -1,6 +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="src/geometry.cbp" />
|
<ActiveProject path="dev/geometry-dev.cbp" />
|
||||||
<PreferredTarget name="Debug" />
|
<PreferredTarget name="Release" />
|
||||||
</CodeBlocks_workspace_layout_file>
|
</CodeBlocks_workspace_layout_file>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# depslib dependency file v1.0
|
# depslib dependency file v1.0
|
||||||
1729764426 source:/home/andrey/Projects/Private/C/Geometry/dev/main.c
|
1731995770 source:/home/andrey/Projects/Private/C/Geometry/dev/main.c
|
||||||
<stdio.h>
|
<stdio.h>
|
||||||
<stdlib.h>
|
<stdlib.h>
|
||||||
<math.h>
|
<math.h>
|
||||||
|
@ -7,34 +7,32 @@
|
||||||
<windows.h>
|
<windows.h>
|
||||||
<time.h>
|
<time.h>
|
||||||
|
|
||||||
1729526406 /home/andrey/Projects/Private/C/Geometry/src/geometry.h
|
1731906002 /home/andrey/Projects/Private/C/Geometry/src/geometry.h
|
||||||
"basis.h"
|
"basis.h"
|
||||||
"angle.h"
|
"angle.h"
|
||||||
"vector2.h"
|
"vector2.h"
|
||||||
"vector3.h"
|
"vector3.h"
|
||||||
"vector4.h"
|
"matrixes.h"
|
||||||
"matrix2x2.h"
|
"matrix2x2.h"
|
||||||
|
"matrix2x3.h"
|
||||||
|
"matrix3x2.h"
|
||||||
"matrix3x3.h"
|
"matrix3x3.h"
|
||||||
"matrix4x4.h"
|
|
||||||
"tangent.h"
|
|
||||||
"rotation3.h"
|
"rotation3.h"
|
||||||
|
"quaternion.h"
|
||||||
"versor.h"
|
"versor.h"
|
||||||
"affine_map2.h"
|
|
||||||
"affine_map3.h"
|
|
||||||
"affine_map4.h"
|
|
||||||
"position2.h"
|
|
||||||
"position3.h"
|
|
||||||
|
|
||||||
1729427506 /home/andrey/Projects/Private/C/Geometry/src/basis.h
|
1730476002 /home/andrey/Projects/Private/C/Geometry/src/basis.h
|
||||||
|
|
||||||
1729764440 /home/andrey/Projects/Private/C/Geometry/src/angle.h
|
1730392488 /home/andrey/Projects/Private/C/Geometry/src/angle.h
|
||||||
|
<math.h>
|
||||||
|
"basis.h"
|
||||||
|
|
||||||
1729503050 /home/andrey/Projects/Private/C/Geometry/src/vector2.h
|
1731673023 /home/andrey/Projects/Private/C/Geometry/src/vector2.h
|
||||||
"basis.h"
|
"basis.h"
|
||||||
"angle.h"
|
"angle.h"
|
||||||
<math.h>
|
<math.h>
|
||||||
|
|
||||||
1729502950 /home/andrey/Projects/Private/C/Geometry/src/vector3.h
|
1731673331 /home/andrey/Projects/Private/C/Geometry/src/vector3.h
|
||||||
"basis.h"
|
"basis.h"
|
||||||
"angle.h"
|
"angle.h"
|
||||||
<math.h>
|
<math.h>
|
||||||
|
@ -44,11 +42,14 @@
|
||||||
"angle.h"
|
"angle.h"
|
||||||
<math.h>
|
<math.h>
|
||||||
|
|
||||||
1729490828 /home/andrey/Projects/Private/C/Geometry/src/matrix2x2.h
|
1731673308 /home/andrey/Projects/Private/C/Geometry/src/matrix2x2.h
|
||||||
|
"angle.h"
|
||||||
"vector2.h"
|
"vector2.h"
|
||||||
|
"matrixes.h"
|
||||||
|
|
||||||
1729612680 /home/andrey/Projects/Private/C/Geometry/src/matrix3x3.h
|
1731906002 /home/andrey/Projects/Private/C/Geometry/src/matrix3x3.h
|
||||||
"vector3.h"
|
"vector3.h"
|
||||||
|
"matrixes.h"
|
||||||
|
|
||||||
1729490844 /home/andrey/Projects/Private/C/Geometry/src/matrix4x4.h
|
1729490844 /home/andrey/Projects/Private/C/Geometry/src/matrix4x4.h
|
||||||
"vector4.h"
|
"vector4.h"
|
||||||
|
@ -60,18 +61,17 @@
|
||||||
"vector2.h"
|
"vector2.h"
|
||||||
"matrix2x2.h"
|
"matrix2x2.h"
|
||||||
|
|
||||||
1729428324 /home/andrey/Projects/Private/C/Geometry/src/rotation3.h
|
1730355414 /home/andrey/Projects/Private/C/Geometry/src/rotation3.h
|
||||||
"basis.h"
|
"basis.h"
|
||||||
"angle.h"
|
"angle.h"
|
||||||
"vector3.h"
|
"vector3.h"
|
||||||
|
|
||||||
1729595110 /home/andrey/Projects/Private/C/Geometry/src/versor.h
|
1731995858 /home/andrey/Projects/Private/C/Geometry/src/versor.h
|
||||||
<stdint.h>
|
<stdint.h>
|
||||||
"basis.h"
|
"basis.h"
|
||||||
"vector3.h"
|
"vector3.h"
|
||||||
"rotation3.h"
|
"rotation3.h"
|
||||||
"matrix3x3.h"
|
"matrix3x3.h"
|
||||||
"matrix4x4.h"
|
|
||||||
|
|
||||||
1729503008 /home/andrey/Projects/Private/C/Geometry/src/affine_map2.h
|
1729503008 /home/andrey/Projects/Private/C/Geometry/src/affine_map2.h
|
||||||
"vector2.h"
|
"vector2.h"
|
||||||
|
@ -107,3 +107,20 @@
|
||||||
"versor.h"
|
"versor.h"
|
||||||
"affine_map3.h"
|
"affine_map3.h"
|
||||||
|
|
||||||
|
1731906002 /home/andrey/Projects/Private/C/Geometry/src/matrixes.h
|
||||||
|
|
||||||
|
1731906002 /home/andrey/Projects/Private/C/Geometry/src/matrix2x3.h
|
||||||
|
"vector2.h"
|
||||||
|
"vector3.h"
|
||||||
|
"matrixes.h"
|
||||||
|
|
||||||
|
1731906002 /home/andrey/Projects/Private/C/Geometry/src/matrix3x2.h
|
||||||
|
"vector2.h"
|
||||||
|
"vector3.h"
|
||||||
|
"matrixes.h"
|
||||||
|
|
||||||
|
1731407834 /home/andrey/Projects/Private/C/Geometry/src/quaternion.h
|
||||||
|
<math.h>
|
||||||
|
"basis.h"
|
||||||
|
"matrix3x3.h"
|
||||||
|
|
||||||
|
|
131
dev/main.c
131
dev/main.c
|
@ -50,12 +50,77 @@ SPVersor * make_random_versors(const unsigned int amount)
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_versor(const SPVersor * versor)
|
void print_versor(const SPVersor* versor)
|
||||||
{
|
{
|
||||||
printf("(%f, %f, %f, %f) / %e\n", versor->_s0, versor->_x1, versor->_x2, versor->_x3, versor->_corrector - 1.0f);
|
printf("(%f, %f, %f, %f)\n", versor->_s0, versor->_x1, versor->_x2, versor->_x3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*/
|
void print_vector(const SPVector3* vector)
|
||||||
|
{
|
||||||
|
printf("(%f, %f, %f) / %f\n", vector->x1, vector->x2, vector->x3, sp_vector3_get_module(vector));
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
const unsigned int amount = 1000000;
|
||||||
|
|
||||||
|
#ifdef _WIN64
|
||||||
|
ULONGLONG now;
|
||||||
|
now = GetTickCount64();
|
||||||
|
srand((unsigned int)(now & 0xfffffff));
|
||||||
|
#else
|
||||||
|
struct timespec now;
|
||||||
|
clock_gettime(CLOCK_REALTIME, &now);
|
||||||
|
srand((unsigned int)(now.tv_nsec & 0xfffffff));
|
||||||
|
#endif // _WIN64
|
||||||
|
|
||||||
|
SPVersor * versors = make_random_versors(amount);
|
||||||
|
|
||||||
|
if (versors == 0) {
|
||||||
|
printf("Cannot allocate memory for versors");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPVector3 initial, result;
|
||||||
|
|
||||||
|
sp_vector3_set_values(1, 2, 3, &initial);
|
||||||
|
sp_vector3_copy(&initial, &result);
|
||||||
|
|
||||||
|
#ifdef _WIN64
|
||||||
|
ULONGLONG start, end;
|
||||||
|
start = GetTickCount64();
|
||||||
|
#else
|
||||||
|
struct timespec start, end;
|
||||||
|
clock_gettime(CLOCK_REALTIME, &start);
|
||||||
|
#endif // _WIN64
|
||||||
|
for (unsigned int i = 0; i < amount; i++) {
|
||||||
|
sp_versor_turn2(&versors[i], &result, &result);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (unsigned int i = amount; i > 0; i--) {
|
||||||
|
sp_versor_turn_back2(&versors[i - 1], &result, &result);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN64
|
||||||
|
end = GetTickCount64();
|
||||||
|
|
||||||
|
printf("Time: %lld\n", end - start);
|
||||||
|
#else
|
||||||
|
clock_gettime(CLOCK_REALTIME, &end);
|
||||||
|
|
||||||
|
printf("Time: %lf\n", (end.tv_sec - start.tv_sec) * 1000.0 + (end.tv_nsec - start.tv_nsec) * 0.000001);
|
||||||
|
#endif // _WIN64
|
||||||
|
|
||||||
|
|
||||||
|
print_vector(&initial);
|
||||||
|
print_vector(&result);
|
||||||
|
|
||||||
|
free(versors);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
const unsigned int amount = 1000000;
|
const unsigned int amount = 1000000;
|
||||||
|
@ -103,7 +168,7 @@ int main()
|
||||||
#endif // _WIN64
|
#endif // _WIN64
|
||||||
for (int j = 0; j < 1000; j++) {
|
for (int j = 0; j < 1000; j++) {
|
||||||
for (unsigned int i = 0; i < amount; i++) {
|
for (unsigned int i = 0; i < amount; i++) {
|
||||||
sp_versor_combine2(&versors1[i], &versors2[i], &results[i]);
|
sp_versor_combine(&versors1[i], &versors2[i], &results[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,61 +192,3 @@ int main()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*/
|
|
||||||
|
|
||||||
void print_matrix(const DPMatrix3x3* matrix)
|
|
||||||
{
|
|
||||||
printf("(%lf, %lf, %lf)\n", matrix->r1c1, matrix->r1c2, matrix->r1c3);
|
|
||||||
printf("(%lf, %lf, %lf)\n", matrix->r2c1, matrix->r2c2, matrix->r2c3);
|
|
||||||
printf("(%lf, %lf, %lf)\n\n", matrix->r3c1, matrix->r3c2, matrix->r3c3);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
DPMatrix3x3 m1, m2, check;
|
|
||||||
|
|
||||||
dp_matrix3x3_set_row1(1, 3, 5, &m1);
|
|
||||||
dp_matrix3x3_set_row2(2, 2, -1, &m1);
|
|
||||||
dp_matrix3x3_set_row3(2, 0, 4, &m1);
|
|
||||||
|
|
||||||
printf("Initial matrix:\n");
|
|
||||||
print_matrix(&m1);
|
|
||||||
|
|
||||||
if (!dp_matrix3x3_make_inverted(&m1, &m2)) {
|
|
||||||
printf("Cannot get the inverted matrix.\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Inverted matrix:\n");
|
|
||||||
|
|
||||||
print_matrix(&m2);
|
|
||||||
|
|
||||||
dp_matrix3x3_matrix_product(&m1, &m2, &check);
|
|
||||||
|
|
||||||
printf("m1 * m2:\n");
|
|
||||||
|
|
||||||
print_matrix(&check);
|
|
||||||
|
|
||||||
dp_matrix3x3_matrix_product(&m2, &m1, &check);
|
|
||||||
|
|
||||||
printf("m2 * m1:\n");
|
|
||||||
|
|
||||||
print_matrix(&check);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
SPVector2 vector;
|
|
||||||
|
|
||||||
sp_vector2_set_values(0, 0, &vector);
|
|
||||||
|
|
||||||
printf("SPVector2(%f, %f), module = %d\n",
|
|
||||||
vector.x1,
|
|
||||||
vector.x2,
|
|
||||||
sp_vector2_is_zero(&vector)
|
|
||||||
);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,59 +2,9 @@
|
||||||
<CodeBlocks_layout_file>
|
<CodeBlocks_layout_file>
|
||||||
<FileVersion major="1" minor="0" />
|
<FileVersion major="1" minor="0" />
|
||||||
<ActiveTarget name="Debug" />
|
<ActiveTarget name="Debug" />
|
||||||
<File name="quaternion.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="matrix2x2.c" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="1849" topLine="67" />
|
<Cursor1 position="24" topLine="0" />
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="vector2.h" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="2293" topLine="74" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="basis.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="103" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="angle.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="1082" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="matrix3x3.c" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="23" topLine="72" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="matrix3x2.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<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>
|
|
||||||
</File>
|
|
||||||
<File name="matrix2x2.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="2885" topLine="183" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="vector3.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="2779" topLine="79" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="versor.h" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="27" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="versor.c" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<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">
|
<File name="quaternion.c" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
@ -62,9 +12,19 @@
|
||||||
<Cursor1 position="6789" topLine="145" />
|
<Cursor1 position="6789" topLine="145" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="vector3.c" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="matrix3x3.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="1436" topLine="15" />
|
<Cursor1 position="18608" topLine="582" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="matrix3x2.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="897" topLine="52" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="vector2.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="556" topLine="12" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="rotation3.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="rotation3.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
@ -72,14 +32,39 @@
|
||||||
<Cursor1 position="305" topLine="29" />
|
<Cursor1 position="305" topLine="29" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="matrix2x2.c" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="vector3.h" open="1" top="1" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="24" topLine="0" />
|
<Cursor1 position="16048" topLine="102" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="matrix3x3.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="quaternion.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="3618" topLine="127" />
|
<Cursor1 position="1849" topLine="187" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="basis.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="103" topLine="0" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="versor.c" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="504" topLine="0" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="matrix3x3.c" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="23" topLine="72" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="angle.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="1082" topLine="0" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="versor.h" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="27" topLine="0" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="rotation3.c" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="rotation3.c" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
@ -87,14 +72,24 @@
|
||||||
<Cursor1 position="154" topLine="0" />
|
<Cursor1 position="154" topLine="0" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
|
<File name="matrix2x3.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="1596" 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">
|
<File name="geometry.h" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="316" topLine="0" />
|
<Cursor1 position="316" topLine="0" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="vector2.c" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="vector3.c" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="1940" topLine="25" />
|
<Cursor1 position="24" topLine="0" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="matrix2x2.h" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="18276" topLine="538" />
|
||||||
</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="basis.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
@ -102,6 +97,11 @@
|
||||||
<Cursor1 position="20" topLine="0" />
|
<Cursor1 position="20" topLine="0" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
|
<File name="vector2.c" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="24" 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">
|
<File name="angle.c" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="0" topLine="0" />
|
<Cursor1 position="0" topLine="0" />
|
||||||
|
|
|
@ -118,7 +118,7 @@ void dp_matrix_product_2x3_at_3x2(const DPMatrix2x3* matrix1, const DPMatrix3x2*
|
||||||
|
|
||||||
// ========== Matrix Product 3x2 at 2x3 ========= //
|
// ========== Matrix Product 3x2 at 2x3 ========= //
|
||||||
|
|
||||||
static inline 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->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->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
|
||||||
|
|
|
@ -17,17 +17,8 @@ void sp_quaternion_make_matrix(const SPQuaternion* quaternion, SPMatrix3x3* matr
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float corrector1;
|
const float corrector1 = 1.0f / square_module;
|
||||||
float corrector2;
|
const float corrector2 = 2.0f * corrector1;
|
||||||
|
|
||||||
if (1.0f - SP_TWO_EPSYLON <= square_module && square_module <= 1.0f + SP_TWO_EPSYLON) {
|
|
||||||
corrector1 = 2.0f - square_module;
|
|
||||||
corrector2 = 2.0f * corrector1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
corrector1 = 1.0f / square_module;
|
|
||||||
corrector2 = 2.0f / square_module;
|
|
||||||
}
|
|
||||||
|
|
||||||
const float s0x1 = quaternion->s0 * quaternion->x1;
|
const float s0x1 = quaternion->s0 * quaternion->x1;
|
||||||
const float s0x2 = quaternion->s0 * quaternion->x2;
|
const float s0x2 = quaternion->s0 * quaternion->x2;
|
||||||
|
@ -64,17 +55,8 @@ void dp_quaternion_make_matrix(const DPQuaternion* quaternion, DPMatrix3x3* matr
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double corrector1;
|
const double corrector1 = 1.0f / square_module;
|
||||||
double corrector2;
|
const double corrector2 = 2.0f * corrector1;
|
||||||
|
|
||||||
if (1.0 - DP_TWO_EPSYLON <= square_module && square_module <= 1.0 + DP_TWO_EPSYLON) {
|
|
||||||
corrector1 = 2.0 - square_module;
|
|
||||||
corrector2 = 2.0 * corrector1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
corrector1 = 1.0 / square_module;
|
|
||||||
corrector2 = 2.0 / square_module;
|
|
||||||
}
|
|
||||||
|
|
||||||
const double s0x1 = quaternion->s0 * quaternion->x1;
|
const double s0x1 = quaternion->s0 * quaternion->x1;
|
||||||
const double s0x2 = quaternion->s0 * quaternion->x2;
|
const double s0x2 = quaternion->s0 * quaternion->x2;
|
||||||
|
@ -113,17 +95,8 @@ void sp_quaternion_make_reverse_matrix(const SPQuaternion* quaternion, SPMatrix3
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float corrector1;
|
const float corrector1 = 1.0f / square_module;
|
||||||
float corrector2;
|
const float corrector2 = 2.0f * corrector1;
|
||||||
|
|
||||||
if (1.0f - SP_TWO_EPSYLON <= square_module && square_module <= 1.0f + SP_TWO_EPSYLON) {
|
|
||||||
corrector1 = 2.0f - square_module;
|
|
||||||
corrector2 = 2.0f * corrector1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
corrector1 = 1.0f / square_module;
|
|
||||||
corrector2 = 2.0f / square_module;
|
|
||||||
}
|
|
||||||
|
|
||||||
const float s0x1 = quaternion->s0 * quaternion->x1;
|
const float s0x1 = quaternion->s0 * quaternion->x1;
|
||||||
const float s0x2 = quaternion->s0 * quaternion->x2;
|
const float s0x2 = quaternion->s0 * quaternion->x2;
|
||||||
|
@ -160,17 +133,8 @@ void dp_quaternion_make_reverse_matrix(const DPQuaternion* quaternion, DPMatrix3
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double corrector1;
|
const double corrector1 = 1.0f / square_module;
|
||||||
double corrector2;
|
const double corrector2 = 2.0f * corrector1;
|
||||||
|
|
||||||
if (1.0 - DP_TWO_EPSYLON <= square_module && square_module <= 1.0 + DP_TWO_EPSYLON) {
|
|
||||||
corrector1 = 2.0 - square_module;
|
|
||||||
corrector2 = 2.0 * corrector1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
corrector1 = 1.0 / square_module;
|
|
||||||
corrector2 = 2.0 / square_module;
|
|
||||||
}
|
|
||||||
|
|
||||||
const double s0x1 = quaternion->s0 * quaternion->x1;
|
const double s0x1 = quaternion->s0 * quaternion->x1;
|
||||||
const double s0x2 = quaternion->s0 * quaternion->x2;
|
const double s0x2 = quaternion->s0 * quaternion->x2;
|
||||||
|
|
10
src/versor.c
10
src/versor.c
|
@ -3,11 +3,9 @@
|
||||||
#include "angle.h"
|
#include "angle.h"
|
||||||
#include "versor.h"
|
#include "versor.h"
|
||||||
|
|
||||||
const uint16_t GEOMETRY_VERSOR_COUNTER_LIMIT = 64;
|
const SPVersor SP_IDLE_VERSOR = { 1.0f, 0.0f, 0.0f, 0.0f };
|
||||||
|
|
||||||
const SPVersor SP_IDLE_VERSOR = { 1.0f, 1.0f, 0.0f, 0.0f, 0.0f };
|
const DPVersor DP_IDLE_VERSOR = { 1.0, 0.0, 0.0, 0.0 };
|
||||||
|
|
||||||
const DPVersor DP_IDLE_VERSOR = { 1.0, 1.0, 0.0, 0.0, 0.0 };
|
|
||||||
|
|
||||||
void __sp_versor_normalize(const float square_module, SPVersor* versor)
|
void __sp_versor_normalize(const float square_module, SPVersor* versor)
|
||||||
{
|
{
|
||||||
|
@ -27,8 +25,6 @@ void __sp_versor_normalize(const float square_module, SPVersor* versor)
|
||||||
versor->_x1 /= module;
|
versor->_x1 /= module;
|
||||||
versor->_x2 /= module;
|
versor->_x2 /= module;
|
||||||
versor->_x3 /= module;
|
versor->_x3 /= module;
|
||||||
|
|
||||||
versor->_corrector = 2.0f - (versor->_s0 * versor->_s0 + versor->_x1 * versor->_x1) - (versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void __dp_versor_normalize(const double square_module, DPVersor* versor)
|
void __dp_versor_normalize(const double square_module, DPVersor* versor)
|
||||||
|
@ -51,8 +47,6 @@ void __dp_versor_normalize(const double square_module, DPVersor* versor)
|
||||||
versor->_x1 /= module;
|
versor->_x1 /= module;
|
||||||
versor->_x2 /= module;
|
versor->_x2 /= module;
|
||||||
versor->_x3 /= module;
|
versor->_x3 /= module;
|
||||||
|
|
||||||
versor->_corrector = 2.0 - (versor->_s0 * versor->_s0 + versor->_x1 * versor->_x1) - (versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== Make ==================== //
|
// ==================== Make ==================== //
|
||||||
|
|
401
src/versor.h
401
src/versor.h
|
@ -9,11 +9,11 @@
|
||||||
#include "matrix3x3.h"
|
#include "matrix3x3.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float _corrector, _s0, _x1, _x2, _x3;
|
float _s0, _x1, _x2, _x3;
|
||||||
} SPVersor;
|
} SPVersor;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
double _corrector, _s0, _x1, _x2, _x3;
|
double _s0, _x1, _x2, _x3;
|
||||||
} DPVersor;
|
} DPVersor;
|
||||||
|
|
||||||
extern const SPVersor SP_IDLE_VERSOR;
|
extern const SPVersor SP_IDLE_VERSOR;
|
||||||
|
@ -23,7 +23,6 @@ extern const DPVersor DP_IDLE_VERSOR;
|
||||||
|
|
||||||
static inline void sp_versor_reset(SPVersor* versor)
|
static inline void sp_versor_reset(SPVersor* versor)
|
||||||
{
|
{
|
||||||
versor->_corrector = 1.0f;
|
|
||||||
versor->_s0 = 1.0f;
|
versor->_s0 = 1.0f;
|
||||||
versor->_x1 = 0.0f;
|
versor->_x1 = 0.0f;
|
||||||
versor->_x2 = 0.0f;
|
versor->_x2 = 0.0f;
|
||||||
|
@ -32,7 +31,6 @@ static inline void sp_versor_reset(SPVersor* versor)
|
||||||
|
|
||||||
static inline void dp_versor_reset(DPVersor* versor)
|
static inline void dp_versor_reset(DPVersor* versor)
|
||||||
{
|
{
|
||||||
versor->_corrector = 1.0;
|
|
||||||
versor->_s0 = 1.0;
|
versor->_s0 = 1.0;
|
||||||
versor->_x1 = 0.0;
|
versor->_x1 = 0.0;
|
||||||
versor->_x2 = 0.0;
|
versor->_x2 = 0.0;
|
||||||
|
@ -104,18 +102,6 @@ static inline double dp_get_x3(const DPVersor* versor)
|
||||||
return versor->_x3;
|
return versor->_x3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================ Get Corrector =============== //
|
|
||||||
|
|
||||||
static inline float sp_get_corrector(const SPVersor* versor)
|
|
||||||
{
|
|
||||||
return versor->_corrector;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline double dp_get_corrector(const DPVersor* versor)
|
|
||||||
{
|
|
||||||
return versor->_corrector;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==================== Set ===================== //
|
// ==================== Set ===================== //
|
||||||
|
|
||||||
void __sp_versor_normalize(const float square_module, SPVersor* versor);
|
void __sp_versor_normalize(const float square_module, SPVersor* versor);
|
||||||
|
@ -131,17 +117,16 @@ static inline void sp_versor_set(const float s0, const float x1, const float x2,
|
||||||
|
|
||||||
const float square_module = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
|
const float square_module = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
|
||||||
|
|
||||||
if (square_module < 1.0f - SP_TWO_EPSYLON || 1.0f + SP_TWO_EPSYLON < square_module) {
|
if (1.0f - SP_TWO_EPSYLON <= square_module && square_module <= 1.0f + SP_TWO_EPSYLON) {
|
||||||
__sp_versor_normalize(square_module, result);
|
if (s0 > -1.0f + SP_EPSYLON) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sp_versor_reset(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-1.0f + SP_EPSYLON < s0 && s0 < 1.0f - SP_EPSYLON) {
|
__sp_versor_normalize(square_module, result);
|
||||||
result->_corrector = 2.0f - square_module;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sp_versor_reset(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dp_versor_set(const double s0, const double x1, const double x2, const double x3, DPVersor* result)
|
static inline void dp_versor_set(const double s0, const double x1, const double x2, const double x3, DPVersor* result)
|
||||||
|
@ -153,24 +138,22 @@ static inline void dp_versor_set(const double s0, const double x1, const double
|
||||||
|
|
||||||
const double square_module = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
|
const double square_module = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
|
||||||
|
|
||||||
if (square_module < 1.0 - DP_TWO_EPSYLON || 1.0 + DP_TWO_EPSYLON < square_module) {
|
if (1.0 - DP_TWO_EPSYLON <= square_module && square_module <= 1.0 + DP_TWO_EPSYLON) {
|
||||||
__dp_versor_normalize(square_module, result);
|
if (s0 > -1.0 + DP_EPSYLON) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s0 < -1.0 + DP_EPSYLON || 1.0 - DP_EPSYLON < s0) {
|
|
||||||
dp_versor_reset(result);
|
dp_versor_reset(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
result->_corrector = 2.0 - square_module;
|
__sp_versor_normalize(square_module, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== Copy ==================== //
|
// ==================== Copy ==================== //
|
||||||
|
|
||||||
static inline void sp_versor_copy(const SPVersor* from, SPVersor* to)
|
static inline void sp_versor_copy(const SPVersor* from, SPVersor* to)
|
||||||
{
|
{
|
||||||
to->_corrector = from->_corrector;
|
|
||||||
to->_s0 = from->_s0;
|
to->_s0 = from->_s0;
|
||||||
to->_x1 = from->_x1;
|
to->_x1 = from->_x1;
|
||||||
to->_x2 = from->_x2;
|
to->_x2 = from->_x2;
|
||||||
|
@ -179,7 +162,6 @@ static inline void sp_versor_copy(const SPVersor* from, SPVersor* to)
|
||||||
|
|
||||||
static inline void dp_versor_copy(const DPVersor* from, DPVersor* to)
|
static inline void dp_versor_copy(const DPVersor* from, DPVersor* to)
|
||||||
{
|
{
|
||||||
to->_corrector = from->_corrector;
|
|
||||||
to->_s0 = from->_s0;
|
to->_s0 = from->_s0;
|
||||||
to->_x1 = from->_x1;
|
to->_x1 = from->_x1;
|
||||||
to->_x2 = from->_x2;
|
to->_x2 = from->_x2;
|
||||||
|
@ -268,7 +250,6 @@ static inline void dp_versor_invert(DPVersor* versor)
|
||||||
|
|
||||||
static inline void sp_versor_make_inverted(const SPVersor* versor, SPVersor* result)
|
static inline void sp_versor_make_inverted(const SPVersor* versor, SPVersor* result)
|
||||||
{
|
{
|
||||||
result->_corrector = versor->_corrector;
|
|
||||||
result->_s0 = versor->_s0;
|
result->_s0 = versor->_s0;
|
||||||
result->_x1 = -versor->_x1;
|
result->_x1 = -versor->_x1;
|
||||||
result->_x2 = -versor->_x2;
|
result->_x2 = -versor->_x2;
|
||||||
|
@ -277,7 +258,6 @@ static inline void sp_versor_make_inverted(const SPVersor* versor, SPVersor* res
|
||||||
|
|
||||||
static inline void dp_versor_make_inverted(const DPVersor* versor, DPVersor* result)
|
static inline void dp_versor_make_inverted(const DPVersor* versor, DPVersor* result)
|
||||||
{
|
{
|
||||||
result->_corrector = versor->_corrector;
|
|
||||||
result->_s0 = versor->_s0;
|
result->_s0 = versor->_s0;
|
||||||
result->_x1 = -versor->_x1;
|
result->_x1 = -versor->_x1;
|
||||||
result->_x2 = -versor->_x2;
|
result->_x2 = -versor->_x2;
|
||||||
|
@ -288,52 +268,11 @@ static inline void dp_versor_make_inverted(const DPVersor* versor, DPVersor* res
|
||||||
|
|
||||||
static inline void sp_versor_combine(const SPVersor* second, const SPVersor* first, SPVersor* result)
|
static inline void sp_versor_combine(const SPVersor* second, const SPVersor* first, SPVersor* result)
|
||||||
{
|
{
|
||||||
const float s0s0 = second->_s0 * first->_s0;
|
|
||||||
const float x1s0 = second->_x1 * first->_s0;
|
|
||||||
const float x2s0 = second->_x2 * first->_s0;
|
|
||||||
const float x3s0 = second->_x3 * first->_s0;
|
|
||||||
|
|
||||||
const float s0x1 = second->_s0 * first->_x1;
|
|
||||||
const float x1x1 = second->_x1 * first->_x1;
|
|
||||||
const float x2x1 = second->_x2 * first->_x1;
|
|
||||||
const float x3x1 = second->_x3 * first->_x1;
|
|
||||||
|
|
||||||
const float s0x2 = second->_s0 * first->_x2;
|
|
||||||
const float x1x2 = second->_x1 * first->_x2;
|
|
||||||
const float x2x2 = second->_x2 * first->_x2;
|
|
||||||
const float x3x2 = second->_x3 * first->_x2;
|
|
||||||
|
|
||||||
const float s0x3 = second->_s0 * first->_x3;
|
|
||||||
const float x1x3 = second->_x1 * first->_x3;
|
|
||||||
const float x2x3 = second->_x2 * first->_x3;
|
|
||||||
const float x3x3 = second->_x3 * first->_x3;
|
|
||||||
|
|
||||||
const float s0b = (x2x2 + x3x3);
|
|
||||||
const float x1a = (x1s0 + s0x1);
|
|
||||||
const float x2a = (x2s0 + s0x2);
|
|
||||||
const float x3a = (x3s0 + s0x3);
|
|
||||||
|
|
||||||
const float s0a = (s0s0 - x1x1);
|
|
||||||
const float x1b = (x3x2 - x2x3);
|
|
||||||
const float x2b = (x1x3 - x3x1);
|
|
||||||
const float x3b = (x2x1 - x1x2);
|
|
||||||
|
|
||||||
sp_versor_set(
|
sp_versor_set(
|
||||||
s0a - s0b,
|
(second->_s0 * first->_s0 - second->_x1 * first->_x1) - (second->_x2 * first->_x2 + second->_x3 * first->_x3),
|
||||||
x1a - x1b,
|
(second->_x1 * first->_s0 + second->_s0 * first->_x1) - (second->_x3 * first->_x2 - second->_x2 * first->_x3),
|
||||||
x2a - x2b,
|
(second->_x2 * first->_s0 + second->_s0 * first->_x2) - (second->_x1 * first->_x3 - second->_x3 * first->_x1),
|
||||||
x3a - x3b,
|
(second->_x3 * first->_s0 + second->_s0 * first->_x3) - (second->_x2 * first->_x1 - second->_x1 * first->_x2),
|
||||||
result
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void sp_versor_combine2(const SPVersor* second, const SPVersor* first, SPVersor* result)
|
|
||||||
{
|
|
||||||
sp_versor_set(
|
|
||||||
((second->_s0 * first->_s0 - second->_x1 * first->_x1) - (second->_x2 * first->_x2 + second->_x3 * first->_x3)),
|
|
||||||
((second->_x1 * first->_s0 + second->_s0 * first->_x1) - (second->_x3 * first->_x2 - second->_x2 * first->_x3)),
|
|
||||||
((second->_x2 * first->_s0 + second->_s0 * first->_x2) - (second->_x1 * first->_x3 - second->_x3 * first->_x1)),
|
|
||||||
((second->_x3 * first->_s0 + second->_s0 * first->_x3) - (second->_x2 * first->_x1 - second->_x1 * first->_x2)),
|
|
||||||
result
|
result
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -364,27 +303,25 @@ static inline void sp_versor_make_matrix(const SPVersor* versor, SPMatrix3x3* ma
|
||||||
const float x2x2 = versor->_x2 * versor->_x2;
|
const float x2x2 = versor->_x2 * versor->_x2;
|
||||||
const float x3x3 = versor->_x3 * versor->_x3;
|
const float x3x3 = versor->_x3 * versor->_x3;
|
||||||
|
|
||||||
const float s0x1 = versor->_s0 * versor->_x1;
|
const float s0x1 = 2.0f * versor->_s0 * versor->_x1;
|
||||||
const float s0x2 = versor->_s0 * versor->_x2;
|
const float s0x2 = 2.0f * versor->_s0 * versor->_x2;
|
||||||
const float s0x3 = versor->_s0 * versor->_x3;
|
const float s0x3 = 2.0f * versor->_s0 * versor->_x3;
|
||||||
|
|
||||||
const float x1x2 = versor->_x1 * versor->_x2;
|
const float x1x2 = 2.0f * versor->_x1 * versor->_x2;
|
||||||
const float x1x3 = versor->_x1 * versor->_x3;
|
const float x1x3 = 2.0f * versor->_x1 * versor->_x3;
|
||||||
const float x2x3 = versor->_x2 * versor->_x3;
|
const float x2x3 = 2.0f * versor->_x2 * versor->_x3;
|
||||||
|
|
||||||
const float corrector2 = 2.0f * versor->_corrector;
|
matrix->r1c1 = (s0s0 + x1x1) - (x2x2 + x3x3);
|
||||||
|
matrix->r2c2 = (s0s0 + x2x2) - (x1x1 + x3x3);
|
||||||
|
matrix->r3c3 = (s0s0 + x3x3) - (x1x1 + x2x2);
|
||||||
|
|
||||||
matrix->r1c1 = versor->_corrector * ((s0s0 + x1x1) - (x2x2 + x3x3));
|
matrix->r1c2 = x1x2 - s0x3;
|
||||||
matrix->r2c2 = versor->_corrector * ((s0s0 + x2x2) - (x1x1 + x3x3));
|
matrix->r2c3 = x2x3 - s0x1;
|
||||||
matrix->r3c3 = versor->_corrector * ((s0s0 + x3x3) - (x1x1 + x2x2));
|
matrix->r3c1 = x1x3 - s0x2;
|
||||||
|
|
||||||
matrix->r1c2 = corrector2 * (x1x2 - s0x3);
|
matrix->r2c1 = x1x2 + s0x3;
|
||||||
matrix->r2c3 = corrector2 * (x2x3 - s0x1);
|
matrix->r3c2 = x2x3 + s0x1;
|
||||||
matrix->r3c1 = corrector2 * (x1x3 - s0x2);
|
matrix->r1c3 = x1x3 + s0x2;
|
||||||
|
|
||||||
matrix->r2c1 = corrector2 * (x1x2 + s0x3);
|
|
||||||
matrix->r3c2 = corrector2 * (x2x3 + s0x1);
|
|
||||||
matrix->r1c3 = corrector2 * (x1x3 + s0x2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dp_versor_make_matrix(const DPVersor* versor, DPMatrix3x3* matrix)
|
static inline void dp_versor_make_matrix(const DPVersor* versor, DPMatrix3x3* matrix)
|
||||||
|
@ -394,27 +331,25 @@ static inline void dp_versor_make_matrix(const DPVersor* versor, DPMatrix3x3* ma
|
||||||
const double x2x2 = versor->_x2 * versor->_x2;
|
const double x2x2 = versor->_x2 * versor->_x2;
|
||||||
const double x3x3 = versor->_x3 * versor->_x3;
|
const double x3x3 = versor->_x3 * versor->_x3;
|
||||||
|
|
||||||
const double s0x1 = versor->_s0 * versor->_x1;
|
const double s0x1 = 2.0 * versor->_s0 * versor->_x1;
|
||||||
const double s0x2 = versor->_s0 * versor->_x2;
|
const double s0x2 = 2.0 * versor->_s0 * versor->_x2;
|
||||||
const double s0x3 = versor->_s0 * versor->_x3;
|
const double s0x3 = 2.0 * versor->_s0 * versor->_x3;
|
||||||
|
|
||||||
const double x1x2 = versor->_x1 * versor->_x2;
|
const double x1x2 = 2.0 * versor->_x1 * versor->_x2;
|
||||||
const double x1x3 = versor->_x1 * versor->_x3;
|
const double x1x3 = 2.0 * versor->_x1 * versor->_x3;
|
||||||
const double x2x3 = versor->_x2 * versor->_x3;
|
const double x2x3 = 2.0 * versor->_x2 * versor->_x3;
|
||||||
|
|
||||||
const double corrector2 = 2.0 * versor->_corrector;
|
matrix->r1c1 = (s0s0 + x1x1) - (x2x2 + x3x3);
|
||||||
|
matrix->r2c2 = (s0s0 + x2x2) - (x1x1 + x3x3);
|
||||||
|
matrix->r3c3 = (s0s0 + x3x3) - (x1x1 + x2x2);
|
||||||
|
|
||||||
matrix->r1c1 = versor->_corrector * ((s0s0 + x1x1) - (x2x2 + x3x3));
|
matrix->r1c2 = x1x2 - s0x3;
|
||||||
matrix->r2c2 = versor->_corrector * ((s0s0 + x2x2) - (x1x1 + x3x3));
|
matrix->r2c3 = x2x3 - s0x1;
|
||||||
matrix->r3c3 = versor->_corrector * ((s0s0 + x3x3) - (x1x1 + x2x2));
|
matrix->r3c1 = x1x3 - s0x2;
|
||||||
|
|
||||||
matrix->r1c2 = corrector2 * (x1x2 - s0x3);
|
matrix->r2c1 = x1x2 + s0x3;
|
||||||
matrix->r2c3 = corrector2 * (x2x3 - s0x1);
|
matrix->r3c2 = x2x3 + s0x1;
|
||||||
matrix->r3c1 = corrector2 * (x1x3 - s0x2);
|
matrix->r1c3 = x1x3 + s0x2;
|
||||||
|
|
||||||
matrix->r2c1 = corrector2 * (x1x2 + s0x3);
|
|
||||||
matrix->r3c2 = corrector2 * (x2x3 + s0x1);
|
|
||||||
matrix->r1c3 = corrector2 * (x1x3 + s0x2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =========== Make Reverse Matrix3x3 =========== //
|
// =========== Make Reverse Matrix3x3 =========== //
|
||||||
|
@ -426,27 +361,25 @@ static inline void sp_versor_make_reverse_matrix(const SPVersor* versor, SPMatri
|
||||||
const float x2x2 = versor->_x2 * versor->_x2;
|
const float x2x2 = versor->_x2 * versor->_x2;
|
||||||
const float x3x3 = versor->_x3 * versor->_x3;
|
const float x3x3 = versor->_x3 * versor->_x3;
|
||||||
|
|
||||||
const float s0x1 = versor->_s0 * versor->_x1;
|
const float s0x1 = 2.0f * versor->_s0 * versor->_x1;
|
||||||
const float s0x2 = versor->_s0 * versor->_x2;
|
const float s0x2 = 2.0f * versor->_s0 * versor->_x2;
|
||||||
const float s0x3 = versor->_s0 * versor->_x3;
|
const float s0x3 = 2.0f * versor->_s0 * versor->_x3;
|
||||||
|
|
||||||
const float x1x2 = versor->_x1 * versor->_x2;
|
const float x1x2 = 2.0f * versor->_x1 * versor->_x2;
|
||||||
const float x1x3 = versor->_x1 * versor->_x3;
|
const float x1x3 = 2.0f * versor->_x1 * versor->_x3;
|
||||||
const float x2x3 = versor->_x2 * versor->_x3;
|
const float x2x3 = 2.0f * versor->_x2 * versor->_x3;
|
||||||
|
|
||||||
const float corrector2 = 2.0f * versor->_corrector;
|
matrix->r1c1 = (s0s0 + x1x1) - (x2x2 + x3x3);
|
||||||
|
matrix->r2c2 = (s0s0 + x2x2) - (x1x1 + x3x3);
|
||||||
|
matrix->r3c3 = (s0s0 + x3x3) - (x1x1 + x2x2);
|
||||||
|
|
||||||
matrix->r1c1 = versor->_corrector * ((s0s0 + x1x1) - (x2x2 + x3x3));
|
matrix->r1c2 = x1x2 + s0x3;
|
||||||
matrix->r2c2 = versor->_corrector * ((s0s0 + x2x2) - (x1x1 + x3x3));
|
matrix->r2c3 = x2x3 + s0x1;
|
||||||
matrix->r3c3 = versor->_corrector * ((s0s0 + x3x3) - (x1x1 + x2x2));
|
matrix->r3c1 = x1x3 + s0x2;
|
||||||
|
|
||||||
matrix->r1c2 = corrector2 * (x1x2 + s0x3);
|
matrix->r2c1 = x1x2 - s0x3;
|
||||||
matrix->r2c3 = corrector2 * (x2x3 + s0x1);
|
matrix->r3c2 = x2x3 - s0x1;
|
||||||
matrix->r3c1 = corrector2 * (x1x3 + s0x2);
|
matrix->r1c3 = x1x3 - s0x2;
|
||||||
|
|
||||||
matrix->r2c1 = corrector2 * (x1x2 - s0x3);
|
|
||||||
matrix->r3c2 = corrector2 * (x2x3 - s0x1);
|
|
||||||
matrix->r1c3 = corrector2 * (x1x3 - s0x2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void dp_versor_make_reverse_matrix(const DPVersor* versor, DPMatrix3x3* matrix)
|
static inline void dp_versor_make_reverse_matrix(const DPVersor* versor, DPMatrix3x3* matrix)
|
||||||
|
@ -456,37 +389,34 @@ static inline void dp_versor_make_reverse_matrix(const DPVersor* versor, DPMatri
|
||||||
const double x2x2 = versor->_x2 * versor->_x2;
|
const double x2x2 = versor->_x2 * versor->_x2;
|
||||||
const double x3x3 = versor->_x3 * versor->_x3;
|
const double x3x3 = versor->_x3 * versor->_x3;
|
||||||
|
|
||||||
const double s0x1 = versor->_s0 * versor->_x1;
|
const double s0x1 = 2.0 * versor->_s0 * versor->_x1;
|
||||||
const double s0x2 = versor->_s0 * versor->_x2;
|
const double s0x2 = 2.0 * versor->_s0 * versor->_x2;
|
||||||
const double s0x3 = versor->_s0 * versor->_x3;
|
const double s0x3 = 2.0 * versor->_s0 * versor->_x3;
|
||||||
|
|
||||||
const double x1x2 = versor->_x1 * versor->_x2;
|
const double x1x2 = 2.0 * versor->_x1 * versor->_x2;
|
||||||
const double x1x3 = versor->_x1 * versor->_x3;
|
const double x1x3 = 2.0 * versor->_x1 * versor->_x3;
|
||||||
const double x2x3 = versor->_x2 * versor->_x3;
|
const double x2x3 = 2.0 * versor->_x2 * versor->_x3;
|
||||||
|
|
||||||
const double corrector2 = 2.0 * versor->_corrector;
|
matrix->r1c1 = (s0s0 + x1x1) - (x2x2 + x3x3);
|
||||||
|
matrix->r2c2 = (s0s0 + x2x2) - (x1x1 + x3x3);
|
||||||
|
matrix->r3c3 = (s0s0 + x3x3) - (x1x1 + x2x2);
|
||||||
|
|
||||||
matrix->r1c1 = versor->_corrector * ((s0s0 + x1x1) - (x2x2 + x3x3));
|
matrix->r1c2 = x1x2 + s0x3;
|
||||||
matrix->r2c2 = versor->_corrector * ((s0s0 + x2x2) - (x1x1 + x3x3));
|
matrix->r2c3 = x2x3 + s0x1;
|
||||||
matrix->r3c3 = versor->_corrector * ((s0s0 + x3x3) - (x1x1 + x2x2));
|
matrix->r3c1 = x1x3 + s0x2;
|
||||||
|
|
||||||
matrix->r1c2 = corrector2 * (x1x2 + s0x3);
|
matrix->r2c1 = x1x2 - s0x3;
|
||||||
matrix->r2c3 = corrector2 * (x2x3 + s0x1);
|
matrix->r3c2 = x2x3 - s0x1;
|
||||||
matrix->r3c1 = corrector2 * (x1x3 + s0x2);
|
matrix->r1c3 = x1x3 - s0x2;
|
||||||
|
|
||||||
matrix->r2c1 = corrector2 * (x1x2 - s0x3);
|
|
||||||
matrix->r3c2 = corrector2 * (x2x3 - s0x1);
|
|
||||||
matrix->r1c3 = corrector2 * (x1x3 - s0x2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================ Turn Vector ================= //
|
// ================ Turn Vector ================= //
|
||||||
|
|
||||||
static inline void sp_versor_turn(const SPVersor* versor, const SPVector3* vector, SPVector3* result)
|
static inline void sp_versor_turn(const SPVersor* versor, const SPVector3* vector, SPVector3* result)
|
||||||
{
|
{
|
||||||
const float multiplier = 2.0f * versor->_corrector;
|
const float tx1 = 2.0f * (versor->_x2 * vector->x3 - versor->_x3 * vector->x2);
|
||||||
const float tx1 = multiplier * (versor->_x2 * vector->x3 - versor->_x3 * vector->x2);
|
const float tx2 = 2.0f * (versor->_x3 * vector->x1 - versor->_x1 * vector->x3);
|
||||||
const float tx2 = multiplier * (versor->_x3 * vector->x1 - versor->_x1 * vector->x3);
|
const float tx3 = 2.0f * (versor->_x1 * vector->x2 - versor->_x2 * vector->x1);
|
||||||
const float tx3 = multiplier * (versor->_x1 * vector->x2 - versor->_x2 * vector->x1);
|
|
||||||
|
|
||||||
const float x1 = (vector->x1 + tx1 * versor->_s0) + (versor->_x2 * tx3 - versor->_x3 * tx2);
|
const float x1 = (vector->x1 + tx1 * versor->_s0) + (versor->_x2 * tx3 - versor->_x3 * tx2);
|
||||||
const float x2 = (vector->x2 + tx2 * versor->_s0) + (versor->_x3 * tx1 - versor->_x1 * tx3);
|
const float x2 = (vector->x2 + tx2 * versor->_s0) + (versor->_x3 * tx1 - versor->_x1 * tx3);
|
||||||
|
@ -499,10 +429,9 @@ static inline void sp_versor_turn(const SPVersor* versor, const SPVector3* vecto
|
||||||
|
|
||||||
static inline void dp_versor_turn(const DPVersor* versor, const DPVector3* vector, DPVector3* result)
|
static inline void dp_versor_turn(const DPVersor* versor, const DPVector3* vector, DPVector3* result)
|
||||||
{
|
{
|
||||||
const double multiplier = 2.0 * versor->_corrector;
|
const double tx1 = 2.0 * (versor->_x2 * vector->x3 - versor->_x3 * vector->x2);
|
||||||
const double tx1 = multiplier * (versor->_x2 * vector->x3 - versor->_x3 * vector->x2);
|
const double tx2 = 2.0 * (versor->_x3 * vector->x1 - versor->_x1 * vector->x3);
|
||||||
const double tx2 = multiplier * (versor->_x3 * vector->x1 - versor->_x1 * vector->x3);
|
const double tx3 = 2.0 * (versor->_x1 * vector->x2 - versor->_x2 * vector->x1);
|
||||||
const double tx3 = multiplier * (versor->_x1 * vector->x2 - versor->_x2 * vector->x1);
|
|
||||||
|
|
||||||
const double x1 = (vector->x1 + tx1 * versor->_s0) + (versor->_x2 * tx3 - versor->_x3 * tx2);
|
const double x1 = (vector->x1 + tx1 * versor->_s0) + (versor->_x2 * tx3 - versor->_x3 * tx2);
|
||||||
const double x2 = (vector->x2 + tx2 * versor->_s0) + (versor->_x3 * tx1 - versor->_x1 * tx3);
|
const double x2 = (vector->x2 + tx2 * versor->_s0) + (versor->_x3 * tx1 - versor->_x1 * tx3);
|
||||||
|
@ -513,14 +442,87 @@ static inline void dp_versor_turn(const DPVersor* versor, const DPVector3* vecto
|
||||||
result->x3 = x3;
|
result->x3 = x3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ================ Turn2 Vector ================ //
|
||||||
|
|
||||||
|
static inline void sp_versor_turn2(const SPVersor* versor, const SPVector3* vector, SPVector3* result)
|
||||||
|
{
|
||||||
|
const float s0s0 = versor->_s0 * versor->_s0;
|
||||||
|
const float x1x1 = versor->_x1 * versor->_x1;
|
||||||
|
const float x2x2 = versor->_x2 * versor->_x2;
|
||||||
|
const float x3x3 = versor->_x3 * versor->_x3;
|
||||||
|
|
||||||
|
const float s0x1 = 2.0f * versor->_s0 * versor->_x1;
|
||||||
|
const float s0x2 = 2.0f * versor->_s0 * versor->_x2;
|
||||||
|
const float s0x3 = 2.0f * versor->_s0 * versor->_x3;
|
||||||
|
|
||||||
|
const float x1x2 = 2.0f * versor->_x1 * versor->_x2;
|
||||||
|
const float x1x3 = 2.0f * versor->_x1 * versor->_x3;
|
||||||
|
const float x2x3 = 2.0f * versor->_x2 * versor->_x3;
|
||||||
|
|
||||||
|
const float r2c1 = x1x2 + s0x3;
|
||||||
|
const float r3c2 = x2x3 + s0x1;
|
||||||
|
const float r1c3 = x1x3 + s0x2;
|
||||||
|
|
||||||
|
const float r1c1 = (s0s0 + x1x1) - (x2x2 + x3x3);
|
||||||
|
const float r2c2 = (s0s0 + x2x2) - (x1x1 + x3x3);
|
||||||
|
const float r3c3 = (s0s0 + x3x3) - (x1x1 + x2x2);
|
||||||
|
|
||||||
|
const float r1c2 = x1x2 - s0x3;
|
||||||
|
const float r2c3 = x2x3 - s0x1;
|
||||||
|
const float r3c1 = x1x3 - s0x2;
|
||||||
|
|
||||||
|
const float x1 = r1c1 * vector->x1 + r1c2 * vector->x2 + r1c3 * vector->x3;
|
||||||
|
const float x2 = r2c1 * vector->x1 + r2c2 * vector->x2 + r2c3 * vector->x3;
|
||||||
|
const float x3 = r3c1 * vector->x1 + r3c2 * vector->x2 + r3c3 * vector->x3;
|
||||||
|
|
||||||
|
result->x1 = x1;
|
||||||
|
result->x2 = x2;
|
||||||
|
result->x3 = x3;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_versor_turn2(const DPVersor* versor, const DPVector3* vector, DPVector3* result)
|
||||||
|
{
|
||||||
|
const double s0s0 = versor->_s0 * versor->_s0;
|
||||||
|
const double x1x1 = versor->_x1 * versor->_x1;
|
||||||
|
const double x2x2 = versor->_x2 * versor->_x2;
|
||||||
|
const double x3x3 = versor->_x3 * versor->_x3;
|
||||||
|
|
||||||
|
const double s0x1 = 2.0f * versor->_s0 * versor->_x1;
|
||||||
|
const double s0x2 = 2.0f * versor->_s0 * versor->_x2;
|
||||||
|
const double s0x3 = 2.0f * versor->_s0 * versor->_x3;
|
||||||
|
|
||||||
|
const double x1x2 = 2.0f * versor->_x1 * versor->_x2;
|
||||||
|
const double x1x3 = 2.0f * versor->_x1 * versor->_x3;
|
||||||
|
const double x2x3 = 2.0f * versor->_x2 * versor->_x3;
|
||||||
|
|
||||||
|
const double r2c1 = x1x2 + s0x3;
|
||||||
|
const double r3c2 = x2x3 + s0x1;
|
||||||
|
const double r1c3 = x1x3 + s0x2;
|
||||||
|
|
||||||
|
const double r1c1 = (s0s0 + x1x1) - (x2x2 + x3x3);
|
||||||
|
const double r2c2 = (s0s0 + x2x2) - (x1x1 + x3x3);
|
||||||
|
const double r3c3 = (s0s0 + x3x3) - (x1x1 + x2x2);
|
||||||
|
|
||||||
|
const double r1c2 = x1x2 - s0x3;
|
||||||
|
const double r2c3 = x2x3 - s0x1;
|
||||||
|
const double r3c1 = x1x3 - s0x2;
|
||||||
|
|
||||||
|
const double x1 = r1c1 * vector->x1 + r1c2 * vector->x2 + r1c3 * vector->x3;
|
||||||
|
const double x2 = r2c1 * vector->x1 + r2c2 * vector->x2 + r2c3 * vector->x3;
|
||||||
|
const double x3 = r3c1 * vector->x1 + r3c2 * vector->x2 + r3c3 * vector->x3;
|
||||||
|
|
||||||
|
result->x1 = x1;
|
||||||
|
result->x2 = x2;
|
||||||
|
result->x3 = x3;
|
||||||
|
}
|
||||||
|
|
||||||
// ============== Turn Vector Back ============== //
|
// ============== Turn Vector Back ============== //
|
||||||
|
|
||||||
static inline void sp_versor_turn_back(const SPVersor* versor, const SPVector3* vector, SPVector3* result)
|
static inline void sp_versor_turn_back(const SPVersor* versor, const SPVector3* vector, SPVector3* result)
|
||||||
{
|
{
|
||||||
const float multiplier = 2.0f * versor->_corrector;
|
const float tx1 = 2.0f * (versor->_x2 * vector->x3 - versor->_x3 * vector->x2);
|
||||||
const float tx1 = multiplier * (versor->_x2 * vector->x3 - versor->_x3 * vector->x2);
|
const float tx2 = 2.0f * (versor->_x3 * vector->x1 - versor->_x1 * vector->x3);
|
||||||
const float tx2 = multiplier * (versor->_x3 * vector->x1 - versor->_x1 * vector->x3);
|
const float tx3 = 2.0f * (versor->_x1 * vector->x2 - versor->_x2 * vector->x1);
|
||||||
const float tx3 = multiplier * (versor->_x1 * vector->x2 - versor->_x2 * vector->x1);
|
|
||||||
|
|
||||||
const float x1 = (vector->x1 - tx1 * versor->_s0) + (versor->_x2 * tx3 - versor->_x3 * tx2);
|
const float x1 = (vector->x1 - tx1 * versor->_s0) + (versor->_x2 * tx3 - versor->_x3 * tx2);
|
||||||
const float x2 = (vector->x2 - tx2 * versor->_s0) + (versor->_x3 * tx1 - versor->_x1 * tx3);
|
const float x2 = (vector->x2 - tx2 * versor->_s0) + (versor->_x3 * tx1 - versor->_x1 * tx3);
|
||||||
|
@ -533,10 +535,9 @@ static inline void sp_versor_turn_back(const SPVersor* versor, const SPVector3*
|
||||||
|
|
||||||
static inline void dp_versor_turn_back(const DPVersor* versor, const DPVector3* vector, DPVector3* result)
|
static inline void dp_versor_turn_back(const DPVersor* versor, const DPVector3* vector, DPVector3* result)
|
||||||
{
|
{
|
||||||
const double multiplier = 2.0 * versor->_corrector;
|
const double tx1 = 2.0 * (versor->_x2 * vector->x3 - versor->_x3 * vector->x2);
|
||||||
const double tx1 = multiplier * (versor->_x2 * vector->x3 - versor->_x3 * vector->x2);
|
const double tx2 = 2.0 * (versor->_x3 * vector->x1 - versor->_x1 * vector->x3);
|
||||||
const double tx2 = multiplier * (versor->_x3 * vector->x1 - versor->_x1 * vector->x3);
|
const double tx3 = 2.0 * (versor->_x1 * vector->x2 - versor->_x2 * vector->x1);
|
||||||
const double tx3 = multiplier * (versor->_x1 * vector->x2 - versor->_x2 * vector->x1);
|
|
||||||
|
|
||||||
const double x1 = (vector->x1 - tx1 * versor->_s0) + (versor->_x2 * tx3 - versor->_x3 * tx2);
|
const double x1 = (vector->x1 - tx1 * versor->_s0) + (versor->_x2 * tx3 - versor->_x3 * tx2);
|
||||||
const double x2 = (vector->x2 - tx2 * versor->_s0) + (versor->_x3 * tx1 - versor->_x1 * tx3);
|
const double x2 = (vector->x2 - tx2 * versor->_s0) + (versor->_x3 * tx1 - versor->_x1 * tx3);
|
||||||
|
@ -547,4 +548,78 @@ static inline void dp_versor_turn_back(const DPVersor* versor, const DPVector3*
|
||||||
result->x3 = x3;
|
result->x3 = x3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ============== Turn Vector Back2 ============= //
|
||||||
|
|
||||||
|
static inline void sp_versor_turn_back2(const SPVersor* versor, const SPVector3* vector, SPVector3* result)
|
||||||
|
{
|
||||||
|
const float s0s0 = versor->_s0 * versor->_s0;
|
||||||
|
const float x1x1 = versor->_x1 * versor->_x1;
|
||||||
|
const float x2x2 = versor->_x2 * versor->_x2;
|
||||||
|
const float x3x3 = versor->_x3 * versor->_x3;
|
||||||
|
|
||||||
|
const float s0x1 = 2.0f * versor->_s0 * versor->_x1;
|
||||||
|
const float s0x2 = 2.0f * versor->_s0 * versor->_x2;
|
||||||
|
const float s0x3 = 2.0f * versor->_s0 * versor->_x3;
|
||||||
|
|
||||||
|
const float x1x2 = 2.0f * versor->_x1 * versor->_x2;
|
||||||
|
const float x1x3 = 2.0f * versor->_x1 * versor->_x3;
|
||||||
|
const float x2x3 = 2.0f * versor->_x2 * versor->_x3;
|
||||||
|
|
||||||
|
const float r1c2 = x1x2 + s0x3;
|
||||||
|
const float r2c3 = x2x3 + s0x1;
|
||||||
|
const float r3c1 = x1x3 + s0x2;
|
||||||
|
|
||||||
|
const float r1c1 = (s0s0 + x1x1) - (x2x2 + x3x3);
|
||||||
|
const float r2c2 = (s0s0 + x2x2) - (x1x1 + x3x3);
|
||||||
|
const float r3c3 = (s0s0 + x3x3) - (x1x1 + x2x2);
|
||||||
|
|
||||||
|
const float r2c1 = x1x2 - s0x3;
|
||||||
|
const float r3c2 = x2x3 - s0x1;
|
||||||
|
const float r1c3 = x1x3 - s0x2;
|
||||||
|
|
||||||
|
const float x1 = r1c1 * vector->x1 + r1c2 * vector->x2 + r1c3 * vector->x3;
|
||||||
|
const float x2 = r2c1 * vector->x1 + r2c2 * vector->x2 + r2c3 * vector->x3;
|
||||||
|
const float x3 = r3c1 * vector->x1 + r3c2 * vector->x2 + r3c3 * vector->x3;
|
||||||
|
|
||||||
|
result->x1 = x1;
|
||||||
|
result->x2 = x2;
|
||||||
|
result->x3 = x3;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dp_versor_turn_back2(const DPVersor* versor, const DPVector3* vector, DPVector3* result)
|
||||||
|
{
|
||||||
|
const double s0s0 = versor->_s0 * versor->_s0;
|
||||||
|
const double x1x1 = versor->_x1 * versor->_x1;
|
||||||
|
const double x2x2 = versor->_x2 * versor->_x2;
|
||||||
|
const double x3x3 = versor->_x3 * versor->_x3;
|
||||||
|
|
||||||
|
const double s0x1 = 2.0f * versor->_s0 * versor->_x1;
|
||||||
|
const double s0x2 = 2.0f * versor->_s0 * versor->_x2;
|
||||||
|
const double s0x3 = 2.0f * versor->_s0 * versor->_x3;
|
||||||
|
|
||||||
|
const double x1x2 = 2.0f * versor->_x1 * versor->_x2;
|
||||||
|
const double x1x3 = 2.0f * versor->_x1 * versor->_x3;
|
||||||
|
const double x2x3 = 2.0f * versor->_x2 * versor->_x3;
|
||||||
|
|
||||||
|
const double r1c2 = x1x2 + s0x3;
|
||||||
|
const double r2c3 = x2x3 + s0x1;
|
||||||
|
const double r3c1 = x1x3 + s0x2;
|
||||||
|
|
||||||
|
const double r1c1 = (s0s0 + x1x1) - (x2x2 + x3x3);
|
||||||
|
const double r2c2 = (s0s0 + x2x2) - (x1x1 + x3x3);
|
||||||
|
const double r3c3 = (s0s0 + x3x3) - (x1x1 + x2x2);
|
||||||
|
|
||||||
|
const double r2c1 = x1x2 - s0x3;
|
||||||
|
const double r3c2 = x2x3 - s0x1;
|
||||||
|
const double r1c3 = x1x3 - s0x2;
|
||||||
|
|
||||||
|
const double x1 = r1c1 * vector->x1 + r1c2 * vector->x2 + r1c3 * vector->x3;
|
||||||
|
const double x2 = r2c1 * vector->x1 + r2c2 * vector->x2 + r2c3 * vector->x3;
|
||||||
|
const double x3 = r3c1 * vector->x1 + r3c2 * vector->x2 + r3c3 * vector->x3;
|
||||||
|
|
||||||
|
result->x1 = x1;
|
||||||
|
result->x2 = x2;
|
||||||
|
result->x3 = x3;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2,6 +2,11 @@
|
||||||
<CodeBlocks_layout_file>
|
<CodeBlocks_layout_file>
|
||||||
<FileVersion major="1" minor="0" />
|
<FileVersion major="1" minor="0" />
|
||||||
<ActiveTarget name="Debug" />
|
<ActiveTarget name="Debug" />
|
||||||
|
<File name="main.c" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="178" topLine="0" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
<File name="geometry_test.c" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="geometry_test.c" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="407" topLine="0" />
|
<Cursor1 position="407" topLine="0" />
|
||||||
|
@ -12,9 +17,4 @@
|
||||||
<Cursor1 position="177" topLine="4" />
|
<Cursor1 position="177" topLine="4" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="main.c" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="178" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
</CodeBlocks_layout_file>
|
</CodeBlocks_layout_file>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue