Отказ от терминов Versor и Cotes Number в пользу Turn3 и Turn2, использование кватернионов внутри Turn3
This commit is contained in:
parent
38cff7e27d
commit
b470a3194b
27 changed files with 1815 additions and 2045 deletions
|
|
@ -40,7 +40,7 @@ BGC_FP32_Affine3* _create_bgc_affine3_random_list(int affine_amount)
|
|||
BGC_FP32_Position3 position;
|
||||
|
||||
for (int i = 0; i < affine_amount; i++) {
|
||||
bgc_fp32_versor_make(
|
||||
bgc_fp32_turn3_set_raw_values(
|
||||
&position.turn,
|
||||
get_random_value_fp32(),
|
||||
get_random_value_fp32(),
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
#endif // _WINDOWS_
|
||||
|
||||
typedef struct {
|
||||
BGC_FP32_Versor versor1, versor2, result;
|
||||
BGC_FP32_Turn3 versor1, versor2, result;
|
||||
} structure_fp32_t;
|
||||
|
||||
structure_fp32_t* allocate_structures(const unsigned int amount)
|
||||
|
|
@ -29,7 +29,7 @@ structure_fp32_t* make_structures(const unsigned int amount)
|
|||
const float multiplier = 2.0f / RAND_MAX;
|
||||
|
||||
for (unsigned int i = 0; i < amount; i++) {
|
||||
bgc_fp32_versor_make(
|
||||
bgc_fp32_turn3_set_raw_values(
|
||||
&list[i].versor1,
|
||||
rand() * multiplier - 1.0f,
|
||||
rand() * multiplier - 1.0f,
|
||||
|
|
@ -37,7 +37,7 @@ structure_fp32_t* make_structures(const unsigned int amount)
|
|||
rand() * multiplier - 1.0f
|
||||
);
|
||||
|
||||
bgc_fp32_versor_make(
|
||||
bgc_fp32_turn3_set_raw_values(
|
||||
&list[i].versor2,
|
||||
rand() * multiplier - 1.0f,
|
||||
rand() * multiplier - 1.0f,
|
||||
|
|
@ -45,20 +45,20 @@ structure_fp32_t* make_structures(const unsigned int amount)
|
|||
rand() * multiplier - 1.0f
|
||||
);
|
||||
|
||||
bgc_fp32_versor_reset(&list[i].result);
|
||||
bgc_fp32_turn3_reset(&list[i].result);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
void print_versor_fp32(const BGC_FP32_Versor* versor)
|
||||
void print_quaternion_fp32(const BGC_FP32_Quaternion* quaternion)
|
||||
{
|
||||
printf("Versor (s0 = %0.12f, x1 = %0.12f, x2 = %0.12f, x3 = %0.12f)\n", versor->_s0, versor->_x1, versor->_x2, versor->_x3);
|
||||
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_versor_fp64(const BGC_FP64_Versor* versor)
|
||||
void print_quaternion_fp64(const BGC_FP64_Quaternion* quaternion)
|
||||
{
|
||||
printf("Versor (s0 = %0.20f, x1 = %0.20f, x2 = %0.20f, x3 = %0.20f)\n", versor->_s0, versor->_x1, versor->_x2, versor->_x3);
|
||||
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)
|
||||
|
|
@ -75,11 +75,11 @@ 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_versor_combine(&list[i].versor1, &list[i].versor1, &list[i].result);
|
||||
bgc_fp32_turn3_combine(&list[i].result, &list[i].versor1, &list[i].versor2);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
int main()
|
||||
{
|
||||
const unsigned int amount = 1000000;
|
||||
|
|
@ -113,15 +113,15 @@ int main()
|
|||
printf("Time: %lf\n", (end.tv_sec - start.tv_sec) * 1000.0 + (end.tv_nsec - start.tv_nsec) * 0.000001);
|
||||
#endif // _WIN64
|
||||
|
||||
print_versor_fp32(&list[10].versor1);
|
||||
print_versor_fp32(&list[10].versor2);
|
||||
print_versor_fp32(&list[10].result);
|
||||
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() {
|
||||
|
|
@ -140,10 +140,10 @@ int main() {
|
|||
*/
|
||||
/*
|
||||
int main() {
|
||||
BGC_FP32_Versor start = { 1.0f, 0.0f, 0.0f, 0.0f };
|
||||
BGC_FP32_Versor end = { 0.0f, 1.0f, 0.0f, 0.0f };
|
||||
BGC_FP32_Versor result;
|
||||
bgc_fp32_versor_spherical_interpolation(&start, &end, 0.5f, &result);
|
||||
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;
|
||||
}
|
||||
|
|
@ -154,7 +154,7 @@ void test_basis_difference_fp32()
|
|||
|
||||
BGC_FP32_Vector3 initial_primary, initial_auxiliary;
|
||||
BGC_FP32_Vector3 final_primary, final_auxiliary;
|
||||
BGC_FP32_Versor turn;
|
||||
BGC_FP32_Turn3 turn;
|
||||
|
||||
// No turn
|
||||
bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f);
|
||||
|
|
@ -163,10 +163,10 @@ void test_basis_difference_fp32()
|
|||
bgc_fp32_vector3_make(&final_primary, 1.0f, 0.0f, 0.0f);
|
||||
bgc_fp32_vector3_make(&final_auxiliary, 0.0f, 1.0f, 0.0f);
|
||||
|
||||
bgc_fp32_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary);
|
||||