Задача 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++) {
|
||||||