517 lines
18 KiB
C
517 lines
18 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <math.h>
|
|
#include <basic-geometry.h>
|
|
|
|
#ifdef _WIN64
|
|
#include <windows.h>
|
|
#else
|
|
#include <time.h>
|
|
#endif // _WINDOWS_
|
|
|
|
typedef struct {
|
|
BGC_FP32_Turn3 versor1, versor2, result;
|
|
} structure_fp32_t;
|
|
|
|
structure_fp32_t* allocate_structures(const unsigned int amount)
|
|
{
|
|
return calloc(amount, sizeof(structure_fp32_t));
|
|
}
|
|
|
|
structure_fp32_t* make_structures(const unsigned int amount)
|
|
{
|
|
structure_fp32_t* list = allocate_structures(amount);
|
|
|
|
if (list == 0) {
|
|
return 0;
|
|
}
|
|
|
|
const float multiplier = 2.0f / RAND_MAX;
|
|
|
|
for (unsigned int i = 0; i < amount; i++) {
|
|
bgc_fp32_turn3_set_raw_values(
|
|
&list[i].versor1,
|
|
rand() * multiplier - 1.0f,
|
|
rand() * multiplier - 1.0f,
|
|
rand() * multiplier - 1.0f,
|
|
rand() * multiplier - 1.0f
|
|
);
|
|
|
|
bgc_fp32_turn3_set_raw_values(
|
|
&list[i].versor2,
|
|
rand() * multiplier - 1.0f,
|
|
rand() * multiplier - 1.0f,
|
|
rand() * multiplier - 1.0f,
|
|
rand() * multiplier - 1.0f
|
|
);
|
|
|
|
bgc_fp32_turn3_reset(&list[i].result);
|
|
}
|
|
|
|
return list;
|
|
}
|
|
|
|
void print_quaternion_fp32(const BGC_FP32_Quaternion* quaternion)
|
|
{
|
|
printf("Quaternion FP32(s0 = %0.12f, x1 = %0.12f, x2 = %0.12f, x3 = %0.12f)\n", quaternion->s0, quaternion->x1, quaternion->x2, quaternion->x3);
|
|
}
|
|
|
|
void print_quaternion_fp64(const BGC_FP64_Quaternion* quaternion)
|
|
{
|
|
printf("Quaternion FP64(s0 = %0.12f, x1 = %0.12f, x2 = %0.12f, x3 = %0.12f)\n", quaternion->s0, quaternion->x1, quaternion->x2, quaternion->x3);
|
|
}
|
|
|
|
void print_vector_fp32(const BGC_FP32_Vector3* vector)
|
|
{
|
|
printf("(%f, %f, %f) / %f\n", vector->x1, vector->x2, vector->x3, bgc_fp32_vector3_get_modulus(vector));
|
|
}
|
|
|
|
void print_vector_fp64(const BGC_FP64_Vector3* vector)
|
|
{
|
|
printf("(%lf, %lf, %lf) / %lf\n", vector->x1, vector->x2, vector->x3, bgc_fp64_vector3_get_modulus(vector));
|
|
}
|
|
|
|
void list_work(const uint_fast32_t amount, structure_fp32_t* list)
|
|
{
|
|
for (uint_fast32_t j = 0; j < 1000; j++) {
|
|
for (uint_fast32_t i = 0; i < amount; i++) {
|
|
bgc_fp32_turn3_combine(&list[i].result, &list[i].versor1, &list[i].versor2);
|
|
}
|
|
}
|
|
}
|
|
/*
|
|
int main()
|
|
{
|
|
const unsigned int amount = 1000000;
|
|
structure_fp32_t* list = make_structures(amount);
|
|
|
|
#ifdef _WIN64
|
|
ULONGLONG start, end;
|
|
|
|
start = GetTickCount64();
|
|
|
|
srand((unsigned int)(start & 0xfffffff));
|
|
|
|
start = GetTickCount64();
|
|
#else
|
|
struct timespec start, end;
|
|
clock_gettime(0, &start);
|
|
srand((unsigned int)(start.tv_nsec & 0xfffffff));
|
|
|
|
clock_gettime(CLOCK_REALTIME, &start);
|
|
#endif // _WIN64
|
|
|
|
list_work(amount, list);
|
|
|
|
#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_quaternion_fp32(&list[10].versor1._versor);
|
|
print_quaternion_fp32(&list[10].versor2._versor);
|
|
print_quaternion_fp32(&list[10].result._versor);
|
|
|
|
free(list);
|
|
|
|
return 0;
|
|
}
|
|
*/
|
|
|
|
/*
|
|
int main() {
|
|
BGC_FP32_Complex complex, exponent, result;
|
|
|
|
bgc_fp32_complex_make(0, 1, &complex);
|
|
|
|
bgc_fp32_complex_make(4, 0, &exponent);
|
|
|
|
bgc_fp32_complex_get_exponation(&complex, exponent.real, exponent.imaginary, &result);
|
|
|
|
printf("(%f, %f) ^ (%f, %f) = (%f, %f)\n", complex.real, complex.imaginary, exponent.real, exponent.imaginary, result.real, result.imaginary);
|
|
|
|
return 0;
|
|
}
|
|
*/
|
|
/*
|
|
int main() {
|
|
BGC_FP32_Turn3 start = { 1.0f, 0.0f, 0.0f, 0.0f };
|
|
BGC_FP32_Turn3 end = { 0.0f, 1.0f, 0.0f, 0.0f };
|
|
BGC_FP32_Turn3 result;
|
|
bgc_fp32_turn3_spherical_interpolation(&start, &end, 0.5f, &result);
|
|
printf("Result: %0.12f, %0.12f, %0.12f, %0.12f\n", result.s0, result.x1, result.x2, result.x3);
|
|
return 0;
|
|
}
|
|
*/
|
|
|
|
void test_pair_difference_fp32()
|
|
{
|
|
|
|
BGC_FP32_Vector3 initial_main, initial_branch;
|
|
BGC_FP32_Vector3 final_main, final_branch;
|
|
BGC_FP32_Turn3 turn;
|
|
|
|
// No turn
|
|
bgc_fp32_vector3_make(&initial_main, 1.0f, 0.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&initial_branch, 0.0f, 1.0f, 0.0f);
|
|
|
|
bgc_fp32_vector3_make(&final_main, 1.0f, 0.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&final_branch, 0.0f, 1.0f, 0.0f);
|
|
|
|
bgc_fp32_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
printf("\nNo turn:\n");
|
|
print_quaternion_fp32(&turn._versor);
|
|
|
|
// Turn around (1, 1, 0) axis on 180 degrees
|
|
bgc_fp32_vector3_make(&initial_main, 1.0f, 0.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&initial_branch, 0.0f, 1.0f, 0.0f);
|
|
|
|
bgc_fp32_vector3_make(&final_main, 0.0f, 1.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&final_branch, 1.0f, 0.0f, 0.0f);
|
|
|
|
bgc_fp32_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
printf("\nTurn around (1, 1, 0) axis on 180 degrees:\n");
|
|
print_quaternion_fp32(&turn._versor);
|
|
|
|
// 180 degree turn
|
|
bgc_fp32_vector3_make(&initial_main, 1.0f, 0.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&initial_branch, 0.0f, 1.0f, 0.0f);
|
|
|
|
bgc_fp32_vector3_make(&final_main, -1.0f, 0.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&final_branch, 0.0f, 1.0f, 0.0f);
|
|
|
|
bgc_fp32_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
printf("\n180 degree turn around (0, 1, 0):\n");
|
|
print_quaternion_fp32(&turn._versor);
|
|
|
|
// 90 degree turn around x3 axis
|
|
bgc_fp32_vector3_make(&initial_main, 2.0f, 0.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&initial_branch, 0.0f, 3.1f, 0.0f);
|
|
|
|
bgc_fp32_vector3_make(&final_main, 0.0f, 10.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&final_branch,-1.0f, 0.0f, 0.0f);
|
|
|
|
bgc_fp32_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
printf("\n90 degree turn around (0, 0, 1):\n");
|
|
print_quaternion_fp32(&turn._versor);
|
|
|
|
// Unorthogonal pairs turn at 90 degrees around x3 axis
|
|
bgc_fp32_vector3_make(&initial_main, 2.0f, 0.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&initial_branch, -2.0f, 3.1f, 0.0f);
|
|
|
|
bgc_fp32_vector3_make(&final_main, 0.0f, 10.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&final_branch, -1.0f, 5.0f, 0.0f);
|
|
|
|
bgc_fp32_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
printf("\nUnorthogonal pairs turn at 90 degrees around (0, 0, 1):\n");
|
|
print_quaternion_fp32(&turn._versor);
|
|
|
|
// Zero vectors
|
|
bgc_fp32_vector3_make(&initial_main, 0.0f, 0.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&initial_branch, 0.0f, 1.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&final_main, 1.0f, 0.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&final_branch, 0.0f, 1.0f, 0.0f);
|
|
|
|
int code;
|
|
|
|
code = bgc_fp32_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
if (code == BGC_SUCCESS) {
|
|
printf("\nZero vectors: this cannot be!\n");
|
|
print_quaternion_fp32(&turn._versor);
|
|
}
|
|
else {
|
|
printf("\nZero vector validation works fine\n");
|
|
}
|
|
|
|
// Parallel vectors
|
|
bgc_fp32_vector3_make(&initial_main, 1.0f, 0.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&initial_branch, 2.0f, 0.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&final_main, 1.0f, 0.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&final_branch, 0.0f, 1.0f, 0.0f);
|
|
|
|
code = bgc_fp32_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
if (code == BGC_SUCCESS) {
|
|
printf("\nParallel vectors: this cannot be!\n");
|
|
print_quaternion_fp32(&turn._versor);
|
|
}
|
|
else {
|
|
printf("\nParallelism validation works fine\n");
|
|
}
|
|
|
|
// Small angle turn (about 1 degree):
|
|
bgc_fp32_vector3_make(&initial_main, 1.0f, 0.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&initial_branch, 0.0f, 1.0f, 0.0f);
|
|
|
|
bgc_fp32_vector3_make(&final_main, 0.999848f, 0.017452f, 0.0f);
|
|
bgc_fp32_vector3_make(&final_branch, -0.017452f, 0.999848f, 0.0f);
|
|
|
|
bgc_fp32_turn3_find_pair_difference(&turn , &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
printf("\nSmall angle turn (about 1 degree):\n");
|
|
print_quaternion_fp32(&turn._versor);
|
|
|
|
// About 179 degrees turn
|
|
bgc_fp32_vector3_make(&initial_main, 1.0f, 0.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&initial_branch, 0.0f, 1.0f, 0.0f);
|
|
|
|
bgc_fp32_vector3_make(&final_main, -0.999848f, -0.017452f, 0.0f);
|
|
bgc_fp32_vector3_make(&final_branch, 0.017452f, -0.999848f, 0.0f);
|
|
|
|
bgc_fp32_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
printf("\nAbout 179 degrees turn:\n");
|
|
print_quaternion_fp32(&turn._versor);
|
|
|
|
// 120 degrees around (-1, -1, 1)
|
|
bgc_fp32_vector3_make(&initial_main, 1.0f, 0.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&initial_branch, 0.0f, 1.0f, 0.0f);
|
|
|
|
bgc_fp32_vector3_make(&final_main, 0.0f, 1.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&final_branch, 0.0f, 0.0f, -1.0f);
|
|
|
|
bgc_fp32_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
printf("\n120 degees turn:\n");
|
|
print_quaternion_fp32(&turn._versor);
|
|
|
|
|
|
// About 1 degree turn difference between initial_main and initial_branch directions
|
|
bgc_fp32_vector3_make(&initial_main, 1.0f, 0.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&initial_branch, 0.999848f, 0.017452f, 0.0f);
|
|
bgc_fp32_vector3_make(&final_main, 0.0f, 1.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&final_branch, -1.0f, 0.0f, 0.0f);
|
|
|
|
bgc_fp32_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
printf("\nAbout 1 degree turn difference between initial_main and initial_branch directions:\n");
|
|
print_quaternion_fp32(&turn._versor);
|
|
|
|
// About 0.01 degree turn difference between initial_main and initial_branch directions
|
|
bgc_fp32_vector3_make(&initial_main, 1.0f, 0.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&initial_branch, 1.0f, 0.000001f, 0.0f);
|
|
bgc_fp32_vector3_make(&final_main, 0.0f, -1.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&final_branch, 1.0f, 0.0f, 0.0f);
|
|
|
|
bgc_fp32_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
printf("\nAbout 0.01 degree turn difference between initial_main and initial_branch directions:\n");
|
|
print_quaternion_fp32(&turn._versor);
|
|
|
|
bgc_fp32_vector3_make(&initial_main, 1.0f, 0.0f, 0.0f);
|
|
bgc_fp32_vector3_make(&initial_branch, 0.0f, 0.999999f, 0.00014142f); // почти (0,1,0), но крошечный z
|
|
|
|
bgc_fp32_vector3_make(&final_main, -0.999999f, 0.0f, 0.00014142f);
|
|
bgc_fp32_vector3_make(&final_branch, 0.0f, 0.999999f, -0.00014142f);
|
|
|
|
bgc_fp32_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
printf("\nNear 180° with tiny branch deviation:\n");
|
|
print_quaternion_fp32(&turn._versor);
|
|
|
|
bgc_fp32_vector3_make(&initial_main, 1.0f, 0.2f, 0.1f);
|
|
bgc_fp32_vector3_make(&initial_branch, 0.1f, 1.0f, 0.3f); // почти (0,1,0), но крошечный z
|
|
|
|
BGC_FP32_Turn3 known;
|
|
|
|
bgc_fp32_turn3_set_rotation(&known, 0.0f, 0.0f, 1.0f, 90.0f, BGC_ANGLE_UNIT_DEGREES);
|
|
|
|
bgc_fp32_vector3_make(&initial_main, -0.999999f, 0.0f, 0.00014142f);
|
|
bgc_fp32_vector3_make(&initial_branch, 0.0f, 0.999999f, -0.00014142f);
|
|
|
|
bgc_fp32_turn3_vector(&final_main, &known, &initial_main);
|
|
bgc_fp32_turn3_vector(&final_branch, &known, &initial_branch);
|
|
|
|
bgc_fp32_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
printf("\nRecover known 90° Z rotation:\n");
|
|
print_quaternion_fp32(&turn._versor);
|
|
|
|
printf("Known was: ");
|
|
print_quaternion_fp32(&known._versor);
|
|
}
|
|
|
|
void test_pair_difference_fp64()
|
|
{
|
|
|
|
BGC_FP64_Vector3 initial_main, initial_branch;
|
|
BGC_FP64_Vector3 final_main, final_branch;
|
|
BGC_FP64_Turn3 turn;
|
|
|
|
// No turn
|
|
bgc_fp64_vector3_make(&initial_main, 1.0, 0.0, 0.0);
|
|
bgc_fp64_vector3_make(&initial_branch, 0.0, 1.0, 0.0);
|
|
bgc_fp64_vector3_make(&final_main, 1.0, 0.0, 0.0);
|
|
bgc_fp64_vector3_make(&final_branch, 0.0, 1.0, 0.0);
|
|
|
|
bgc_fp64_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
printf("\nNo turn:\n");
|
|
print_quaternion_fp64(&turn._versor);
|
|
|
|
// Turn around (1, 1, 0) axis on 180 degrees
|
|
bgc_fp64_vector3_make(&initial_main, 1.0, 0.0, 0.0);
|
|
bgc_fp64_vector3_make(&initial_branch, 0.0, 1.0, 0.0);
|
|
bgc_fp64_vector3_make(&final_main, 0.0, 1.0, 0.0);
|
|
bgc_fp64_vector3_make(&final_branch, 1.0, 0.0, 0.0);
|
|
|
|
bgc_fp64_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
printf("\nTurn around (1, 1, 0) axis on 180 degrees:\n");
|
|
print_quaternion_fp64(&turn._versor);
|
|
|
|
// 180 degree turn
|
|
bgc_fp64_vector3_make(&initial_main, 1.0, 0.0, 0.0);
|
|
bgc_fp64_vector3_make(&initial_branch, 0.0, 1.0, 0.0);
|
|
|
|
bgc_fp64_vector3_make(&initial_branch, -1.0, 0.0, 0.0);
|
|
bgc_fp64_vector3_make(&final_branch, 0.0, 1.0, 0.0);
|
|
|
|
bgc_fp64_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
printf("\n180 degree turn around (0, 1, 0):\n");
|
|
print_quaternion_fp64(&turn._versor);
|
|
|
|
// 90 degree turn around x3 axis
|
|
bgc_fp64_vector3_make(&initial_main, 2.0, 0.0, 0.0);
|
|
bgc_fp64_vector3_make(&initial_branch, 0.0, 3.1, 0.0);
|
|
|
|
bgc_fp64_vector3_make(&final_main, 0.0, 10.0, 0.0);
|
|
bgc_fp64_vector3_make(&final_branch, -1.0, 0.0, 0.0);
|
|
|
|
bgc_fp64_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
printf("\n90 degree turn around (0, 0, 1):\n");
|
|
print_quaternion_fp64(&turn._versor);
|
|
|
|
// Unorthogonal pairs turn at 90 degrees around x3 axis
|
|
bgc_fp64_vector3_make(&initial_main, 2.0, 0.0, 0.0);
|
|
bgc_fp64_vector3_make(&initial_branch, -2.0, 3.1, 0.0);
|
|
|
|
bgc_fp64_vector3_make(&final_main, 0.0, 10.0, 0.0);
|
|
bgc_fp64_vector3_make(&final_branch, -1.0, 5.0, 0.0);
|
|
|
|
bgc_fp64_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
printf("\nUnorthogonal pairs turn at 90 degrees around (0, 0, 1):\n");
|
|
print_quaternion_fp64(&turn._versor);
|
|
|
|
// Zero vectors
|
|
bgc_fp64_vector3_make(&initial_main, 0.0, 0.0, 0.0);
|
|
bgc_fp64_vector3_make(&initial_branch, 0.0, 1.0, 0.0);
|
|
bgc_fp64_vector3_make(&final_main, 1.0, 0.0, 0.0);
|
|
bgc_fp64_vector3_make(&final_branch, 0.0, 1.0, 0.0);
|
|
|
|
int code;
|
|
|
|
code = bgc_fp64_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
if (code == BGC_SUCCESS) {
|
|
printf("\nZero vectors: this cannot be!\n");
|
|
print_quaternion_fp64(&turn._versor);
|
|
}
|
|
else {
|
|
printf("\nZero vector validation works fine\n");
|
|
}
|
|
|
|
// Parallel vectors
|
|
bgc_fp64_vector3_make(&initial_main, 1.0, 0.0, 0.0);
|
|
bgc_fp64_vector3_make(&initial_branch, 2.0, 0.0, 0.0);
|
|
bgc_fp64_vector3_make(&final_main, 1.0, 0.0, 0.0);
|
|
bgc_fp64_vector3_make(&final_branch, 0.0, 1.0, 0.0);
|
|
|
|
code = bgc_fp64_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
if (code == BGC_SUCCESS) {
|
|
printf("\nParallel vectors: this cannot be!\n");
|
|
print_quaternion_fp64(&turn._versor);
|
|
}
|
|
else {
|
|
printf("\nParallelism validation works fine\n");
|
|
}
|
|
|
|
// Small angle turn (about 1 degree):
|
|
bgc_fp64_vector3_make(&initial_main, 1.0, 0.0, 0.0);
|
|
bgc_fp64_vector3_make(&initial_branch, 0.0, 1.0, 0.0);
|
|
|
|
bgc_fp64_vector3_make(&final_main, 0.999848, 0.017452, 0.0);
|
|
bgc_fp64_vector3_make(&final_branch, -0.017452, 0.999848, 0.0);
|
|
|
|
bgc_fp64_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
printf("\nSmall angle turn (about 1 degree):\n");
|
|
print_quaternion_fp64(&turn._versor);
|
|
|
|
// About 179 degrees turn
|
|
bgc_fp64_vector3_make(&initial_main, 1.0, 0.0, 0.0);
|
|
bgc_fp64_vector3_make(&initial_branch, 0.0, 1.0, 0.0);
|
|
|
|
bgc_fp64_vector3_make(&final_main, -0.999848, -0.017452, 0.0);
|
|
bgc_fp64_vector3_make(&final_branch, 0.017452, -0.999848, 0.0);
|
|
|
|
bgc_fp64_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
printf("\nAbout 179 degrees turn:\n");
|
|
print_quaternion_fp64(&turn._versor);
|
|
|
|
// 120 degrees around (-1, -1, 1)
|
|
bgc_fp64_vector3_make(&initial_main, 1.0, 0.0, 0.0);
|
|
bgc_fp64_vector3_make(&initial_branch, 0.0, 1.0, 0.0);
|
|
|
|
bgc_fp64_vector3_make(&final_main, 0.0, 1.0, 0.0);
|
|
bgc_fp64_vector3_make(&final_branch, 0.0, 0.0, -1.0);
|
|
|
|
bgc_fp64_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
printf("\n120 degees turn:\n");
|
|
print_quaternion_fp64(&turn._versor);
|
|
|
|
|
|
// About 1 degree turn difference between initial_main and initial_branch directions
|
|
bgc_fp64_vector3_make(&initial_main, 1.0, 0.0, 0.0);
|
|
bgc_fp64_vector3_make(&initial_branch, 0.999848, 0.017452, 0.0);
|
|
bgc_fp64_vector3_make(&final_main, 0.0, 1.0, 0.0);
|
|
bgc_fp64_vector3_make(&final_branch, -1.0, 0.0, 0.0);
|
|
|
|
bgc_fp64_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
printf("\nAbout 1 degree turn difference between initial_main and initial_branch directions:\n");
|
|
print_quaternion_fp64(&turn._versor);
|
|
|
|
// About 0.001 degree turn difference between initial_main and initial_branch directions
|
|
bgc_fp64_vector3_make(&initial_main, 1.0, 0.0, 0.0);
|
|
bgc_fp64_vector3_make(&initial_branch, 1.0, 0.000001, 0.0);
|
|
bgc_fp64_vector3_make(&final_main, 0.0, -1.0, 0.0);
|
|
bgc_fp64_vector3_make(&final_branch, 1.0, 0.0, 0.0);
|
|
|
|
bgc_fp64_turn3_find_pair_difference(&turn, &initial_main, &initial_branch, &final_main, &final_branch);
|
|
|
|
printf("\nAbout 0.01 degree turn difference between initial_main and initial_branch directions:\n");
|
|
print_quaternion_fp64(&turn._versor);
|
|
}
|
|
|
|
#include "affine3.h"
|
|
|
|
int main()
|
|
{
|
|
//test_pair_difference_fp32();
|
|
test_pair_difference_fp64();
|
|
|
|
//printf("Affine3 performance test: %f\n", test_bgc_affine3_performance(10000000, 10));
|
|
|
|
//printf("sizeof(BGC_FP32_Affine3) = %zu\n", sizeof(BGC_FP32_Affine3));
|
|
//printf("offsetof(shift) = %zu\n", offsetof(BGC_FP32_Affine3, shift));
|
|
//printf("sizeof(BGC_FP32_Matrix3x3) = %zu\n", sizeof(BGC_FP32_Matrix3x3));
|
|
|
|
return 0;
|
|
}
|
|
|