Задача 0000001: отказ от использования корректоров в версорах / Task 0000001: declining of usage of correctors in versors

This commit is contained in:
Andrey Pokidov 2024-11-19 14:21:01 +07:00
parent 07c1330858
commit 791557fb94
9 changed files with 421 additions and 364 deletions

View file

@ -50,12 +50,77 @@ SPVersor * make_random_versors(const unsigned int amount)
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()
{
const unsigned int amount = 1000000;
@ -103,7 +168,7 @@ int main()
#endif // _WIN64
for (int j = 0; j < 1000; j++) {
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;
}
/*/
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;
}