Переход на версию 0.3: изменение подхода к именованию сущностей, добавление, изменение и удаление ряда функций

This commit is contained in:
Andrey Pokidov 2026-01-30 19:37:49 +07:00
parent d33daf4e2d
commit f7e41645fe
87 changed files with 4580 additions and 4051 deletions

View file

@ -4,9 +4,9 @@
<Project filename="basic-geometry-dev/basic-geometry-dev.cbp"> <Project filename="basic-geometry-dev/basic-geometry-dev.cbp">
<Depends filename="basic-geometry/basic-geometry.cbp" /> <Depends filename="basic-geometry/basic-geometry.cbp" />
</Project> </Project>
<Project filename="basic-geometry/basic-geometry.cbp" />
<Project filename="basic-geometry-test/basic-geometry-test.cbp"> <Project filename="basic-geometry-test/basic-geometry-test.cbp">
<Depends filename="basic-geometry/basic-geometry.cbp" /> <Depends filename="basic-geometry/basic-geometry.cbp" />
</Project> </Project>
<Project filename="basic-geometry/basic-geometry.cbp" />
</Workspace> </Workspace>
</CodeBlocks_workspace_file> </CodeBlocks_workspace_file>

View file

@ -8,7 +8,7 @@
Programming language: C (C99) Programming language: C (C99)
Version: 0.2.0-dev Version: 0.3.0-dev
License: Apache-2.0 License: Apache-2.0

View file

@ -10,7 +10,7 @@
Язык программирования: Си (C99) Язык программирования: Си (C99)
Версия: 0.2.0-dev Версия: 0.3.0-dev
Лицензия: Apache-2.0 Лицензия: Apache-2.0

View file

@ -9,16 +9,16 @@
#include <time.h> #include <time.h>
#endif // _WINDOWS_ #endif // _WINDOWS_
BgcAffine3FP32* _create_bgc_affine3_list(int affine_amount) BGC_FP32_Affine3* _create_bgc_affine3_list(int affine_amount)
{ {
BgcAffine3FP32* affines = malloc(affine_amount * sizeof(BgcAffine3FP32)); BGC_FP32_Affine3* affines = malloc(affine_amount * sizeof(BGC_FP32_Affine3));
if (affines == 0) { if (affines == 0) {
return 0; return 0;
} }
for (int i = 0; i < affine_amount; i++) { for (int i = 0; i < affine_amount; i++) {
bgc_affine3_reset_fp32(&affines[i]); bgc_fp32_affine3_reset(&affines[i]);
} }
return affines; return affines;
@ -29,18 +29,18 @@ float get_random_value_fp32()
return rand() * (2.0f / RAND_MAX) - 1.0f; return rand() * (2.0f / RAND_MAX) - 1.0f;
} }
BgcAffine3FP32* _create_bgc_affine3_random_list(int affine_amount) BGC_FP32_Affine3* _create_bgc_affine3_random_list(int affine_amount)
{ {
BgcAffine3FP32* affines = malloc(affine_amount * sizeof(BgcAffine3FP32)); BGC_FP32_Affine3* affines = malloc(affine_amount * sizeof(BGC_FP32_Affine3));
if (affines == 0) { if (affines == 0) {
return 0; return 0;
} }
BgcPosition3FP32 position; BGC_FP32_Position3 position;
for (int i = 0; i < affine_amount; i++) { for (int i = 0; i < affine_amount; i++) {
bgc_versor_set_values_fp32( bgc_fp32_versor_make(
get_random_value_fp32(), get_random_value_fp32(),
get_random_value_fp32(), get_random_value_fp32(),
get_random_value_fp32(), get_random_value_fp32(),
@ -52,20 +52,20 @@ BgcAffine3FP32* _create_bgc_affine3_random_list(int affine_amount)
position.shift.x2 = get_random_value_fp32(); position.shift.x2 = get_random_value_fp32();
position.shift.x3 = get_random_value_fp32(); position.shift.x3 = get_random_value_fp32();
bgc_position3_get_outward_affine_fp32(&position, &affines[i]); bgc_fp32_position3_get_outward_affine(&position, &affines[i]);
} }
return affines; return affines;
} }
BgcVector3FP32* _create_bgc_vector3_list(int amount) BGC_FP32_Vector3* _create_bgc_vector3_list(int amount)
{ {
return malloc(amount * sizeof(BgcVector3FP32)); return malloc(amount * sizeof(BGC_FP32_Vector3));
} }
BgcVector3FP32* _create_bgc_vector3_random_list(int amount) BGC_FP32_Vector3* _create_bgc_vector3_random_list(int amount)
{ {
BgcVector3FP32* vectors = _create_bgc_vector3_list(amount); BGC_FP32_Vector3* vectors = _create_bgc_vector3_list(amount);
if (vectors == 0) { if (vectors == 0) {
return 0; return 0;
@ -82,9 +82,9 @@ BgcVector3FP32* _create_bgc_vector3_random_list(int amount)
float test_bgc_affine3_performance(int affine_amount, int vector_per_affine) float test_bgc_affine3_performance(int affine_amount, int vector_per_affine)
{ {
BgcAffine3FP32* affines; BGC_FP32_Affine3* affines;
BgcVector3FP32* source_vectors; BGC_FP32_Vector3* source_vectors;
BgcVector3FP32* result_vectors; BGC_FP32_Vector3* result_vectors;
int vector_index = 0; int vector_index = 0;
float time = -1.0f; float time = -1.0f;
@ -131,7 +131,7 @@ float test_bgc_affine3_performance(int affine_amount, int vector_per_affine)
for (int i = 0; i < affine_amount; i++) for (int i = 0; i < affine_amount; i++)
{ {
for (int j = 0; j < vector_per_affine; j++) { for (int j = 0; j < vector_per_affine; j++) {
bgc_affine3_transform_point_fp32(&affines[i], &source_vectors[vector_index], &result_vectors[vector_index]); bgc_fp32_affine3_transform_point(&affines[i], &source_vectors[vector_index], &result_vectors[vector_index]);
vector_index++; vector_index++;
} }
} }

View file

@ -10,7 +10,7 @@
#endif // _WINDOWS_ #endif // _WINDOWS_
typedef struct { typedef struct {
BgcVersorFP32 versor1, versor2, result; BGC_FP32_Versor versor1, versor2, result;
} structure_fp32_t; } structure_fp32_t;
structure_fp32_t* allocate_structures(const unsigned int amount) 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; const float multiplier = 2.0f / RAND_MAX;
for (unsigned int i = 0; i < amount; i++) { for (unsigned int i = 0; i < amount; i++) {
bgc_versor_set_values_fp32( bgc_fp32_versor_make(
rand() * multiplier - 1.0f, rand() * multiplier - 1.0f,
rand() * multiplier - 1.0f, rand() * multiplier - 1.0f,
rand() * multiplier - 1.0f, rand() * multiplier - 1.0f,
@ -37,7 +37,7 @@ structure_fp32_t* make_structures(const unsigned int amount)
&list[i].versor1 &list[i].versor1
); );
bgc_versor_set_values_fp32( bgc_fp32_versor_make(
rand() * multiplier - 1.0f, rand() * multiplier - 1.0f,
rand() * multiplier - 1.0f, rand() * multiplier - 1.0f,
rand() * multiplier - 1.0f, rand() * multiplier - 1.0f,
@ -45,37 +45,37 @@ structure_fp32_t* make_structures(const unsigned int amount)
&list[i].versor2 &list[i].versor2
); );
bgc_versor_reset_fp32(&list[i].result); bgc_fp32_versor_reset(&list[i].result);
} }
return list; return list;
} }
void print_versor_fp32(const BgcVersorFP32* versor) void print_versor_fp32(const BGC_FP32_Versor* versor)
{ {
printf("Versor (s0 = %0.12f, x1 = %0.12f, x2 = %0.12f, x3 = %0.12f)\n", versor->_s0, versor->_x1, versor->_x2, versor->_x3); printf("Versor (s0 = %0.12f, x1 = %0.12f, x2 = %0.12f, x3 = %0.12f)\n", versor->_s0, versor->_x1, versor->_x2, versor->_x3);
} }
void print_versor_fp64(const BgcVersorFP64* versor) void print_versor_fp64(const BGC_FP64_Versor* versor)
{ {
printf("Versor (s0 = %0.20f, x1 = %0.20f, x2 = %0.20f, x3 = %0.20f)\n", versor->_s0, versor->_x1, versor->_x2, versor->_x3); printf("Versor (s0 = %0.20f, x1 = %0.20f, x2 = %0.20f, x3 = %0.20f)\n", versor->_s0, versor->_x1, versor->_x2, versor->_x3);
} }
void print_vector_fp32(const BgcVector3FP32* vector) void print_vector_fp32(const BGC_FP32_Vector3* vector)
{ {
printf("(%f, %f, %f) / %f\n", vector->x1, vector->x2, vector->x3, bgc_vector3_get_modulus_fp32(vector)); printf("(%f, %f, %f) / %f\n", vector->x1, vector->x2, vector->x3, bgc_fp32_vector3_get_modulus(vector));
} }
void print_vector_fp64(const BgcVector3FP64* vector) void print_vector_fp64(const BGC_FP64_Vector3* vector)
{ {
printf("(%lf, %lf, %lf) / %lf\n", vector->x1, vector->x2, vector->x3, bgc_vector3_get_modulus_fp64(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) 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 j = 0; j < 1000; j++) {
for (uint_fast32_t i = 0; i < amount; i++) { for (uint_fast32_t i = 0; i < amount; i++) {
bgc_versor_combine_fp32(&list[i].versor1, &list[i].versor1, &list[i].result); bgc_fp32_versor_combine(&list[i].versor1, &list[i].versor1, &list[i].result);
} }
} }
} }
@ -125,13 +125,13 @@ int main()
/* /*
int main() { int main() {
BgcComplexFP32 complex, exponent, result; BGC_FP32_Complex complex, exponent, result;
bgc_complex_set_values_fp32(0, 1, &complex); bgc_fp32_complex_make(0, 1, &complex);
bgc_complex_set_values_fp32(4, 0, &exponent); bgc_fp32_complex_make(4, 0, &exponent);
bgc_complex_get_exponation_fp32(&complex, exponent.real, exponent.imaginary, &result); 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); printf("(%f, %f) ^ (%f, %f) = (%f, %f)\n", complex.real, complex.imaginary, exponent.real, exponent.imaginary, result.real, result.imaginary);
@ -140,10 +140,10 @@ int main() {
*/ */
/* /*
int main() { int main() {
BgcVersorFP32 start = { 1.0f, 0.0f, 0.0f, 0.0f }; BGC_FP32_Versor start = { 1.0f, 0.0f, 0.0f, 0.0f };
BgcVersorFP32 end = { 0.0f, 1.0f, 0.0f, 0.0f }; BGC_FP32_Versor end = { 0.0f, 1.0f, 0.0f, 0.0f };
BgcVersorFP32 result; BGC_FP32_Versor result;
bgc_versor_spherical_interpolation_fp32(&start, &end, 0.5f, &result); bgc_fp32_versor_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); printf("Result: %0.12f, %0.12f, %0.12f, %0.12f\n", result.s0, result.x1, result.x2, result.x3);
return 0; return 0;
} }
@ -152,79 +152,79 @@ int main() {
void test_basis_difference_fp32() void test_basis_difference_fp32()
{ {
BgcVector3FP32 initial_primary, initial_auxiliary; BGC_FP32_Vector3 initial_primary, initial_auxiliary;
BgcVector3FP32 final_primary, final_auxiliary; BGC_FP32_Vector3 final_primary, final_auxiliary;
BgcVersorFP32 turn; BGC_FP32_Versor turn;
// No turn // No turn
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_auxiliary);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nNo turn:\n"); printf("\nNo turn:\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// Turn around (1, 1, 0) axis on 180 degrees // Turn around (1, 1, 0) axis on 180 degrees
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &final_auxiliary);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nTurn around (1, 1, 0) axis on 180 degrees:\n"); printf("\nTurn around (1, 1, 0) axis on 180 degrees:\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// 180 degree turn // 180 degree turn
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(-1.0f, 0.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(-1.0f, 0.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_auxiliary);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\n180 degree turn around (0, 1, 0):\n"); printf("\n180 degree turn around (0, 1, 0):\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// 90 degree turn around x3 axis // 90 degree turn around x3 axis
bgc_vector3_set_values_fp32(2.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(2.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 3.1f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(0.0f, 3.1f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(0.0f, 10.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(0.0f, 10.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(-1.0f, 0.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(-1.0f, 0.0f, 0.0f, &final_auxiliary);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\n90 degree turn around (0, 0, 1):\n"); printf("\n90 degree turn around (0, 0, 1):\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// Unorthogonal pairs turn at 90 degrees around x3 axis // Unorthogonal pairs turn at 90 degrees around x3 axis
bgc_vector3_set_values_fp32(2.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(2.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(-2.0f, 3.1f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(-2.0f, 3.1f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(0.0f, 10.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(0.0f, 10.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(-1.0f, 5.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(-1.0f, 5.0f, 0.0f, &final_auxiliary);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nUnorthogonal pairs turn at 90 degrees around (0, 0, 1):\n"); printf("\nUnorthogonal pairs turn at 90 degrees around (0, 0, 1):\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// Zero vectors // Zero vectors
bgc_vector3_set_values_fp32(0.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(0.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_auxiliary);
int code; int code;
code = bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); code = bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
if (code >= 0) { if (code >= 0) {
printf("\nZero vectors: this cannot be!\n"); printf("\nZero vectors: this cannot be!\n");
@ -235,12 +235,12 @@ void test_basis_difference_fp32()
} }
// Parallel vectors // Parallel vectors
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(2.0f, 0.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(2.0f, 0.0f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_auxiliary);
code = bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); code = bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
if (code >= 0) { if (code >= 0) {
printf("\nParallel vectors: this cannot be!\n"); printf("\nParallel vectors: this cannot be!\n");
@ -251,60 +251,60 @@ void test_basis_difference_fp32()
} }
// Small angle turn (about 1 degree): // Small angle turn (about 1 degree):
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(0.999848f, 0.017452f, 0.0f, &final_primary); bgc_fp32_vector3_make(0.999848f, 0.017452f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(-0.017452f, 0.999848f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(-0.017452f, 0.999848f, 0.0f, &final_auxiliary);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nSmall angle turn (about 1 degree):\n"); printf("\nSmall angle turn (about 1 degree):\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// About 179 degrees turn // About 179 degrees turn
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(-0.999848f, -0.017452f, 0.0f, &final_primary); bgc_fp32_vector3_make(-0.999848f, -0.017452f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(0.017452f, -0.999848f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(0.017452f, -0.999848f, 0.0f, &final_auxiliary);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nAbout 179 degrees turn:\n"); printf("\nAbout 179 degrees turn:\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// 120 degrees around (-1, -1, 1) // 120 degrees around (-1, -1, 1)
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(0.0f, 0.0f, -1.0f, &final_auxiliary); bgc_fp32_vector3_make(0.0f, 0.0f, -1.0f, &final_auxiliary);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\n120 degees turn:\n"); printf("\n120 degees turn:\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// About 1 degree turn difference between initial_primary and initial_auxiliary directions // About 1 degree turn difference between initial_primary and initial_auxiliary directions
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(0.999848f, 0.017452f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(0.999848f, 0.017452f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(-1.0f, 0.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(-1.0f, 0.0f, 0.0f, &final_auxiliary);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nAbout 1 degree turn difference between initial_primary and initial_auxiliary directions:\n"); printf("\nAbout 1 degree turn difference between initial_primary and initial_auxiliary directions:\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
// About 0.01 degree turn difference between initial_primary and initial_auxiliary directions // About 0.01 degree turn difference between initial_primary and initial_auxiliary directions
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &initial_primary);
bgc_vector3_set_values_fp32(1.0f, 0.000001f, 0.0f, &initial_auxiliary); bgc_fp32_vector3_make(1.0f, 0.000001f, 0.0f, &initial_auxiliary);
bgc_vector3_set_values_fp32(0.0f, -1.0f, 0.0f, &final_primary); bgc_fp32_vector3_make(0.0f, -1.0f, 0.0f, &final_primary);
bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &final_auxiliary); bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &final_auxiliary);
bgc_versor_make_basis_difference_fp32(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp32_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nAbout 0.01 degree turn difference between initial_primary and initial_auxiliary directions:\n"); printf("\nAbout 0.01 degree turn difference between initial_primary and initial_auxiliary directions:\n");
print_versor_fp32(&turn); print_versor_fp32(&turn);
@ -313,77 +313,77 @@ void test_basis_difference_fp32()
void test_basis_difference_fp64() void test_basis_difference_fp64()
{ {
BgcVector3FP64 initial_primary, initial_auxiliary; BGC_FP64_Vector3 initial_primary, initial_auxiliary;
BgcVector3FP64 final_primary, final_auxiliary; BGC_FP64_Vector3 final_primary, final_auxiliary;
BgcVersorFP64 turn; BGC_FP64_Versor turn;
// No turn // No turn
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &final_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_auxiliary);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nNo turn:\n"); printf("\nNo turn:\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// Turn around (1, 1, 0) axis on 180 degrees // Turn around (1, 1, 0) axis on 180 degrees
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_primary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &final_auxiliary);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nTurn around (1, 1, 0) axis on 180 degrees:\n"); printf("\nTurn around (1, 1, 0) axis on 180 degrees:\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// 180 degree turn // 180 degree turn
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(-1.0, 0.0, 0.0, &final_primary); bgc_fp64_vector3_make(-1.0, 0.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_auxiliary);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\n180 degree turn around (0, 1, 0):\n"); printf("\n180 degree turn around (0, 1, 0):\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// 90 degree turn around x3 axis // 90 degree turn around x3 axis
bgc_vector3_set_values_fp64(2.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(2.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 3.1, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(0.0, 3.1, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(0.0, 10.0, 0.0, &final_primary); bgc_fp64_vector3_make(0.0, 10.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(-1.0, 0.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(-1.0, 0.0, 0.0, &final_auxiliary);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\n90 degree turn around (0, 0, 1):\n"); printf("\n90 degree turn around (0, 0, 1):\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// Unorthogonal pairs turn at 90 degrees around x3 axis // Unorthogonal pairs turn at 90 degrees around x3 axis
bgc_vector3_set_values_fp64(2.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(2.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(-2.0, 3.1, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(-2.0, 3.1, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(0.0, 10.0, 0.0, &final_primary); bgc_fp64_vector3_make(0.0, 10.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(-1.0, 5.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(-1.0, 5.0, 0.0, &final_auxiliary);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nUnorthogonal pairs turn at 90 degrees around (0, 0, 1):\n"); printf("\nUnorthogonal pairs turn at 90 degrees around (0, 0, 1):\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// Zero vectors // Zero vectors
bgc_vector3_set_values_fp64(0.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(0.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &final_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_auxiliary);
int code; int code;
code = bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); code = bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
if (code >= 0) { if (code >= 0) {
printf("\nZero vectors: this cannot be!\n"); printf("\nZero vectors: this cannot be!\n");
@ -394,12 +394,12 @@ void test_basis_difference_fp64()
} }
// Parallel vectors // Parallel vectors
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(2.0, 0.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(2.0, 0.0, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &final_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_auxiliary);
code = bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); code = bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
if (code >= 0) { if (code >= 0) {
printf("\nParallel vectors: this cannot be!\n"); printf("\nParallel vectors: this cannot be!\n");
@ -410,60 +410,60 @@ void test_basis_difference_fp64()
} }
// Small angle turn (about 1 degree): // Small angle turn (about 1 degree):
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(0.999848, 0.017452, 0.0, &final_primary); bgc_fp64_vector3_make(0.999848, 0.017452, 0.0, &final_primary);
bgc_vector3_set_values_fp64(-0.017452, 0.999848, 0.0, &final_auxiliary); bgc_fp64_vector3_make(-0.017452, 0.999848, 0.0, &final_auxiliary);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nSmall angle turn (about 1 degree):\n"); printf("\nSmall angle turn (about 1 degree):\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// About 179 degrees turn // About 179 degrees turn
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(-0.999848, -0.017452, 0.0, &final_primary); bgc_fp64_vector3_make(-0.999848, -0.017452, 0.0, &final_primary);
bgc_vector3_set_values_fp64(0.017452, -0.999848, 0.0, &final_auxiliary); bgc_fp64_vector3_make(0.017452, -0.999848, 0.0, &final_auxiliary);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nAbout 179 degrees turn:\n"); printf("\nAbout 179 degrees turn:\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// 120 degrees around (-1, -1, 1) // 120 degrees around (-1, -1, 1)
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_primary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(0.0, 0.0, -1.0, &final_auxiliary); bgc_fp64_vector3_make(0.0, 0.0, -1.0, &final_auxiliary);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\n120 degees turn:\n"); printf("\n120 degees turn:\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// About 1 degree turn difference between initial_primary and initial_auxiliary directions // About 1 degree turn difference between initial_primary and initial_auxiliary directions
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(0.999848, 0.017452, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(0.999848, 0.017452, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_primary); bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(-1.0, 0.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(-1.0, 0.0, 0.0, &final_auxiliary);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nAbout 1 degree turn difference between initial_primary and initial_auxiliary directions:\n"); printf("\nAbout 1 degree turn difference between initial_primary and initial_auxiliary directions:\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
// About 0.001 degree turn difference between initial_primary and initial_auxiliary directions // About 0.001 degree turn difference between initial_primary and initial_auxiliary directions
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &initial_primary);
bgc_vector3_set_values_fp64(1.0, 0.000001, 0.0, &initial_auxiliary); bgc_fp64_vector3_make(1.0, 0.000001, 0.0, &initial_auxiliary);
bgc_vector3_set_values_fp64(0.0, -1.0, 0.0, &final_primary); bgc_fp64_vector3_make(0.0, -1.0, 0.0, &final_primary);
bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &final_auxiliary); bgc_fp64_vector3_make(1.0, 0.0, 0.0, &final_auxiliary);
bgc_versor_make_basis_difference_fp64(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn); bgc_fp64_versor_make_basis_difference(&initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary, &turn);
printf("\nAbout 0.01 degree turn difference between initial_primary and initial_auxiliary directions:\n"); printf("\nAbout 0.01 degree turn difference between initial_primary and initial_auxiliary directions:\n");
print_versor_fp64(&turn); print_versor_fp64(&turn);
@ -473,15 +473,15 @@ void test_basis_difference_fp64()
int main() int main()
{ {
//BgcVersorFP32 start = { 1.0f, 0.0f, 0.0f, 0.0f }; //BGC_FP32_Versor start = { 1.0f, 0.0f, 0.0f, 0.0f };
//BgcVersorFP32 end = { 0.0f, 1.0f, 0.0f, 0.0f }; //BGC_FP32_Versor end = { 0.0f, 1.0f, 0.0f, 0.0f };
/* /*
BgcVersorFP32 start = { 1.0f, 0.0f, 0.0f, 0.0f }; BGC_FP32_Versor start = { 1.0f, 0.0f, 0.0f, 0.0f };
BgcVersorFP32 end = { 0.9999f, 0.01414f, 0.0f, 0.0f }; BGC_FP32_Versor end = { 0.9999f, 0.01414f, 0.0f, 0.0f };
BgcSlerpFP32 slerp; BGC_FP32_Slerp slerp;
BgcVersorFP32 result; BGC_FP32_Versor result;
bgc_slerp_make_full_fp32(&start, &end, &slerp); bgc_fp32_slerp_make_full(&start, &end, &slerp);
bgc_slerp_get_turn_for_phase_fp32(&slerp, 0.5f, &result); bgc_fp32_slerp_get_phase_versor(&slerp, 0.5f, &result);
print_versor_fp32(&result); print_versor_fp32(&result);
*/ */
@ -489,9 +489,9 @@ int main()
printf("Affine3 performance test: %f\n", test_bgc_affine3_performance(10000000, 10)); printf("Affine3 performance test: %f\n", test_bgc_affine3_performance(10000000, 10));
printf("sizeof(BgcAffine3FP32) = %zu\n", sizeof(BgcAffine3FP32)); printf("sizeof(BGC_FP32_Affine3) = %zu\n", sizeof(BGC_FP32_Affine3));
//printf("offsetof(shift) = %zu\n", offsetof(BgcAffine3FP32, shift)); //printf("offsetof(shift) = %zu\n", offsetof(BGC_FP32_Affine3, shift));
printf("sizeof(BgcMatrix3x3FP32) = %zu\n", sizeof(BgcMatrix3x3FP32)); printf("sizeof(BGC_FP32_Matrix3x3) = %zu\n", sizeof(BGC_FP32_Matrix3x3));
return 0; return 0;
} }

View file

@ -25,19 +25,19 @@ typedef struct {
// =================== Versor =================== // // =================== Versor =================== //
typedef struct { typedef struct {
BgcVersorFP32 first, second; BGC_FP32_Versor first, second;
} TestVersorPairFP32; } TestVersorPairFP32;
typedef struct { typedef struct {
BgcVersorFP64 first, second; BGC_FP64_Versor first, second;
} TestVersorPairFP64; } TestVersorPairFP64;
typedef struct { typedef struct {
BgcVersorFP32 first, second, result; BGC_FP32_Versor first, second, result;
} TestVersorTripletFP32; } TestVersorTripletFP32;
typedef struct { typedef struct {
BgcVersorFP64 first, second, result; BGC_FP64_Versor first, second, result;
} TestVersorTripletFP64; } TestVersorTripletFP64;
// ================= Functions ================== // // ================= Functions ================== //

View file

@ -7,7 +7,7 @@
// ==================== FP32 ==================== // // ==================== FP32 ==================== //
static const int _TEST_FP32_COMPLEX_AMOUNT = 4; static const int _TEST_FP32_COMPLEX_AMOUNT = 4;
static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST[] = { static const BGC_FP32_Complex _TEST_FP32_COMPLEX_LIST[] = {
{ 1.0f, 2.0f }, { 1.0f, 2.0f },
{ -4.0f, -3.0f }, { -4.0f, -3.0f },
{ -0.001f, 100.0f }, { -0.001f, 100.0f },
@ -16,13 +16,13 @@ static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST[] = {
void test_complex_copy_fp32() void test_complex_copy_fp32()
{ {
BgcComplexFP32 vector; BGC_FP32_Complex vector;
print_testing_name("bgc_complex_copy_fp32"); print_testing_name("bgc_fp32_complex_copy");
for (int i = 0; i < _TEST_FP32_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_COMPLEX_AMOUNT; i++) {
bgc_complex_copy_fp32(&_TEST_FP32_COMPLEX_LIST[i], &vector); bgc_fp32_complex_copy(&_TEST_FP32_COMPLEX_LIST[i], &vector);
if (vector.real != _TEST_FP32_COMPLEX_LIST[i].real || if (vector.real != _TEST_FP32_COMPLEX_LIST[i].real ||
vector.imaginary != _TEST_FP32_COMPLEX_LIST[i].imaginary) { vector.imaginary != _TEST_FP32_COMPLEX_LIST[i].imaginary) {
@ -37,7 +37,7 @@ void test_complex_copy_fp32()
// ==================== FP64 ==================== // // ==================== FP64 ==================== //
static const int _TEST_FP64_COMPLEX_AMOUNT = 4; static const int _TEST_FP64_COMPLEX_AMOUNT = 4;
static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST[] = { static const BGC_FP64_Complex _TEST_FP64_COMPLEX_LIST[] = {
{ 1.0, 2.0 }, { 1.0, 2.0 },
{ -4.0, -3.0 }, { -4.0, -3.0 },
{ -0.001, 100.0 }, { -0.001, 100.0 },
@ -46,13 +46,13 @@ static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST[] = {
void test_complex_copy_fp64() void test_complex_copy_fp64()
{ {
BgcComplexFP64 vector; BGC_FP64_Complex vector;
print_testing_name("bgc_complex_copy_fp64"); print_testing_name("bgc_fp64_complex_copy");
for (int i = 0; i < _TEST_FP64_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_COMPLEX_AMOUNT; i++) {
bgc_complex_copy_fp64(&_TEST_FP64_COMPLEX_LIST[i], &vector); bgc_fp64_complex_copy(&_TEST_FP64_COMPLEX_LIST[i], &vector);
if (vector.real != _TEST_FP64_COMPLEX_LIST[i].real || if (vector.real != _TEST_FP64_COMPLEX_LIST[i].real ||
vector.imaginary != _TEST_FP64_COMPLEX_LIST[i].imaginary) { vector.imaginary != _TEST_FP64_COMPLEX_LIST[i].imaginary) {

View file

@ -7,35 +7,35 @@
static const int _TEST_FP32_UNIT_COMPLEX_AMOUNT = 10; static const int _TEST_FP32_UNIT_COMPLEX_AMOUNT = 10;
static const int _TEST_FP32_NONUNIT_COMPLEX_AMOUNT = 6; static const int _TEST_FP32_NONUNIT_COMPLEX_AMOUNT = 6;
static const BgcComplexFP32 _TEST_FP32_UNIT_COMPLEX_LIST[] = { static const BGC_FP32_Complex _TEST_FP32_UNIT_COMPLEX_LIST[] = {
{ 1.0f, 0.0f }, { 1.0f, 0.0f },
{ -1.0f, 0.0f }, { -1.0f, 0.0f },
{ 0.6f, -0.8f }, { 0.6f, -0.8f },
{ 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f }, { 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f }, { 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32 }, { 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON },
{ 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32 }, { 0.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON },
{ 0.7071067812f, 0.7071067812f }, { 0.7071067812f, 0.7071067812f },
{ 0.7071067812f + 0.75f * BGC_EPSYLON_FP32, 0.7071067812f }, { 0.7071067812f + 0.75f * BGC_FP32_EPSYLON, 0.7071067812f },
{ 0.7071067812f, 0.7071067812f - 0.75f * BGC_EPSYLON_FP32 } { 0.7071067812f, 0.7071067812f - 0.75f * BGC_FP32_EPSYLON }
}; };
static const BgcComplexFP32 _TEST_FP32_NONUNIT_QUATERION_LIST[] = { static const BGC_FP32_Complex _TEST_FP32_NONUNIT_QUATERION_LIST[] = {
{ 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f }, { 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f }, { 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32 }, { 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON },
{ 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32 }, { 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON },
{ 0.7071067812f + 1.25f * BGC_EPSYLON_FP32, 0.7071067812f + 1.25f * BGC_EPSYLON_FP32 }, { 0.7071067812f + 1.25f * BGC_FP32_EPSYLON, 0.7071067812f + 1.25f * BGC_FP32_EPSYLON },
{ 0.7071067812f - 1.25f * BGC_EPSYLON_FP32, 0.7071067812f - 1.25f * BGC_EPSYLON_FP32 } { 0.7071067812f - 1.25f * BGC_FP32_EPSYLON, 0.7071067812f - 1.25f * BGC_FP32_EPSYLON }
}; };
void test_complex_is_unit_fp32() void test_complex_is_unit_fp32()
{ {
print_testing_name("bgc_complex_is_unit_fp32"); print_testing_name("bgc_fp32_complex_is_unit");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP32_UNIT_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_UNIT_COMPLEX_AMOUNT; i++) {
if (!bgc_complex_is_unit_fp32(&_TEST_FP32_UNIT_COMPLEX_LIST[i])) { if (!bgc_fp32_complex_is_unit(&_TEST_FP32_UNIT_COMPLEX_LIST[i])) {
print_testing_error("A unit complex number was not recognized"); print_testing_error("A unit complex number was not recognized");
return; return;
} }
@ -43,7 +43,7 @@ void test_complex_is_unit_fp32()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONUNIT_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_NONUNIT_COMPLEX_AMOUNT; i++) {
if (bgc_complex_is_unit_fp32(&_TEST_FP32_NONUNIT_QUATERION_LIST[i])) { if (bgc_fp32_complex_is_unit(&_TEST_FP32_NONUNIT_QUATERION_LIST[i])) {
print_testing_error("A non-unit complex number was recognized a unit complex number"); print_testing_error("A non-unit complex number was recognized a unit complex number");
return; return;
} }
@ -57,35 +57,35 @@ void test_complex_is_unit_fp32()
static const int _TEST_FP64_UNIT_COMPLEX_AMOUNT = 10; static const int _TEST_FP64_UNIT_COMPLEX_AMOUNT = 10;
static const int _TEST_FP64_NONUNIT_COMPLEX_AMOUNT = 6; static const int _TEST_FP64_NONUNIT_COMPLEX_AMOUNT = 6;
static const BgcComplexFP64 _TEST_FP64_UNIT_COMPLEX_LIST[] = { static const BGC_FP64_Complex _TEST_FP64_UNIT_COMPLEX_LIST[] = {
{ 1.0, 0.0 }, { 1.0, 0.0 },
{ -1.0, 0.0 }, { -1.0, 0.0 },
{ -0.6, 0.8 }, { -0.6, 0.8 },
{ 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0 }, { 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0 }, { 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64 }, { 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON },
{ 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64 }, { 0.0, 1.0 - 0.75 * BGC_FP64_EPSYLON },
{ 0.7071067811865475244, 0.7071067811865475244 }, { 0.7071067811865475244, 0.7071067811865475244 },
{ 0.7071067811865475244 + 0.75 * BGC_EPSYLON_FP64, 0.7071067811865475244 }, { 0.7071067811865475244 + 0.75 * BGC_FP64_EPSYLON, 0.7071067811865475244 },
{ 0.7071067811865475244, 0.7071067811865475244 - 0.75 * BGC_EPSYLON_FP64 } { 0.7071067811865475244, 0.7071067811865475244 - 0.75 * BGC_FP64_EPSYLON }
}; };
static const BgcComplexFP64 _TEST_FP64_NONUNIT_QUATERION_LIST[] = { static const BGC_FP64_Complex _TEST_FP64_NONUNIT_QUATERION_LIST[] = {
{ 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0 }, { 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0 }, { 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64 }, { 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON },
{ 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64 }, { 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON },
{ 0.7071067811865475244 + 1.25 * BGC_EPSYLON_FP64, 0.7071067811865475244 + 1.25 * BGC_EPSYLON_FP64 }, { 0.7071067811865475244 + 1.25 * BGC_FP64_EPSYLON, 0.7071067811865475244 + 1.25 * BGC_FP64_EPSYLON },
{ 0.7071067811865475244 - 1.25 * BGC_EPSYLON_FP64, 0.7071067811865475244 - 1.25 * BGC_EPSYLON_FP64 } { 0.7071067811865475244 - 1.25 * BGC_FP64_EPSYLON, 0.7071067811865475244 - 1.25 * BGC_FP64_EPSYLON }
}; };
void test_complex_is_unit_fp64() void test_complex_is_unit_fp64()
{ {
print_testing_name("bgc_complex_is_unit_fp64"); print_testing_name("bgc_fp64_complex_is_unit");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP64_UNIT_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_UNIT_COMPLEX_AMOUNT; i++) {
if (!bgc_complex_is_unit_fp64(&_TEST_FP64_UNIT_COMPLEX_LIST[i])) { if (!bgc_fp64_complex_is_unit(&_TEST_FP64_UNIT_COMPLEX_LIST[i])) {
print_testing_error("A unit complex number was not recognized"); print_testing_error("A unit complex number was not recognized");
return; return;
} }
@ -93,7 +93,7 @@ void test_complex_is_unit_fp64()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONUNIT_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_NONUNIT_COMPLEX_AMOUNT; i++) {
if (bgc_complex_is_unit_fp64(&_TEST_FP64_NONUNIT_QUATERION_LIST[i])) { if (bgc_fp64_complex_is_unit(&_TEST_FP64_NONUNIT_QUATERION_LIST[i])) {
print_testing_error("A non-unit complex number was recognized a unit complex number"); print_testing_error("A non-unit complex number was recognized a unit complex number");
return; return;
} }

View file

@ -7,31 +7,31 @@
static const int _TEST_FP32_ZERO_COMPLEX_AMOUNT = 4; static const int _TEST_FP32_ZERO_COMPLEX_AMOUNT = 4;
static const int _TEST_FP32_NONZERO_COMPLEX_AMOUNT = 7; static const int _TEST_FP32_NONZERO_COMPLEX_AMOUNT = 7;
static const BgcComplexFP32 _TEST_FP32_ZERO_COMPLEX_LIST[] = { static const BGC_FP32_Complex _TEST_FP32_ZERO_COMPLEX_LIST[] = {
{ 0.0f, 0.0f }, { 0.0f, 0.0f },
{ 0.75f * BGC_EPSYLON_FP32, 0.0f }, { 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ -0.75f * BGC_EPSYLON_FP32, 0.0f }, { -0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.75f * BGC_EPSYLON_FP32 }, { 0.0f, 0.75f * BGC_FP32_EPSYLON },
{ 0.0f, -0.75f * BGC_EPSYLON_FP32 } { 0.0f, -0.75f * BGC_FP32_EPSYLON }
}; };
static const BgcComplexFP32 _TEST_FP32_NONZERO_QUATERION_LIST[] = { static const BGC_FP32_Complex _TEST_FP32_NONZERO_QUATERION_LIST[] = {
{ 0.0f, 1.0f }, { 0.0f, 1.0f },
{ 1.25f * BGC_EPSYLON_FP32 }, { 1.25f * BGC_FP32_EPSYLON },
{ -1.25f * BGC_EPSYLON_FP32 }, { -1.25f * BGC_FP32_EPSYLON },
{ 0.0f, 1.25f * BGC_EPSYLON_FP32 }, { 0.0f, 1.25f * BGC_FP32_EPSYLON },
{ 0.0f, -1.25f * BGC_EPSYLON_FP32 }, { 0.0f, -1.25f * BGC_FP32_EPSYLON },
{ 1.25f * BGC_EPSYLON_FP32, 1.25f * BGC_EPSYLON_FP32 }, { 1.25f * BGC_FP32_EPSYLON, 1.25f * BGC_FP32_EPSYLON },
{ -1.25f * BGC_EPSYLON_FP32, -1.25f * BGC_EPSYLON_FP32 } { -1.25f * BGC_FP32_EPSYLON, -1.25f * BGC_FP32_EPSYLON }
}; };
void test_complex_is_zero_fp32() void test_complex_is_zero_fp32()
{ {
print_testing_name("bgc_complex_is_zero_fp32"); print_testing_name("bgc_fp32_complex_is_zero");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP32_ZERO_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_ZERO_COMPLEX_AMOUNT; i++) {
if (!bgc_complex_is_zero_fp32(&_TEST_FP32_ZERO_COMPLEX_LIST[i])) { if (!bgc_fp32_complex_is_zero(&_TEST_FP32_ZERO_COMPLEX_LIST[i])) {
print_testing_error("A zero complex number was not recognized"); print_testing_error("A zero complex number was not recognized");
return; return;
} }
@ -39,7 +39,7 @@ void test_complex_is_zero_fp32()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONZERO_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_NONZERO_COMPLEX_AMOUNT; i++) {
if (bgc_complex_is_zero_fp32(&_TEST_FP32_NONZERO_QUATERION_LIST[i])) { if (bgc_fp32_complex_is_zero(&_TEST_FP32_NONZERO_QUATERION_LIST[i])) {
print_testing_error("A non-zero complex number was recognized as a zero complex number"); print_testing_error("A non-zero complex number was recognized as a zero complex number");
return; return;
} }
@ -53,31 +53,31 @@ void test_complex_is_zero_fp32()
static const int _TEST_FP64_ZERO_COMPLEX_AMOUNT = 4; static const int _TEST_FP64_ZERO_COMPLEX_AMOUNT = 4;
static const int _TEST_FP64_NONZERO_COMPLEX_AMOUNT = 7; static const int _TEST_FP64_NONZERO_COMPLEX_AMOUNT = 7;
static const BgcComplexFP64 _TEST_FP64_ZERO_COMPLEX_LIST[] = { static const BGC_FP64_Complex _TEST_FP64_ZERO_COMPLEX_LIST[] = {
{ 0.0, 0.0 }, { 0.0, 0.0 },
{ 0.75 * BGC_EPSYLON_FP64, 0.0 }, { 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ -0.75 * BGC_EPSYLON_FP64, 0.0 }, { -0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.75 * BGC_EPSYLON_FP64 }, { 0.0, 0.75 * BGC_FP64_EPSYLON },
{ 0.0, -0.75 * BGC_EPSYLON_FP64 } { 0.0, -0.75 * BGC_FP64_EPSYLON }
}; };
static const BgcComplexFP64 _TEST_FP64_NONZERO_QUATERION_LIST[] = { static const BGC_FP64_Complex _TEST_FP64_NONZERO_QUATERION_LIST[] = {
{ 0.0, 1.0 }, { 0.0, 1.0 },
{ 1.25 * BGC_EPSYLON_FP64, 0.0 }, { 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ -1.25 * BGC_EPSYLON_FP64, 0.0 }, { -1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 1.25 * BGC_EPSYLON_FP64 }, { 0.0, 1.25 * BGC_FP64_EPSYLON },
{ 0.0, -1.25 * BGC_EPSYLON_FP64 }, { 0.0, -1.25 * BGC_FP64_EPSYLON },
{ 1.25 * BGC_EPSYLON_FP64, 1.25 * BGC_EPSYLON_FP64 }, { 1.25 * BGC_FP64_EPSYLON, 1.25 * BGC_FP64_EPSYLON },
{ -1.25 * BGC_EPSYLON_FP64, -1.25 * BGC_EPSYLON_FP64 } { -1.25 * BGC_FP64_EPSYLON, -1.25 * BGC_FP64_EPSYLON }
}; };
void test_complex_is_zero_fp64() void test_complex_is_zero_fp64()
{ {
print_testing_name("bgc_complex_is_zero_fp64"); print_testing_name("bgc_fp64_complex_is_zero");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP64_ZERO_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_ZERO_COMPLEX_AMOUNT; i++) {
if (!bgc_complex_is_zero_fp64(&_TEST_FP64_ZERO_COMPLEX_LIST[i])) { if (!bgc_fp64_complex_is_zero(&_TEST_FP64_ZERO_COMPLEX_LIST[i])) {
print_testing_error("A zero complex number was not recognized"); print_testing_error("A zero complex number was not recognized");
return; return;
} }
@ -85,7 +85,7 @@ void test_complex_is_zero_fp64()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONZERO_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_NONZERO_COMPLEX_AMOUNT; i++) {
if (bgc_complex_is_zero_fp64(&_TEST_FP64_NONZERO_QUATERION_LIST[i])) { if (bgc_fp64_complex_is_zero(&_TEST_FP64_NONZERO_QUATERION_LIST[i])) {
print_testing_error("A non-zero complex number was recognized as a zero complex number"); print_testing_error("A non-zero complex number was recognized as a zero complex number");
return; return;
} }

View file

@ -6,7 +6,7 @@
static const int _TEST_FP32_COMPLEX_AMOUNT = 4; static const int _TEST_FP32_COMPLEX_AMOUNT = 4;
static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST[] = { static const BGC_FP32_Complex _TEST_FP32_COMPLEX_LIST[] = {
{ 4.0f, 3.0f }, { 4.0f, 3.0f },
{ -1.0f, 1.0f }, { -1.0f, 1.0f },
{ 100.0f, -100.0f }, { 100.0f, -100.0f },
@ -29,10 +29,10 @@ static const float _TEST_FP32_MODULUS_LIST[] = {
void test_complex_square_modulus_fp32() void test_complex_square_modulus_fp32()
{ {
print_testing_name("bgc_complex_get_square_modulus_fp32"); print_testing_name("bgc_fp32_complex_get_square_modulus");
for (int i = 0; i < _TEST_FP32_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_COMPLEX_AMOUNT; i++) {
if (!bgc_are_close_fp32(bgc_complex_get_square_modulus_fp32(&_TEST_FP32_COMPLEX_LIST[i]), _TEST_FP32_SQUARE_MODULUS_LIST[i])) { if (!bgc_fp32_are_close(bgc_fp32_complex_get_square_modulus(&_TEST_FP32_COMPLEX_LIST[i]), _TEST_FP32_SQUARE_MODULUS_LIST[i])) {
print_testing_failed(); print_testing_failed();
return; return;
} }
@ -43,10 +43,10 @@ void test_complex_square_modulus_fp32()
void test_complex_modulus_fp32() void test_complex_modulus_fp32()
{ {
print_testing_name("bgc_complex_get_modulus_fp32"); print_testing_name("bgc_fp32_complex_get_modulus");
for (int i = 0; i < _TEST_FP32_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_COMPLEX_AMOUNT; i++) {
if (!bgc_are_close_fp32(bgc_complex_get_modulus_fp32(&_TEST_FP32_COMPLEX_LIST[i]), _TEST_FP32_MODULUS_LIST[i])) { if (!bgc_fp32_are_close(bgc_fp32_complex_get_modulus(&_TEST_FP32_COMPLEX_LIST[i]), _TEST_FP32_MODULUS_LIST[i])) {
print_testing_failed(); print_testing_failed();
return; return;
} }
@ -59,7 +59,7 @@ void test_complex_modulus_fp32()
static const int _TEST_FP64_COMPLEX_AMOUNT = 4; static const int _TEST_FP64_COMPLEX_AMOUNT = 4;
static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST[] = { static const BGC_FP64_Complex _TEST_FP64_COMPLEX_LIST[] = {
{ 4.0, 3.0 }, { 4.0, 3.0 },
{ -1.0, -1.0 }, { -1.0, -1.0 },
{ -100.0, 100.0 }, { -100.0, 100.0 },
@ -82,10 +82,10 @@ static const double _TEST_FP64_MODULUS_LIST[] = {
void test_complex_square_modulus_fp64() void test_complex_square_modulus_fp64()
{ {
print_testing_name("bgc_complex_get_square_modulus_fp64"); print_testing_name("bgc_fp64_complex_get_square_modulus");
for (int i = 0; i < _TEST_FP64_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_COMPLEX_AMOUNT; i++) {
if (!bgc_are_close_fp64(bgc_complex_get_square_modulus_fp64(&_TEST_FP64_COMPLEX_LIST[i]), _TEST_FP64_SQUARE_MODULUS_LIST[i])) { if (!bgc_fp64_are_close(bgc_fp64_complex_get_square_modulus(&_TEST_FP64_COMPLEX_LIST[i]), _TEST_FP64_SQUARE_MODULUS_LIST[i])) {
print_testing_failed(); print_testing_failed();
return; return;
} }
@ -96,10 +96,10 @@ void test_complex_square_modulus_fp64()
void test_complex_modulus_fp64() void test_complex_modulus_fp64()
{ {
print_testing_name("bgc_complex_get_modulus_fp64"); print_testing_name("bgc_fp64_complex_get_modulus");
for (int i = 0; i < _TEST_FP64_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_COMPLEX_AMOUNT; i++) {
if (!bgc_are_close_fp64(bgc_complex_get_modulus_fp64(&_TEST_FP64_COMPLEX_LIST[i]), _TEST_FP64_MODULUS_LIST[i])) { if (!bgc_fp64_are_close(bgc_fp64_complex_get_modulus(&_TEST_FP64_COMPLEX_LIST[i]), _TEST_FP64_MODULUS_LIST[i])) {
print_testing_failed(); print_testing_failed();
return; return;
} }

View file

@ -4,11 +4,11 @@
void test_complex_reset_fp32() void test_complex_reset_fp32()
{ {
BgcComplexFP32 vector; BGC_FP32_Complex vector;
print_testing_name("bgc_complex_reset_fp32"); print_testing_name("bgc_fp32_complex_reset");
bgc_complex_reset_fp32(&vector); bgc_fp32_complex_reset(&vector);
if (vector.real != 0.0f || vector.imaginary != 0.0f) { if (vector.real != 0.0f || vector.imaginary != 0.0f) {
print_testing_failed(); print_testing_failed();
@ -20,11 +20,11 @@ void test_complex_reset_fp32()
void test_complex_reset_fp64() void test_complex_reset_fp64()
{ {
BgcComplexFP64 vector; BGC_FP64_Complex vector;
print_testing_name("bgc_complex_reset_fp64"); print_testing_name("bgc_fp64_complex_reset");
bgc_complex_reset_fp64(&vector); bgc_fp64_complex_reset(&vector);
if (vector.real != 0.0 || vector.imaginary != 0.0) { if (vector.real != 0.0 || vector.imaginary != 0.0) {
print_testing_failed(); print_testing_failed();

View file

@ -8,25 +8,25 @@
void test_complex_set_values_fp32() void test_complex_set_values_fp32()
{ {
BgcComplexFP32 vector; BGC_FP32_Complex vector;
print_testing_name("bgc_complex_set_values_fp32"); print_testing_name("bgc_fp32_complex_make");
bgc_complex_set_values_fp32(1.0f, 2.0f, &vector); bgc_fp32_complex_make(1.0f, 2.0f, &vector);
if (vector.real != 1.0f || vector.imaginary != 2.0f) { if (vector.real != 1.0f || vector.imaginary != 2.0f) {
print_testing_error("First step failed"); print_testing_error("First step failed");
return; return;
} }
bgc_complex_set_values_fp32(-1.0f, -3.0f, &vector); bgc_fp32_complex_make(-1.0f, -3.0f, &vector);
if (vector.real != -1.0f || vector.imaginary != -3.0f) { if (vector.real != -1.0f || vector.imaginary != -3.0f) {
print_testing_error("Second step failed"); print_testing_error("Second step failed");
return; return;
} }
bgc_complex_set_values_fp32(-8.0f, -2.0f, &vector); bgc_fp32_complex_make(-8.0f, -2.0f, &vector);
if (vector.real != -8.0f || vector.imaginary != -2.0f) { if (vector.real != -8.0f || vector.imaginary != -2.0f) {
print_testing_error("Third step failed"); print_testing_error("Third step failed");
@ -40,25 +40,25 @@ void test_complex_set_values_fp32()
void test_complex_set_values_fp64() void test_complex_set_values_fp64()
{ {
BgcComplexFP64 vector; BGC_FP64_Complex vector;
print_testing_name("bgc_complex_set_values_fp64"); print_testing_name("bgc_fp64_complex_make");
bgc_complex_set_values_fp64(1.0, 2.0, &vector); bgc_fp64_complex_make(1.0, 2.0, &vector);
if (vector.real != 1.0 || vector.imaginary != 2.0) { if (vector.real != 1.0 || vector.imaginary != 2.0) {
print_testing_error("First step failed"); print_testing_error("First step failed");
return; return;
} }
bgc_complex_set_values_fp64(-1.0, -3.0, &vector); bgc_fp64_complex_make(-1.0, -3.0, &vector);
if (vector.real != -1.0 || vector.imaginary != -3.0) { if (vector.real != -1.0 || vector.imaginary != -3.0) {
print_testing_error("Second step failed"); print_testing_error("Second step failed");
return; return;
} }
bgc_complex_set_values_fp64(-8.0, -2.0, &vector); bgc_fp64_complex_make(-8.0, -2.0, &vector);
if (vector.real != -8.0 || vector.imaginary != -2.0) { if (vector.real != -8.0 || vector.imaginary != -2.0) {
print_testing_error("Third step failed"); print_testing_error("Third step failed");

View file

@ -8,14 +8,14 @@
static const int _TEST_FP32_COMPLEX_AMOUNT = 4; static const int _TEST_FP32_COMPLEX_AMOUNT = 4;
static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST1[] = { static const BGC_FP32_Complex _TEST_FP32_COMPLEX_LIST1[] = {
{ 3.0f, 4.0f }, { 3.0f, 4.0f },
{ -2.0f, -1.0f }, { -2.0f, -1.0f },
{ -244.8f, 100.0f }, { -244.8f, 100.0f },
{ 1000.32f, -100.1f } { 1000.32f, -100.1f }
}; };
static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST2[] = { static const BGC_FP32_Complex _TEST_FP32_COMPLEX_LIST2[] = {
{ 5.3f, 1003.28f }, { 5.3f, 1003.28f },
{ -0.0032f, 891.3f }, { -0.0032f, 891.3f },
{ 5.322f, 0.9275f }, { 5.322f, 0.9275f },
@ -24,15 +24,15 @@ static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST2[] = {
void test_complex_swap_fp32() void test_complex_swap_fp32()
{ {
BgcComplexFP32 compleimaginary, complex2; BGC_FP32_Complex compleimaginary, complex2;
print_testing_name("bgc_complex_swap_fp32"); print_testing_name("bgc_fp32_complex_swap");
for (int i = 0; i < _TEST_FP32_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_COMPLEX_AMOUNT; i++) {
bgc_complex_copy_fp32(&_TEST_FP32_COMPLEX_LIST1[i], &compleimaginary); bgc_fp32_complex_copy(&_TEST_FP32_COMPLEX_LIST1[i], &compleimaginary);
bgc_complex_copy_fp32(&_TEST_FP32_COMPLEX_LIST2[i], &complex2); bgc_fp32_complex_copy(&_TEST_FP32_COMPLEX_LIST2[i], &complex2);
bgc_complex_swap_fp32(&compleimaginary, &complex2); bgc_fp32_complex_swap(&compleimaginary, &complex2);
if (compleimaginary.real != _TEST_FP32_COMPLEX_LIST2[i].real || if (compleimaginary.real != _TEST_FP32_COMPLEX_LIST2[i].real ||
compleimaginary.imaginary != _TEST_FP32_COMPLEX_LIST2[i].imaginary || compleimaginary.imaginary != _TEST_FP32_COMPLEX_LIST2[i].imaginary ||
@ -50,14 +50,14 @@ void test_complex_swap_fp32()
static const int _TEST_FP64_COMPLEX_AMOUNT = 4; static const int _TEST_FP64_COMPLEX_AMOUNT = 4;
static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST1[] = { static const BGC_FP64_Complex _TEST_FP64_COMPLEX_LIST1[] = {
{ 1.0, 4.0 }, { 1.0, 4.0 },
{ -4.0, -3.0 }, { -4.0, -3.0 },
{ -244.8, 344.7 }, { -244.8, 344.7 },
{ 1000.32, -271.3 } { 1000.32, -271.3 }
}; };
static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST2[] = { static const BGC_FP64_Complex _TEST_FP64_COMPLEX_LIST2[] = {
{ -0.123, 1003.28 }, { -0.123, 1003.28 },
{ 204.07, -781.89 }, { 204.07, -781.89 },
{ 5.322, 0.9275 }, { 5.322, 0.9275 },
@ -66,15 +66,15 @@ static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST2[] = {
void test_complex_swap_fp64() void test_complex_swap_fp64()
{ {
BgcComplexFP64 compleimaginary, complex2; BGC_FP64_Complex compleimaginary, complex2;
print_testing_name("bgc_complex_swap_fp64"); print_testing_name("bgc_fp64_complex_swap");
for (int i = 0; i < _TEST_FP64_COMPLEX_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_COMPLEX_AMOUNT; i++) {
bgc_complex_copy_fp64(&_TEST_FP64_COMPLEX_LIST1[i], &compleimaginary); bgc_fp64_complex_copy(&_TEST_FP64_COMPLEX_LIST1[i], &compleimaginary);
bgc_complex_copy_fp64(&_TEST_FP64_COMPLEX_LIST2[i], &complex2); bgc_fp64_complex_copy(&_TEST_FP64_COMPLEX_LIST2[i], &complex2);
bgc_complex_swap_fp64(&compleimaginary, &complex2); bgc_fp64_complex_swap(&compleimaginary, &complex2);
if (compleimaginary.real != _TEST_FP64_COMPLEX_LIST2[i].real || if (compleimaginary.real != _TEST_FP64_COMPLEX_LIST2[i].real ||
compleimaginary.imaginary != _TEST_FP64_COMPLEX_LIST2[i].imaginary || compleimaginary.imaginary != _TEST_FP64_COMPLEX_LIST2[i].imaginary ||

View file

@ -7,7 +7,7 @@
// ==================== FP32 ==================== // // ==================== FP32 ==================== //
static const int _TEST_FP32_QUATERNION_AMOUNT = 4; static const int _TEST_FP32_QUATERNION_AMOUNT = 4;
static const BgcQuaternionFP32 _TEST_FP32_QUATERNION_LIST[] = { static const BGC_FP32_Quaternion _TEST_FP32_QUATERNION_LIST[] = {
{ 1.0f, 2.0f, 3.0f, 4.0f }, { 1.0f, 2.0f, 3.0f, 4.0f },
{ -4.0f, -3.0f, -2.0f, -1.0f }, { -4.0f, -3.0f, -2.0f, -1.0f },
{ -0.001f, 100.0f, -100.0f, 0.001f }, { -0.001f, 100.0f, -100.0f, 0.001f },
@ -16,13 +16,13 @@ static const BgcQuaternionFP32 _TEST_FP32_QUATERNION_LIST[] = {
void test_quaternion_copy_fp32() void test_quaternion_copy_fp32()
{ {
BgcQuaternionFP32 vector; BGC_FP32_Quaternion vector;
print_testing_name("bgc_quaternion_copy_fp32"); print_testing_name("bgc_fp32_quaternion_copy");
for (int i = 0; i < _TEST_FP32_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_QUATERNION_AMOUNT; i++) {
bgc_quaternion_copy_fp32(&_TEST_FP32_QUATERNION_LIST[i], &vector); bgc_fp32_quaternion_copy(&_TEST_FP32_QUATERNION_LIST[i], &vector);
if (vector.s0 != _TEST_FP32_QUATERNION_LIST[i].s0 || if (vector.s0 != _TEST_FP32_QUATERNION_LIST[i].s0 ||
vector.x1 != _TEST_FP32_QUATERNION_LIST[i].x1 || vector.x1 != _TEST_FP32_QUATERNION_LIST[i].x1 ||
@ -39,7 +39,7 @@ void test_quaternion_copy_fp32()
// ==================== FP64 ==================== // // ==================== FP64 ==================== //
static const int _TEST_FP64_QUATERNION_AMOUNT = 4; static const int _TEST_FP64_QUATERNION_AMOUNT = 4;
static const BgcQuaternionFP64 _TEST_FP64_QUATERNION_LIST[] = { static const BGC_FP64_Quaternion _TEST_FP64_QUATERNION_LIST[] = {
{ 1.0, 2.0, 3.0, 4.0 }, { 1.0, 2.0, 3.0, 4.0 },
{ -4.0, -3.0, -2.0, -1.0 }, { -4.0, -3.0, -2.0, -1.0 },
{ -0.001, 100.0, -100.0, 0.001 }, { -0.001, 100.0, -100.0, 0.001 },
@ -48,13 +48,13 @@ static const BgcQuaternionFP64 _TEST_FP64_QUATERNION_LIST[] = {
void test_quaternion_copy_fp64() void test_quaternion_copy_fp64()
{ {
BgcQuaternionFP64 vector; BGC_FP64_Quaternion vector;
print_testing_name("bgc_quaternion_copy_fp64"); print_testing_name("bgc_fp64_quaternion_copy");
for (int i = 0; i < _TEST_FP64_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_QUATERNION_AMOUNT; i++) {
bgc_quaternion_copy_fp64(&_TEST_FP64_QUATERNION_LIST[i], &vector); bgc_fp64_quaternion_copy(&_TEST_FP64_QUATERNION_LIST[i], &vector);
if (vector.s0 != _TEST_FP64_QUATERNION_LIST[i].s0 || if (vector.s0 != _TEST_FP64_QUATERNION_LIST[i].s0 ||
vector.x1 != _TEST_FP64_QUATERNION_LIST[i].x1 || vector.x1 != _TEST_FP64_QUATERNION_LIST[i].x1 ||

View file

@ -7,45 +7,45 @@
static const int _TEST_FP32_UNIT_QUATERNION_AMOUNT = 16; static const int _TEST_FP32_UNIT_QUATERNION_AMOUNT = 16;
static const int _TEST_FP32_NONUNIT_QUATERNION_AMOUNT = 10; static const int _TEST_FP32_NONUNIT_QUATERNION_AMOUNT = 10;
static const BgcQuaternionFP32 _TEST_FP32_UNIT_QUATERNION_LIST[] = { static const BGC_FP32_Quaternion _TEST_FP32_UNIT_QUATERNION_LIST[] = {
{ 1.0f, 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f, 0.0f },
{ -1.0f, 0.0f, 0.0f, 0.0f }, { -1.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, -0.8f, 0.6f, 0.0f }, { 0.0f, -0.8f, 0.6f, 0.0f },
{ 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, { 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, { 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 0.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 0.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32 }, { 0.0f, 0.0f, 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON },
{ 0.0f, 0.0f, 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32 }, { 0.0f, 0.0f, 0.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON },
{ 0.5f, 0.5f, 0.5f, 0.5f }, { 0.5f, 0.5f, 0.5f, 0.5f },
{ 0.5f + 0.75f * BGC_EPSYLON_FP32, 0.5f, 0.5f, 0.5f }, { 0.5f + 0.75f * BGC_FP32_EPSYLON, 0.5f, 0.5f, 0.5f },
{ 0.5f, 0.5f - 0.75f * BGC_EPSYLON_FP32, 0.5f, 0.5f }, { 0.5f, 0.5f - 0.75f * BGC_FP32_EPSYLON, 0.5f, 0.5f },
{ 0.5f, 0.5f, 0.5f + 0.75f * BGC_EPSYLON_FP32, 0.5f }, { 0.5f, 0.5f, 0.5f + 0.75f * BGC_FP32_EPSYLON, 0.5f },
{ 0.5f, 0.5f, 0.5f, 0.5f - 0.75f * BGC_EPSYLON_FP32 } { 0.5f, 0.5f, 0.5f, 0.5f - 0.75f * BGC_FP32_EPSYLON }
}; };
static const BgcQuaternionFP32 _TEST_FP32_NONUNIT_QUATERION_LIST[] = { static const BGC_FP32_Quaternion _TEST_FP32_NONUNIT_QUATERION_LIST[] = {
{ 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, { 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, { 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32 }, { 0.0f, 0.0f, 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON },
{ 0.0f, 0.0f, 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32 }, { 0.0f, 0.0f, 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON },
{ 0.5f + 1.25f * BGC_EPSYLON_FP32, 0.5f + 1.25f * BGC_EPSYLON_FP32, 0.5f, 0.5f }, { 0.5f + 1.25f * BGC_FP32_EPSYLON, 0.5f + 1.25f * BGC_FP32_EPSYLON, 0.5f, 0.5f },
{ 0.5f - 1.25f * BGC_EPSYLON_FP32, 0.5f - 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.5f } { 0.5f - 1.25f * BGC_FP32_EPSYLON, 0.5f - 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.5f }
}; };
void test_quaternion_is_unit_fp32() void test_quaternion_is_unit_fp32()
{ {
print_testing_name("bgc_quaternion_is_unit_fp32"); print_testing_name("bgc_fp32_quaternion_is_unit");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP32_UNIT_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_UNIT_QUATERNION_AMOUNT; i++) {
if (!bgc_quaternion_is_unit_fp32(&_TEST_FP32_UNIT_QUATERNION_LIST[i])) { if (!bgc_fp32_quaternion_is_unit(&_TEST_FP32_UNIT_QUATERNION_LIST[i])) {
print_testing_error("A unit quaternion was not recognized"); print_testing_error("A unit quaternion was not recognized");
return; return;
} }
@ -53,7 +53,7 @@ void test_quaternion_is_unit_fp32()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONUNIT_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_NONUNIT_QUATERNION_AMOUNT; i++) {
if (bgc_quaternion_is_unit_fp32(&_TEST_FP32_NONUNIT_QUATERION_LIST[i])) { if (bgc_fp32_quaternion_is_unit(&_TEST_FP32_NONUNIT_QUATERION_LIST[i])) {
print_testing_error("A non-unit quaternion was recognized a unit quaternion"); print_testing_error("A non-unit quaternion was recognized a unit quaternion");
return; return;
} }
@ -67,45 +67,45 @@ void test_quaternion_is_unit_fp32()
static const int _TEST_FP64_UNIT_QUATERNION_AMOUNT = 16; static const int _TEST_FP64_UNIT_QUATERNION_AMOUNT = 16;
static const int _TEST_FP64_NONUNIT_QUATERNION_AMOUNT = 10; static const int _TEST_FP64_NONUNIT_QUATERNION_AMOUNT = 10;
static const BgcQuaternionFP64 _TEST_FP64_UNIT_QUATERNION_LIST[] = { static const BGC_FP64_Quaternion _TEST_FP64_UNIT_QUATERNION_LIST[] = {
{ 1.0, 0.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0, 0.0 },
{ -1.0, 0.0, 0.0, 0.0 }, { -1.0, 0.0, 0.0, 0.0 },
{ 0.0, -0.6, 0.8, 0.0 }, { 0.0, -0.6, 0.8, 0.0 },
{ 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, { 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, { 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 0.0, 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, 0.0, 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64 }, { 0.0, 0.0, 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON },
{ 0.0, 0.0, 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64 }, { 0.0, 0.0, 0.0, 1.0 - 0.75 * BGC_FP64_EPSYLON },
{ 0.5, 0.5, 0.5, 0.5 }, { 0.5, 0.5, 0.5, 0.5 },
{ 0.5 + 0.75 * BGC_EPSYLON_FP64, 0.5, 0.5, 0.5 }, { 0.5 + 0.75 * BGC_FP64_EPSYLON, 0.5, 0.5, 0.5 },
{ 0.5, 0.5 - 0.75 * BGC_EPSYLON_FP64, 0.5, 0.5 }, { 0.5, 0.5 - 0.75 * BGC_FP64_EPSYLON, 0.5, 0.5 },
{ 0.5, 0.5, 0.5 + 0.75 * BGC_EPSYLON_FP64, 0.5 }, { 0.5, 0.5, 0.5 + 0.75 * BGC_FP64_EPSYLON, 0.5 },
{ 0.5, 0.5, 0.5, 0.5 - 0.75 * BGC_EPSYLON_FP64 } { 0.5, 0.5, 0.5, 0.5 - 0.75 * BGC_FP64_EPSYLON }
}; };
static const BgcQuaternionFP64 _TEST_FP64_NONUNIT_QUATERION_LIST[] = { static const BGC_FP64_Quaternion _TEST_FP64_NONUNIT_QUATERION_LIST[] = {
{ 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, { 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, { 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64 }, { 0.0, 0.0, 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON },
{ 0.0, 0.0, 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64 }, { 0.0, 0.0, 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON },
{ 0.5 + 1.25 * BGC_EPSYLON_FP64, 0.5 + 1.25 * BGC_EPSYLON_FP64, 0.5, 0.5 }, { 0.5 + 1.25 * BGC_FP64_EPSYLON, 0.5 + 1.25 * BGC_FP64_EPSYLON, 0.5, 0.5 },
{ 0.5 - 1.25 * BGC_EPSYLON_FP64, 0.5 - 1.25 * BGC_EPSYLON_FP64, 0.0, 0.5 } { 0.5 - 1.25 * BGC_FP64_EPSYLON, 0.5 - 1.25 * BGC_FP64_EPSYLON, 0.0, 0.5 }
}; };
void test_quaternion_is_unit_fp64() void test_quaternion_is_unit_fp64()
{ {
print_testing_name("bgc_quaternion_is_unit_fp64"); print_testing_name("bgc_fp64_quaternion_is_unit");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP64_UNIT_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_UNIT_QUATERNION_AMOUNT; i++) {
if (!bgc_quaternion_is_unit_fp64(&_TEST_FP64_UNIT_QUATERNION_LIST[i])) { if (!bgc_fp64_quaternion_is_unit(&_TEST_FP64_UNIT_QUATERNION_LIST[i])) {
print_testing_error("A unit quaternion was not recognized"); print_testing_error("A unit quaternion was not recognized");
return; return;
} }
@ -113,7 +113,7 @@ void test_quaternion_is_unit_fp64()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONUNIT_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_NONUNIT_QUATERNION_AMOUNT; i++) {
if (bgc_quaternion_is_unit_fp64(&_TEST_FP64_NONUNIT_QUATERION_LIST[i])) { if (bgc_fp64_quaternion_is_unit(&_TEST_FP64_NONUNIT_QUATERION_LIST[i])) {
print_testing_error("A non-unit quaternion was recognized a unit quaternion"); print_testing_error("A non-unit quaternion was recognized a unit quaternion");
return; return;
} }

View file

@ -7,39 +7,39 @@
static const int _TEST_FP32_ZERO_QUATERNION_AMOUNT = 9; static const int _TEST_FP32_ZERO_QUATERNION_AMOUNT = 9;
static const int _TEST_FP32_NONZERO_QUATERNION_AMOUNT = 11; static const int _TEST_FP32_NONZERO_QUATERNION_AMOUNT = 11;
static const BgcQuaternionFP32 _TEST_FP32_ZERO_QUATERNION_LIST[] = { static const BGC_FP32_Quaternion _TEST_FP32_ZERO_QUATERNION_LIST[] = {
{ 0.0f, 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f, 0.0f },
{ 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, { 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ -0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, { -0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ 0.0f, 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 0.0f, 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, -0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 0.0f, -0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 0.0f, 0.75f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 0.0f, 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, -0.75f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 0.0f, -0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 0.0f, 0.75f * BGC_EPSYLON_FP32 }, { 0.0f, 0.0f, 0.0f, 0.75f * BGC_FP32_EPSYLON },
{ 0.0f, 0.0f, 0.0f, -0.75f * BGC_EPSYLON_FP32 } { 0.0f, 0.0f, 0.0f, -0.75f * BGC_FP32_EPSYLON }
}; };
static const BgcQuaternionFP32 _TEST_FP32_NONZERO_QUATERION_LIST[] = { static const BGC_FP32_Quaternion _TEST_FP32_NONZERO_QUATERION_LIST[] = {
{ 0.0f, 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f, 0.0f },
{ 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, { 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ -1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, { -1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 0.0f, 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, -1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 0.0f, -1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.25f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 0.0f, 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, -1.25f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 0.0f, -1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.25f * BGC_EPSYLON_FP32 }, { 0.0f, 0.0f, 0.0f, 1.25f * BGC_FP32_EPSYLON },
{ 0.0f, 0.0f, 0.0f, -1.25f * BGC_EPSYLON_FP32 }, { 0.0f, 0.0f, 0.0f, -1.25f * BGC_FP32_EPSYLON },
{ 1.25f * BGC_EPSYLON_FP32, 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 1.25f * BGC_FP32_EPSYLON, 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ -1.25f * BGC_EPSYLON_FP32, -1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f } { -1.25f * BGC_FP32_EPSYLON, -1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f }
}; };
void test_quaternion_is_zero_fp32() void test_quaternion_is_zero_fp32()
{ {
print_testing_name("bgc_quaternion_is_zero_fp32"); print_testing_name("bgc_fp32_quaternion_is_zero");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP32_ZERO_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_ZERO_QUATERNION_AMOUNT; i++) {
if (!bgc_quaternion_is_zero_fp32(&_TEST_FP32_ZERO_QUATERNION_LIST[i])) { if (!bgc_fp32_quaternion_is_zero(&_TEST_FP32_ZERO_QUATERNION_LIST[i])) {
print_testing_error("A zero quaternion was not recognized"); print_testing_error("A zero quaternion was not recognized");
return; return;
} }
@ -47,7 +47,7 @@ void test_quaternion_is_zero_fp32()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONZERO_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_NONZERO_QUATERNION_AMOUNT; i++) {
if (bgc_quaternion_is_zero_fp32(&_TEST_FP32_NONZERO_QUATERION_LIST[i])) { if (bgc_fp32_quaternion_is_zero(&_TEST_FP32_NONZERO_QUATERION_LIST[i])) {
print_testing_error("A non-zero quaternion was recognized as a zero quaternion"); print_testing_error("A non-zero quaternion was recognized as a zero quaternion");
return; return;
} }
@ -61,39 +61,39 @@ void test_quaternion_is_zero_fp32()
static const int _TEST_FP64_ZERO_QUATERNION_AMOUNT = 9; static const int _TEST_FP64_ZERO_QUATERNION_AMOUNT = 9;
static const int _TEST_FP64_NONZERO_QUATERNION_AMOUNT = 11; static const int _TEST_FP64_NONZERO_QUATERNION_AMOUNT = 11;
static const BgcQuaternionFP64 _TEST_FP64_ZERO_QUATERNION_LIST[] = { static const BGC_FP64_Quaternion _TEST_FP64_ZERO_QUATERNION_LIST[] = {
{ 0.0, 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0, 0.0 },
{ 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, { 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ -0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, { -0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ 0.0, 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 0.0, 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, -0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 0.0, -0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 0.0, 0.75 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, 0.0, 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, -0.75 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, 0.0, -0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 0.0, 0.75 * BGC_EPSYLON_FP64 }, { 0.0, 0.0, 0.0, 0.75 * BGC_FP64_EPSYLON },
{ 0.0, 0.0, 0.0, -0.75 * BGC_EPSYLON_FP64 } { 0.0, 0.0, 0.0, -0.75 * BGC_FP64_EPSYLON }
}; };
static const BgcQuaternionFP64 _TEST_FP64_NONZERO_QUATERION_LIST[] = { static const BGC_FP64_Quaternion _TEST_FP64_NONZERO_QUATERION_LIST[] = {
{ 0.0, 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0, 0.0 },
{ 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, { 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ -1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, { -1.25 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ 0.0, 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 0.0, 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, -1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 0.0, -1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 0.0, 1.25 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, 0.0, 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, -1.25 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, 0.0, -1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 0.0, 1.25 * BGC_EPSYLON_FP64 }, { 0.0, 0.0, 0.0, 1.25 * BGC_FP64_EPSYLON },
{ 0.0, 0.0, 0.0, -1.25 * BGC_EPSYLON_FP64 }, { 0.0, 0.0, 0.0, -1.25 * BGC_FP64_EPSYLON },
{ 1.25 * BGC_EPSYLON_FP64, 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 1.25 * BGC_FP64_EPSYLON, 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ -1.25 * BGC_EPSYLON_FP64, -1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 } { -1.25 * BGC_FP64_EPSYLON, -1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 }
}; };
void test_quaternion_is_zero_fp64() void test_quaternion_is_zero_fp64()
{ {
print_testing_name("bgc_quaternion_is_zero_fp64"); print_testing_name("bgc_fp64_quaternion_is_zero");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP64_ZERO_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_ZERO_QUATERNION_AMOUNT; i++) {
if (!bgc_quaternion_is_zero_fp64(&_TEST_FP64_ZERO_QUATERNION_LIST[i])) { if (!bgc_fp64_quaternion_is_zero(&_TEST_FP64_ZERO_QUATERNION_LIST[i])) {
print_testing_error("A zero quaternion was not recognized"); print_testing_error("A zero quaternion was not recognized");
return; return;
} }
@ -101,7 +101,7 @@ void test_quaternion_is_zero_fp64()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONZERO_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_NONZERO_QUATERNION_AMOUNT; i++) {
if (bgc_quaternion_is_zero_fp64(&_TEST_FP64_NONZERO_QUATERION_LIST[i])) { if (bgc_fp64_quaternion_is_zero(&_TEST_FP64_NONZERO_QUATERION_LIST[i])) {
print_testing_error("A non-zero quaternion was recognized as a zero quaternion"); print_testing_error("A non-zero quaternion was recognized as a zero quaternion");
return; return;
} }

View file

@ -6,7 +6,7 @@
static const int _TEST_FP32_QUATERNION_AMOUNT = 4; static const int _TEST_FP32_QUATERNION_AMOUNT = 4;
static const BgcQuaternionFP32 _TEST_FP32_QUATERNION_LIST[] = { static const BGC_FP32_Quaternion _TEST_FP32_QUATERNION_LIST[] = {
{ 0.0f, 4.0f, 3.0f, 0.0f }, { 0.0f, 4.0f, 3.0f, 0.0f },
{ -1.0f, 1.0f, -1.0f, 1.0f }, { -1.0f, 1.0f, -1.0f, 1.0f },
{ 100.0f, -100.0f, 0.0f, 100.0f }, { 100.0f, -100.0f, 0.0f, 100.0f },
@ -29,10 +29,10 @@ static const float _TEST_FP32_MODULUS_LIST[] = {
void test_quaternion_square_modulus_fp32() void test_quaternion_square_modulus_fp32()
{ {
print_testing_name("bgc_quaternion_get_square_modulus_fp32"); print_testing_name("bgc_fp32_quaternion_get_square_modulus");
for (int i = 0; i < _TEST_FP32_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_QUATERNION_AMOUNT; i++) {
if (!bgc_are_close_fp32(bgc_quaternion_get_square_modulus_fp32(&_TEST_FP32_QUATERNION_LIST[i]), _TEST_FP32_SQUARE_MODULUS_LIST[i])) { if (!bgc_fp32_are_close(bgc_fp32_quaternion_get_square_modulus(&_TEST_FP32_QUATERNION_LIST[i]), _TEST_FP32_SQUARE_MODULUS_LIST[i])) {
print_testing_failed(); print_testing_failed();
return; return;
} }
@ -43,10 +43,10 @@ void test_quaternion_square_modulus_fp32()
void test_quaternion_modulus_fp32() void test_quaternion_modulus_fp32()
{ {
print_testing_name("bgc_quaternion_get_modulus_fp32"); print_testing_name("bgc_fp32_quaternion_get_modulus");
for (int i = 0; i < _TEST_FP32_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_QUATERNION_AMOUNT; i++) {
if (!bgc_are_close_fp32(bgc_quaternion_get_modulus_fp32(&_TEST_FP32_QUATERNION_LIST[i]), _TEST_FP32_MODULUS_LIST[i])) { if (!bgc_fp32_are_close(bgc_fp32_quaternion_get_modulus(&_TEST_FP32_QUATERNION_LIST[i]), _TEST_FP32_MODULUS_LIST[i])) {
print_testing_failed(); print_testing_failed();
return; return;
} }
@ -59,7 +59,7 @@ void test_quaternion_modulus_fp32()
static const int _TEST_FP64_QUATERNION_AMOUNT = 4; static const int _TEST_FP64_QUATERNION_AMOUNT = 4;
static const BgcQuaternionFP64 _TEST_FP64_QUATERNION_LIST[] = { static const BGC_FP64_Quaternion _TEST_FP64_QUATERNION_LIST[] = {
{ 0.0, 4.0, 3.0, 0.0 }, { 0.0, 4.0, 3.0, 0.0 },
{ -1.0, 1.0, -1.0, 1.0 }, { -1.0, 1.0, -1.0, 1.0 },
{ 100.0, -100.0, 0.0, 100.0 }, { 100.0, -100.0, 0.0, 100.0 },
@ -82,10 +82,10 @@ static const double _TEST_FP64_MODULUS_LIST[] = {
void test_quaternion_square_modulus_fp64() void test_quaternion_square_modulus_fp64()
{ {
print_testing_name("bgc_quaternion_get_square_modulus_fp64"); print_testing_name("bgc_fp64_quaternion_get_square_modulus");
for (int i = 0; i < _TEST_FP64_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_QUATERNION_AMOUNT; i++) {
if (!bgc_are_close_fp64(bgc_quaternion_get_square_modulus_fp64(&_TEST_FP64_QUATERNION_LIST[i]), _TEST_FP64_SQUARE_MODULUS_LIST[i])) { if (!bgc_fp64_are_close(bgc_fp64_quaternion_get_square_modulus(&_TEST_FP64_QUATERNION_LIST[i]), _TEST_FP64_SQUARE_MODULUS_LIST[i])) {
print_testing_failed(); print_testing_failed();
return; return;
} }
@ -96,10 +96,10 @@ void test_quaternion_square_modulus_fp64()
void test_quaternion_modulus_fp64() void test_quaternion_modulus_fp64()
{ {
print_testing_name("bgc_quaternion_get_modulus_fp64"); print_testing_name("bgc_fp64_quaternion_get_modulus");
for (int i = 0; i < _TEST_FP64_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_QUATERNION_AMOUNT; i++) {
if (!bgc_are_close_fp64(bgc_quaternion_get_modulus_fp64(&_TEST_FP64_QUATERNION_LIST[i]), _TEST_FP64_MODULUS_LIST[i])) { if (!bgc_fp64_are_close(bgc_fp64_quaternion_get_modulus(&_TEST_FP64_QUATERNION_LIST[i]), _TEST_FP64_MODULUS_LIST[i])) {
print_testing_failed(); print_testing_failed();
return; return;
} }

View file

@ -4,11 +4,11 @@
void test_quaternion_reset_fp32() void test_quaternion_reset_fp32()
{ {
BgcQuaternionFP32 vector; BGC_FP32_Quaternion vector;
print_testing_name("bgc_quaternion_reset_fp32"); print_testing_name("bgc_fp32_quaternion_reset");
bgc_quaternion_reset_fp32(&vector); bgc_fp32_quaternion_reset(&vector);
if (vector.s0 != 0.0f || vector.x1 != 0.0f || vector.x2 != 0.0f || vector.x3 != 0.0f) { if (vector.s0 != 0.0f || vector.x1 != 0.0f || vector.x2 != 0.0f || vector.x3 != 0.0f) {
print_testing_failed(); print_testing_failed();
@ -20,11 +20,11 @@ void test_quaternion_reset_fp32()
void test_quaternion_reset_fp64() void test_quaternion_reset_fp64()
{ {
BgcQuaternionFP64 vector; BGC_FP64_Quaternion vector;
print_testing_name("bgc_quaternion_reset_fp64"); print_testing_name("bgc_fp64_quaternion_reset");
bgc_quaternion_reset_fp64(&vector); bgc_fp64_quaternion_reset(&vector);
if (vector.s0 != 0.0 || vector.x1 != 0.0 || vector.x2 != 0.0 || vector.x3 != 0.0) { if (vector.s0 != 0.0 || vector.x1 != 0.0 || vector.x2 != 0.0 || vector.x3 != 0.0) {
print_testing_failed(); print_testing_failed();

View file

@ -2,13 +2,13 @@
#include "./../../helpers.h" #include "./../../helpers.h"
void test_quaternion_set_to_identity_fp32() void test_quaternion_make_unit_fp32()
{ {
BgcQuaternionFP32 vector; BGC_FP32_Quaternion vector;
print_testing_name("bgc_quaternion_set_to_identity_fp32"); print_testing_name("bgc_fp32_quaternion_make_unit");
bgc_quaternion_make_unit_fp32(&vector); bgc_fp32_quaternion_make_unit(&vector);
if (vector.s0 != 1.0f || vector.x1 != 0.0f || vector.x2 != 0.0f || vector.x3 != 0.0f) { if (vector.s0 != 1.0f || vector.x1 != 0.0f || vector.x2 != 0.0f || vector.x3 != 0.0f) {
print_testing_failed(); print_testing_failed();
@ -18,13 +18,13 @@ void test_quaternion_set_to_identity_fp32()
print_testing_success(); print_testing_success();
} }
void test_quaternion_set_to_identity_fp64() void test_quaternion_make_unit_fp64()
{ {
BgcQuaternionFP64 vector; BGC_FP64_Quaternion vector;
print_testing_name("bgc_quaternion_set_to_identity_fp64"); print_testing_name("bgc_fp64_quaternion_make_unit");
bgc_quaternion_make_unit_fp64(&vector); bgc_fp64_quaternion_make_unit(&vector);
if (vector.s0 != 1.0 || vector.x1 != 0.0 || vector.x2 != 0.0 || vector.x3 != 0.0) { if (vector.s0 != 1.0 || vector.x1 != 0.0 || vector.x2 != 0.0 || vector.x3 != 0.0) {
print_testing_failed(); print_testing_failed();
@ -36,6 +36,6 @@ void test_quaternion_set_to_identity_fp64()
void test_quaternion_set_to_identity() void test_quaternion_set_to_identity()
{ {
test_quaternion_set_to_identity_fp32(); test_quaternion_make_unit_fp32();
test_quaternion_set_to_identity_fp64(); test_quaternion_make_unit_fp64();
} }

View file

@ -1,9 +1,9 @@
#ifndef _TEST_QUATERNION_SET_TO_IDENTITY_H_ #ifndef _TEST_QUATERNION_SET_TO_IDENTITY_H_
#define _TEST_QUATERNION_SET_TO_IDENTITY_H_ #define _TEST_QUATERNION_SET_TO_IDENTITY_H_
void test_quaternion_set_to_identity_fp32(); void test_quaternion_make_unit_fp32();
void test_quaternion_set_to_identity_fp64(); void test_quaternion_make_unit_fp64();
void test_quaternion_set_to_identity(); void test_quaternion_set_to_identity();

View file

@ -8,25 +8,25 @@
void test_quaternion_set_values_fp32() void test_quaternion_set_values_fp32()
{ {
BgcQuaternionFP32 vector; BGC_FP32_Quaternion vector;
print_testing_name("bgc_quaternion_set_values_fp32"); print_testing_name("bgc_fp32_quaternion_make");
bgc_quaternion_set_values_fp32(1.0f, 2.0f, 3.0f, 4.0f, &vector); bgc_fp32_quaternion_make(1.0f, 2.0f, 3.0f, 4.0f, &vector);
if (vector.s0 != 1.0f || vector.x1 != 2.0f || vector.x2 != 3.0f || vector.x3 != 4.0f) { if (vector.s0 != 1.0f || vector.x1 != 2.0f || vector.x2 != 3.0f || vector.x3 != 4.0f) {
print_testing_error("First step failed"); print_testing_error("First step failed");
return; return;
} }
bgc_quaternion_set_values_fp32(-1.0f, -3.0f, -5.0f, -7.0f, &vector); bgc_fp32_quaternion_make(-1.0f, -3.0f, -5.0f, -7.0f, &vector);
if (vector.s0 != -1.0f || vector.x1 != -3.0f || vector.x2 != -5.0f || vector.x3 != -7.0f) { if (vector.s0 != -1.0f || vector.x1 != -3.0f || vector.x2 != -5.0f || vector.x3 != -7.0f) {
print_testing_error("Second step failed"); print_testing_error("Second step failed");
return; return;
} }
bgc_quaternion_set_values_fp32(-8.0f, -2.0f, 2.0f, 4.0f, &vector); bgc_fp32_quaternion_make(-8.0f, -2.0f, 2.0f, 4.0f, &vector);
if (vector.s0 != -8.0f || vector.x1 != -2.0f || vector.x2 != 2.0f || vector.x3 != 4.0f) { if (vector.s0 != -8.0f || vector.x1 != -2.0f || vector.x2 != 2.0f || vector.x3 != 4.0f) {
print_testing_error("Third step failed"); print_testing_error("Third step failed");
@ -40,25 +40,25 @@ void test_quaternion_set_values_fp32()
void test_quaternion_set_values_fp64() void test_quaternion_set_values_fp64()
{ {
BgcQuaternionFP64 vector; BGC_FP64_Quaternion vector;
print_testing_name("bgc_quaternion_set_values_fp64"); print_testing_name("bgc_fp64_quaternion_make");
bgc_quaternion_set_values_fp64(1.0, 2.0, 3.0, 4.0, &vector); bgc_fp64_quaternion_make(1.0, 2.0, 3.0, 4.0, &vector);
if (vector.s0 != 1.0 || vector.x1 != 2.0 || vector.x2 != 3.0 || vector.x3 != 4.0) { if (vector.s0 != 1.0 || vector.x1 != 2.0 || vector.x2 != 3.0 || vector.x3 != 4.0) {
print_testing_error("First step failed"); print_testing_error("First step failed");
return; return;
} }
bgc_quaternion_set_values_fp64(-1.0, -3.0, -5.0, -7.0, &vector); bgc_fp64_quaternion_make(-1.0, -3.0, -5.0, -7.0, &vector);
if (vector.s0 != -1.0 || vector.x1 != -3.0 || vector.x2 != -5.0 || vector.x3 != -7.0) { if (vector.s0 != -1.0 || vector.x1 != -3.0 || vector.x2 != -5.0 || vector.x3 != -7.0) {
print_testing_error("Second step failed"); print_testing_error("Second step failed");
return; return;
} }
bgc_quaternion_set_values_fp64(-8.0, -2.0, 2.0, 4.0, &vector); bgc_fp64_quaternion_make(-8.0, -2.0, 2.0, 4.0, &vector);
if (vector.s0 != -8.0 || vector.x1 != -2.0 || vector.x2 != 2.0 || vector.x3 != 4.0) { if (vector.s0 != -8.0 || vector.x1 != -2.0 || vector.x2 != 2.0 || vector.x3 != 4.0) {
print_testing_error("Third step failed"); print_testing_error("Third step failed");

View file

@ -8,14 +8,14 @@
static const int _TEST_FP32_QUATERNION_AMOUNT = 4; static const int _TEST_FP32_QUATERNION_AMOUNT = 4;
static const BgcQuaternionFP32 _TEST_FP32_QUATERNION_LIST1[] = { static const BGC_FP32_Quaternion _TEST_FP32_QUATERNION_LIST1[] = {
{ 1.0f, 2.0f, 3.0f, 4.0f }, { 1.0f, 2.0f, 3.0f, 4.0f },
{ -4.0f, -3.0f, -2.0f, -1.0f }, { -4.0f, -3.0f, -2.0f, -1.0f },
{ -244.8f, 100.0f, -100.0f, 344.7f }, { -244.8f, 100.0f, -100.0f, 344.7f },
{ 1000.32f, -100.1f, 100.2f, -271.3f } { 1000.32f, -100.1f, 100.2f, -271.3f }
}; };
static const BgcQuaternionFP32 _TEST_FP32_QUATERNION_LIST2[] = { static const BGC_FP32_Quaternion _TEST_FP32_QUATERNION_LIST2[] = {
{ 3.6f, -0.123f, 5.3f, 1003.28f }, { 3.6f, -0.123f, 5.3f, 1003.28f },
{ 204.07f, -781.89f, -0.0032f, 891.3f }, { 204.07f, -781.89f, -0.0032f, 891.3f },
{ -20.02f, -1.0003f, 5.322f, 0.9275f }, { -20.02f, -1.0003f, 5.322f, 0.9275f },
@ -24,15 +24,15 @@ static const BgcQuaternionFP32 _TEST_FP32_QUATERNION_LIST2[] = {
void test_quaternion_swap_fp32() void test_quaternion_swap_fp32()
{ {
BgcQuaternionFP32 quaternion1, quaternion2; BGC_FP32_Quaternion quaternion1, quaternion2;
print_testing_name("bgc_quaternion_swap_fp32"); print_testing_name("bgc_fp32_quaternion_swap");
for (int i = 0; i < _TEST_FP32_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_QUATERNION_AMOUNT; i++) {
bgc_quaternion_copy_fp32(&_TEST_FP32_QUATERNION_LIST1[i], &quaternion1); bgc_fp32_quaternion_copy(&_TEST_FP32_QUATERNION_LIST1[i], &quaternion1);
bgc_quaternion_copy_fp32(&_TEST_FP32_QUATERNION_LIST2[i], &quaternion2); bgc_fp32_quaternion_copy(&_TEST_FP32_QUATERNION_LIST2[i], &quaternion2);
bgc_quaternion_swap_fp32(&quaternion1, &quaternion2); bgc_fp32_quaternion_swap(&quaternion1, &quaternion2);
if (quaternion1.s0 != _TEST_FP32_QUATERNION_LIST2[i].s0 || if (quaternion1.s0 != _TEST_FP32_QUATERNION_LIST2[i].s0 ||
quaternion1.x1 != _TEST_FP32_QUATERNION_LIST2[i].x1 || quaternion1.x1 != _TEST_FP32_QUATERNION_LIST2[i].x1 ||
@ -54,14 +54,14 @@ void test_quaternion_swap_fp32()
static const int _TEST_FP64_QUATERNION_AMOUNT = 4; static const int _TEST_FP64_QUATERNION_AMOUNT = 4;
static const BgcQuaternionFP64 _TEST_FP64_QUATERNION_LIST1[] = { static const BGC_FP64_Quaternion _TEST_FP64_QUATERNION_LIST1[] = {
{ 1.0, 2.0, 3.0, 4.0 }, { 1.0, 2.0, 3.0, 4.0 },
{ -4.0, -3.0, -2.0, -1.0 }, { -4.0, -3.0, -2.0, -1.0 },
{ -244.8, 100.0, -100.0, 344.7 }, { -244.8, 100.0, -100.0, 344.7 },
{ 1000.32, -100.1, 100.2, -271.3 } { 1000.32, -100.1, 100.2, -271.3 }
}; };
static const BgcQuaternionFP64 _TEST_FP64_QUATERNION_LIST2[] = { static const BGC_FP64_Quaternion _TEST_FP64_QUATERNION_LIST2[] = {
{ 3.6, -0.123, 5.3, 1003.28 }, { 3.6, -0.123, 5.3, 1003.28 },
{ 204.07, -781.89, -0.0032, 891.3 }, { 204.07, -781.89, -0.0032, 891.3 },
{ -20.02, -1.0003, 5.322, 0.9275 }, { -20.02, -1.0003, 5.322, 0.9275 },
@ -70,15 +70,15 @@ static const BgcQuaternionFP64 _TEST_FP64_QUATERNION_LIST2[] = {
void test_quaternion_swap_fp64() void test_quaternion_swap_fp64()
{ {
BgcQuaternionFP64 quaternion1, quaternion2; BGC_FP64_Quaternion quaternion1, quaternion2;
print_testing_name("bgc_quaternion_swap_fp64"); print_testing_name("bgc_fp64_quaternion_swap");
for (int i = 0; i < _TEST_FP64_QUATERNION_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_QUATERNION_AMOUNT; i++) {
bgc_quaternion_copy_fp64(&_TEST_FP64_QUATERNION_LIST1[i], &quaternion1); bgc_fp64_quaternion_copy(&_TEST_FP64_QUATERNION_LIST1[i], &quaternion1);
bgc_quaternion_copy_fp64(&_TEST_FP64_QUATERNION_LIST2[i], &quaternion2); bgc_fp64_quaternion_copy(&_TEST_FP64_QUATERNION_LIST2[i], &quaternion2);
bgc_quaternion_swap_fp64(&quaternion1, &quaternion2); bgc_fp64_quaternion_swap(&quaternion1, &quaternion2);
if (quaternion1.s0 != _TEST_FP64_QUATERNION_LIST2[i].s0 || if (quaternion1.s0 != _TEST_FP64_QUATERNION_LIST2[i].s0 ||
quaternion1.x1 != _TEST_FP64_QUATERNION_LIST2[i].x1 || quaternion1.x1 != _TEST_FP64_QUATERNION_LIST2[i].x1 ||

View file

@ -12,22 +12,22 @@ static const TestNumberPairFP32 _TEST_FP32_DATA_CLOSE[] = {
{1.0f, 1.0f}, {1.0f, 1.0f},
{-1.0f, -1.0f}, {-1.0f, -1.0f},
{-0.4f * BGC_EPSYLON_FP32, 0.4f * BGC_EPSYLON_FP32}, {-0.4f * BGC_FP32_EPSYLON, 0.4f * BGC_FP32_EPSYLON},
{1.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32}, {1.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON},
{1.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32}, {1.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON},
{1.0f + 0.75f * BGC_EPSYLON_FP32, 1.0f}, {1.0f + 0.75f * BGC_FP32_EPSYLON, 1.0f},
{1.0f - 0.75f * BGC_EPSYLON_FP32, 1.0f}, {1.0f - 0.75f * BGC_FP32_EPSYLON, 1.0f},
{-1.0f, -1.0f + 0.75f * BGC_EPSYLON_FP32}, {-1.0f, -1.0f + 0.75f * BGC_FP32_EPSYLON},
{-1.0f, -1.0f - 0.75f * BGC_EPSYLON_FP32}, {-1.0f, -1.0f - 0.75f * BGC_FP32_EPSYLON},
{-1.0f + 0.75f * BGC_EPSYLON_FP32, -1.0f}, {-1.0f + 0.75f * BGC_FP32_EPSYLON, -1.0f},
{-1.0f - 0.75f * BGC_EPSYLON_FP32, -1.0f}, {-1.0f - 0.75f * BGC_FP32_EPSYLON, -1.0f},
{100.0f, 100.0f * (1.0f + 0.75f * BGC_EPSYLON_FP32)}, {100.0f, 100.0f * (1.0f + 0.75f * BGC_FP32_EPSYLON)},
{100.0f, 100.0f * (1.0f - 0.75f * BGC_EPSYLON_FP32)}, {100.0f, 100.0f * (1.0f - 0.75f * BGC_FP32_EPSYLON)},
{-100.0f, -100.0f * (1.0f + 0.75f * BGC_EPSYLON_FP32)}, {-100.0f, -100.0f * (1.0f + 0.75f * BGC_FP32_EPSYLON)},
{-100.0f, -100.0f * (1.0f - 0.75f * BGC_EPSYLON_FP32)} {-100.0f, -100.0f * (1.0f - 0.75f * BGC_FP32_EPSYLON)}
}; };
static const TestNumberPairFP32 _TEST_FP32_DATA_DIFFERENT[] = { static const TestNumberPairFP32 _TEST_FP32_DATA_DIFFERENT[] = {
@ -35,31 +35,31 @@ static const TestNumberPairFP32 _TEST_FP32_DATA_DIFFERENT[] = {
{1.0f, 0.999f}, {1.0f, 0.999f},
{-1.0f, -0.999f}, {-1.0f, -0.999f},
{-0.6f * BGC_EPSYLON_FP32, 0.6f * BGC_EPSYLON_FP32}, {-0.6f * BGC_FP32_EPSYLON, 0.6f * BGC_FP32_EPSYLON},
{1.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32}, {1.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON},
{1.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32}, {1.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON},
{1.0f + 1.25f * BGC_EPSYLON_FP32, 1.0f}, {1.0f + 1.25f * BGC_FP32_EPSYLON, 1.0f},
{1.0f - 1.25f * BGC_EPSYLON_FP32, 1.0f}, {1.0f - 1.25f * BGC_FP32_EPSYLON, 1.0f},
{-1.0f, -1.0f + 1.25f * BGC_EPSYLON_FP32}, {-1.0f, -1.0f + 1.25f * BGC_FP32_EPSYLON},
{-1.0f, -1.0f - 1.25f * BGC_EPSYLON_FP32}, {-1.0f, -1.0f - 1.25f * BGC_FP32_EPSYLON},
{-1.0f + 1.25f * BGC_EPSYLON_FP32, -1.0f}, {-1.0f + 1.25f * BGC_FP32_EPSYLON, -1.0f},
{-1.0f - 1.25f * BGC_EPSYLON_FP32, -1.0f}, {-1.0f - 1.25f * BGC_FP32_EPSYLON, -1.0f},
{100.0f, 100.0f * (1.0f + 1.25f * BGC_EPSYLON_FP32)}, {100.0f, 100.0f * (1.0f + 1.25f * BGC_FP32_EPSYLON)},
{100.0f, 100.0f * (1.0f - 1.25f * BGC_EPSYLON_FP32)}, {100.0f, 100.0f * (1.0f - 1.25f * BGC_FP32_EPSYLON)},
{-100.0f, -100.0f * (1.0f + 1.25f * BGC_EPSYLON_FP32)}, {-100.0f, -100.0f * (1.0f + 1.25f * BGC_FP32_EPSYLON)},
{-100.0f, -100.0f * (1.0f - 1.25f * BGC_EPSYLON_FP32)} {-100.0f, -100.0f * (1.0f - 1.25f * BGC_FP32_EPSYLON)}
}; };
void test_are_close_fp32() void test_are_close_fp32()
{ {
print_testing_name("bgc_are_close_fp32"); print_testing_name("bgc_fp32_are_close");
// Testing close pairs of values: // Testing close pairs of values:
for (int i = 0; i < _TEST_FP32_CLOSE_NUMBERS_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_CLOSE_NUMBERS_AMOUNT; i++) {
if (!bgc_are_close_fp32(_TEST_FP32_DATA_CLOSE[i].number1, _TEST_FP32_DATA_CLOSE[i].number2)) { if (!bgc_fp32_are_close(_TEST_FP32_DATA_CLOSE[i].number1, _TEST_FP32_DATA_CLOSE[i].number2)) {
print_testing_error("A pair of close numbers was not recognized"); print_testing_error("A pair of close numbers was not recognized");
return; return;
} }
@ -67,7 +67,7 @@ void test_are_close_fp32()
// Testing different pairs of values: // Testing different pairs of values:
for (int i = 0; i < _TEST_FP32_DIFFERENT_NUMBERS_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_DIFFERENT_NUMBERS_AMOUNT; i++) {
if (bgc_are_close_fp32(_TEST_FP32_DATA_DIFFERENT[i].number1, _TEST_FP32_DATA_DIFFERENT[i].number2)) { if (bgc_fp32_are_close(_TEST_FP32_DATA_DIFFERENT[i].number1, _TEST_FP32_DATA_DIFFERENT[i].number2)) {
print_testing_error("A pair of close numbers was not recognized"); print_testing_error("A pair of close numbers was not recognized");
return; return;
} }
@ -86,22 +86,22 @@ static const TestNumberPairFP64 _TEST_FP64_DATA_CLOSE[] = {
{1.0, 1.0}, {1.0, 1.0},
{-1.0, -1.0}, {-1.0, -1.0},
{-0.4 * BGC_EPSYLON_FP64, 0.4 * BGC_EPSYLON_FP64}, {-0.4 * BGC_FP64_EPSYLON, 0.4 * BGC_FP64_EPSYLON},
{1.0, 1.0 + 0.75 * BGC_EPSYLON_FP64}, {1.0, 1.0 + 0.75 * BGC_FP64_EPSYLON},
{1.0, 1.0 - 0.75 * BGC_EPSYLON_FP64}, {1.0, 1.0 - 0.75 * BGC_FP64_EPSYLON},
{1.0 + 0.75 * BGC_EPSYLON_FP64, 1.0}, {1.0 + 0.75 * BGC_FP64_EPSYLON, 1.0},
{1.0 - 0.75 * BGC_EPSYLON_FP64, 1.0}, {1.0 - 0.75 * BGC_FP64_EPSYLON, 1.0},
{-1.0, -1.0 + 0.75 * BGC_EPSYLON_FP64}, {-1.0, -1.0 + 0.75 * BGC_FP64_EPSYLON},
{-1.0, -1.0 - 0.75 * BGC_EPSYLON_FP64}, {-1.0, -1.0 - 0.75 * BGC_FP64_EPSYLON},
{-1.0 + 0.75 * BGC_EPSYLON_FP64, -1.0}, {-1.0 + 0.75 * BGC_FP64_EPSYLON, -1.0},
{-1.0 - 0.75 * BGC_EPSYLON_FP64, -1.0}, {-1.0 - 0.75 * BGC_FP64_EPSYLON, -1.0},
{100.0, 100.0 * (1.0 + 0.75 * BGC_EPSYLON_FP64)}, {100.0, 100.0 * (1.0 + 0.75 * BGC_FP64_EPSYLON)},
{100.0, 100.0 * (1.0 - 0.75 * BGC_EPSYLON_FP64)}, {100.0, 100.0 * (1.0 - 0.75 * BGC_FP64_EPSYLON)},
{-100.0, -100.0 * (1.0 + 0.75 * BGC_EPSYLON_FP64)}, {-100.0, -100.0 * (1.0 + 0.75 * BGC_FP64_EPSYLON)},
{-100.0, -100.0 * (1.0 - 0.75 * BGC_EPSYLON_FP64)} {-100.0, -100.0 * (1.0 - 0.75 * BGC_FP64_EPSYLON)}
}; };
static const TestNumberPairFP64 _TEST_FP64_DATA_DIFFERENT[] = { static const TestNumberPairFP64 _TEST_FP64_DATA_DIFFERENT[] = {
@ -109,31 +109,31 @@ static const TestNumberPairFP64 _TEST_FP64_DATA_DIFFERENT[] = {
{1.0, 0.999999}, {1.0, 0.999999},
{-1.0, -0.999999}, {-1.0, -0.999999},
{-0.6 * BGC_EPSYLON_FP64, 0.6 * BGC_EPSYLON_FP64}, {-0.6 * BGC_FP64_EPSYLON, 0.6 * BGC_FP64_EPSYLON},
{1.0, 1.0 + 1.25 * BGC_EPSYLON_FP64}, {1.0, 1.0 + 1.25 * BGC_FP64_EPSYLON},
{1.0, 1.0 - 1.25 * BGC_EPSYLON_FP64}, {1.0, 1.0 - 1.25 * BGC_FP64_EPSYLON},
{1.0 + 1.25 * BGC_EPSYLON_FP64, 1.0}, {1.0 + 1.25 * BGC_FP64_EPSYLON, 1.0},
{1.0 - 1.25 * BGC_EPSYLON_FP64, 1.0}, {1.0 - 1.25 * BGC_FP64_EPSYLON, 1.0},
{-1.0, -1.0 + 1.25 * BGC_EPSYLON_FP64}, {-1.0, -1.0 + 1.25 * BGC_FP64_EPSYLON},
{-1.0, -1.0 - 1.25 * BGC_EPSYLON_FP64}, {-1.0, -1.0 - 1.25 * BGC_FP64_EPSYLON},
{-1.0 + 1.25 * BGC_EPSYLON_FP64, -1.0}, {-1.0 + 1.25 * BGC_FP64_EPSYLON, -1.0},
{-1.0 - 1.25 * BGC_EPSYLON_FP64, -1.0}, {-1.0 - 1.25 * BGC_FP64_EPSYLON, -1.0},
{100.0, 100.0 * (1.0 + 1.25 * BGC_EPSYLON_FP64)}, {100.0, 100.0 * (1.0 + 1.25 * BGC_FP64_EPSYLON)},
{100.0, 100.0 * (1.0 - 1.25 * BGC_EPSYLON_FP64)}, {100.0, 100.0 * (1.0 - 1.25 * BGC_FP64_EPSYLON)},
{-100.0, -100.0 * (1.0 + 1.25 * BGC_EPSYLON_FP64)}, {-100.0, -100.0 * (1.0 + 1.25 * BGC_FP64_EPSYLON)},
{-100.0, -100.0 * (1.0 - 1.25 * BGC_EPSYLON_FP64)} {-100.0, -100.0 * (1.0 - 1.25 * BGC_FP64_EPSYLON)}
}; };
void test_are_close_fp64() void test_are_close_fp64()
{ {
print_testing_name("bgc_are_close_fp64"); print_testing_name("bgc_fp64_are_close");
// Testing close pairs of values: // Testing close pairs of values:
for (int i = 0; i < _TEST_FP64_CLOSE_NUMBERS_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_CLOSE_NUMBERS_AMOUNT; i++) {
if (!bgc_are_close_fp64(_TEST_FP64_DATA_CLOSE[i].number1, _TEST_FP64_DATA_CLOSE[i].number2)) { if (!bgc_fp64_are_close(_TEST_FP64_DATA_CLOSE[i].number1, _TEST_FP64_DATA_CLOSE[i].number2)) {
print_testing_error("A pair of close numbers was not recognized"); print_testing_error("A pair of close numbers was not recognized");
return; return;
} }
@ -141,7 +141,7 @@ void test_are_close_fp64()
// Testing different pairs of values: // Testing different pairs of values:
for (int i = 0; i < _TEST_FP64_DIFFERENT_NUMBERS_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_DIFFERENT_NUMBERS_AMOUNT; i++) {
if (bgc_are_close_fp64(_TEST_FP64_DATA_DIFFERENT[i].number1, _TEST_FP64_DATA_DIFFERENT[i].number2)) { if (bgc_fp64_are_close(_TEST_FP64_DATA_DIFFERENT[i].number1, _TEST_FP64_DATA_DIFFERENT[i].number2)) {
print_testing_error("A pair of different numbers was recognized as close numbers"); print_testing_error("A pair of different numbers was recognized as close numbers");
return; return;
} }

View file

@ -9,24 +9,24 @@ static const int _TEST_FP32_NONUNIT_NUMBERS_AMOUNT = 4;
static const float _TEST_FP32_UNIT_NUMBERS[] = { static const float _TEST_FP32_UNIT_NUMBERS[] = {
1.0f, 1.0f,
1.0f + 0.75f * BGC_EPSYLON_FP32, 1.0f + 0.75f * BGC_FP32_EPSYLON,
1.0f - 0.75f * BGC_EPSYLON_FP32 1.0f - 0.75f * BGC_FP32_EPSYLON
}; };
static const float _TEST_FP32_NONUNIT_NUMBERS[] = { static const float _TEST_FP32_NONUNIT_NUMBERS[] = {
0.0f, 0.0f,
-1.0f, -1.0f,
1.0f + 1.25f * BGC_EPSYLON_FP32, 1.0f + 1.25f * BGC_FP32_EPSYLON,
1.0f - 1.25f * BGC_EPSYLON_FP32 1.0f - 1.25f * BGC_FP32_EPSYLON
}; };
void test_is_unit_fp32() void test_is_unit_fp32()
{ {
print_testing_name("bgc_is_unit_fp32"); print_testing_name("bgc_fp32_is_unit");
// Testing unit values: // Testing unit values:
for (int i = 0; i < _TEST_FP32_UNIT_NUMBERS_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_UNIT_NUMBERS_AMOUNT; i++) {
if (!bgc_is_unit_fp32(_TEST_FP32_UNIT_NUMBERS[i])) { if (!bgc_fp32_is_unit(_TEST_FP32_UNIT_NUMBERS[i])) {
print_testing_error("A unit value was not recognized"); print_testing_error("A unit value was not recognized");
return; return;
} }
@ -34,7 +34,7 @@ void test_is_unit_fp32()
// Testing non-unit values: // Testing non-unit values:
for (int i = 0; i < _TEST_FP32_NONUNIT_NUMBERS_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_NONUNIT_NUMBERS_AMOUNT; i++) {
if (bgc_is_unit_fp32(_TEST_FP32_NONUNIT_NUMBERS[i])) { if (bgc_fp32_is_unit(_TEST_FP32_NONUNIT_NUMBERS[i])) {
print_testing_error("A non-unit value was recognized as a unit value"); print_testing_error("A non-unit value was recognized as a unit value");
return; return;
} }
@ -50,24 +50,24 @@ static const int _TEST_FP64_NONUNIT_NUMBERS_AMOUNT = 4;
static const double _TEST_FP64_UNIT_NUMBERS[] = { static const double _TEST_FP64_UNIT_NUMBERS[] = {
1.0, 1.0,
1.0 + 0.75 * BGC_EPSYLON_FP64, 1.0 + 0.75 * BGC_FP64_EPSYLON,
1.0 - 0.75 * BGC_EPSYLON_FP64 1.0 - 0.75 * BGC_FP64_EPSYLON
}; };
static const double _TEST_FP64_NONUNIT_NUMBERS[] = { static const double _TEST_FP64_NONUNIT_NUMBERS[] = {
0.0, 0.0,
-1.0, -1.0,
1.0 + 1.25 * BGC_EPSYLON_FP64, 1.0 + 1.25 * BGC_FP64_EPSYLON,
1.0 - 1.25 * BGC_EPSYLON_FP64 1.0 - 1.25 * BGC_FP64_EPSYLON
}; };
void test_is_unit_fp64() void test_is_unit_fp64()
{ {
print_testing_name("bgc_is_unit_fp64"); print_testing_name("bgc_fp64_is_unit");
// Testing unit values: // Testing unit values:
for (int i = 0; i < _TEST_FP64_UNIT_NUMBERS_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_UNIT_NUMBERS_AMOUNT; i++) {
if (!bgc_is_unit_fp64(_TEST_FP64_UNIT_NUMBERS[i])) { if (!bgc_fp64_is_unit(_TEST_FP64_UNIT_NUMBERS[i])) {
print_testing_error("A unit value was not recognized"); print_testing_error("A unit value was not recognized");
return; return;
} }
@ -75,7 +75,7 @@ void test_is_unit_fp64()
// Testing non-unit values: // Testing non-unit values:
for (int i = 0; i < _TEST_FP64_NONUNIT_NUMBERS_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_NONUNIT_NUMBERS_AMOUNT; i++) {
if (bgc_is_unit_fp64(_TEST_FP64_NONUNIT_NUMBERS[i])) { if (bgc_fp64_is_unit(_TEST_FP64_NONUNIT_NUMBERS[i])) {
print_testing_error("A non-unit value was recognized as a unit value"); print_testing_error("A non-unit value was recognized as a unit value");
return; return;
} }
@ -91,24 +91,24 @@ static const int _TEST_FP32_DATA_SQUARE_NONUNIT_AMOUNT = 4;
static const float _TEST_FP32_DATA_SQUARE_UNIT[] = { static const float _TEST_FP32_DATA_SQUARE_UNIT[] = {
1.0f, 1.0f,
1.0f + 1.75f * BGC_EPSYLON_FP32, 1.0f + 1.75f * BGC_FP32_EPSYLON,
1.0f - 1.75f * BGC_EPSYLON_FP32 1.0f - 1.75f * BGC_FP32_EPSYLON
}; };
static const float _TEST_FP32_DATA_SQUARE_NONUNIT[] = { static const float _TEST_FP32_DATA_SQUARE_NONUNIT[] = {
0.0f, 0.0f,
-1.0f, -1.0f,
1.0f + 2.25f * BGC_EPSYLON_FP32, 1.0f + 2.25f * BGC_FP32_EPSYLON,
1.0f - 2.25f * BGC_EPSYLON_FP32 1.0f - 2.25f * BGC_FP32_EPSYLON
}; };
void test_is_sqare_unit_fp32() void test_is_square_unit_fp32()
{ {
print_testing_name("bgc_is_sqare_unit_fp32"); print_testing_name("bgc_fp32_is_square_unit");
// Testing unit values: // Testing unit values:
for (int i = 0; i < _TEST_FP32_DATA_SQUARE_UNIT_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_DATA_SQUARE_UNIT_AMOUNT; i++) {
if (!bgc_is_sqare_unit_fp32(_TEST_FP32_DATA_SQUARE_UNIT[i])) { if (!bgc_fp32_is_square_unit(_TEST_FP32_DATA_SQUARE_UNIT[i])) {
print_testing_error("A square unit value was not recognized"); print_testing_error("A square unit value was not recognized");
return; return;
} }
@ -116,7 +116,7 @@ void test_is_sqare_unit_fp32()
// Testing non-unit values: // Testing non-unit values:
for (int i = 0; i < _TEST_FP32_DATA_SQUARE_NONUNIT_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_DATA_SQUARE_NONUNIT_AMOUNT; i++) {
if (bgc_is_sqare_unit_fp32(_TEST_FP32_DATA_SQUARE_NONUNIT[i])) { if (bgc_fp32_is_square_unit(_TEST_FP32_DATA_SQUARE_NONUNIT[i])) {
print_testing_error("A non-unit value was recognized as a square unit value"); print_testing_error("A non-unit value was recognized as a square unit value");
return; return;
} }
@ -132,24 +132,24 @@ static const int _TEST_FP64_DATA_SQUARE_NONUNIT_AMOUNT = 4;
static const double _TEST_FP64_DATA_SQUARE_UNIT[] = { static const double _TEST_FP64_DATA_SQUARE_UNIT[] = {
1.0, 1.0,
1.0 + 1.75 * BGC_EPSYLON_FP64, 1.0 + 1.75 * BGC_FP64_EPSYLON,
1.0 - 1.75 * BGC_EPSYLON_FP64 1.0 - 1.75 * BGC_FP64_EPSYLON
}; };
static const double _TEST_FP64_DATA_SQUARE_NONUNIT[] = { static const double _TEST_FP64_DATA_SQUARE_NONUNIT[] = {
0.0, 0.0,
-1.0, -1.0,
1.0 + 2.25 * BGC_EPSYLON_FP64, 1.0 + 2.25 * BGC_FP64_EPSYLON,
1.0 - 2.25 * BGC_EPSYLON_FP64 1.0 - 2.25 * BGC_FP64_EPSYLON
}; };
void test_is_sqare_unit_fp64() void test_is_square_unit_fp64()
{ {
print_testing_name("bgc_is_sqare_unit_fp64"); print_testing_name("bgc_fp64_is_square_unit");
// Testing unit values: // Testing unit values:
for (int i = 0; i < _TEST_FP64_DATA_SQUARE_UNIT_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_DATA_SQUARE_UNIT_AMOUNT; i++) {
if (!bgc_is_sqare_unit_fp64(_TEST_FP64_DATA_SQUARE_UNIT[i])) { if (!bgc_fp64_is_square_unit(_TEST_FP64_DATA_SQUARE_UNIT[i])) {
print_testing_error("A square unit value was not recognized"); print_testing_error("A square unit value was not recognized");
return; return;
} }
@ -157,7 +157,7 @@ void test_is_sqare_unit_fp64()
// Testing non-unit values: // Testing non-unit values:
for (int i = 0; i < _TEST_FP64_DATA_SQUARE_NONUNIT_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_DATA_SQUARE_NONUNIT_AMOUNT; i++) {
if (bgc_is_sqare_unit_fp64(_TEST_FP64_DATA_SQUARE_NONUNIT[i])) { if (bgc_fp64_is_square_unit(_TEST_FP64_DATA_SQUARE_NONUNIT[i])) {
print_testing_error("A non-unit value was recognized as a square unit value"); print_testing_error("A non-unit value was recognized as a square unit value");
return; return;
} }
@ -171,6 +171,6 @@ void test_is_unit()
test_is_unit_fp32(); test_is_unit_fp32();
test_is_unit_fp64(); test_is_unit_fp64();
test_is_sqare_unit_fp32(); test_is_square_unit_fp32();
test_is_sqare_unit_fp64(); test_is_square_unit_fp64();
} }

View file

@ -5,9 +5,9 @@ void test_is_unit_fp32();
void test_is_unit_fp64(); void test_is_unit_fp64();
void test_is_sqare_unit_fp32(); void test_is_square_unit_fp32();
void test_is_sqare_unit_fp64(); void test_is_square_unit_fp64();
void test_is_unit(); void test_is_unit();

View file

@ -9,24 +9,24 @@ static const int _TEST_FP32_NONZERO_NUMBERS_AMOUNT = 4;
static const float _TEST_FP32_ZERO_NUMBERS[] = { static const float _TEST_FP32_ZERO_NUMBERS[] = {
0.0f, 0.0f,
0.75f * BGC_EPSYLON_FP32, 0.75f * BGC_FP32_EPSYLON,
-0.75f * BGC_EPSYLON_FP32 -0.75f * BGC_FP32_EPSYLON
}; };
static const float _TEST_FP32_NONZERO_NUMBERS[] = { static const float _TEST_FP32_NONZERO_NUMBERS[] = {
1.0f, 1.0f,
-1.0f, -1.0f,
1.25f * BGC_EPSYLON_FP32, 1.25f * BGC_FP32_EPSYLON,
-1.25f * BGC_EPSYLON_FP32 -1.25f * BGC_FP32_EPSYLON
}; };
void test_is_zero_fp32() void test_is_zero_fp32()
{ {
print_testing_name("bgc_is_zero_fp32"); print_testing_name("bgc_fp32_is_zero");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP32_ZERO_NUMBERS_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_ZERO_NUMBERS_AMOUNT; i++) {
if (!bgc_is_zero_fp32(_TEST_FP32_ZERO_NUMBERS[i])) { if (!bgc_fp32_is_zero(_TEST_FP32_ZERO_NUMBERS[i])) {
print_testing_error("A zero value was not recognized"); print_testing_error("A zero value was not recognized");
return; return;
} }
@ -34,7 +34,7 @@ void test_is_zero_fp32()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONZERO_NUMBERS_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_NONZERO_NUMBERS_AMOUNT; i++) {
if (bgc_is_zero_fp32(_TEST_FP32_NONZERO_NUMBERS[i])) { if (bgc_fp32_is_zero(_TEST_FP32_NONZERO_NUMBERS[i])) {
print_testing_error("A non-zero value was recognized as a zero value"); print_testing_error("A non-zero value was recognized as a zero value");
return; return;
} }
@ -50,24 +50,24 @@ static const int _TEST_FP64_NONZERO_NUMBERS_AMOUNT = 4;
static const double _TEST_FP64_ZERO_NUMBERS[] = { static const double _TEST_FP64_ZERO_NUMBERS[] = {
0.0, 0.0,
0.75 * BGC_EPSYLON_FP64, 0.75 * BGC_FP64_EPSYLON,
-0.75 * BGC_EPSYLON_FP64 -0.75 * BGC_FP64_EPSYLON
}; };
static const double _TEST_FP64_NONZERO_NUMBERS[] = { static const double _TEST_FP64_NONZERO_NUMBERS[] = {
1.0, 1.0,
-1.0, -1.0,
1.25 * BGC_EPSYLON_FP64, 1.25 * BGC_FP64_EPSYLON,
-1.25 * BGC_EPSYLON_FP64 -1.25 * BGC_FP64_EPSYLON
}; };
void test_is_zero_fp64() void test_is_zero_fp64()
{ {
print_testing_name("bgc_is_zero_fp64"); print_testing_name("bgc_fp64_is_zero");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP64_ZERO_NUMBERS_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_ZERO_NUMBERS_AMOUNT; i++) {
if (!bgc_is_zero_fp64(_TEST_FP64_ZERO_NUMBERS[i])) { if (!bgc_fp64_is_zero(_TEST_FP64_ZERO_NUMBERS[i])) {
print_testing_error("A zero value was not recognized"); print_testing_error("A zero value was not recognized");
return; return;
} }
@ -75,7 +75,7 @@ void test_is_zero_fp64()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONZERO_NUMBERS_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_NONZERO_NUMBERS_AMOUNT; i++) {
if (bgc_is_zero_fp64(_TEST_FP64_NONZERO_NUMBERS[i])) { if (bgc_fp64_is_zero(_TEST_FP64_NONZERO_NUMBERS[i])) {
print_testing_error("A non-zero value was recognized as a zero value"); print_testing_error("A non-zero value was recognized as a zero value");
return; return;
} }

View file

@ -22,7 +22,7 @@ void test_vector2()
const int TEST_FP32_VECTOR2_AMOUNT_1 = 5; const int TEST_FP32_VECTOR2_AMOUNT_1 = 5;
const BgcVector2FP32 TEST_FP32_VECTOR2_COMMON_1[] = { const BGC_FP32_Vector2 TEST_FP32_VECTOR2_COMMON_1[] = {
{ 3.0f, 4.0f }, { 3.0f, 4.0f },
{ -3.0f, -4.0f }, { -3.0f, -4.0f },
{ 10000.0f, -20000.0f }, { 10000.0f, -20000.0f },
@ -30,7 +30,7 @@ const BgcVector2FP32 TEST_FP32_VECTOR2_COMMON_1[] = {
{ -123.5f, 3.7283f } { -123.5f, 3.7283f }
}; };
const BgcVector2FP32 TEST_FP32_VECTOR2_COMMON_2[] = { const BGC_FP32_Vector2 TEST_FP32_VECTOR2_COMMON_2[] = {
{ -3.0f, -4.0f }, { -3.0f, -4.0f },
{ -3.0f, -4.0f }, { -3.0f, -4.0f },
{ 0.002f, -0.05f }, { 0.002f, -0.05f },
@ -49,7 +49,7 @@ int test_vector2_fp32_square_modulus()
float square_modulus; float square_modulus;
for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) { for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) {
square_modulus = bgc_vector2_get_square_modulus_fp32(&TEST_FP32_VECTOR2_COMMON_1[i]); square_modulus = bgc_fp32_vector2_get_square_modulus(&TEST_FP32_VECTOR2_COMMON_1[i]);
if (!test_are_equal_fp32(square_modulus, FP32_VECTOR2_SQUARE_MODULUS_1[i])) { if (!test_are_equal_fp32(square_modulus, FP32_VECTOR2_SQUARE_MODULUS_1[i])) {
print_testing_failed(); print_testing_failed();
@ -72,7 +72,7 @@ int test_vector2_fp32_modulus()
float square_modulus; float square_modulus;
for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) { for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) {
square_modulus = bgc_vector2_get_modulus_fp32(&TEST_FP32_VECTOR2_COMMON_1[i]); square_modulus = bgc_fp32_vector2_get_modulus(&TEST_FP32_VECTOR2_COMMON_1[i]);
if (!test_are_equal_fp32(square_modulus, FP32_VECTOR2_MODULUS_1[i])) { if (!test_are_equal_fp32(square_modulus, FP32_VECTOR2_MODULUS_1[i])) {
print_testing_failed(); print_testing_failed();
@ -86,7 +86,7 @@ int test_vector2_fp32_modulus()
// ===================== Add ==================== // // ===================== Add ==================== //
const BgcVector2FP32 TEST_FP32_VECTOR2_COMMON_1_2_SUM[] = { const BGC_FP32_Vector2 TEST_FP32_VECTOR2_COMMON_1_2_SUM[] = {
{ 0.0f, 0.0f }, { 0.0f, 0.0f },
{ -6.0f, -8.0f }, { -6.0f, -8.0f },
{ 10000.002f, -20000.05f }, { 10000.002f, -20000.05f },
@ -98,10 +98,10 @@ int test_vector2_add_fp32()
{ {
print_testing_name("vector2_fp32_t add"); print_testing_name("vector2_fp32_t add");
BgcVector2FP32 vector; BGC_FP32_Vector2 vector;
for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) { for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) {
bgc_vector2_add_fp32(&TEST_FP32_VECTOR2_COMMON_1[i], &TEST_FP32_VECTOR2_COMMON_2[i], &vector); bgc_fp32_vector2_add(&TEST_FP32_VECTOR2_COMMON_1[i], &TEST_FP32_VECTOR2_COMMON_2[i], &vector);
if (!test_are_equal_fp32(vector.x1, TEST_FP32_VECTOR2_COMMON_1_2_SUM[i].x1) || if (!test_are_equal_fp32(vector.x1, TEST_FP32_VECTOR2_COMMON_1_2_SUM[i].x1) ||
!test_are_equal_fp32(vector.x2, TEST_FP32_VECTOR2_COMMON_1_2_SUM[i].x2)) { !test_are_equal_fp32(vector.x2, TEST_FP32_VECTOR2_COMMON_1_2_SUM[i].x2)) {
@ -116,7 +116,7 @@ int test_vector2_add_fp32()
// ================== Subtract ================== // // ================== Subtract ================== //
const BgcVector2FP32 TEST_FP32_VECTOR2_COMMON_1_2_DIFF[] = { const BGC_FP32_Vector2 TEST_FP32_VECTOR2_COMMON_1_2_DIFF[] = {
{ 6.0f, 8.0f }, { 6.0f, 8.0f },
{ 0.0f, 0.0f }, { 0.0f, 0.0f },
{ 9999.998f, -19999.95f }, { 9999.998f, -19999.95f },
@ -128,10 +128,10 @@ int test_vector2_subtract_fp32()
{ {
print_testing_name("vector2_fp32_t subtract"); print_testing_name("vector2_fp32_t subtract");
BgcVector2FP32 vector; BGC_FP32_Vector2 vector;
for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) { for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) {
bgc_vector2_subtract_fp32(&TEST_FP32_VECTOR2_COMMON_1[i], &TEST_FP32_VECTOR2_COMMON_2[i], &vector); bgc_fp32_vector2_subtract(&TEST_FP32_VECTOR2_COMMON_1[i], &TEST_FP32_VECTOR2_COMMON_2[i], &vector);
if (!test_are_equal_fp32(vector.x1, TEST_FP32_VECTOR2_COMMON_1_2_DIFF[i].x1) || if (!test_are_equal_fp32(vector.x1, TEST_FP32_VECTOR2_COMMON_1_2_DIFF[i].x1) ||
!test_are_equal_fp32(vector.x2, TEST_FP32_VECTOR2_COMMON_1_2_DIFF[i].x2)) { !test_are_equal_fp32(vector.x2, TEST_FP32_VECTOR2_COMMON_1_2_DIFF[i].x2)) {

View file

@ -7,7 +7,7 @@
// ==================== FP32 ==================== // // ==================== FP32 ==================== //
static const int _TEST_FP32_VECTOR2_AMOUNT = 4; static const int _TEST_FP32_VECTOR2_AMOUNT = 4;
static const BgcVector2FP32 _TEST_FP32_VECTOR2_LIST[] = { static const BGC_FP32_Vector2 _TEST_FP32_VECTOR2_LIST[] = {
{ 1.0f, 2.0f }, { 1.0f, 2.0f },
{ -2.0f, -1.0f }, { -2.0f, -1.0f },
{ 100.0f, -100.0f }, { 100.0f, -100.0f },
@ -16,13 +16,13 @@ static const BgcVector2FP32 _TEST_FP32_VECTOR2_LIST[] = {
void test_vector2_copy_fp32() void test_vector2_copy_fp32()
{ {
BgcVector2FP32 vector; BGC_FP32_Vector2 vector;
print_testing_name("bgc_vector2_copy_fp32"); print_testing_name("bgc_fp32_vector2_copy");
for (int i = 0; i < _TEST_FP32_VECTOR2_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_VECTOR2_AMOUNT; i++) {
bgc_vector2_copy_fp32(&_TEST_FP32_VECTOR2_LIST[i], &vector); bgc_fp32_vector2_copy(&_TEST_FP32_VECTOR2_LIST[i], &vector);
if (vector.x1 != _TEST_FP32_VECTOR2_LIST[i].x1 || vector.x2 != _TEST_FP32_VECTOR2_LIST[i].x2) { if (vector.x1 != _TEST_FP32_VECTOR2_LIST[i].x1 || vector.x2 != _TEST_FP32_VECTOR2_LIST[i].x2) {
print_testing_failed(); print_testing_failed();
@ -36,7 +36,7 @@ void test_vector2_copy_fp32()
// ==================== FP64 ==================== // // ==================== FP64 ==================== //
static const int _TEST_FP64_VECTOR2_AMOUNT = 4; static const int _TEST_FP64_VECTOR2_AMOUNT = 4;
static const BgcVector2FP64 _TEST_FP64_VECTOR2_LIST[] = { static const BGC_FP64_Vector2 _TEST_FP64_VECTOR2_LIST[] = {
{ 1.0, 2.0 }, { 1.0, 2.0 },
{ -2.0, -1.0 }, { -2.0, -1.0 },
{ 100.0, -100.0 }, { 100.0, -100.0 },
@ -45,13 +45,13 @@ static const BgcVector2FP64 _TEST_FP64_VECTOR2_LIST[] = {
void test_vector2_copy_fp64() void test_vector2_copy_fp64()
{ {
BgcVector2FP64 vector; BGC_FP64_Vector2 vector;
print_testing_name("bgc_vector2_copy_fp64"); print_testing_name("bgc_fp64_vector2_copy");
for (int i = 0; i < _TEST_FP64_VECTOR2_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_VECTOR2_AMOUNT; i++) {
bgc_vector2_copy_fp64(&_TEST_FP64_VECTOR2_LIST[i], &vector); bgc_fp64_vector2_copy(&_TEST_FP64_VECTOR2_LIST[i], &vector);
if (vector.x1 != _TEST_FP64_VECTOR2_LIST[i].x1 || vector.x2 != _TEST_FP64_VECTOR2_LIST[i].x2) { if (vector.x1 != _TEST_FP64_VECTOR2_LIST[i].x1 || vector.x2 != _TEST_FP64_VECTOR2_LIST[i].x2) {
print_testing_failed(); print_testing_failed();

View file

@ -7,32 +7,32 @@
static const int _TEST_FP32_UNIT_VECTOR2_AMOUNT = 6; static const int _TEST_FP32_UNIT_VECTOR2_AMOUNT = 6;
static const int _TEST_FP32_NONUNIT_VECTOR2_AMOUNT = 7; static const int _TEST_FP32_NONUNIT_VECTOR2_AMOUNT = 7;
static const BgcVector2FP32 _TEST_FP32_UNIT_VECTOR2_LIST[] = { static const BGC_FP32_Vector2 _TEST_FP32_UNIT_VECTOR2_LIST[] = {
{ 1.0f, 0.0f }, { 1.0f, 0.0f },
{ 0.0f, -1.0f }, { 0.0f, -1.0f },
{ 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f }, { 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f }, { 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32 }, { 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON },
{ 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32 } { 0.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON }
}; };
static const BgcVector2FP32 _TEST_FP32_NONUNIT_VECTOR2_LIST[] = { static const BGC_FP32_Vector2 _TEST_FP32_NONUNIT_VECTOR2_LIST[] = {
{ 0.0f, 0.0f }, { 0.0f, 0.0f },
{ 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f }, { 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f }, { 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32 }, { 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON },
{ 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32 }, { 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON },
{ 0.8f + 1.25f * BGC_EPSYLON_FP32, 0.6f + 1.25f * BGC_EPSYLON_FP32 }, { 0.8f + 1.25f * BGC_FP32_EPSYLON, 0.6f + 1.25f * BGC_FP32_EPSYLON },
{ 0.6f - 1.25f * BGC_EPSYLON_FP32, 0.8f - 1.25f * BGC_EPSYLON_FP32 } { 0.6f - 1.25f * BGC_FP32_EPSYLON, 0.8f - 1.25f * BGC_FP32_EPSYLON }
}; };
void test_vector2_is_unit_fp32() void test_vector2_is_unit_fp32()
{ {
print_testing_name("bgc_vector2_is_unit_fp32"); print_testing_name("bgc_fp32_vector2_is_unit");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP32_UNIT_VECTOR2_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_UNIT_VECTOR2_AMOUNT; i++) {
if (!bgc_vector2_is_unit_fp32(&_TEST_FP32_UNIT_VECTOR2_LIST[i])) { if (!bgc_fp32_vector2_is_unit(&_TEST_FP32_UNIT_VECTOR2_LIST[i])) {
print_testing_error("A unit vector was not recognized"); print_testing_error("A unit vector was not recognized");
return; return;
} }
@ -40,7 +40,7 @@ void test_vector2_is_unit_fp32()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONUNIT_VECTOR2_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_NONUNIT_VECTOR2_AMOUNT; i++) {
if (bgc_vector2_is_unit_fp32(&_TEST_FP32_NONUNIT_VECTOR2_LIST[i])) { if (bgc_fp32_vector2_is_unit(&_TEST_FP32_NONUNIT_VECTOR2_LIST[i])) {
print_testing_error("A non-unit vector was recognized as a unit vector"); print_testing_error("A non-unit vector was recognized as a unit vector");
return; return;
} }
@ -54,32 +54,32 @@ void test_vector2_is_unit_fp32()
static const int _TEST_FP64_UNIT_VECTOR2_AMOUNT = 6; static const int _TEST_FP64_UNIT_VECTOR2_AMOUNT = 6;
static const int _TEST_FP64_NONUNIT_VECTOR2_AMOUNT = 7; static const int _TEST_FP64_NONUNIT_VECTOR2_AMOUNT = 7;
static const BgcVector2FP64 _TEST_FP64_UNIT_VECTOR2_LIST[] = { static const BGC_FP64_Vector2 _TEST_FP64_UNIT_VECTOR2_LIST[] = {
{ -1.0, 0.0 }, { -1.0, 0.0 },
{ 0.0, 1.0 }, { 0.0, 1.0 },
{ 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0 }, { 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0 }, { 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64 }, { 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON },
{ 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64 } { 0.0, 1.0 - 0.75 * BGC_FP64_EPSYLON }
}; };
static const BgcVector2FP64 _TEST_FP64_NONUNIT_VECTOR2_LIST[] = { static const BGC_FP64_Vector2 _TEST_FP64_NONUNIT_VECTOR2_LIST[] = {
{ 0.0, 0.0 }, { 0.0, 0.0 },
{ 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0 }, { 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0 }, { 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64 }, { 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON },
{ 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64 }, { 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON },
{ 0.6 + 1.25 * BGC_EPSYLON_FP64, 0.8 + 1.25 * BGC_EPSYLON_FP64 }, { 0.6 + 1.25 * BGC_FP64_EPSYLON, 0.8 + 1.25 * BGC_FP64_EPSYLON },
{ 0.8 - 1.25 * BGC_EPSYLON_FP64, 0.6 - 1.25 * BGC_EPSYLON_FP64 } { 0.8 - 1.25 * BGC_FP64_EPSYLON, 0.6 - 1.25 * BGC_FP64_EPSYLON }
}; };
void test_vector2_is_unit_fp64() void test_vector2_is_unit_fp64()
{ {
print_testing_name("bgc_vector2_is_unit_fp64"); print_testing_name("bgc_fp64_vector2_is_unit");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP64_UNIT_VECTOR2_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_UNIT_VECTOR2_AMOUNT; i++) {
if (!bgc_vector2_is_unit_fp64(&_TEST_FP64_UNIT_VECTOR2_LIST[i])) { if (!bgc_fp64_vector2_is_unit(&_TEST_FP64_UNIT_VECTOR2_LIST[i])) {
print_testing_error("A unit vector was not recognized"); print_testing_error("A unit vector was not recognized");
return; return;
} }
@ -87,7 +87,7 @@ void test_vector2_is_unit_fp64()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONUNIT_VECTOR2_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_NONUNIT_VECTOR2_AMOUNT; i++) {
if (bgc_vector2_is_unit_fp64(&_TEST_FP64_NONUNIT_VECTOR2_LIST[i])) { if (bgc_fp64_vector2_is_unit(&_TEST_FP64_NONUNIT_VECTOR2_LIST[i])) {
print_testing_error("A non-unit vector was recognized as a unit vector"); print_testing_error("A non-unit vector was recognized as a unit vector");
return; return;
} }

View file

@ -7,31 +7,31 @@
static const int _TEST_FP32_ZERO_VECTOR2_AMOUNT = 5; static const int _TEST_FP32_ZERO_VECTOR2_AMOUNT = 5;
static const int _TEST_FP32_NONZERO_VECTOR2_AMOUNT = 7; static const int _TEST_FP32_NONZERO_VECTOR2_AMOUNT = 7;
static const BgcVector2FP32 _TEST_FP32_ZERO_VECTOR2_LIST[] = { static const BGC_FP32_Vector2 _TEST_FP32_ZERO_VECTOR2_LIST[] = {
{ 0.0f, 0.0f }, { 0.0f, 0.0f },
{ 0.75f * BGC_EPSYLON_FP32, 0.0f }, { 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ -0.75f * BGC_EPSYLON_FP32, 0.0f }, { -0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.75f * BGC_EPSYLON_FP32 }, { 0.0f, 0.75f * BGC_FP32_EPSYLON },
{ 0.0f, -0.75f * BGC_EPSYLON_FP32 } { 0.0f, -0.75f * BGC_FP32_EPSYLON }
}; };
static const BgcVector2FP32 _TEST_FP32_NONZERO_VECTOR2_LIST[] = { static const BGC_FP32_Vector2 _TEST_FP32_NONZERO_VECTOR2_LIST[] = {
{ 0.0f, 1.0f }, { 0.0f, 1.0f },
{ 1.25f * BGC_EPSYLON_FP32, 0.0f }, { 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ -1.25f * BGC_EPSYLON_FP32, 0.0f }, { -1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 1.25f * BGC_EPSYLON_FP32 }, { 0.0f, 1.25f * BGC_FP32_EPSYLON },
{ 0.0f, -1.25f * BGC_EPSYLON_FP32 }, { 0.0f, -1.25f * BGC_FP32_EPSYLON },
{ 1.25f * BGC_EPSYLON_FP32, 1.25f * BGC_EPSYLON_FP32 }, { 1.25f * BGC_FP32_EPSYLON, 1.25f * BGC_FP32_EPSYLON },
{ -1.25f * BGC_EPSYLON_FP32, -1.25f * BGC_EPSYLON_FP32 } { -1.25f * BGC_FP32_EPSYLON, -1.25f * BGC_FP32_EPSYLON }
}; };
void test_vector2_is_zero_fp32() void test_vector2_is_zero_fp32()
{ {
print_testing_name("bgc_vector2_is_zero_fp32"); print_testing_name("bgc_fp32_vector2_is_zero");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP32_ZERO_VECTOR2_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_ZERO_VECTOR2_AMOUNT; i++) {
if (!bgc_vector2_is_zero_fp32(&_TEST_FP32_ZERO_VECTOR2_LIST[i])) { if (!bgc_fp32_vector2_is_zero(&_TEST_FP32_ZERO_VECTOR2_LIST[i])) {
print_testing_error("A zero vector was not recongized"); print_testing_error("A zero vector was not recongized");
return; return;
} }
@ -39,7 +39,7 @@ void test_vector2_is_zero_fp32()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONZERO_VECTOR2_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_NONZERO_VECTOR2_AMOUNT; i++) {
if (bgc_vector2_is_zero_fp32(&_TEST_FP32_NONZERO_VECTOR2_LIST[i])) { if (bgc_fp32_vector2_is_zero(&_TEST_FP32_NONZERO_VECTOR2_LIST[i])) {
print_testing_error("A non-zero vector was recongized as a zero vector"); print_testing_error("A non-zero vector was recongized as a zero vector");
return; return;
} }
@ -53,31 +53,31 @@ void test_vector2_is_zero_fp32()
static const int _TEST_FP64_ZERO_VECTOR2_AMOUNT = 5; static const int _TEST_FP64_ZERO_VECTOR2_AMOUNT = 5;
static const int _TEST_FP64_NONZERO_VECTOR2_AMOUNT = 7; static const int _TEST_FP64_NONZERO_VECTOR2_AMOUNT = 7;
static const BgcVector2FP64 _TEST_FP64_ZERO_VECTOR2_LIST[] = { static const BGC_FP64_Vector2 _TEST_FP64_ZERO_VECTOR2_LIST[] = {
{ 0.0, 0.0 }, { 0.0, 0.0 },
{ 0.75 * BGC_EPSYLON_FP64, 0.0 }, { 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ -0.75 * BGC_EPSYLON_FP64, 0.0 }, { -0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.75 * BGC_EPSYLON_FP64 }, { 0.0, 0.75 * BGC_FP64_EPSYLON },
{ 0.0, -0.75 * BGC_EPSYLON_FP64 } { 0.0, -0.75 * BGC_FP64_EPSYLON }
}; };
static const BgcVector2FP64 _TEST_FP64_NONZERO_VECTOR2_LIST[] = { static const BGC_FP64_Vector2 _TEST_FP64_NONZERO_VECTOR2_LIST[] = {
{ 0.0, 1.0 }, { 0.0, 1.0 },
{ 1.25 * BGC_EPSYLON_FP64, 0.0 }, { 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ -1.25 * BGC_EPSYLON_FP64, 0.0 }, { -1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 1.25 * BGC_EPSYLON_FP64 }, { 0.0, 1.25 * BGC_FP64_EPSYLON },
{ 0.0, -1.25 * BGC_EPSYLON_FP64 }, { 0.0, -1.25 * BGC_FP64_EPSYLON },
{ 1.25 * BGC_EPSYLON_FP64, 1.25 * BGC_EPSYLON_FP64 }, { 1.25 * BGC_FP64_EPSYLON, 1.25 * BGC_FP64_EPSYLON },
{ -1.25 * BGC_EPSYLON_FP64, -1.25 * BGC_EPSYLON_FP64 } { -1.25 * BGC_FP64_EPSYLON, -1.25 * BGC_FP64_EPSYLON }
}; };
void test_vector2_is_zero_fp64() void test_vector2_is_zero_fp64()
{ {
print_testing_name("bgc_vector2_is_zero_fp64"); print_testing_name("bgc_fp64_vector2_is_zero");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP64_ZERO_VECTOR2_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_ZERO_VECTOR2_AMOUNT; i++) {
if (!bgc_vector2_is_zero_fp64(&_TEST_FP64_ZERO_VECTOR2_LIST[i])) { if (!bgc_fp64_vector2_is_zero(&_TEST_FP64_ZERO_VECTOR2_LIST[i])) {
print_testing_error("A zero vector was not recongized"); print_testing_error("A zero vector was not recongized");
return; return;
} }
@ -85,7 +85,7 @@ void test_vector2_is_zero_fp64()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONZERO_VECTOR2_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_NONZERO_VECTOR2_AMOUNT; i++) {
if (bgc_vector2_is_zero_fp64(&_TEST_FP64_NONZERO_VECTOR2_LIST[i])) { if (bgc_fp64_vector2_is_zero(&_TEST_FP64_NONZERO_VECTOR2_LIST[i])) {
print_testing_error("A non-zero vector was recongized as a zero vector"); print_testing_error("A non-zero vector was recongized as a zero vector");
return; return;
} }

View file

@ -6,7 +6,7 @@
static const int _TEST_FP32_VECTOR2_AMOUNT = 4; static const int _TEST_FP32_VECTOR2_AMOUNT = 4;
static const BgcVector2FP32 _TEST_FP32_VECTOR2_LIST[] = { static const BGC_FP32_Vector2 _TEST_FP32_VECTOR2_LIST[] = {
{ 4.0f, 3.0f }, { 4.0f, 3.0f },
{ -3.0f, -4.0f }, { -3.0f, -4.0f },
{ 100.0f, -100.0f }, { 100.0f, -100.0f },
@ -29,10 +29,10 @@ static const float _TEST_FP32_MODULUS_LIST[] = {
void test_vector2_square_modulus_fp32() void test_vector2_square_modulus_fp32()
{ {
print_testing_name("bgc_vector2_get_square_modulus_fp32"); print_testing_name("bgc_fp32_vector2_get_square_modulus");
for (int i = 0; i < _TEST_FP32_VECTOR2_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_VECTOR2_AMOUNT; i++) {
if (!bgc_are_close_fp32(bgc_vector2_get_square_modulus_fp32(&_TEST_FP32_VECTOR2_LIST[i]), _TEST_FP32_SQUARE_MODULUS_LIST[i])) { if (!bgc_fp32_are_close(bgc_fp32_vector2_get_square_modulus(&_TEST_FP32_VECTOR2_LIST[i]), _TEST_FP32_SQUARE_MODULUS_LIST[i])) {
print_testing_failed(); print_testing_failed();
return; return;
} }
@ -43,10 +43,10 @@ void test_vector2_square_modulus_fp32()
void test_vector2_modulus_fp32() void test_vector2_modulus_fp32()
{ {
print_testing_name("bgc_vector2_get_modulus_fp32"); print_testing_name("bgc_fp32_vector2_get_modulus");
for (int i = 0; i < _TEST_FP32_VECTOR2_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_VECTOR2_AMOUNT; i++) {
if (!bgc_are_close_fp32(bgc_vector2_get_modulus_fp32(&_TEST_FP32_VECTOR2_LIST[i]), _TEST_FP32_MODULUS_LIST[i])) { if (!bgc_fp32_are_close(bgc_fp32_vector2_get_modulus(&_TEST_FP32_VECTOR2_LIST[i]), _TEST_FP32_MODULUS_LIST[i])) {
print_testing_failed(); print_testing_failed();
return; return;
} }
@ -59,7 +59,7 @@ void test_vector2_modulus_fp32()
static const int _TEST_FP64_VECTOR2_AMOUNT = 4; static const int _TEST_FP64_VECTOR2_AMOUNT = 4;
static const BgcVector2FP64 _TEST_FP64_VECTOR2_LIST[] = { static const BGC_FP64_Vector2 _TEST_FP64_VECTOR2_LIST[] = {
{ 4.0, 3.0 }, { 4.0, 3.0 },
{ -3.0, -4.0 }, { -3.0, -4.0 },
{ 100.0, -100.0 }, { 100.0, -100.0 },
@ -82,10 +82,10 @@ static const double _TEST_FP64_MODULUS_LIST[] = {
void test_vector2_square_modulus_fp64() void test_vector2_square_modulus_fp64()
{ {
print_testing_name("bgc_vector2_get_square_modulus_fp64"); print_testing_name("bgc_fp64_vector2_get_square_modulus");
for (int i = 0; i < _TEST_FP64_VECTOR2_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_VECTOR2_AMOUNT; i++) {
if (!bgc_are_close_fp64(bgc_vector2_get_square_modulus_fp64(&_TEST_FP64_VECTOR2_LIST[i]), _TEST_FP64_SQUARE_MODULUS_LIST[i])) { if (!bgc_fp64_are_close(bgc_fp64_vector2_get_square_modulus(&_TEST_FP64_VECTOR2_LIST[i]), _TEST_FP64_SQUARE_MODULUS_LIST[i])) {
print_testing_failed(); print_testing_failed();
return; return;
} }
@ -96,10 +96,10 @@ void test_vector2_square_modulus_fp64()
void test_vector2_modulus_fp64() void test_vector2_modulus_fp64()
{ {
print_testing_name("bgc_vector2_get_modulus_fp64"); print_testing_name("bgc_fp64_vector2_get_modulus");
for (int i = 0; i < _TEST_FP64_VECTOR2_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_VECTOR2_AMOUNT; i++) {
if (!bgc_are_close_fp64(bgc_vector2_get_modulus_fp64(&_TEST_FP64_VECTOR2_LIST[i]), _TEST_FP64_MODULUS_LIST[i])) { if (!bgc_fp64_are_close(bgc_fp64_vector2_get_modulus(&_TEST_FP64_VECTOR2_LIST[i]), _TEST_FP64_MODULUS_LIST[i])) {
print_testing_failed(); print_testing_failed();
return; return;
} }

View file

@ -4,11 +4,11 @@
void test_vector2_reset_fp32() void test_vector2_reset_fp32()
{ {
BgcVector2FP32 vector; BGC_FP32_Vector2 vector;
print_testing_name("bgc_vector2_reset_fp32"); print_testing_name("bgc_fp32_vector2_reset");
bgc_vector2_reset_fp32(&vector); bgc_fp32_vector2_reset(&vector);
if (vector.x1 != 0.0f || vector.x2 != 0.0f) { if (vector.x1 != 0.0f || vector.x2 != 0.0f) {
print_testing_failed(); print_testing_failed();
@ -20,11 +20,11 @@ void test_vector2_reset_fp32()
void test_vector2_reset_fp64() void test_vector2_reset_fp64()
{ {
BgcVector2FP64 vector; BGC_FP64_Vector2 vector;
print_testing_name("bgc_vector2_reset_fp64"); print_testing_name("bgc_fp64_vector2_reset");
bgc_vector2_reset_fp64(&vector); bgc_fp64_vector2_reset(&vector);
if (vector.x1 != 0.0 || vector.x2 != 0.0) { if (vector.x1 != 0.0 || vector.x2 != 0.0) {
print_testing_failed(); print_testing_failed();

View file

@ -8,25 +8,25 @@
void test_vector2_set_values_fp32() void test_vector2_set_values_fp32()
{ {
BgcVector2FP32 vector; BGC_FP32_Vector2 vector;
print_testing_name("bgc_vector2_set_values_fp32"); print_testing_name("bgc_fp32_vector2_make");
bgc_vector2_set_values_fp32(1.0f, 2.0f, &vector); bgc_fp32_vector2_make(1.0f, 2.0f, &vector);
if (vector.x1 != 1.0f || vector.x2 != 2.0f) { if (vector.x1 != 1.0f || vector.x2 != 2.0f) {
print_testing_error("First step failed"); print_testing_error("First step failed");
return; return;
} }
bgc_vector2_set_values_fp32(-3.0f, -5.0f, &vector); bgc_fp32_vector2_make(-3.0f, -5.0f, &vector);
if (vector.x1 != -3.0f || vector.x2 != -5.0f) { if (vector.x1 != -3.0f || vector.x2 != -5.0f) {
print_testing_error("Second step failed"); print_testing_error("Second step failed");
return; return;
} }
bgc_vector2_set_values_fp32(-2.0f, 2.0f, &vector); bgc_fp32_vector2_make(-2.0f, 2.0f, &vector);
if (vector.x1 != -2.0f || vector.x2 != 2.0f) { if (vector.x1 != -2.0f || vector.x2 != 2.0f) {
print_testing_error("Third step failed"); print_testing_error("Third step failed");
@ -40,26 +40,26 @@ void test_vector2_set_values_fp32()
void test_vector2_set_values_fp64() void test_vector2_set_values_fp64()
{ {
BgcVector2FP64 vector; BGC_FP64_Vector2 vector;
print_testing_name("bgc_vector2_set_values_fp64"); print_testing_name("bgc_fp64_vector2_make");
bgc_vector2_set_values_fp64(1.0, 2.0, &vector); bgc_fp64_vector2_make(1.0, 2.0, &vector);
if (vector.x1 != 1.0 || vector.x2 != 2.0) { if (vector.x1 != 1.0 || vector.x2 != 2.0) {
print_testing_error("First step failed"); print_testing_error("First step failed");
return; return;
} }
bgc_vector2_set_values_fp64(-3.0, -5.0, &vector); bgc_fp64_vector2_make(-3.0, -5.0, &vector);
if (vector.x1 != -3.0 || vector.x2 != -5.0) { if (vector.x1 != -3.0 || vector.x2 != -5.0) {
print_testing_error("Second step failed"); print_testing_error("Second step failed");
return; return;
} }
bgc_vector2_set_values_fp64(-2.0, 2.0, &vector); bgc_fp64_vector2_make(-2.0, 2.0, &vector);
if (vector.x1 != -2.0 || vector.x2 != 2.0) { if (vector.x1 != -2.0 || vector.x2 != 2.0) {
print_testing_error("Third step failed"); print_testing_error("Third step failed");

View file

@ -8,14 +8,14 @@
static const int _TEST_FP32_VECTOR2_AMOUNT = 4; static const int _TEST_FP32_VECTOR2_AMOUNT = 4;
static const BgcVector2FP32 _TEST_FP32_VECTOR2_LIST1[] = { static const BGC_FP32_Vector2 _TEST_FP32_VECTOR2_LIST1[] = {
{ 1.0f, 2.0f }, { 1.0f, 2.0f },
{ -2.0f, -1.0f }, { -2.0f, -1.0f },
{ 100.0f, -100.0f }, { 100.0f, -100.0f },
{ -100.1f, 100.2f } { -100.1f, 100.2f }
}; };
static const BgcVector2FP32 _TEST_FP32_VECTOR2_LIST2[] = { static const BGC_FP32_Vector2 _TEST_FP32_VECTOR2_LIST2[] = {
{ 3.6f, 5.3f }, { 3.6f, 5.3f },
{ 204.07f, -781.89f }, { 204.07f, -781.89f },
{ -20.02f, -1.0003f }, { -20.02f, -1.0003f },
@ -24,15 +24,15 @@ static const BgcVector2FP32 _TEST_FP32_VECTOR2_LIST2[] = {
void test_vector2_swap_fp32() void test_vector2_swap_fp32()
{ {
BgcVector2FP32 vector1, vector2; BGC_FP32_Vector2 vector1, vector2;
print_testing_name("bgc_vector2_swap_fp32"); print_testing_name("bgc_fp32_vector2_swap");
for (int i = 0; i < _TEST_FP32_VECTOR2_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_VECTOR2_AMOUNT; i++) {
bgc_vector2_copy_fp32(&_TEST_FP32_VECTOR2_LIST1[i], &vector1); bgc_fp32_vector2_copy(&_TEST_FP32_VECTOR2_LIST1[i], &vector1);
bgc_vector2_copy_fp32(&_TEST_FP32_VECTOR2_LIST2[i], &vector2); bgc_fp32_vector2_copy(&_TEST_FP32_VECTOR2_LIST2[i], &vector2);
bgc_vector2_swap_fp32(&vector1, &vector2); bgc_fp32_vector2_swap(&vector1, &vector2);
if (vector1.x1 != _TEST_FP32_VECTOR2_LIST2[i].x1 || if (vector1.x1 != _TEST_FP32_VECTOR2_LIST2[i].x1 ||
vector1.x2 != _TEST_FP32_VECTOR2_LIST2[i].x2 || vector1.x2 != _TEST_FP32_VECTOR2_LIST2[i].x2 ||
@ -50,14 +50,14 @@ void test_vector2_swap_fp32()
static const int _TEST_FP64_VECTOR2_AMOUNT = 4; static const int _TEST_FP64_VECTOR2_AMOUNT = 4;
static const BgcVector2FP64 _TEST_FP64_VECTOR2_LIST1[] = { static const BGC_FP64_Vector2 _TEST_FP64_VECTOR2_LIST1[] = {
{ 1.0, 2.0 }, { 1.0, 2.0 },
{ -2.0, -1.0 }, { -2.0, -1.0 },
{ 100.0, -100.0 }, { 100.0, -100.0 },
{ -100.1, 100.2 } { -100.1, 100.2 }
}; };
static const BgcVector2FP64 _TEST_FP64_VECTOR2_LIST2[] = { static const BGC_FP64_Vector2 _TEST_FP64_VECTOR2_LIST2[] = {
{ 3.6, 5.3 }, { 3.6, 5.3 },
{ 204.07, -781.89 }, { 204.07, -781.89 },
{ -20.02, -1.0003 }, { -20.02, -1.0003 },
@ -66,15 +66,15 @@ static const BgcVector2FP64 _TEST_FP64_VECTOR2_LIST2[] = {
void test_vector2_swap_fp64() void test_vector2_swap_fp64()
{ {
BgcVector2FP64 vector1, vector2; BGC_FP64_Vector2 vector1, vector2;
print_testing_name("bgc_vector2_swap_fp64"); print_testing_name("bgc_fp64_vector2_swap");
for (int i = 0; i < _TEST_FP64_VECTOR2_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_VECTOR2_AMOUNT; i++) {
bgc_vector2_copy_fp64(&_TEST_FP64_VECTOR2_LIST1[i], &vector1); bgc_fp64_vector2_copy(&_TEST_FP64_VECTOR2_LIST1[i], &vector1);
bgc_vector2_copy_fp64(&_TEST_FP64_VECTOR2_LIST2[i], &vector2); bgc_fp64_vector2_copy(&_TEST_FP64_VECTOR2_LIST2[i], &vector2);
bgc_vector2_swap_fp64(&vector1, &vector2); bgc_fp64_vector2_swap(&vector1, &vector2);
if (vector1.x1 != _TEST_FP64_VECTOR2_LIST2[i].x1 || if (vector1.x1 != _TEST_FP64_VECTOR2_LIST2[i].x1 ||
vector1.x2 != _TEST_FP64_VECTOR2_LIST2[i].x2 || vector1.x2 != _TEST_FP64_VECTOR2_LIST2[i].x2 ||

View file

@ -7,7 +7,7 @@
// ==================== FP32 ==================== // // ==================== FP32 ==================== //
static const int _TEST_FP32_VECTOR3_AMOUNT = 4; static const int _TEST_FP32_VECTOR3_AMOUNT = 4;
static const BgcVector3FP32 _TEST_FP32_VECTOR3_LIST[] = { static const BGC_FP32_Vector3 _TEST_FP32_VECTOR3_LIST[] = {
{ 1.0f, 2.0f, 3.0f }, { 1.0f, 2.0f, 3.0f },
{ -3.0f, -2.0f, -1.0f }, { -3.0f, -2.0f, -1.0f },
{ 100.0f, -100.0f, 0.001f }, { 100.0f, -100.0f, 0.001f },
@ -16,13 +16,13 @@ static const BgcVector3FP32 _TEST_FP32_VECTOR3_LIST[] = {
void test_vector3_copy_fp32() void test_vector3_copy_fp32()
{ {
BgcVector3FP32 vector; BGC_FP32_Vector3 vector;
print_testing_name("bgc_vector3_copy_fp32"); print_testing_name("bgc_fp32_vector3_copy");
for (int i = 0; i < _TEST_FP32_VECTOR3_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_VECTOR3_AMOUNT; i++) {
bgc_vector3_copy_fp32(&_TEST_FP32_VECTOR3_LIST[i], &vector); bgc_fp32_vector3_copy(&_TEST_FP32_VECTOR3_LIST[i], &vector);
if (vector.x1 != _TEST_FP32_VECTOR3_LIST[i].x1 || if (vector.x1 != _TEST_FP32_VECTOR3_LIST[i].x1 ||
vector.x2 != _TEST_FP32_VECTOR3_LIST[i].x2 || vector.x2 != _TEST_FP32_VECTOR3_LIST[i].x2 ||
@ -38,7 +38,7 @@ void test_vector3_copy_fp32()
// ==================== FP64 ==================== // // ==================== FP64 ==================== //
static const int _TEST_FP64_VECTOR3_AMOUNT = 4; static const int _TEST_FP64_VECTOR3_AMOUNT = 4;
static const BgcVector3FP64 _TEST_FP64_VECTOR3_LIST[] = { static const BGC_FP64_Vector3 _TEST_FP64_VECTOR3_LIST[] = {
{ 1.0, 2.0, 3.0 }, { 1.0, 2.0, 3.0 },
{ -3.0, -2.0, -1.0 }, { -3.0, -2.0, -1.0 },
{ 100.0, -100.0, 0.001 }, { 100.0, -100.0, 0.001 },
@ -47,13 +47,13 @@ static const BgcVector3FP64 _TEST_FP64_VECTOR3_LIST[] = {
void test_vector3_copy_fp64() void test_vector3_copy_fp64()
{ {
BgcVector3FP64 vector; BGC_FP64_Vector3 vector;
print_testing_name("bgc_vector3_copy_fp64"); print_testing_name("bgc_fp64_vector3_copy");
for (int i = 0; i < _TEST_FP64_VECTOR3_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_VECTOR3_AMOUNT; i++) {
bgc_vector3_copy_fp64(&_TEST_FP64_VECTOR3_LIST[i], &vector); bgc_fp64_vector3_copy(&_TEST_FP64_VECTOR3_LIST[i], &vector);
if (vector.x1 != _TEST_FP64_VECTOR3_LIST[i].x1 || if (vector.x1 != _TEST_FP64_VECTOR3_LIST[i].x1 ||
vector.x2 != _TEST_FP64_VECTOR3_LIST[i].x2 || vector.x2 != _TEST_FP64_VECTOR3_LIST[i].x2 ||

View file

@ -7,38 +7,38 @@
static const int _TEST_FP32_UNIT_VECTOR3_AMOUNT = 10; static const int _TEST_FP32_UNIT_VECTOR3_AMOUNT = 10;
static const int _TEST_FP32_NONUNIT_VECTOR3_AMOUNT = 9; static const int _TEST_FP32_NONUNIT_VECTOR3_AMOUNT = 9;
static const BgcVector3FP32 _TEST_FP32_UNIT_VECTOR3_LIST[] = { static const BGC_FP32_Vector3 _TEST_FP32_UNIT_VECTOR3_LIST[] = {
{ 1.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f },
{ 0.0f, -1.0f, 0.0f }, { 0.0f, -1.0f, 0.0f },
{ 0.0f, -0.8f, 0.6f }, { 0.0f, -0.8f, 0.6f },
{ -0.6f, 0.0f, 0.8f }, { -0.6f, 0.0f, 0.8f },
{ 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, -1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, -1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, -1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, -1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32 }, { 0.0f, 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON },
{ 0.0f, 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32 } { 0.0f, 0.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON }
}; };
static const BgcVector3FP32 _TEST_FP32_NONUNIT_VECTOR3_LIST[] = { static const BGC_FP32_Vector3 _TEST_FP32_NONUNIT_VECTOR3_LIST[] = {
{ 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f },
{ 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32 }, { 0.0f, 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON },
{ 0.0f, 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32 }, { 0.0f, 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON },
{ 0.8f + 1.25f * BGC_EPSYLON_FP32, -0.6f - 1.25f * BGC_EPSYLON_FP32, 0.0f }, { 0.8f + 1.25f * BGC_FP32_EPSYLON, -0.6f - 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.6f - 1.25f * BGC_EPSYLON_FP32, -0.8f + 1.25f * BGC_EPSYLON_FP32, 0.0f } { 0.6f - 1.25f * BGC_FP32_EPSYLON, -0.8f + 1.25f * BGC_FP32_EPSYLON, 0.0f }
}; };
void test_vector3_is_unit_fp32() void test_vector3_is_unit_fp32()
{ {
print_testing_name("bgc_vector3_is_unit_fp32"); print_testing_name("bgc_fp32_vector3_is_unit");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP32_UNIT_VECTOR3_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_UNIT_VECTOR3_AMOUNT; i++) {
if (!bgc_vector3_is_unit_fp32(&_TEST_FP32_UNIT_VECTOR3_LIST[i])) { if (!bgc_fp32_vector3_is_unit(&_TEST_FP32_UNIT_VECTOR3_LIST[i])) {
print_testing_error("A unit vector was not recognized"); print_testing_error("A unit vector was not recognized");
return; return;
} }
@ -46,7 +46,7 @@ void test_vector3_is_unit_fp32()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONUNIT_VECTOR3_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_NONUNIT_VECTOR3_AMOUNT; i++) {
if (bgc_vector3_is_unit_fp32(&_TEST_FP32_NONUNIT_VECTOR3_LIST[i])) { if (bgc_fp32_vector3_is_unit(&_TEST_FP32_NONUNIT_VECTOR3_LIST[i])) {
print_testing_error("A non-unit vector was recognized as a unit vector"); print_testing_error("A non-unit vector was recognized as a unit vector");
return; return;
} }
@ -60,38 +60,38 @@ void test_vector3_is_unit_fp32()
static const int _TEST_FP64_UNIT_VECTOR3_AMOUNT = 10; static const int _TEST_FP64_UNIT_VECTOR3_AMOUNT = 10;
static const int _TEST_FP64_NONUNIT_VECTOR3_AMOUNT = 9; static const int _TEST_FP64_NONUNIT_VECTOR3_AMOUNT = 9;
static const BgcVector3FP64 _TEST_FP64_UNIT_VECTOR3_LIST[] = { static const BGC_FP64_Vector3 _TEST_FP64_UNIT_VECTOR3_LIST[] = {
{ 1.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0 },
{ 0.0, -1.0, 0.0 }, { 0.0, -1.0, 0.0 },
{ 0.0, -0.8, 0.6 }, { 0.0, -0.8, 0.6 },
{ -0.6, 0.0, 0.8 }, { -0.6, 0.0, 0.8 },
{ 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, -1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, -1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, -1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, -1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64 }, { 0.0, 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON },
{ 0.0, 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64 } { 0.0, 0.0, 1.0 - 0.75 * BGC_FP64_EPSYLON }
}; };
static const BgcVector3FP64 _TEST_FP64_NONUNIT_VECTOR3_LIST[] = { static const BGC_FP64_Vector3 _TEST_FP64_NONUNIT_VECTOR3_LIST[] = {
{ 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0 },
{ 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64 }, { 0.0, 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON },
{ 0.0, 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64 }, { 0.0, 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON },
{ 0.8 + 1.25 * BGC_EPSYLON_FP64, -0.6 - 1.25 * BGC_EPSYLON_FP64, 0.0 }, { 0.8 + 1.25 * BGC_FP64_EPSYLON, -0.6 - 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.6 - 1.25 * BGC_EPSYLON_FP64, -0.8 + 1.25 * BGC_EPSYLON_FP64, 0.0 } { 0.6 - 1.25 * BGC_FP64_EPSYLON, -0.8 + 1.25 * BGC_FP64_EPSYLON, 0.0 }
}; };
void test_vector3_is_unit_fp64() void test_vector3_is_unit_fp64()
{ {
print_testing_name("bgc_vector3_is_unit_fp64"); print_testing_name("bgc_fp64_vector3_is_unit");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP64_UNIT_VECTOR3_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_UNIT_VECTOR3_AMOUNT; i++) {
if (!bgc_vector3_is_unit_fp64(&_TEST_FP64_UNIT_VECTOR3_LIST[i])) { if (!bgc_fp64_vector3_is_unit(&_TEST_FP64_UNIT_VECTOR3_LIST[i])) {
print_testing_error("A unit vector was not recognized"); print_testing_error("A unit vector was not recognized");
return; return;
} }
@ -99,7 +99,7 @@ void test_vector3_is_unit_fp64()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONUNIT_VECTOR3_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_NONUNIT_VECTOR3_AMOUNT; i++) {
if (bgc_vector3_is_unit_fp64(&_TEST_FP64_NONUNIT_VECTOR3_LIST[i])) { if (bgc_fp64_vector3_is_unit(&_TEST_FP64_NONUNIT_VECTOR3_LIST[i])) {
print_testing_error("A non-unit vector was recognized as a unit vector"); print_testing_error("A non-unit vector was recognized as a unit vector");
return; return;
} }

View file

@ -7,35 +7,35 @@
static const int _TEST_FP32_ZERO_VECTOR3_AMOUNT = 7; static const int _TEST_FP32_ZERO_VECTOR3_AMOUNT = 7;
static const int _TEST_FP32_NONZERO_VECTOR3_AMOUNT = 9; static const int _TEST_FP32_NONZERO_VECTOR3_AMOUNT = 9;
static const BgcVector3FP32 _TEST_FP32_ZERO_VECTOR3_LIST[] = { static const BGC_FP32_Vector3 _TEST_FP32_ZERO_VECTOR3_LIST[] = {
{ 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f },
{ 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ -0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { -0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 0.75f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, -0.75f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, -0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 0.75f * BGC_EPSYLON_FP32 }, { 0.0f, 0.0f, 0.75f * BGC_FP32_EPSYLON },
{ 0.0f, 0.0f, -0.75f * BGC_EPSYLON_FP32 } { 0.0f, 0.0f, -0.75f * BGC_FP32_EPSYLON }
}; };
static const BgcVector3FP32 _TEST_FP32_NONZERO_VECTOR3_LIST[] = { static const BGC_FP32_Vector3 _TEST_FP32_NONZERO_VECTOR3_LIST[] = {
{ 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f },
{ 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ -1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { -1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 0.0f, 1.25f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, -1.25f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, -1.25f * BGC_FP32_EPSYLON, 0.0f },
{ 0.0f, 0.0f, 1.25f * BGC_EPSYLON_FP32 }, { 0.0f, 0.0f, 1.25f * BGC_FP32_EPSYLON },
{ 0.0f, 0.0f, -1.25f * BGC_EPSYLON_FP32 }, { 0.0f, 0.0f, -1.25f * BGC_FP32_EPSYLON },
{ 1.25f * BGC_EPSYLON_FP32, 1.25f * BGC_EPSYLON_FP32, 0.0f }, { 1.25f * BGC_FP32_EPSYLON, 1.25f * BGC_FP32_EPSYLON, 0.0f },
{ -1.25f * BGC_EPSYLON_FP32, -1.25f * BGC_EPSYLON_FP32, 0.0f } { -1.25f * BGC_FP32_EPSYLON, -1.25f * BGC_FP32_EPSYLON, 0.0f }
}; };
void test_vector3_is_zero_fp32() void test_vector3_is_zero_fp32()
{ {
print_testing_name("bgc_vector3_is_zero_fp32"); print_testing_name("bgc_fp32_vector3_is_zero");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP32_ZERO_VECTOR3_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_ZERO_VECTOR3_AMOUNT; i++) {
if (!bgc_vector3_is_zero_fp32(&_TEST_FP32_ZERO_VECTOR3_LIST[i])) { if (!bgc_fp32_vector3_is_zero(&_TEST_FP32_ZERO_VECTOR3_LIST[i])) {
print_testing_error("A zero vector was not recongized"); print_testing_error("A zero vector was not recongized");
return; return;
} }
@ -43,7 +43,7 @@ void test_vector3_is_zero_fp32()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONZERO_VECTOR3_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_NONZERO_VECTOR3_AMOUNT; i++) {
if (bgc_vector3_is_zero_fp32(&_TEST_FP32_NONZERO_VECTOR3_LIST[i])) { if (bgc_fp32_vector3_is_zero(&_TEST_FP32_NONZERO_VECTOR3_LIST[i])) {
print_testing_error("A non-zero vector was recongized as a zero vector"); print_testing_error("A non-zero vector was recongized as a zero vector");
return; return;
} }
@ -57,35 +57,35 @@ void test_vector3_is_zero_fp32()
static const int _TEST_FP64_ZERO_VECTOR3_AMOUNT = 7; static const int _TEST_FP64_ZERO_VECTOR3_AMOUNT = 7;
static const int _TEST_FP64_NONZERO_VECTOR3_AMOUNT = 9; static const int _TEST_FP64_NONZERO_VECTOR3_AMOUNT = 9;
static const BgcVector3FP64 _TEST_FP64_ZERO_VECTOR3_LIST[] = { static const BGC_FP64_Vector3 _TEST_FP64_ZERO_VECTOR3_LIST[] = {
{ 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0 },
{ 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ -0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { -0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 0.75 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, -0.75 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, -0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 0.75 * BGC_EPSYLON_FP64 }, { 0.0, 0.0, 0.75 * BGC_FP64_EPSYLON },
{ 0.0, 0.0, -0.75 * BGC_EPSYLON_FP64 } { 0.0, 0.0, -0.75 * BGC_FP64_EPSYLON }
}; };
static const BgcVector3FP64 _TEST_FP64_NONZERO_VECTOR3_LIST[] = { static const BGC_FP64_Vector3 _TEST_FP64_NONZERO_VECTOR3_LIST[] = {
{ 0.0, 1.0, 0.0 }, { 0.0, 1.0, 0.0 },
{ 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ -1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { -1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 0.0, 1.25 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, -1.25 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, -1.25 * BGC_FP64_EPSYLON, 0.0 },
{ 0.0, 0.0, 1.25 * BGC_EPSYLON_FP64 }, { 0.0, 0.0, 1.25 * BGC_FP64_EPSYLON },
{ 0.0, 0.0, -1.25 * BGC_EPSYLON_FP64 }, { 0.0, 0.0, -1.25 * BGC_FP64_EPSYLON },
{ 1.25 * BGC_EPSYLON_FP64, 1.25 * BGC_EPSYLON_FP64, 0.0 }, { 1.25 * BGC_FP64_EPSYLON, 1.25 * BGC_FP64_EPSYLON, 0.0 },
{ -BGC_EPSYLON_FP64, -BGC_EPSYLON_FP64, 0.0 } { -BGC_FP64_EPSYLON, -BGC_FP64_EPSYLON, 0.0 }
}; };
void test_vector3_is_zero_fp64() void test_vector3_is_zero_fp64()
{ {
print_testing_name("bgc_vector3_is_zero_fp64"); print_testing_name("bgc_fp64_vector3_is_zero");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP64_ZERO_VECTOR3_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_ZERO_VECTOR3_AMOUNT; i++) {
if (!bgc_vector3_is_zero_fp64(&_TEST_FP64_ZERO_VECTOR3_LIST[i])) { if (!bgc_fp64_vector3_is_zero(&_TEST_FP64_ZERO_VECTOR3_LIST[i])) {
print_testing_error("A zero vector was not recongized"); print_testing_error("A zero vector was not recongized");
return; return;
} }
@ -93,7 +93,7 @@ void test_vector3_is_zero_fp64()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONZERO_VECTOR3_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_NONZERO_VECTOR3_AMOUNT; i++) {
if (bgc_vector3_is_zero_fp64(&_TEST_FP64_NONZERO_VECTOR3_LIST[i])) { if (bgc_fp64_vector3_is_zero(&_TEST_FP64_NONZERO_VECTOR3_LIST[i])) {
print_testing_error("A non-zero vector was recongized as a zero vector"); print_testing_error("A non-zero vector was recongized as a zero vector");
return; return;
} }

View file

@ -6,7 +6,7 @@
static const int _TEST_FP32_VECTOR3_AMOUNT = 4; static const int _TEST_FP32_VECTOR3_AMOUNT = 4;
static const BgcVector3FP32 _TEST_FP32_VECTOR3_LIST[] = { static const BGC_FP32_Vector3 _TEST_FP32_VECTOR3_LIST[] = {
{ 4.0f, 3.0f, 0.0f }, { 4.0f, 3.0f, 0.0f },
{ 0.0f, -3.0f, -4.0f }, { 0.0f, -3.0f, -4.0f },
{ 100.0f, -100.0f, 100.0f }, { 100.0f, -100.0f, 100.0f },
@ -29,10 +29,10 @@ static const float _TEST_FP32_MODULUS_LIST[] = {
void test_vector3_square_modulus_fp32() void test_vector3_square_modulus_fp32()
{ {
print_testing_name("bgc_vector3_get_square_modulus_fp32"); print_testing_name("bgc_fp32_vector3_get_square_modulus");
for (int i = 0; i < _TEST_FP32_VECTOR3_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_VECTOR3_AMOUNT; i++) {
if (!bgc_are_close_fp32(bgc_vector3_get_square_modulus_fp32(&_TEST_FP32_VECTOR3_LIST[i]), _TEST_FP32_SQUARE_MODULUS_LIST[i])) { if (!bgc_fp32_are_close(bgc_fp32_vector3_get_square_modulus(&_TEST_FP32_VECTOR3_LIST[i]), _TEST_FP32_SQUARE_MODULUS_LIST[i])) {
print_testing_failed(); print_testing_failed();
return; return;
} }
@ -43,10 +43,10 @@ void test_vector3_square_modulus_fp32()
void test_vector3_modulus_fp32() void test_vector3_modulus_fp32()
{ {
print_testing_name("bgc_vector3_get_modulus_fp32"); print_testing_name("bgc_fp32_vector3_get_modulus");
for (int i = 0; i < _TEST_FP32_VECTOR3_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_VECTOR3_AMOUNT; i++) {
if (!bgc_are_close_fp32(bgc_vector3_get_modulus_fp32(&_TEST_FP32_VECTOR3_LIST[i]), _TEST_FP32_MODULUS_LIST[i])) { if (!bgc_fp32_are_close(bgc_fp32_vector3_get_modulus(&_TEST_FP32_VECTOR3_LIST[i]), _TEST_FP32_MODULUS_LIST[i])) {
print_testing_failed(); print_testing_failed();
return; return;
} }
@ -59,7 +59,7 @@ void test_vector3_modulus_fp32()
static const int _TEST_FP64_VECTOR3_AMOUNT = 4; static const int _TEST_FP64_VECTOR3_AMOUNT = 4;
static const BgcVector3FP64 _TEST_FP64_VECTOR3_LIST[] = { static const BGC_FP64_Vector3 _TEST_FP64_VECTOR3_LIST[] = {
{ 0.0, 4.0, 3.0 }, { 0.0, 4.0, 3.0 },
{ -3.0, 0.0, -4.0 }, { -3.0, 0.0, -4.0 },
{ 100.0, -100.0, 100.0 }, { 100.0, -100.0, 100.0 },
@ -82,10 +82,10 @@ static const double _TEST_FP64_MODULUS_LIST[] = {
void test_vector3_square_modulus_fp64() void test_vector3_square_modulus_fp64()
{ {
print_testing_name("bgc_vector3_get_square_modulus_fp64"); print_testing_name("bgc_fp64_vector3_get_square_modulus");
for (int i = 0; i < _TEST_FP64_VECTOR3_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_VECTOR3_AMOUNT; i++) {
if (!bgc_are_close_fp64(bgc_vector3_get_square_modulus_fp64(&_TEST_FP64_VECTOR3_LIST[i]), _TEST_FP64_SQUARE_MODULUS_LIST[i])) { if (!bgc_fp64_are_close(bgc_fp64_vector3_get_square_modulus(&_TEST_FP64_VECTOR3_LIST[i]), _TEST_FP64_SQUARE_MODULUS_LIST[i])) {
print_testing_failed(); print_testing_failed();
return; return;
} }
@ -96,10 +96,10 @@ void test_vector3_square_modulus_fp64()
void test_vector3_modulus_fp64() void test_vector3_modulus_fp64()
{ {
print_testing_name("bgc_vector3_get_modulus_fp64"); print_testing_name("bgc_fp64_vector3_get_modulus");
for (int i = 0; i < _TEST_FP64_VECTOR3_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_VECTOR3_AMOUNT; i++) {
if (!bgc_are_close_fp64(bgc_vector3_get_modulus_fp64(&_TEST_FP64_VECTOR3_LIST[i]), _TEST_FP64_MODULUS_LIST[i])) { if (!bgc_fp64_are_close(bgc_fp64_vector3_get_modulus(&_TEST_FP64_VECTOR3_LIST[i]), _TEST_FP64_MODULUS_LIST[i])) {
print_testing_failed(); print_testing_failed();
return; return;
} }

View file

@ -4,11 +4,11 @@
void test_vector3_reset_fp32() void test_vector3_reset_fp32()
{ {
BgcVector3FP32 vector; BGC_FP32_Vector3 vector;
print_testing_name("bgc_vector3_reset_fp32"); print_testing_name("bgc_fp32_vector3_reset");
bgc_vector3_reset_fp32(&vector); bgc_fp32_vector3_reset(&vector);
if (vector.x1 != 0.0f || vector.x2 != 0.0f || vector.x3 != 0.0f) { if (vector.x1 != 0.0f || vector.x2 != 0.0f || vector.x3 != 0.0f) {
print_testing_failed(); print_testing_failed();
@ -20,11 +20,11 @@ void test_vector3_reset_fp32()
void test_vector3_reset_fp64() void test_vector3_reset_fp64()
{ {
BgcVector3FP64 vector; BGC_FP64_Vector3 vector;
print_testing_name("bgc_vector3_reset_fp64"); print_testing_name("bgc_fp64_vector3_reset");
bgc_vector3_reset_fp64(&vector); bgc_fp64_vector3_reset(&vector);
if (vector.x1 != 0.0 || vector.x2 != 0.0 || vector.x3 != 0.0) { if (vector.x1 != 0.0 || vector.x2 != 0.0 || vector.x3 != 0.0) {
print_testing_failed(); print_testing_failed();

View file

@ -8,25 +8,25 @@
void test_vector3_set_values_fp32() void test_vector3_set_values_fp32()
{ {
BgcVector3FP32 vector; BGC_FP32_Vector3 vector;
print_testing_name("bgc_vector3_set_values_fp32"); print_testing_name("bgc_fp32_vector3_make");
bgc_vector3_set_values_fp32(1.0f, 2.0f, 3.0f, &vector); bgc_fp32_vector3_make(1.0f, 2.0f, 3.0f, &vector);
if (vector.x1 != 1.0f || vector.x2 != 2.0f || vector.x3 != 3.0f) { if (vector.x1 != 1.0f || vector.x2 != 2.0f || vector.x3 != 3.0f) {
print_testing_error("First step failed"); print_testing_error("First step failed");
return; return;
} }
bgc_vector3_set_values_fp32(-3.0f, -5.0f, -7.0f, &vector); bgc_fp32_vector3_make(-3.0f, -5.0f, -7.0f, &vector);
if (vector.x1 != -3.0f || vector.x2 != -5.0f || vector.x3 != -7.0f) { if (vector.x1 != -3.0f || vector.x2 != -5.0f || vector.x3 != -7.0f) {
print_testing_error("Second step failed"); print_testing_error("Second step failed");
return; return;
} }
bgc_vector3_set_values_fp32(-2.0f, 2.0f, 4.0f, &vector); bgc_fp32_vector3_make(-2.0f, 2.0f, 4.0f, &vector);
if (vector.x1 != -2.0f || vector.x2 != 2.0f || vector.x3 != 4.0f) { if (vector.x1 != -2.0f || vector.x2 != 2.0f || vector.x3 != 4.0f) {
print_testing_error("Third step failed"); print_testing_error("Third step failed");
@ -40,26 +40,26 @@ void test_vector3_set_values_fp32()
void test_vector3_set_values_fp64() void test_vector3_set_values_fp64()
{ {
BgcVector3FP64 vector; BGC_FP64_Vector3 vector;
print_testing_name("bgc_vector3_set_values_fp64"); print_testing_name("bgc_fp64_vector3_make");
bgc_vector3_set_values_fp64(1.0, 2.0, 3.0, &vector); bgc_fp64_vector3_make(1.0, 2.0, 3.0, &vector);
if (vector.x1 != 1.0 || vector.x2 != 2.0 || vector.x3 != 3.0) { if (vector.x1 != 1.0 || vector.x2 != 2.0 || vector.x3 != 3.0) {
print_testing_error("First step failed"); print_testing_error("First step failed");
return; return;
} }
bgc_vector3_set_values_fp64(-3.0, -5.0, -7.0, &vector); bgc_fp64_vector3_make(-3.0, -5.0, -7.0, &vector);
if (vector.x1 != -3.0 || vector.x2 != -5.0 || vector.x3 != -7.0) { if (vector.x1 != -3.0 || vector.x2 != -5.0 || vector.x3 != -7.0) {
print_testing_error("Second step failed"); print_testing_error("Second step failed");
return; return;
} }
bgc_vector3_set_values_fp64(-2.0, 2.0, 4.0, &vector); bgc_fp64_vector3_make(-2.0, 2.0, 4.0, &vector);
if (vector.x1 != -2.0 || vector.x2 != 2.0 || vector.x3 != 4.0) { if (vector.x1 != -2.0 || vector.x2 != 2.0 || vector.x3 != 4.0) {
print_testing_error("Third step failed"); print_testing_error("Third step failed");

View file

@ -8,14 +8,14 @@
static const int _TEST_FP32_VECTOR3_AMOUNT = 4; static const int _TEST_FP32_VECTOR3_AMOUNT = 4;
static const BgcVector3FP32 _TEST_FP32_VECTOR3_LIST1[] = { static const BGC_FP32_Vector3 _TEST_FP32_VECTOR3_LIST1[] = {
{ 1.0f, 2.0f, 3.0f }, { 1.0f, 2.0f, 3.0f },
{ -3.0f, -2.0f, -1.0f }, { -3.0f, -2.0f, -1.0f },
{ 100.0f, -100.0f, 344.7f }, { 100.0f, -100.0f, 344.7f },
{ -100.1f, 100.2f, -271.3f } { -100.1f, 100.2f, -271.3f }
}; };
static const BgcVector3FP32 _TEST_FP32_VECTOR3_LIST2[] = { static const BGC_FP32_Vector3 _TEST_FP32_VECTOR3_LIST2[] = {
{ 3.6f, 5.3f, -0.123f }, { 3.6f, 5.3f, -0.123f },
{ 204.07f, -781.89f, 891.3f }, { 204.07f, -781.89f, 891.3f },
{ -20.02f, -1.0003f, 0.9275f }, { -20.02f, -1.0003f, 0.9275f },
@ -24,15 +24,15 @@ static const BgcVector3FP32 _TEST_FP32_VECTOR3_LIST2[] = {
void test_vector3_swap_fp32() void test_vector3_swap_fp32()
{ {
BgcVector3FP32 vector1, vector2; BGC_FP32_Vector3 vector1, vector2;
print_testing_name("bgc_vector3_swap_fp32"); print_testing_name("bgc_fp32_vector3_swap");
for (int i = 0; i < _TEST_FP32_VECTOR3_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_VECTOR3_AMOUNT; i++) {
bgc_vector3_copy_fp32(&_TEST_FP32_VECTOR3_LIST1[i], &vector1); bgc_fp32_vector3_copy(&_TEST_FP32_VECTOR3_LIST1[i], &vector1);
bgc_vector3_copy_fp32(&_TEST_FP32_VECTOR3_LIST2[i], &vector2); bgc_fp32_vector3_copy(&_TEST_FP32_VECTOR3_LIST2[i], &vector2);
bgc_vector3_swap_fp32(&vector1, &vector2); bgc_fp32_vector3_swap(&vector1, &vector2);
if (vector1.x1 != _TEST_FP32_VECTOR3_LIST2[i].x1 || if (vector1.x1 != _TEST_FP32_VECTOR3_LIST2[i].x1 ||
vector1.x2 != _TEST_FP32_VECTOR3_LIST2[i].x2 || vector1.x2 != _TEST_FP32_VECTOR3_LIST2[i].x2 ||
@ -52,14 +52,14 @@ void test_vector3_swap_fp32()
static const int _TEST_FP64_VECTOR3_AMOUNT = 4; static const int _TEST_FP64_VECTOR3_AMOUNT = 4;
static const BgcVector3FP64 _TEST_FP64_VECTOR3_LIST1[] = { static const BGC_FP64_Vector3 _TEST_FP64_VECTOR3_LIST1[] = {
{ 1.0, 2.0, 3.0 }, { 1.0, 2.0, 3.0 },
{ -3.0, -2.0, -1.0 }, { -3.0, -2.0, -1.0 },
{ 100.0, -100.0, 344.7 }, { 100.0, -100.0, 344.7 },
{ -100.1, 100.2, -271.3 } { -100.1, 100.2, -271.3 }
}; };
static const BgcVector3FP64 _TEST_FP64_VECTOR3_LIST2[] = { static const BGC_FP64_Vector3 _TEST_FP64_VECTOR3_LIST2[] = {
{ 3.6, 5.3, -0.123 }, { 3.6, 5.3, -0.123 },
{ 204.07, -781.89, 891.3 }, { 204.07, -781.89, 891.3 },
{ -20.02, -1.0003, 0.9275 }, { -20.02, -1.0003, 0.9275 },
@ -68,15 +68,15 @@ static const BgcVector3FP64 _TEST_FP64_VECTOR3_LIST2[] = {
void test_vector3_swap_fp64() void test_vector3_swap_fp64()
{ {
BgcVector3FP64 vector1, vector2; BGC_FP64_Vector3 vector1, vector2;
print_testing_name("bgc_vector3_swap_fp64"); print_testing_name("bgc_fp64_vector3_swap");
for (int i = 0; i < _TEST_FP64_VECTOR3_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_VECTOR3_AMOUNT; i++) {
bgc_vector3_copy_fp64(&_TEST_FP64_VECTOR3_LIST1[i], &vector1); bgc_fp64_vector3_copy(&_TEST_FP64_VECTOR3_LIST1[i], &vector1);
bgc_vector3_copy_fp64(&_TEST_FP64_VECTOR3_LIST2[i], &vector2); bgc_fp64_vector3_copy(&_TEST_FP64_VECTOR3_LIST2[i], &vector2);
bgc_vector3_swap_fp64(&vector1, &vector2); bgc_fp64_vector3_swap(&vector1, &vector2);
if (vector1.x1 != _TEST_FP64_VECTOR3_LIST2[i].x1 || if (vector1.x1 != _TEST_FP64_VECTOR3_LIST2[i].x1 ||
vector1.x2 != _TEST_FP64_VECTOR3_LIST2[i].x2 || vector1.x2 != _TEST_FP64_VECTOR3_LIST2[i].x2 ||

View file

@ -9,35 +9,35 @@ static const int _TEST_FP32_CLOSE_VERSOR_PAIR_AMOUNT = 10;
static const TestVersorPairFP32 _TEST_FP32_CLOSE_VERSOR_PAIR_LIST[] = { static const TestVersorPairFP32 _TEST_FP32_CLOSE_VERSOR_PAIR_LIST[] = {
{ {
{ 1.0f, 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f, 0.0f },
{ 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f } { 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f }
}, },
{ {
{ 1.0f, 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f, 0.0f },
{ 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f } { 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f }
}, },
{ {
{ 0.0f, 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f } { 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f }
}, },
{ {
{ 0.0f, 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f } { 0.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f }
}, },
{ {
{ 0.0f, 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f } { 0.0f, 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f }
}, },
{ {
{ 0.0f, 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f } { 0.0f, 0.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f }
}, },
{ {
{ 0.0f, 0.0f, 0.0f, 1.0f }, { 0.0f, 0.0f, 0.0f, 1.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32 } { 0.0f, 0.0f, 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON }
}, },
{ {
{ 0.0f, 0.0f, 0.0f, 1.0f }, { 0.0f, 0.0f, 0.0f, 1.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32 } { 0.0f, 0.0f, 0.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON }
}, },
{ {
{ 0.70710678f, 0.0f, 0.70710675f, 0.0f }, { 0.70710678f, 0.0f, 0.70710675f, 0.0f },
@ -54,35 +54,35 @@ static const int _TEST_FP32_DIFFERENT_VERSOR_PAIR_AMOUNT = 10;
static const TestVersorPairFP32 _TEST_FP32_DIFFERENT_VERSOR_PAIR_LIST[] = { static const TestVersorPairFP32 _TEST_FP32_DIFFERENT_VERSOR_PAIR_LIST[] = {
{ {
{ 1.0f, 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f, 0.0f },
{ 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f } { 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f }
}, },
{ {
{ 1.0f, 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f, 0.0f },
{ 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f } { 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f }
}, },
{ {
{ 0.0f, 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f } { 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f }
}, },
{ {
{ 0.0f, 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f } { 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f }
}, },
{ {
{ 0.0f, 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f } { 0.0f, 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f }
}, },
{ {
{ 0.0f, 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f } { 0.0f, 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f }
}, },
{ {
{ 0.0f, 0.0f, 0.0f, 1.0f }, { 0.0f, 0.0f, 0.0f, 1.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32 } { 0.0f, 0.0f, 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON }
}, },
{ {
{ 0.0f, 0.0f, 0.0f, 1.0f }, { 0.0f, 0.0f, 0.0f, 1.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32 } { 0.0f, 0.0f, 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON }
}, },
{ {
{ 0.707106f, 0.0f, 0.707107f, 0.0f }, { 0.707106f, 0.0f, 0.707107f, 0.0f },
@ -96,11 +96,11 @@ static const TestVersorPairFP32 _TEST_FP32_DIFFERENT_VERSOR_PAIR_LIST[] = {
void test_versor_are_close_fp32() void test_versor_are_close_fp32()
{ {
print_testing_name("bgc_versor_are_close_fp32"); print_testing_name("bgc_fp32_versor_are_close");
// Testing close pairs of versors: // Testing close pairs of versors:
for (int i = 0; i < _TEST_FP32_CLOSE_VERSOR_PAIR_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_CLOSE_VERSOR_PAIR_AMOUNT; i++) {
if (!bgc_versor_are_close_fp32(&_TEST_FP32_CLOSE_VERSOR_PAIR_LIST[i].first, &_TEST_FP32_CLOSE_VERSOR_PAIR_LIST[i].second)) { if (!bgc_fp32_versor_are_close(&_TEST_FP32_CLOSE_VERSOR_PAIR_LIST[i].first, &_TEST_FP32_CLOSE_VERSOR_PAIR_LIST[i].second)) {
print_testing_error("A pair of close versors was not recognized"); print_testing_error("A pair of close versors was not recognized");
return; return;
} }
@ -108,7 +108,7 @@ void test_versor_are_close_fp32()
// Testing different pairs of versors: // Testing different pairs of versors:
for (int i = 0; i < _TEST_FP32_DIFFERENT_VERSOR_PAIR_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_DIFFERENT_VERSOR_PAIR_AMOUNT; i++) {
if (bgc_versor_are_close_fp32(&_TEST_FP32_DIFFERENT_VERSOR_PAIR_LIST[i].first, &_TEST_FP32_DIFFERENT_VERSOR_PAIR_LIST[i].second)) { if (bgc_fp32_versor_are_close(&_TEST_FP32_DIFFERENT_VERSOR_PAIR_LIST[i].first, &_TEST_FP32_DIFFERENT_VERSOR_PAIR_LIST[i].second)) {
print_testing_error("A pair of different versors was recognized as close versors"); print_testing_error("A pair of different versors was recognized as close versors");
return; return;
} }
@ -125,35 +125,35 @@ static const int _TEST_FP64_CLOSE_VERSOR_PAIR_AMOUNT = 10;
static const TestVersorPairFP64 _TEST_FP64_CLOSE_VERSOR_PAIR_LIST[] = { static const TestVersorPairFP64 _TEST_FP64_CLOSE_VERSOR_PAIR_LIST[] = {
{ {
{ 1.0, 0.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0, 0.0 },
{ 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 } { 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 }
}, },
{ {
{ 1.0, 0.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0, 0.0 },
{ 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 } { 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 }
}, },
{ {
{ 0.0, 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0, 0.0 },
{ 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 } { 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 }
}, },
{ {
{ 0.0, 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0, 0.0 },
{ 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 } { 0.0, 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 }
}, },
{ {
{ 0.0, 0.0, 1.0, 0.0 }, { 0.0, 0.0, 1.0, 0.0 },
{ 0.0, 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0 } { 0.0, 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0 }
}, },
{ {
{ 0.0, 0.0, 1.0, 0.0 }, { 0.0, 0.0, 1.0, 0.0 },
{ 0.0, 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0 } { 0.0, 0.0, 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0 }
}, },
{ {
{ 0.0, 0.0, 0.0, 1.0 }, { 0.0, 0.0, 0.0, 1.0 },
{ 0.0, 0.0, 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64 } { 0.0, 0.0, 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON }
}, },
{ {
{ 0.0, 0.0, 0.0, 1.0 }, { 0.0, 0.0, 0.0, 1.0 },
{ 0.0, 0.0, 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64 } { 0.0, 0.0, 0.0, 1.0 - 0.75 * BGC_FP64_EPSYLON }
}, },
{ {
{ 0.7071067811865475244, 0.0, 0.7071067811865465244, 0.0 }, { 0.7071067811865475244, 0.0, 0.7071067811865465244, 0.0 },
@ -170,35 +170,35 @@ static const int _TEST_FP64_DIFFERENT_VERSOR_PAIR_AMOUNT = 10;
static const TestVersorPairFP64 _TEST_FP64_DIFFERENT_VERSOR_PAIR_LIST[] = { static const TestVersorPairFP64 _TEST_FP64_DIFFERENT_VERSOR_PAIR_LIST[] = {
{ {
{ 1.0, 0.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0, 0.0 },
{ 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 } { 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 }
}, },
{ {
{ 1.0, 0.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0, 0.0 },
{ 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 } { 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 }
}, },
{ {
{ 0.0, 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0, 0.0 },
{ 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 } { 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 }
}, },
{ {
{ 0.0, 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0, 0.0 },
{ 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 } { 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 }
}, },
{ {
{ 0.0, 0.0, 1.0, 0.0 }, { 0.0, 0.0, 1.0, 0.0 },
{ 0.0, 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0 } { 0.0, 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0 }
}, },
{ {
{ 0.0, 0.0, 1.0, 0.0 }, { 0.0, 0.0, 1.0, 0.0 },
{ 0.0, 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0 } { 0.0, 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0 }
}, },
{ {
{ 0.0, 0.0, 0.0, 1.0 }, { 0.0, 0.0, 0.0, 1.0 },
{ 0.0, 0.0, 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64 } { 0.0, 0.0, 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON }
}, },
{ {
{ 0.0, 0.0, 0.0, 1.0 }, { 0.0, 0.0, 0.0, 1.0 },
{ 0.0, 0.0, 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64 } { 0.0, 0.0, 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON }
}, },
{ {
{ 0.7071067811866, 0.0, 0.7071067811865, 0.0 }, { 0.7071067811866, 0.0, 0.7071067811865, 0.0 },
@ -212,11 +212,11 @@ static const TestVersorPairFP64 _TEST_FP64_DIFFERENT_VERSOR_PAIR_LIST[] = {
void test_versor_are_close_fp64() void test_versor_are_close_fp64()
{ {
print_testing_name("bgc_versor_are_close_fp64"); print_testing_name("bgc_fp64_versor_are_close");
// Testing close pairs of versors: // Testing close pairs of versors:
for (int i = 0; i < _TEST_FP64_CLOSE_VERSOR_PAIR_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_CLOSE_VERSOR_PAIR_AMOUNT; i++) {
if (!bgc_versor_are_close_fp64(&_TEST_FP64_CLOSE_VERSOR_PAIR_LIST[i].first, &_TEST_FP64_CLOSE_VERSOR_PAIR_LIST[i].second)) { if (!bgc_fp64_versor_are_close(&_TEST_FP64_CLOSE_VERSOR_PAIR_LIST[i].first, &_TEST_FP64_CLOSE_VERSOR_PAIR_LIST[i].second)) {
print_testing_error("A pair of close versors was not recognized"); print_testing_error("A pair of close versors was not recognized");
return; return;
} }
@ -224,7 +224,7 @@ void test_versor_are_close_fp64()
// Testing different pairs of versors: // Testing different pairs of versors:
for (int i = 0; i < _TEST_FP64_DIFFERENT_VERSOR_PAIR_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_DIFFERENT_VERSOR_PAIR_AMOUNT; i++) {
if (bgc_versor_are_close_fp64(&_TEST_FP64_DIFFERENT_VERSOR_PAIR_LIST[i].first, &_TEST_FP64_DIFFERENT_VERSOR_PAIR_LIST[i].second)) { if (bgc_fp64_versor_are_close(&_TEST_FP64_DIFFERENT_VERSOR_PAIR_LIST[i].first, &_TEST_FP64_DIFFERENT_VERSOR_PAIR_LIST[i].second)) {
print_testing_error("A pair of different versors was recognized as close versors"); print_testing_error("A pair of different versors was recognized as close versors");
return; return;
} }

View file

@ -38,14 +38,14 @@ static const TestVersorTripletFP32 _TEST_FP32_VERSOR_TRIPLET_LIST[] = {
void test_versor_combine_fp32() void test_versor_combine_fp32()
{ {
BgcVersorFP32 versor; BGC_FP32_Versor versor;
print_testing_name("bgc_versor_combine_fp32"); print_testing_name("bgc_fp32_versor_combine");
for (int i = 0; i < _TEST_FP32_VERSOR_TRIPLET_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_VERSOR_TRIPLET_AMOUNT; i++) {
bgc_versor_combine_fp32(&_TEST_FP32_VERSOR_TRIPLET_LIST[i].first, &_TEST_FP32_VERSOR_TRIPLET_LIST[i].second, &versor); bgc_fp32_versor_combine(&_TEST_FP32_VERSOR_TRIPLET_LIST[i].first, &_TEST_FP32_VERSOR_TRIPLET_LIST[i].second, &versor);
if (!bgc_versor_are_close_fp32(&versor, &_TEST_FP32_VERSOR_TRIPLET_LIST[i].result)) { if (!bgc_fp32_versor_are_close(&versor, &_TEST_FP32_VERSOR_TRIPLET_LIST[i].result)) {
print_testing_failed(); print_testing_failed();
return; return;
} }
@ -88,14 +88,14 @@ static const TestVersorTripletFP64 _TEST_FP64_VERSOR_TRIPLET_LIST[] = {
void test_versor_combine_fp64() void test_versor_combine_fp64()
{ {
BgcVersorFP64 versor; BGC_FP64_Versor versor;
print_testing_name("bgc_versor_combine_fp64"); print_testing_name("bgc_fp64_versor_combine");
for (int i = 0; i < _TEST_FP64_VERSOR_TRIPLET_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_VERSOR_TRIPLET_AMOUNT; i++) {
bgc_versor_combine_fp64(&_TEST_FP64_VERSOR_TRIPLET_LIST[i].first, &_TEST_FP64_VERSOR_TRIPLET_LIST[i].second, &versor); bgc_fp64_versor_combine(&_TEST_FP64_VERSOR_TRIPLET_LIST[i].first, &_TEST_FP64_VERSOR_TRIPLET_LIST[i].second, &versor);
if (!bgc_versor_are_close_fp64(&versor, &_TEST_FP64_VERSOR_TRIPLET_LIST[i].result)) { if (!bgc_fp64_versor_are_close(&versor, &_TEST_FP64_VERSOR_TRIPLET_LIST[i].result)) {
print_testing_failed(); print_testing_failed();
return; return;
} }

View file

@ -7,7 +7,7 @@
// ==================== FP32 ==================== // // ==================== FP32 ==================== //
static const int _TEST_FP32_VERSOR_AMOUNT = 8; static const int _TEST_FP32_VERSOR_AMOUNT = 8;
static const BgcVersorFP32 _TEST_FP32_VERSOR_LIST[] = { static const BGC_FP32_Versor _TEST_FP32_VERSOR_LIST[] = {
{ 1.0f, 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f, 0.0f },
{ -1.0f, 0.0f, 0.0f, 0.0f }, { -1.0f, 0.0f, 0.0f, 0.0f },
{ 0.182574185835f, 0.36514837167f, 0.54772255751f, 0.73029674334f }, { 0.182574185835f, 0.36514837167f, 0.54772255751f, 0.73029674334f },
@ -20,13 +20,13 @@ static const BgcVersorFP32 _TEST_FP32_VERSOR_LIST[] = {
void test_versor_copy_fp32() void test_versor_copy_fp32()
{ {
BgcVersorFP32 versor; BGC_FP32_Versor versor;
print_testing_name("bgc_versor_copy_fp32"); print_testing_name("bgc_fp32_versor_copy");
for (int i = 0; i < _TEST_FP32_VERSOR_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_VERSOR_AMOUNT; i++) {
bgc_versor_copy_fp32(&_TEST_FP32_VERSOR_LIST[i], &versor); bgc_fp32_versor_copy(&_TEST_FP32_VERSOR_LIST[i], &versor);
if (versor._s0 != _TEST_FP32_VERSOR_LIST[i]._s0 || if (versor._s0 != _TEST_FP32_VERSOR_LIST[i]._s0 ||
versor._x1 != _TEST_FP32_VERSOR_LIST[i]._x1 || versor._x1 != _TEST_FP32_VERSOR_LIST[i]._x1 ||
@ -43,7 +43,7 @@ void test_versor_copy_fp32()
// ==================== FP64 ==================== // // ==================== FP64 ==================== //
static const int _TEST_FP64_VERSOR_AMOUNT = 8; static const int _TEST_FP64_VERSOR_AMOUNT = 8;
static const BgcVersorFP64 _TEST_FP64_VERSOR_LIST[] = { static const BGC_FP64_Versor _TEST_FP64_VERSOR_LIST[] = {
{ 1.0f, 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f, 0.0f },
{ -1.0f, 0.0f, 0.0f, 0.0f }, { -1.0f, 0.0f, 0.0f, 0.0f },
{ 0.1825741858350553712, 0.3651483716701107423, 0.5477225575051661135, 0.7302967433402214846 }, { 0.1825741858350553712, 0.3651483716701107423, 0.5477225575051661135, 0.7302967433402214846 },
@ -56,13 +56,13 @@ static const BgcVersorFP64 _TEST_FP64_VERSOR_LIST[] = {
void test_versor_copy_fp64() void test_versor_copy_fp64()
{ {
BgcVersorFP64 versor; BGC_FP64_Versor versor;
print_testing_name("bgc_versor_copy_fp64"); print_testing_name("bgc_fp64_versor_copy");
for (int i = 0; i < _TEST_FP64_VERSOR_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_VERSOR_AMOUNT; i++) {
bgc_versor_copy_fp64(&_TEST_FP64_VERSOR_LIST[i], &versor); bgc_fp64_versor_copy(&_TEST_FP64_VERSOR_LIST[i], &versor);
if (versor._s0 != _TEST_FP64_VERSOR_LIST[i]._s0 || if (versor._s0 != _TEST_FP64_VERSOR_LIST[i]._s0 ||
versor._x1 != _TEST_FP64_VERSOR_LIST[i]._x1 || versor._x1 != _TEST_FP64_VERSOR_LIST[i]._x1 ||

View file

@ -7,33 +7,33 @@
static const int _TEST_FP32_IDENTIYTY_VERSOR_AMOUNT = 9; static const int _TEST_FP32_IDENTIYTY_VERSOR_AMOUNT = 9;
static const int _TEST_FP32_NON_IDENTIYTY_VERSOR_AMOUNT = 5; static const int _TEST_FP32_NON_IDENTIYTY_VERSOR_AMOUNT = 5;
static const BgcVersorFP32 _TEST_FP32_IDENTIYTY_VERSOR_LIST[] = { static const BGC_FP32_Versor _TEST_FP32_IDENTIYTY_VERSOR_LIST[] = {
{ 1.0f, 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f, 0.0f },
{ 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, { 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, { 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f },
{ 1.0f, 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 1.0f, 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 1.0f, -0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 1.0f, -0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f },
{ 1.0f, 0.0f, 0.75f * BGC_EPSYLON_FP32, 0.0f }, { 1.0f, 0.0f, 0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 1.0f, 0.0f, -0.75f * BGC_EPSYLON_FP32, 0.0f }, { 1.0f, 0.0f, -0.75f * BGC_FP32_EPSYLON, 0.0f },
{ 1.0f, 0.0f, 0.0f, 0.75f * BGC_EPSYLON_FP32 }, { 1.0f, 0.0f, 0.0f, 0.75f * BGC_FP32_EPSYLON },
{ 1.0f, 0.0f, 0.0f, -0.75f * BGC_EPSYLON_FP32 } { 1.0f, 0.0f, 0.0f, -0.75f * BGC_FP32_EPSYLON }
}; };
static const BgcVersorFP32 _TEST_FP32_NON_IDENTIYTY_VERSOR_LIST[] = { static const BGC_FP32_Versor _TEST_FP32_NON_IDENTIYTY_VERSOR_LIST[] = {
{ 0.0f, 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f }, { 0.0f, 0.0f, 0.0f, 1.0f },
{ 0.5f, 0.5f, 0.5f, 0.5f }, { 0.5f, 0.5f, 0.5f, 0.5f },
{ 1.0f, -1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f } { 1.0f, -1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f }
}; };
void test_versor_is_identity_fp32() void test_versor_is_identity_fp32()
{ {
print_testing_name("bgc_versor_is_identity_fp32"); print_testing_name("bgc_fp32_versor_is_idle");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP32_IDENTIYTY_VERSOR_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_IDENTIYTY_VERSOR_AMOUNT; i++) {
if (!bgc_versor_is_identity_fp32(&_TEST_FP32_IDENTIYTY_VERSOR_LIST[i])) { if (!bgc_fp32_versor_is_idle(&_TEST_FP32_IDENTIYTY_VERSOR_LIST[i])) {
print_testing_error("An identity versor was not recognized"); print_testing_error("An identity versor was not recognized");
return; return;
} }
@ -41,7 +41,7 @@ void test_versor_is_identity_fp32()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NON_IDENTIYTY_VERSOR_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_NON_IDENTIYTY_VERSOR_AMOUNT; i++) {
if (bgc_versor_is_identity_fp32(&_TEST_FP32_NON_IDENTIYTY_VERSOR_LIST[i])) { if (bgc_fp32_versor_is_idle(&_TEST_FP32_NON_IDENTIYTY_VERSOR_LIST[i])) {
print_testing_error("A non-identity versor was recognized as an identity versor"); print_testing_error("A non-identity versor was recognized as an identity versor");
return; return;
} }
@ -55,33 +55,33 @@ void test_versor_is_identity_fp32()
static const int _TEST_FP64_IDENTIYTY_VERSOR_AMOUNT = 9; static const int _TEST_FP64_IDENTIYTY_VERSOR_AMOUNT = 9;
static const int _TEST_FP64_NON_IDENTIYTY_VERSOR_AMOUNT = 5; static const int _TEST_FP64_NON_IDENTIYTY_VERSOR_AMOUNT = 5;
static const BgcVersorFP64 _TEST_FP64_IDENTIYTY_VERSOR_LIST[] = { static const BGC_FP64_Versor _TEST_FP64_IDENTIYTY_VERSOR_LIST[] = {
{ 1.0, 0.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0, 0.0 },
{ 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, { 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, { 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 },
{ 1.0, -0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 1.0, -0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 1.0, 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 1.0, 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 },
{ 1.0, 0.0, 0.75 * BGC_EPSYLON_FP64, 0.0 }, { 1.0, 0.0, 0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 1.0, 0.0, -0.75 * BGC_EPSYLON_FP64, 0.0 }, { 1.0, 0.0, -0.75 * BGC_FP64_EPSYLON, 0.0 },
{ 1.0, 0.0, 0.0, 0.75 * BGC_EPSYLON_FP64 }, { 1.0, 0.0, 0.0, 0.75 * BGC_FP64_EPSYLON },
{ 1.0, 0.0, 0.0, -0.75 * BGC_EPSYLON_FP64 } { 1.0, 0.0, 0.0, -0.75 * BGC_FP64_EPSYLON }
}; };
static const BgcVersorFP64 _TEST_FP64_NON_IDENTIYTY_VERSOR_LIST[] = { static const BGC_FP64_Versor _TEST_FP64_NON_IDENTIYTY_VERSOR_LIST[] = {
{ 0.0, 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0, 0.0 },
{ 0.0, 0.0, 1.0, 0.0 }, { 0.0, 0.0, 1.0, 0.0 },
{ 0.0, 0.0, 0.0, 1.0 }, { 0.0, 0.0, 0.0, 1.0 },
{ 0.5, 0.5, 0.5, 0.5 }, { 0.5, 0.5, 0.5, 0.5 },
{ 1.0, 0.0, 1.25 * BGC_EPSYLON_FP64, 0.0 } { 1.0, 0.0, 1.25 * BGC_FP64_EPSYLON, 0.0 }
}; };
void test_versor_is_identity_fp64() void test_versor_is_identity_fp64()
{ {
print_testing_name("bgc_versor_is_identity_fp64"); print_testing_name("bgc_fp64_versor_is_idle");
// Testing zero values: // Testing zero values:
for (int i = 0; i < _TEST_FP64_IDENTIYTY_VERSOR_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_IDENTIYTY_VERSOR_AMOUNT; i++) {
if (!bgc_versor_is_identity_fp64(&_TEST_FP64_IDENTIYTY_VERSOR_LIST[i])) { if (!bgc_fp64_versor_is_idle(&_TEST_FP64_IDENTIYTY_VERSOR_LIST[i])) {
print_testing_error("An identity versor was not recognized"); print_testing_error("An identity versor was not recognized");
return; return;
} }
@ -89,7 +89,7 @@ void test_versor_is_identity_fp64()
// Testing non-zero values: // Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NON_IDENTIYTY_VERSOR_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_NON_IDENTIYTY_VERSOR_AMOUNT; i++) {
if (bgc_versor_is_identity_fp64(&_TEST_FP64_NON_IDENTIYTY_VERSOR_LIST[i])) { if (bgc_fp64_versor_is_idle(&_TEST_FP64_NON_IDENTIYTY_VERSOR_LIST[i])) {
print_testing_error("A non-identity versor was recognized as an identity versor"); print_testing_error("A non-identity versor was recognized as an identity versor");
return; return;
} }

View file

@ -4,11 +4,11 @@
void test_versor_reset_fp32() void test_versor_reset_fp32()
{ {
BgcVersorFP32 versor; BGC_FP32_Versor versor;
print_testing_name("bgc_versor_reset_fp32"); print_testing_name("bgc_fp32_versor_reset");
bgc_versor_reset_fp32(&versor); bgc_fp32_versor_reset(&versor);
if (versor._s0 != 1.0f || versor._x1 != 0.0f || versor._x2 != 0.0f || versor._x3 != 0.0f) { if (versor._s0 != 1.0f || versor._x1 != 0.0f || versor._x2 != 0.0f || versor._x3 != 0.0f) {
print_testing_failed(); print_testing_failed();
@ -20,11 +20,11 @@ void test_versor_reset_fp32()
void test_versor_reset_fp64() void test_versor_reset_fp64()
{ {
BgcVersorFP64 versor; BGC_FP64_Versor versor;
print_testing_name("bgc_versor_reset_fp64"); print_testing_name("bgc_fp64_versor_reset");
bgc_versor_reset_fp64(&versor); bgc_fp64_versor_reset(&versor);
if (versor._s0 != 1.0 || versor._x1 != 0.0 || versor._x2 != 0.0 || versor._x3 != 0.0) { if (versor._s0 != 1.0 || versor._x1 != 0.0 || versor._x2 != 0.0 || versor._x3 != 0.0) {
print_testing_failed(); print_testing_failed();

View file

@ -7,7 +7,7 @@
// ==================== FP32 ==================== // // ==================== FP32 ==================== //
static const int _TEST_FP32_VERSOR_DATA_AMOUNT = 4; static const int _TEST_FP32_VERSOR_DATA_AMOUNT = 4;
static const BgcQuaternionFP32 _TEST_FP32_VERSOR_DATA_LIST[] = { static const BGC_FP32_Quaternion _TEST_FP32_VERSOR_DATA_LIST[] = {
{ 1.0f, 2.0f, 3.0f, 4.0f }, { 1.0f, 2.0f, 3.0f, 4.0f },
{ 4.0f, 3.0f, 2.0f, 1.0f }, { 4.0f, 3.0f, 2.0f, 1.0f },
{ -1.0f, 0.0f, 0.0f, 0.0f }, { -1.0f, 0.0f, 0.0f, 0.0f },
@ -17,12 +17,12 @@ static const BgcQuaternionFP32 _TEST_FP32_VERSOR_DATA_LIST[] = {
void test_versor_set_values_fp32() void test_versor_set_values_fp32()
{ {
float versor_module, ratio; float versor_module, ratio;
BgcVersorFP32 versor; BGC_FP32_Versor versor;
print_testing_name("bgc_versor_set_values_fp32"); print_testing_name("bgc_fp32_versor_make");
for (int i = 0; i < _TEST_FP32_VERSOR_DATA_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_VERSOR_DATA_AMOUNT; i++) {
bgc_versor_set_values_fp32( bgc_fp32_versor_make(
_TEST_FP32_VERSOR_DATA_LIST[i].s0, _TEST_FP32_VERSOR_DATA_LIST[i].s0,
_TEST_FP32_VERSOR_DATA_LIST[i].x1, _TEST_FP32_VERSOR_DATA_LIST[i].x1,
_TEST_FP32_VERSOR_DATA_LIST[i].x2, _TEST_FP32_VERSOR_DATA_LIST[i].x2,
@ -32,28 +32,28 @@ void test_versor_set_values_fp32()
versor_module = sqrtf(versor._s0 * versor._s0 + versor._x1 * versor._x1 + versor._x2 * versor._x2 + versor._x3 * versor._x3); versor_module = sqrtf(versor._s0 * versor._s0 + versor._x1 * versor._x1 + versor._x2 * versor._x2 + versor._x3 * versor._x3);
if (!bgc_is_unit_fp32(versor_module)) { if (!bgc_fp32_is_unit(versor_module)) {
print_testing_error("Versor module is not equal to one."); print_testing_error("Versor module is not equal to one.");
return; return;
} }
if (bgc_is_zero_fp32(_TEST_FP32_VERSOR_DATA_LIST[i].s0)) { if (bgc_fp32_is_zero(_TEST_FP32_VERSOR_DATA_LIST[i].s0)) {
continue; continue;
} }
ratio = _TEST_FP32_VERSOR_DATA_LIST[i].s0 / versor._s0; ratio = _TEST_FP32_VERSOR_DATA_LIST[i].s0 / versor._s0;
if (!bgc_is_zero_fp32(_TEST_FP32_VERSOR_DATA_LIST[i].x1) && !bgc_are_close_fp32(ratio, _TEST_FP32_VERSOR_DATA_LIST[i].x1 / versor._x1)) { if (!bgc_fp32_is_zero(_TEST_FP32_VERSOR_DATA_LIST[i].x1) && !bgc_fp32_are_close(ratio, _TEST_FP32_VERSOR_DATA_LIST[i].x1 / versor._x1)) {
print_testing_error("Versor was not normalized proportionally (x1)."); print_testing_error("Versor was not normalized proportionally (x1).");
return; return;
} }
if (!bgc_is_zero_fp32(_TEST_FP32_VERSOR_DATA_LIST[i].x2) && !bgc_are_close_fp32(ratio, _TEST_FP32_VERSOR_DATA_LIST[i].x2 / versor._x2)) { if (!bgc_fp32_is_zero(_TEST_FP32_VERSOR_DATA_LIST[i].x2) && !bgc_fp32_are_close(ratio, _TEST_FP32_VERSOR_DATA_LIST[i].x2 / versor._x2)) {
print_testing_error("Versor was not normalized proportionally (x2)."); print_testing_error("Versor was not normalized proportionally (x2).");
return; return;
} }
if (!bgc_is_zero_fp32(_TEST_FP32_VERSOR_DATA_LIST[i].x3) && !bgc_are_close_fp32(ratio, _TEST_FP32_VERSOR_DATA_LIST[i].x3 / versor._x3)) { if (!bgc_fp32_is_zero(_TEST_FP32_VERSOR_DATA_LIST[i].x3) && !bgc_fp32_are_close(ratio, _TEST_FP32_VERSOR_DATA_LIST[i].x3 / versor._x3)) {
print_testing_error("Versor was not normalized proportionally (x3)."); print_testing_error("Versor was not normalized proportionally (x3).");
return; return;
} }
@ -65,7 +65,7 @@ void test_versor_set_values_fp32()
// ==================== FP64 ==================== // // ==================== FP64 ==================== //
static const int _TEST_FP64_VERSOR_DATA_AMOUNT = 4; static const int _TEST_FP64_VERSOR_DATA_AMOUNT = 4;
static const BgcQuaternionFP64 _TEST_FP64_VERSOR_DATA_LIST[] = { static const BGC_FP64_Quaternion _TEST_FP64_VERSOR_DATA_LIST[] = {
{ 1.0, 2.0, 3.0, 4.0 }, { 1.0, 2.0, 3.0, 4.0 },
{ 4.0, 3.0, 2.0, 1.0 }, { 4.0, 3.0, 2.0, 1.0 },
{ -1.0, 0.0, 0.0, 0.0 }, { -1.0, 0.0, 0.0, 0.0 },
@ -75,12 +75,12 @@ static const BgcQuaternionFP64 _TEST_FP64_VERSOR_DATA_LIST[] = {
void test_versor_set_values_fp64() void test_versor_set_values_fp64()
{ {
double versor_module, ratio; double versor_module, ratio;
BgcVersorFP64 versor; BGC_FP64_Versor versor;
print_testing_name("bgc_versor_set_values_fp64"); print_testing_name("bgc_fp64_versor_make");
for (int i = 0; i < _TEST_FP64_VERSOR_DATA_AMOUNT; i++) { for (int i = 0; i < _TEST_FP64_VERSOR_DATA_AMOUNT; i++) {
bgc_versor_set_values_fp64( bgc_fp64_versor_make(
_TEST_FP64_VERSOR_DATA_LIST[i].s0, _TEST_FP64_VERSOR_DATA_LIST[i].s0,
_TEST_FP64_VERSOR_DATA_LIST[i].x1, _TEST_FP64_VERSOR_DATA_LIST[i].x1,
_TEST_FP64_VERSOR_DATA_LIST[i].x2, _TEST_FP64_VERSOR_DATA_LIST[i].x2,
@ -90,28 +90,28 @@ void test_versor_set_values_fp64()
versor_module = sqrt(versor._s0 * versor._s0 + versor._x1 * versor._x1 + versor._x2 * versor._x2 + versor._x3 * versor._x3); versor_module = sqrt(versor._s0 * versor._s0 + versor._x1 * versor._x1 + versor._x2 * versor._x2 + versor._x3 * versor._x3);
if (!bgc_is_unit_fp64(versor_module)) { if (!bgc_fp64_is_unit(versor_module)) {
print_testing_error("Versor module is not equal to one."); print_testing_error("Versor module is not equal to one.");
return; return;
} }
if (bgc_is_zero_fp64(_TEST_FP64_VERSOR_DATA_LIST[i].s0)) { if (bgc_fp64_is_zero(_TEST_FP64_VERSOR_DATA_LIST[i].s0)) {
continue; continue;
} }
ratio = _TEST_FP64_VERSOR_DATA_LIST[i].s0 / versor._s0; ratio = _TEST_FP64_VERSOR_DATA_LIST[i].s0 / versor._s0;
if (!bgc_is_zero_fp64(_TEST_FP64_VERSOR_DATA_LIST[i].x1) && !bgc_are_close_fp64(ratio, _TEST_FP64_VERSOR_DATA_LIST[i].x1 / versor._x1)) { if (!bgc_fp64_is_zero(_TEST_FP64_VERSOR_DATA_LIST[i].x1) && !bgc_fp64_are_close(ratio, _TEST_FP64_VERSOR_DATA_LIST[i].x1 / versor._x1)) {
print_testing_error("Versor was not normalized proportionally (x1)."); print_testing_error("Versor was not normalized proportionally (x1).");
return; return;
} }
if (!bgc_is_zero_fp64(_TEST_FP64_VERSOR_DATA_LIST[i].x2) && !bgc_are_close_fp64(ratio, _TEST_FP64_VERSOR_DATA_LIST[i].x2 / versor._x2)) { if (!bgc_fp64_is_zero(_TEST_FP64_VERSOR_DATA_LIST[i].x2) && !bgc_fp64_are_close(ratio, _TEST_FP64_VERSOR_DATA_LIST[i].x2 / versor._x2)) {
print_testing_error("Versor was not normalized proportionally (x2)."); print_testing_error("Versor was not normalized proportionally (x2).");
return; return;
} }
if (!bgc_is_zero_fp64(_TEST_FP64_VERSOR_DATA_LIST[i].x3) && !bgc_are_close_fp64(ratio, _TEST_FP64_VERSOR_DATA_LIST[i].x3 / versor._x3)) { if (!bgc_fp64_is_zero(_TEST_FP64_VERSOR_DATA_LIST[i].x3) && !bgc_fp64_are_close(ratio, _TEST_FP64_VERSOR_DATA_LIST[i].x3 / versor._x3)) {
print_testing_error("Versor was not normalized proportionally (x3)."); print_testing_error("Versor was not normalized proportionally (x3).");
return; return;
} }

View file

@ -8,13 +8,13 @@
static const int _TEST_FP32_VERSOR_AMOUNT = 3; static const int _TEST_FP32_VERSOR_AMOUNT = 3;
static const BgcQuaternionFP32 _TEST_FP32_VERSOR_LIST1[] = { static const BGC_FP32_Quaternion _TEST_FP32_VERSOR_LIST1[] = {
{ 1.0f, 2.0f, 3.0f, 4.0f }, { 1.0f, 2.0f, 3.0f, 4.0f },
{ -4.0f, -3.0f, -2.0f, -1.0f }, { -4.0f, -3.0f, -2.0f, -1.0f },
{ 0.5f, -0.5f, -0.5f, -0.5f } { 0.5f, -0.5f, -0.5f, -0.5f }
}; };
static const BgcQuaternionFP32 _TEST_FP32_VERSOR_LIST2[] = { static const BGC_FP32_Quaternion _TEST_FP32_VERSOR_LIST2[] = {
{ -0.5f, 0.5f, 0.5f, 0.5f }, { -0.5f, 0.5f, 0.5f, 0.5f },
{ -1.0f, -2.0f, -3.0f, -4.0f }, { -1.0f, -2.0f, -3.0f, -4.0f },
{ 4.0f, 3.0f, 2.0f, 1.0f } { 4.0f, 3.0f, 2.0f, 1.0f }
@ -22,12 +22,12 @@ static const BgcQuaternionFP32 _TEST_FP32_VERSOR_LIST2[] = {
void test_versor_swap_fp32() void test_versor_swap_fp32()
{ {
BgcVersorFP32 versor1a, versor2a, versor1b, versor2b; BGC_FP32_Versor versor1a, versor2a, versor1b, versor2b;
print_testing_name("bgc_versor_swap_fp32"); print_testing_name("bgc_fp32_versor_swap");
for (int i = 0; i < _TEST_FP32_VERSOR_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_VERSOR_AMOUNT; i++) {
bgc_versor_set_values_fp32( bgc_fp32_versor_make(
_TEST_FP32_VERSOR_LIST1[i].s0, _TEST_FP32_VERSOR_LIST1[i].s0,
_TEST_FP32_VERSOR_LIST1[i].x1, _TEST_FP32_VERSOR_LIST1[i].x1,
_TEST_FP32_VERSOR_LIST1[i].x2, _TEST_FP32_VERSOR_LIST1[i].x2,
@ -35,7 +35,7 @@ void test_versor_swap_fp32()
&versor1a &versor1a
); );
bgc_versor_set_values_fp32( bgc_fp32_versor_make(
_TEST_FP32_VERSOR_LIST2[i].s0, _TEST_FP32_VERSOR_LIST2[i].s0,
_TEST_FP32_VERSOR_LIST2[i].x1, _TEST_FP32_VERSOR_LIST2[i].x1,
_TEST_FP32_VERSOR_LIST2[i].x2, _TEST_FP32_VERSOR_LIST2[i].x2,
@ -43,10 +43,10 @@ void test_versor_swap_fp32()
&versor2a &versor2a
); );
bgc_versor_copy_fp32(&versor1a, &versor1b); bgc_fp32_versor_copy(&versor1a, &versor1b);
bgc_versor_copy_fp32(&versor2a, &versor2b); bgc_fp32_versor_copy(&versor2a, &versor2b);
bgc_versor_swap_fp32(&versor1b, &versor2b); bgc_fp32_versor_swap(&versor1b, &versor2b);
if (versor1a._s0 != versor2b._s0 || versor1a._x1 != versor2b._x1 || versor1a._x2 != versor2b._x2 || versor1a._x3 != versor2b._x3 || if (versor1a._s0 != versor2b._s0 || versor1a._x1 != versor2b._x1 || versor1a._x2 != versor2b._x2 || versor1a._x3 != versor2b._x3 ||
versor2a._s0 != versor1b._s0 || versor2a._x1 != versor1b._x1 || versor2a._x2 != versor1b._x2 || versor2a._x3 != versor1b._x3) { versor2a._s0 != versor1b._s0 || versor2a._x1 != versor1b._x1 || versor2a._x2 != versor1b._x2 || versor2a._x3 != versor1b._x3) {
@ -62,12 +62,12 @@ void test_versor_swap_fp32()
void test_versor_swap_fp64() void test_versor_swap_fp64()
{ {
BgcVersorFP64 versor1a, versor2a, versor1b, versor2b; BGC_FP64_Versor versor1a, versor2a, versor1b, versor2b;
print_testing_name("bgc_versor_swap_fp64"); print_testing_name("bgc_fp64_versor_swap");
for (int i = 0; i < _TEST_FP32_VERSOR_AMOUNT; i++) { for (int i = 0; i < _TEST_FP32_VERSOR_AMOUNT; i++) {
bgc_versor_set_values_fp64( bgc_fp64_versor_make(
_TEST_FP32_VERSOR_LIST1[i].s0, _TEST_FP32_VERSOR_LIST1[i].s0,
_TEST_FP32_VERSOR_LIST1[i].x1, _TEST_FP32_VERSOR_LIST1[i].x1,
_TEST_FP32_VERSOR_LIST1[i].x2, _TEST_FP32_VERSOR_LIST1[i].x2,
@ -75,7 +75,7 @@ void test_versor_swap_fp64()
&versor1a &versor1a
); );
bgc_versor_set_values_fp64( bgc_fp64_versor_make(
_TEST_FP32_VERSOR_LIST2[i].s0, _TEST_FP32_VERSOR_LIST2[i].s0,
_TEST_FP32_VERSOR_LIST2[i].x1, _TEST_FP32_VERSOR_LIST2[i].x1,
_TEST_FP32_VERSOR_LIST2[i].x2, _TEST_FP32_VERSOR_LIST2[i].x2,
@ -83,10 +83,10 @@ void test_versor_swap_fp64()
&versor2a &versor2a
); );
bgc_versor_copy_fp64(&versor1a, &versor1b); bgc_fp64_versor_copy(&versor1a, &versor1b);
bgc_versor_copy_fp64(&versor2a, &versor2b); bgc_fp64_versor_copy(&versor2a, &versor2b);
bgc_versor_swap_fp64(&versor1b, &versor2b); bgc_fp64_versor_swap(&versor1b, &versor2b);
if (versor1a._s0 != versor2b._s0 || versor1a._x1 != versor2b._x1 || versor1a._x2 != versor2b._x2 || versor1a._x3 != versor2b._x3 || if (versor1a._s0 != versor2b._s0 || versor1a._x1 != versor2b._x1 || versor1a._x2 != versor2b._x2 || versor1a._x3 != versor2b._x3 ||
versor2a._s0 != versor1b._s0 || versor2a._x1 != versor1b._x1 || versor2a._x2 != versor1b._x2 || versor2a._x3 != versor1b._x3) { versor2a._s0 != versor1b._s0 || versor2a._x1 != versor1b._x1 || versor2a._x2 != versor1b._x2 || versor2a._x3 != versor1b._x3) {

View file

@ -1,28 +1,31 @@
#include "affine2.h" #include "affine2.h"
extern inline void bgc_affine2_reset_fp32(BgcAffine2FP32 * affine); extern inline void bgc_fp32_affine2_reset(BGC_FP32_Affine2 * affine);
extern inline void bgc_affine2_reset_fp64(BgcAffine2FP64 * affine); extern inline void bgc_fp64_affine2_reset(BGC_FP64_Affine2 * affine);
extern inline void bgc_affine2_make_fp32(const BgcMatrix2x2FP32 * distortion, const BgcVector2FP32 * shift, BgcAffine2FP32 * affine); extern inline void bgc_fp32_affine2_make(const BGC_FP32_Matrix2x2 * distortion, const BGC_FP32_Vector2 * shift, BGC_FP32_Affine2 * affine);
extern inline void bgc_affine2_make_fp64(const BgcMatrix2x2FP64 * distortion, const BgcVector2FP64 * shift, BgcAffine2FP64 * affine); extern inline void bgc_fp64_affine2_make(const BGC_FP64_Matrix2x2 * distortion, const BGC_FP64_Vector2 * shift, BGC_FP64_Affine2 * affine);
extern inline void bgc_affine2_copy_fp32(const BgcAffine2FP32 * source, BgcAffine2FP32 * destination); extern inline void bgc_fp32_affine2_copy(const BGC_FP32_Affine2 * source, BGC_FP32_Affine2 * destination);
extern inline void bgc_affine2_copy_fp64(const BgcAffine2FP64 * source, BgcAffine2FP64 * destination); extern inline void bgc_fp64_affine2_copy(const BGC_FP64_Affine2 * source, BGC_FP64_Affine2 * destination);
extern inline void bgc_affine2_convert_fp64_to_fp32(const BgcAffine2FP64 * source, BgcAffine2FP32 * destination); extern inline void bgc_fp32_affine2_swap(BGC_FP32_Affine2 * first, BGC_FP32_Affine2 * second);
extern inline void bgc_affine2_convert_fp32_to_fp64(const BgcAffine2FP32 * source, BgcAffine2FP64 * destination); extern inline void bgc_fp64_affine2_swap(BGC_FP64_Affine2 * first, BGC_FP64_Affine2 * second);
extern inline int bgc_affine2_invert_fp32(BgcAffine2FP32 * affine); extern inline void bgc_fp64_affine2_convert_to_fp32(const BGC_FP64_Affine2 * source, BGC_FP32_Affine2 * destination);
extern inline int bgc_affine2_invert_fp64(BgcAffine2FP64 * affine); extern inline void bgc_fp32_affine2_convert_to_fp64(const BGC_FP32_Affine2 * source, BGC_FP64_Affine2 * destination);
extern inline int bgc_affine2_get_inverse_fp32(const BgcAffine2FP32 * source, BgcAffine2FP32 * destination); extern inline int bgc_fp32_affine2_invert(BGC_FP32_Affine2 * affine);
extern inline int bgc_affine2_get_inverse_fp64(const BgcAffine2FP64 * source, BgcAffine2FP64 * destination); extern inline int bgc_fp64_affine2_invert(BGC_FP64_Affine2 * affine);
extern inline void bgc_affine2_combine_fp32(const BgcAffine2FP32 * first, const BgcAffine2FP32 * second, BgcAffine2FP32 * combination); extern inline int bgc_fp32_affine2_get_inverse(const BGC_FP32_Affine2 * source, BGC_FP32_Affine2 * destination);
extern inline void bgc_affine2_combine_fp64(const BgcAffine2FP64 * first, const BgcAffine2FP64 * second, BgcAffine2FP64 * combination); extern inline int bgc_fp64_affine2_get_inverse(const BGC_FP64_Affine2 * source, BGC_FP64_Affine2 * destination);
extern inline void bgc_affine2_transform_point_fp32(const BgcAffine2FP32 * affine, const BgcVector2FP32 * initial_point, BgcVector2FP32 * transformed_point); extern inline void bgc_fp32_affine2_combine(const BGC_FP32_Affine2 * first, const BGC_FP32_Affine2 * second, BGC_FP32_Affine2 * combination);
extern inline void bgc_affine2_transform_point_fp64(const BgcAffine2FP64 * affine, const BgcVector2FP64 * initial_point, BgcVector2FP64 * transformed_point); extern inline void bgc_fp64_affine2_combine(const BGC_FP64_Affine2 * first, const BGC_FP64_Affine2 * second, BGC_FP64_Affine2 * combination);
extern inline void bgc_affine2_transform_vector_fp32(const BgcAffine2FP32 * affine, const BgcVector2FP32 * initial_vector, BgcVector2FP32 * transformed_vector); extern inline void bgc_fp32_affine2_transform_point(const BGC_FP32_Affine2 * affine, const BGC_FP32_Vector2 * initial_point, BGC_FP32_Vector2 * transformed_point);
extern inline void bgc_affine2_transform_vector_fp64(const BgcAffine2FP64 * affine, const BgcVector2FP64 * initial_vector, BgcVector2FP64 * transformed_vector); extern inline void bgc_fp64_affine2_transform_point(const BGC_FP64_Affine2 * affine, const BGC_FP64_Vector2 * initial_point, BGC_FP64_Vector2 * transformed_point);
extern inline void bgc_fp32_affine2_transform_vector(const BGC_FP32_Affine2 * affine, const BGC_FP32_Vector2 * initial_vector, BGC_FP32_Vector2 * transformed_vector);
extern inline void bgc_fp64_affine2_transform_vector(const BGC_FP64_Affine2 * affine, const BGC_FP64_Vector2 * initial_vector, BGC_FP64_Vector2 * transformed_vector);

View file

@ -8,168 +8,182 @@
// ==================== Types ==================== // // ==================== Types ==================== //
typedef struct { typedef struct {
BgcMatrix2x2FP32 distortion; BGC_FP32_Matrix2x2 distortion;
BgcVector2FP32 shift; BGC_FP32_Vector2 shift;
} BgcAffine2FP32; } BGC_FP32_Affine2;
typedef struct { typedef struct {
BgcMatrix2x2FP64 distortion; BGC_FP64_Matrix2x2 distortion;
BgcVector2FP64 shift; BGC_FP64_Vector2 shift;
} BgcAffine2FP64; } BGC_FP64_Affine2;
// ==================== Reset ==================== // // ==================== Reset ==================== //
inline void bgc_affine2_reset_fp32(BgcAffine2FP32 * affine) inline void bgc_fp32_affine2_reset(BGC_FP32_Affine2 * affine)
{ {
bgc_matrix2x2_set_to_identity_fp32(&affine->distortion); bgc_fp32_matrix2x2_make_identity(&affine->distortion);
bgc_vector2_reset_fp32(&affine->shift); bgc_fp32_vector2_reset(&affine->shift);
} }
inline void bgc_affine2_reset_fp64(BgcAffine2FP64 * affine) inline void bgc_fp64_affine2_reset(BGC_FP64_Affine2 * affine)
{ {
bgc_matrix2x2_set_to_identity_fp64(&affine->distortion); bgc_fp64_matrix2x2_make_identity(&affine->distortion);
bgc_vector2_reset_fp64(&affine->shift); bgc_fp64_vector2_reset(&affine->shift);
} }
// ==================== Make ===================== // // ==================== Make ===================== //
inline void bgc_affine2_make_fp32(const BgcMatrix2x2FP32 * distortion, const BgcVector2FP32 * shift, BgcAffine2FP32 * affine) inline void bgc_fp32_affine2_make(const BGC_FP32_Matrix2x2 * distortion, const BGC_FP32_Vector2 * shift, BGC_FP32_Affine2 * affine)
{ {
bgc_matrix2x2_copy_fp32(distortion, &affine->distortion); bgc_fp32_matrix2x2_copy(distortion, &affine->distortion);
bgc_vector2_copy_fp32(shift, &affine->shift); bgc_fp32_vector2_copy(shift, &affine->shift);
} }
inline void bgc_affine2_make_fp64(const BgcMatrix2x2FP64 * distortion, const BgcVector2FP64 * shift, BgcAffine2FP64 * affine) inline void bgc_fp64_affine2_make(const BGC_FP64_Matrix2x2 * distortion, const BGC_FP64_Vector2 * shift, BGC_FP64_Affine2 * affine)
{ {
bgc_matrix2x2_copy_fp64(distortion, &affine->distortion); bgc_fp64_matrix2x2_copy(distortion, &affine->distortion);
bgc_vector2_copy_fp64(shift, &affine->shift); bgc_fp64_vector2_copy(shift, &affine->shift);
} }
// ==================== Copy ===================== // // ==================== Copy ===================== //
inline void bgc_affine2_copy_fp32(const BgcAffine2FP32 * source, BgcAffine2FP32 * destination) inline void bgc_fp32_affine2_copy(const BGC_FP32_Affine2 * source, BGC_FP32_Affine2 * destination)
{ {
bgc_matrix2x2_copy_fp32(&source->distortion, &destination->distortion); bgc_fp32_matrix2x2_copy(&source->distortion, &destination->distortion);
bgc_vector2_copy_fp32(&source->shift, &destination->shift); bgc_fp32_vector2_copy(&source->shift, &destination->shift);
} }
inline void bgc_affine2_copy_fp64(const BgcAffine2FP64 * source, BgcAffine2FP64 * destination) inline void bgc_fp64_affine2_copy(const BGC_FP64_Affine2 * source, BGC_FP64_Affine2 * destination)
{ {
bgc_matrix2x2_copy_fp64(&source->distortion, &destination->distortion); bgc_fp64_matrix2x2_copy(&source->distortion, &destination->distortion);
bgc_vector2_copy_fp64(&source->shift, &destination->shift); bgc_fp64_vector2_copy(&source->shift, &destination->shift);
}
// ==================== Swap ===================== //
inline void bgc_fp32_affine2_swap(BGC_FP32_Affine2 * first, BGC_FP32_Affine2 * second)
{
bgc_fp32_matrix2x2_swap(&first->distortion, &second->distortion);
bgc_fp32_vector2_swap(&first->shift, &second->shift);
}
inline void bgc_fp64_affine2_swap(BGC_FP64_Affine2 * first, BGC_FP64_Affine2 * second)
{
bgc_fp64_matrix2x2_swap(&first->distortion, &second->distortion);
bgc_fp64_vector2_swap(&first->shift, &second->shift);
} }
// =================== Convert =================== // // =================== Convert =================== //
inline void bgc_affine2_convert_fp64_to_fp32(const BgcAffine2FP64 * source, BgcAffine2FP32 * destination) inline void bgc_fp64_affine2_convert_to_fp32(const BGC_FP64_Affine2 * source, BGC_FP32_Affine2 * destination)
{ {
bgc_matrix2x2_convert_fp64_to_fp32(&source->distortion, &destination->distortion); bgc_fp64_matrix2x2_convert_to_fp32(&source->distortion, &destination->distortion);
bgc_vector2_convert_fp64_to_fp32(&source->shift, &destination->shift); bgc_fp64_vector2_convert_to_fp32(&source->shift, &destination->shift);
} }
inline void bgc_affine2_convert_fp32_to_fp64(const BgcAffine2FP32 * source, BgcAffine2FP64 * destination) inline void bgc_fp32_affine2_convert_to_fp64(const BGC_FP32_Affine2 * source, BGC_FP64_Affine2 * destination)
{ {
bgc_matrix2x2_convert_fp32_to_fp64(&source->distortion, &destination->distortion); bgc_fp32_matrix2x2_convert_to_fp64(&source->distortion, &destination->distortion);
bgc_vector2_convert_fp32_to_fp64(&source->shift, &destination->shift); bgc_fp32_vector2_convert_to_fp64(&source->shift, &destination->shift);
} }
// =================== Invert ==================== // // =================== Invert ==================== //
inline int bgc_affine2_invert_fp32(BgcAffine2FP32 * affine) inline int bgc_fp32_affine2_invert(BGC_FP32_Affine2 * affine)
{ {
if (!bgc_matrix2x2_invert_fp32(&affine->distortion, &affine->distortion)) { if (!bgc_fp32_matrix2x2_invert(&affine->distortion)) {
return 0; return 0;
} }
bgc_matrix2x2_get_right_product_fp32(&affine->distortion, &affine->shift, &affine->shift); bgc_fp32_multiply_matrix2x2_by_vector2(&affine->distortion, &affine->shift, &affine->shift);
bgc_vector2_make_opposite_fp32(&affine->shift); bgc_fp32_vector2_revert(&affine->shift);
return 1; return 1;
} }
inline int bgc_affine2_invert_fp64(BgcAffine2FP64 * affine) inline int bgc_fp64_affine2_invert(BGC_FP64_Affine2 * affine)
{ {
if (!bgc_matrix2x2_invert_fp64(&affine->distortion, &affine->distortion)) { if (!bgc_fp64_matrix2x2_invert(&affine->distortion)) {
return 0; return 0;
} }
bgc_matrix2x2_get_right_product_fp64(&affine->distortion, &affine->shift, &affine->shift); bgc_fp64_multiply_matrix2x2_by_vector2(&affine->distortion, &affine->shift, &affine->shift);
bgc_vector2_make_opposite_fp64(&affine->shift); bgc_fp64_vector2_revert(&affine->shift);
return 1; return 1;
} }
// ================= Get Inverse ================= // // ================= Get Inverse ================= //
inline int bgc_affine2_get_inverse_fp32(const BgcAffine2FP32 * source, BgcAffine2FP32 * destination) inline int bgc_fp32_affine2_get_inverse(const BGC_FP32_Affine2 * source, BGC_FP32_Affine2 * destination)
{ {
if (!bgc_matrix2x2_invert_fp32(&source->distortion, &destination->distortion)) { if (!bgc_fp32_matrix2x2_get_inverse(&source->distortion, &destination->distortion)) {
return 0; return 0;
} }
bgc_matrix2x2_get_right_product_fp32(&destination->distortion, &source->shift, &destination->shift); bgc_fp32_multiply_matrix2x2_by_vector2(&destination->distortion, &source->shift, &destination->shift);
bgc_vector2_make_opposite_fp32(&destination->shift); bgc_fp32_vector2_revert(&destination->shift);
return 1; return 1;
} }
inline int bgc_affine2_get_inverse_fp64(const BgcAffine2FP64 * source, BgcAffine2FP64 * destination) inline int bgc_fp64_affine2_get_inverse(const BGC_FP64_Affine2 * source, BGC_FP64_Affine2 * destination)
{ {
if (!bgc_matrix2x2_invert_fp64(&source->distortion, &destination->distortion)) { if (!bgc_fp64_matrix2x2_get_inverse(&source->distortion, &destination->distortion)) {
return 0; return 0;
} }
bgc_matrix2x2_get_right_product_fp64(&destination->distortion, &source->shift, &destination->shift); bgc_fp64_multiply_matrix2x2_by_vector2(&destination->distortion, &source->shift, &destination->shift);
bgc_vector2_make_opposite_fp64(&destination->shift); bgc_fp64_vector2_revert(&destination->shift);
return 1; return 1;
} }
// =================== Combine =================== // // =================== Combine =================== //
inline void bgc_affine2_combine_fp32(const BgcAffine2FP32 * first, const BgcAffine2FP32 * second, BgcAffine2FP32 * combination) inline void bgc_fp32_affine2_combine(const BGC_FP32_Affine2 * first, const BGC_FP32_Affine2 * second, BGC_FP32_Affine2 * combination)
{ {
BgcVector2FP32 first_shift; BGC_FP32_Vector2 first_shift;
bgc_matrix2x2_get_right_product_fp32(&second->distortion, &first->shift, &first_shift); bgc_fp32_multiply_matrix2x2_by_vector2(&second->distortion, &first->shift, &first_shift);
bgc_matrix_product_2x2_at_2x2_fp32(&second->distortion, &first->distortion, &combination->distortion); bgc_fp32_multiply_matrix2x2_by_matrix2x2(&second->distortion, &first->distortion, &combination->distortion);
bgc_vector2_add_fp32(&first_shift, &second->shift, &combination->shift); bgc_fp32_vector2_add(&first_shift, &second->shift, &combination->shift);
} }
inline void bgc_affine2_combine_fp64(const BgcAffine2FP64 * first, const BgcAffine2FP64 * second, BgcAffine2FP64 * combination) inline void bgc_fp64_affine2_combine(const BGC_FP64_Affine2 * first, const BGC_FP64_Affine2 * second, BGC_FP64_Affine2 * combination)
{ {
BgcVector2FP64 first_shift; BGC_FP64_Vector2 first_shift;
bgc_matrix2x2_get_right_product_fp64(&second->distortion, &first->shift, &first_shift); bgc_fp64_multiply_matrix2x2_by_vector2(&second->distortion, &first->shift, &first_shift);
bgc_matrix_product_2x2_at_2x2_fp64(&second->distortion, &first->distortion, &combination->distortion); bgc_fp64_multiply_matrix2x2_by_matrix2x2(&second->distortion, &first->distortion, &combination->distortion);
bgc_vector2_add_fp64(&first_shift, &second->shift, &combination->shift); bgc_fp64_vector2_add(&first_shift, &second->shift, &combination->shift);
} }
// =============== Transform Point =============== // // =============== Transform Point =============== //
inline void bgc_affine2_transform_point_fp32(const BgcAffine2FP32 * affine, const BgcVector2FP32 * initial_point, BgcVector2FP32 * transformed_point) inline void bgc_fp32_affine2_transform_point(const BGC_FP32_Affine2 * affine, const BGC_FP32_Vector2 * initial_point, BGC_FP32_Vector2 * transformed_point)
{ {
BgcVector2FP32 distorted; BGC_FP32_Vector2 distorted;
bgc_matrix2x2_get_right_product_fp32(&affine->distortion, initial_point, &distorted); bgc_fp32_multiply_matrix2x2_by_vector2(&affine->distortion, initial_point, &distorted);
bgc_vector2_add_fp32(&affine->shift, &distorted, transformed_point); bgc_fp32_vector2_add(&affine->shift, &distorted, transformed_point);
} }
inline void bgc_affine2_transform_point_fp64(const BgcAffine2FP64 * affine, const BgcVector2FP64 * initial_point, BgcVector2FP64 * transformed_point) inline void bgc_fp64_affine2_transform_point(const BGC_FP64_Affine2 * affine, const BGC_FP64_Vector2 * initial_point, BGC_FP64_Vector2 * transformed_point)
{ {
BgcVector2FP64 distorted; BGC_FP64_Vector2 distorted;
bgc_matrix2x2_get_right_product_fp64(&affine->distortion, initial_point, &distorted); bgc_fp64_multiply_matrix2x2_by_vector2(&affine->distortion, initial_point, &distorted);
bgc_vector2_add_fp64(&affine->shift, &distorted, transformed_point); bgc_fp64_vector2_add(&affine->shift, &distorted, transformed_point);
} }
// ============== Transform Vector =============== // // ============== Transform Vector =============== //
inline void bgc_affine2_transform_vector_fp32(const BgcAffine2FP32 * affine, const BgcVector2FP32 * initial_vector, BgcVector2FP32 * transformed_vector) inline void bgc_fp32_affine2_transform_vector(const BGC_FP32_Affine2 * affine, const BGC_FP32_Vector2 * initial_vector, BGC_FP32_Vector2 * transformed_vector)
{ {
bgc_matrix2x2_get_right_product_fp32(&affine->distortion, initial_vector, transformed_vector); bgc_fp32_multiply_matrix2x2_by_vector2(&affine->distortion, initial_vector, transformed_vector);
} }
inline void bgc_affine2_transform_vector_fp64(const BgcAffine2FP64 * affine, const BgcVector2FP64 * initial_vector, BgcVector2FP64 * transformed_vector) inline void bgc_fp64_affine2_transform_vector(const BGC_FP64_Affine2 * affine, const BGC_FP64_Vector2 * initial_vector, BGC_FP64_Vector2 * transformed_vector)
{ {
bgc_matrix2x2_get_right_product_fp64(&affine->distortion, initial_vector, transformed_vector); bgc_fp64_multiply_matrix2x2_by_vector2(&affine->distortion, initial_vector, transformed_vector);
} }
#endif #endif

View file

@ -1,28 +1,31 @@
#include "affine3.h" #include "affine3.h"
extern inline void bgc_affine3_reset_fp32(BgcAffine3FP32 * affine); extern inline void bgc_fp32_affine3_reset(BGC_FP32_Affine3 * affine);
extern inline void bgc_affine3_reset_fp64(BgcAffine3FP64 * affine); extern inline void bgc_fp64_affine3_reset(BGC_FP64_Affine3 * affine);
extern inline void bgc_affine3_make_fp32(const BgcMatrix3x3FP32 * distortion, const BgcVector3FP32 * shift, BgcAffine3FP32 * affine); extern inline void bgc_fp32_affine3_make(const BGC_FP32_Matrix3x3 * distortion, const BGC_FP32_Vector3 * shift, BGC_FP32_Affine3 * affine);
extern inline void bgc_affine3_make_fp64(const BgcMatrix3x3FP64 * distortion, const BgcVector3FP64 * shift, BgcAffine3FP64 * affine); extern inline void bgc_fp64_affine3_make(const BGC_FP64_Matrix3x3 * distortion, const BGC_FP64_Vector3 * shift, BGC_FP64_Affine3 * affine);
extern inline void bgc_affine3_copy_fp32(const BgcAffine3FP32 * source, BgcAffine3FP32 * destination); extern inline void bgc_fp32_affine3_copy(const BGC_FP32_Affine3 * source, BGC_FP32_Affine3 * destination);
extern inline void bgc_affine3_copy_fp64(const BgcAffine3FP64 * source, BgcAffine3FP64 * destination); extern inline void bgc_fp64_affine3_copy(const BGC_FP64_Affine3 * source, BGC_FP64_Affine3 * destination);
extern inline void bgc_affine3_convert_fp64_to_fp32(const BgcAffine3FP64 * source, BgcAffine3FP32 * destination); extern inline void bgc_fp32_affine3_swap(BGC_FP32_Affine3 * first, BGC_FP32_Affine3 * second);
extern inline void bgc_affine3_convert_fp32_to_fp64(const BgcAffine3FP32 * source, BgcAffine3FP64 * destination); extern inline void bgc_fp64_affine3_swap(BGC_FP64_Affine3 * first, BGC_FP64_Affine3 * second);
extern inline int bgc_affine3_invert_fp32(BgcAffine3FP32 * affine); extern inline void bgc_fp64_affine3_convert_to_fp32(const BGC_FP64_Affine3 * source, BGC_FP32_Affine3 * destination);
extern inline int bgc_affine3_invert_fp64(BgcAffine3FP64 * affine); extern inline void bgc_fp32_affine3_convert_to_fp64(const BGC_FP32_Affine3 * source, BGC_FP64_Affine3 * destination);
extern inline int bgc_affine3_get_inverse_fp32(const BgcAffine3FP32 * source, BgcAffine3FP32 * destination); extern inline int bgc_fp32_affine3_invert(BGC_FP32_Affine3 * affine);
extern inline int bgc_affine3_get_inverse_fp64(const BgcAffine3FP64 * source, BgcAffine3FP64 * destination); extern inline int bgc_fp64_affine3_invert(BGC_FP64_Affine3 * affine);
extern inline void bgc_affine3_combine_fp32(const BgcAffine3FP32 * first, const BgcAffine3FP32 * second, BgcAffine3FP32 * combination); extern inline int bgc_fp32_affine3_get_inverse(const BGC_FP32_Affine3 * source, BGC_FP32_Affine3 * destination);
extern inline void bgc_affine3_combine_fp64(const BgcAffine3FP64 * first, const BgcAffine3FP64 * second, BgcAffine3FP64 * combination); extern inline int bgc_fp64_affine3_get_inverse(const BGC_FP64_Affine3 * source, BGC_FP64_Affine3 * destination);
extern inline void bgc_affine3_transform_point_fp32(const BgcAffine3FP32 * affine, const BgcVector3FP32 * initial_point, BgcVector3FP32 * transformed_point); extern inline void bgc_fp32_affine3_combine(const BGC_FP32_Affine3 * first, const BGC_FP32_Affine3 * second, BGC_FP32_Affine3 * combination);
extern inline void bgc_affine3_transform_point_fp64(const BgcAffine3FP64 * affine, const BgcVector3FP64 * initial_point, BgcVector3FP64 * transformed_point); extern inline void bgc_fp64_affine3_combine(const BGC_FP64_Affine3 * first, const BGC_FP64_Affine3 * second, BGC_FP64_Affine3 * combination);
extern inline void bgc_affine3_transform_vector_fp32(const BgcAffine3FP32 * affine, const BgcVector3FP32 * initial_vector, BgcVector3FP32 * transformed_vector); extern inline void bgc_fp32_affine3_transform_point(const BGC_FP32_Affine3 * affine, const BGC_FP32_Vector3 * initial_point, BGC_FP32_Vector3 * transformed_point);
extern inline void bgc_affine3_transform_vector_fp64(const BgcAffine3FP64 * affine, const BgcVector3FP64 * initial_vector, BgcVector3FP64 * transformed_vector); extern inline void bgc_fp64_affine3_transform_point(const BGC_FP64_Affine3 * affine, const BGC_FP64_Vector3 * initial_point, BGC_FP64_Vector3 * transformed_point);
extern inline void bgc_fp32_affine3_transform_vector(const BGC_FP32_Affine3 * affine, const BGC_FP32_Vector3 * initial_vector, BGC_FP32_Vector3 * transformed_vector);
extern inline void bgc_fp64_affine3_transform_vector(const BGC_FP64_Affine3 * affine, const BGC_FP64_Vector3 * initial_vector, BGC_FP64_Vector3 * transformed_vector);

View file

@ -8,167 +8,181 @@
// ==================== Types ==================== // // ==================== Types ==================== //
typedef struct { typedef struct {
BgcMatrix3x3FP32 distortion; BGC_FP32_Matrix3x3 distortion;
BgcVector3FP32 shift; BGC_FP32_Vector3 shift;
} BgcAffine3FP32; } BGC_FP32_Affine3;
typedef struct { typedef struct {
BgcMatrix3x3FP64 distortion; BGC_FP64_Matrix3x3 distortion;
BgcVector3FP64 shift; BGC_FP64_Vector3 shift;
} BgcAffine3FP64; } BGC_FP64_Affine3;
// ==================== Reset ==================== // // ==================== Reset ==================== //
inline void bgc_affine3_reset_fp32(BgcAffine3FP32 * affine) inline void bgc_fp32_affine3_reset(BGC_FP32_Affine3 * affine)
{ {
bgc_matrix3x3_set_to_identity_fp32(&affine->distortion); bgc_fp32_matrix3x3_make_identity(&affine->distortion);
bgc_vector3_reset_fp32(&affine->shift); bgc_fp32_vector3_reset(&affine->shift);
} }
inline void bgc_affine3_reset_fp64(BgcAffine3FP64 * affine) inline void bgc_fp64_affine3_reset(BGC_FP64_Affine3 * affine)
{ {
bgc_matrix3x3_set_to_identity_fp64(&affine->distortion); bgc_fp64_matrix3x3_make_identity(&affine->distortion);
bgc_vector3_reset_fp64(&affine->shift); bgc_fp64_vector3_reset(&affine->shift);
} }
// ==================== Make ===================== // // ==================== Make ===================== //
inline void bgc_affine3_make_fp32(const BgcMatrix3x3FP32 * distortion, const BgcVector3FP32 * shift, BgcAffine3FP32 * affine) inline void bgc_fp32_affine3_make(const BGC_FP32_Matrix3x3 * distortion, const BGC_FP32_Vector3 * shift, BGC_FP32_Affine3 * affine)
{ {
bgc_matrix3x3_copy_fp32(distortion, &affine->distortion); bgc_fp32_matrix3x3_copy(distortion, &affine->distortion);
bgc_vector3_copy_fp32(shift, &affine->shift); bgc_fp32_vector3_copy(shift, &affine->shift);
} }
inline void bgc_affine3_make_fp64(const BgcMatrix3x3FP64 * distortion, const BgcVector3FP64 * shift, BgcAffine3FP64 * affine) inline void bgc_fp64_affine3_make(const BGC_FP64_Matrix3x3 * distortion, const BGC_FP64_Vector3 * shift, BGC_FP64_Affine3 * affine)
{ {
bgc_matrix3x3_copy_fp64(distortion, &affine->distortion); bgc_fp64_matrix3x3_copy(distortion, &affine->distortion);
bgc_vector3_copy_fp64(shift, &affine->shift); bgc_fp64_vector3_copy(shift, &affine->shift);
} }
// ==================== Copy ===================== // // ==================== Copy ===================== //
inline void bgc_affine3_copy_fp32(const BgcAffine3FP32 * source, BgcAffine3FP32 * destination) inline void bgc_fp32_affine3_copy(const BGC_FP32_Affine3 * source, BGC_FP32_Affine3 * destination)
{ {
bgc_matrix3x3_copy_fp32(&source->distortion, &destination->distortion); bgc_fp32_matrix3x3_copy(&source->distortion, &destination->distortion);
bgc_vector3_copy_fp32(&source->shift, &destination->shift); bgc_fp32_vector3_copy(&source->shift, &destination->shift);
} }
inline void bgc_affine3_copy_fp64(const BgcAffine3FP64 * source, BgcAffine3FP64 * destination) inline void bgc_fp64_affine3_copy(const BGC_FP64_Affine3 * source, BGC_FP64_Affine3 * destination)
{ {
bgc_matrix3x3_copy_fp64(&source->distortion, &destination->distortion); bgc_fp64_matrix3x3_copy(&source->distortion, &destination->distortion);
bgc_vector3_copy_fp64(&source->shift, &destination->shift); bgc_fp64_vector3_copy(&source->shift, &destination->shift);
}
// ==================== Swap ===================== //
inline void bgc_fp32_affine3_swap(BGC_FP32_Affine3 * first, BGC_FP32_Affine3 * second)
{
bgc_fp32_matrix3x3_copy(&first->distortion, &second->distortion);
bgc_fp32_vector3_copy(&first->shift, &second->shift);
}
inline void bgc_fp64_affine3_swap(BGC_FP64_Affine3 * first, BGC_FP64_Affine3 * second)
{
bgc_fp64_matrix3x3_copy(&first->distortion, &second->distortion);
bgc_fp64_vector3_copy(&first->shift, &second->shift);
} }
// =================== Convert =================== // // =================== Convert =================== //
inline void bgc_affine3_convert_fp64_to_fp32(const BgcAffine3FP64 * source, BgcAffine3FP32 * destination) inline void bgc_fp64_affine3_convert_to_fp32(const BGC_FP64_Affine3 * source, BGC_FP32_Affine3 * destination)
{ {
bgc_matrix3x3_convert_fp64_to_fp32(&source->distortion, &destination->distortion); bgc_fp64_matrix3x3_convert_to_fp32(&source->distortion, &destination->distortion);
bgc_vector3_convert_fp64_to_fp32(&source->shift, &destination->shift); bgc_fp64_vector3_convert_to_fp32(&source->shift, &destination->shift);
} }
inline void bgc_affine3_convert_fp32_to_fp64(const BgcAffine3FP32 * source, BgcAffine3FP64 * destination) inline void bgc_fp32_affine3_convert_to_fp64(const BGC_FP32_Affine3 * source, BGC_FP64_Affine3 * destination)
{ {
bgc_matrix3x3_convert_fp32_to_fp64(&source->distortion, &destination->distortion); bgc_fp32_matrix3x3_convert_to_fp64(&source->distortion, &destination->distortion);
bgc_vector3_convert_fp32_to_fp64(&source->shift, &destination->shift); bgc_fp32_vector3_convert_to_fp64(&source->shift, &destination->shift);
} }
// =================== Invert ==================== // // =================== Invert ==================== //
inline int bgc_affine3_invert_fp32(BgcAffine3FP32 * affine) inline int bgc_fp32_affine3_invert(BGC_FP32_Affine3 * affine)
{ {
if (!bgc_matrix3x3_invert_fp32(&affine->distortion, &affine->distortion)) { if (!bgc_fp32_matrix3x3_invert(&affine->distortion)) {
return 0; return 0;
} }
bgc_matrix3x3_get_right_product_fp32(&affine->distortion, &affine->shift, &affine->shift); bgc_fp32_multiply_matrix3x3_by_vector3(&affine->distortion, &affine->shift, &affine->shift);
bgc_vector3_make_opposite_fp32(&affine->shift); bgc_fp32_vector3_revert(&affine->shift);
return 1; return 1;
} }
inline int bgc_affine3_invert_fp64(BgcAffine3FP64 * affine) inline int bgc_fp64_affine3_invert(BGC_FP64_Affine3 * affine)
{ {
if (!bgc_matrix3x3_invert_fp64(&affine->distortion, &affine->distortion)) { if (!bgc_fp64_matrix3x3_invert(&affine->distortion)) {
return 0; return 0;
} }
bgc_matrix3x3_get_right_product_fp64(&affine->distortion, &affine->shift, &affine->shift); bgc_fp64_multiply_matrix3x3_by_vector3(&affine->distortion, &affine->shift, &affine->shift);
bgc_vector3_make_opposite_fp64(&affine->shift); bgc_fp64_vector3_revert(&affine->shift);
return 1; return 1;
} }
// ================= Get Inverse ================= // // ================= Get Inverse ================= //
inline int bgc_affine3_get_inverse_fp32(const BgcAffine3FP32 * source, BgcAffine3FP32 * destination) inline int bgc_fp32_affine3_get_inverse(const BGC_FP32_Affine3 * source, BGC_FP32_Affine3 * destination)
{ {
if (!bgc_matrix3x3_invert_fp32(&source->distortion, &destination->distortion)) { if (!bgc_fp32_matrix3x3_get_inverse(&source->distortion, &destination->distortion)) {
return 0; return 0;
} }
bgc_matrix3x3_get_right_product_fp32(&destination->distortion, &source->shift, &destination->shift); bgc_fp32_multiply_matrix3x3_by_vector3(&destination->distortion, &source->shift, &destination->shift);
bgc_vector3_make_opposite_fp32(&destination->shift); bgc_fp32_vector3_revert(&destination->shift);
return 1; return 1;
} }
inline int bgc_affine3_get_inverse_fp64(const BgcAffine3FP64 * source, BgcAffine3FP64 * destination) inline int bgc_fp64_affine3_get_inverse(const BGC_FP64_Affine3 * source, BGC_FP64_Affine3 * destination)
{ {
if (!bgc_matrix3x3_invert_fp64(&source->distortion, &destination->distortion)) { if (!bgc_fp64_matrix3x3_get_inverse(&source->distortion, &destination->distortion)) {
return 0; return 0;
} }
bgc_matrix3x3_get_right_product_fp64(&destination->distortion, &source->shift, &destination->shift); bgc_fp64_multiply_matrix3x3_by_vector3(&destination->distortion, &source->shift, &destination->shift);
bgc_vector3_make_opposite_fp64(&destination->shift); bgc_fp64_vector3_revert(&destination->shift);
return 1; return 1;
} }
// =================== Combine =================== // // =================== Combine =================== //
inline void bgc_affine3_combine_fp32(const BgcAffine3FP32 * first, const BgcAffine3FP32 * second, BgcAffine3FP32 * combination) inline void bgc_fp32_affine3_combine(const BGC_FP32_Affine3 * first, const BGC_FP32_Affine3 * second, BGC_FP32_Affine3 * combination)
{ {
BgcVector3FP32 first_shift; BGC_FP32_Vector3 first_shift;
bgc_matrix3x3_get_right_product_fp32(&second->distortion, &first->shift, &first_shift); bgc_fp32_multiply_matrix3x3_by_vector3(&second->distortion, &first->shift, &first_shift);
bgc_matrix_product_3x3_at_3x3_fp32(&second->distortion, &first->distortion, &combination->distortion); bgc_fp32_multiply_matrix3x3_by_matrix3x3(&second->distortion, &first->distortion, &combination->distortion);
bgc_vector3_add_fp32(&first_shift, &second->shift, &combination->shift); bgc_fp32_vector3_add(&first_shift, &second->shift, &combination->shift);
} }
inline void bgc_affine3_combine_fp64(const BgcAffine3FP64 * first, const BgcAffine3FP64 * second, BgcAffine3FP64 * combination) inline void bgc_fp64_affine3_combine(const BGC_FP64_Affine3 * first, const BGC_FP64_Affine3 * second, BGC_FP64_Affine3 * combination)
{ {
BgcVector3FP64 first_shift; BGC_FP64_Vector3 first_shift;
bgc_matrix3x3_get_right_product_fp64(&second->distortion, &first->shift, &first_shift); bgc_fp64_multiply_matrix3x3_by_vector3(&second->distortion, &first->shift, &first_shift);
bgc_matrix_product_3x3_at_3x3_fp64(&second->distortion, &first->distortion, &combination->distortion); bgc_fp64_multiply_matrix3x3_by_matrix3x3(&second->distortion, &first->distortion, &combination->distortion);
bgc_vector3_add_fp64(&first_shift, &second->shift, &combination->shift); bgc_fp64_vector3_add(&first_shift, &second->shift, &combination->shift);
} }
// =============== Transform Point =============== // // =============== Transform Point =============== //
inline void bgc_affine3_transform_point_fp32(const BgcAffine3FP32 * affine, const BgcVector3FP32 * initial_point, BgcVector3FP32 * transformed_point) inline void bgc_fp32_affine3_transform_point(const BGC_FP32_Affine3 * affine, const BGC_FP32_Vector3 * initial_point, BGC_FP32_Vector3 * transformed_point)
{ {
BgcVector3FP32 distorted; BGC_FP32_Vector3 distorted;
bgc_matrix3x3_get_right_product_fp32(&affine->distortion, initial_point, &distorted); bgc_fp32_multiply_matrix3x3_by_vector3(&affine->distortion, initial_point, &distorted);
bgc_vector3_add_fp32(&affine->shift, &distorted, transformed_point); bgc_fp32_vector3_add(&affine->shift, &distorted, transformed_point);
} }
inline void bgc_affine3_transform_point_fp64(const BgcAffine3FP64 * affine, const BgcVector3FP64 * initial_point, BgcVector3FP64 * transformed_point) inline void bgc_fp64_affine3_transform_point(const BGC_FP64_Affine3 * affine, const BGC_FP64_Vector3 * initial_point, BGC_FP64_Vector3 * transformed_point)
{ {
BgcVector3FP64 distorted; BGC_FP64_Vector3 distorted;
bgc_matrix3x3_get_right_product_fp64(&affine->distortion, initial_point, &distorted); bgc_fp64_multiply_matrix3x3_by_vector3(&affine->distortion, initial_point, &distorted);
bgc_vector3_add_fp64(&affine->shift, &distorted, transformed_point); bgc_fp64_vector3_add(&affine->shift, &distorted, transformed_point);
} }
// ============== Transform Vector =============== // // ============== Transform Vector =============== //
inline void bgc_affine3_transform_vector_fp32(const BgcAffine3FP32 * affine, const BgcVector3FP32 * initial_vector, BgcVector3FP32 * transformed_vector) inline void bgc_fp32_affine3_transform_vector(const BGC_FP32_Affine3 * affine, const BGC_FP32_Vector3 * initial_vector, BGC_FP32_Vector3 * transformed_vector)
{ {
bgc_matrix3x3_get_right_product_fp32(&affine->distortion, initial_vector, transformed_vector); bgc_fp32_multiply_matrix3x3_by_vector3(&affine->distortion, initial_vector, transformed_vector);
} }
inline void bgc_affine3_transform_vector_fp64(const BgcAffine3FP64 * affine, const BgcVector3FP64 * initial_vector, BgcVector3FP64 * transformed_vector) inline void bgc_fp64_affine3_transform_vector(const BGC_FP64_Affine3 * affine, const BGC_FP64_Vector3 * initial_vector, BGC_FP64_Vector3 * transformed_vector)
{ {
bgc_matrix3x3_get_right_product_fp64(&affine->distortion, initial_vector, transformed_vector); bgc_fp64_multiply_matrix3x3_by_vector3(&affine->distortion, initial_vector, transformed_vector);
} }
#endif #endif

View file

@ -3,65 +3,59 @@
// !================= Radians ==================! // // !================= Radians ==================! //
extern inline float bgc_radians_to_degrees_fp32(const float radians); extern inline float bgc_fp32_radians_to_degrees(const float radians);
extern inline double bgc_radians_to_degrees_fp64(const double radians); extern inline double bgc_fp64_radians_to_degrees(const double radians);
extern inline float bgc_radians_to_turns_fp32(const float radians); extern inline float bgc_fp32_radians_to_turns(const float radians);
extern inline double bgc_radians_to_turns_fp64(const double radians); extern inline double bgc_fp64_radians_to_turns(const double radians);
extern inline float bgc_radians_to_units_fp32(const float radians, const BgcAngleUnitEnum to_unit); extern inline float bgc_fp32_radians_to_units(const float radians, const int angle_unit);
extern inline double bgc_radians_to_units_fp64(const double radians, const BgcAngleUnitEnum to_unit); extern inline double bgc_fp64_radians_to_units(const double radians, const int angle_unit);
extern inline float bgc_radians_normalize_fp32(const float radians, const BgcAngleRangeEnum range); extern inline float bgc_fp32_normalize_radians(const float radians, const int angle_range);
extern inline double bgc_radians_normalize_fp64(const double radians, const BgcAngleRangeEnum range); extern inline double bgc_fp64_normalize_radians(const double radians, const int angle_range);
// !================= Degrees ==================! // // !================= Degrees ==================! //
extern inline float bgc_degrees_to_radians_fp32(const float degrees); extern inline float bgc_fp32_degrees_to_radians(const float degrees);
extern inline double bgc_degrees_to_radians_fp64(const double degrees); extern inline double bgc_fp64_degrees_to_radians(const double degrees);
extern inline float bgc_degrees_to_turns_fp32(const float radians); extern inline float bgc_fp32_degrees_to_turns(const float radians);
extern inline double bgc_degrees_to_turns_fp64(const double radians); extern inline double bgc_fp64_degrees_to_turns(const double radians);
extern inline float bgc_degrees_to_units_fp32(const float degrees, const BgcAngleUnitEnum to_unit); extern inline float bgc_fp32_degrees_to_units(const float degrees, const int angle_unit);
extern inline double bgc_degrees_to_units_fp64(const double degrees, const BgcAngleUnitEnum to_unit); extern inline double bgc_fp64_degrees_to_units(const double degrees, const int angle_unit);
extern inline float bgc_degrees_normalize_fp32(const float degrees, const BgcAngleRangeEnum range); extern inline float bgc_fp32_normalize_degrees(const float degrees, const int angle_range);
extern inline double bgc_degrees_normalize_fp64(const double degrees, const BgcAngleRangeEnum range); extern inline double bgc_fp64_degrees_normalize(const double degrees, const int angle_range);
// !================== Turns ===================! // // !================== Turns ===================! //
extern inline float bgc_turns_to_radians_fp32(const float turns); extern inline float bgc_fp32_turns_to_radians(const float turns);
extern inline double bgc_turns_to_radians_fp64(const double turns); extern inline double bgc_fp64_turns_to_radians(const double turns);
extern inline float bgc_turns_to_degrees_fp32(const float turns); extern inline float bgc_fp32_turns_to_degrees(const float turns);
extern inline double bgc_turns_to_degrees_fp64(const double turns); extern inline double bgc_fp64_turns_to_degrees(const double turns);
extern inline float bgc_turns_to_units_fp32(const float turns, const BgcAngleUnitEnum to_unit); extern inline float bgc_fp32_turns_to_units(const float turns, const int angle_unit);
extern inline double bgc_turns_to_units_fp64(const double turns, const BgcAngleUnitEnum to_unit); extern inline double bgc_fp64_turns_to_units(const double turns, const int angle_unit);
extern inline float bgc_turns_normalize_fp32(const float turns, const BgcAngleRangeEnum range); extern inline float bgc_fp32_normalize_turns(const float turns, const int angle_range);
extern inline double bgc_turns_normalize_fp64(const double turns, const BgcAngleRangeEnum range); extern inline double bgc_fp64_normalize_turns(const double turns, const int angle_range);
// !================== Angle ===================! // // !================== Angle ===================! //
extern inline float bgc_angle_to_radians_fp32(const float angle, const BgcAngleUnitEnum unit); extern inline float bgc_fp32_angle_to_radians(const float angle, const int angle_unit);
extern inline double bgc_angle_to_radians_fp64(const double angle, const BgcAngleUnitEnum unit); extern inline double bgc_fp64_angle_to_radians(const double angle, const int angle_unit);
extern inline float bgc_angle_to_degrees_fp32(const float angle, const BgcAngleUnitEnum unit); extern inline float bgc_fp32_angle_to_degrees(const float angle, const int angle_unit);
extern inline double bgc_angle_to_degrees_fp64(const double angle, const BgcAngleUnitEnum unit); extern inline double bgc_fp64_angle_to_degrees(const double angle, const int angle_unit);
extern inline float bgc_angle_to_turns_fp32(const float angle, const BgcAngleUnitEnum unit); extern inline float bgc_fp32_angle_to_turns(const float angle, const int angle_unit);
extern inline double bgc_angle_to_turns_fp64(const double angle, const BgcAngleUnitEnum unit); extern inline double bgc_fp64_angle_to_turns(const double angle, const int angle_unit);
extern inline float bgc_angle_get_full_circle_fp32(const BgcAngleUnitEnum unit); extern inline float bgc_fp32_full_circle(const int angle_unit);
extern inline double bgc_angle_get_full_circle_fp64(const BgcAngleUnitEnum unit); extern inline double bgc_fp64_full_circle(const int angle_unit);
extern inline float bgc_angle_get_half_circle_fp32(const BgcAngleUnitEnum unit); extern inline float bgc_fp32_normalize_angle(const float angle, const int angle_unit, const int angle_range);
extern inline double bgc_angle_get_half_circle_fp64(const BgcAngleUnitEnum unit); extern inline double bgc_fp64_normalize_angle(const double angle, const int angle_unit, const int angle_range);
extern inline float bgc_angle_get_quater_circle_fp32(const BgcAngleUnitEnum unit);
extern inline double bgc_angle_get_quater_circle_fp64(const BgcAngleUnitEnum unit);
extern inline float bgc_angle_normalize_fp32(const float angle, const BgcAngleUnitEnum unit, const BgcAngleRangeEnum range);
extern inline double bgc_angle_normalize_fp64(const double angle, const BgcAngleUnitEnum unit, const BgcAngleRangeEnum range);

View file

@ -4,99 +4,95 @@
#include <math.h> #include <math.h>
#include "utilities.h" #include "utilities.h"
#define BGC_PI_FP32 3.1415926536f #define BGC_FP32_PI 3.1415926536f
#define BGC_TWO_PI_FP32 6.2831853072f #define BGC_FP32_TWO_PI 6.2831853072f
#define BGC_HALF_OF_PI_FP32 1.5707963268f #define BGC_FP32_HALF_OF_PI 1.5707963268f
#define BGC_THIRD_OF_PI_FP32 1.0471975512f #define BGC_FP32_ONE_THIRD_OF_PI 1.0471975512f
#define BGC_FOURTH_OF_PI_FP32 0.7853981634f #define BGC_FP32_ONE_FOURTH_OF_PI 0.7853981634f
#define BGC_SIXTH_OF_PI_FP32 0.5235987756f #define BGC_FP32_ONE_SIXTH_OF_PI 0.5235987756f
#define BGC_DEGREES_IN_RADIAN_FP32 57.295779513f #define BGC_FP32_DEGREES_IN_RADIAN 57.295779513f
#define BGC_TURNS_IN_RADIAN_FP32 0.1591549431f #define BGC_FP32_TURNS_IN_RADIAN 0.1591549431f
#define BGC_RADIANS_IN_DEGREE_FP32 1.745329252E-2f #define BGC_FP32_RADIANS_IN_DEGREE 1.745329252E-2f
#define BGC_TURNS_IN_DEGREE_FP32 2.7777777778E-3f #define BGC_FP32_TURNS_IN_DEGREE 2.7777777778E-3f
#define BGC_PI_FP64 3.14159265358979324 #define BGC_FP64_PI 3.14159265358979324
#define BGC_TWO_PI_FP64 6.28318530717958648 #define BGC_FP64_TWO_PI 6.28318530717958648
#define BGC_HALF_OF_PI_FP64 1.57079632679489662 #define BGC_FP64_HALF_OF_PI 1.57079632679489662
#define BGC_THIRD_OF_PI_FP64 1.04719755119659775 #define BGC_FP64_ONE_THIRD_OF_PI 1.04719755119659775
#define BGC_FOURTH_OF_PI_FP64 0.78539816339744831 #define BGC_FP64_ONE_FOURTH_OF_PI 0.78539816339744831
#define BGC_SIXTH_OF_PI_FP64 0.523598775598298873 #define BGC_FP64_ONE_SIXTH_OF_PI 0.523598775598298873
#define BGC_DEGREES_IN_RADIAN_FP64 57.2957795130823209 #define BGC_FP64_DEGREES_IN_RADIAN 57.2957795130823209
#define BGC_TURNS_IN_RADIAN_FP64 0.159154943091895336 #define BGC_FP64_TURNS_IN_RADIAN 0.159154943091895336
#define BGC_RADIANS_IN_DEGREE_FP64 1.74532925199432958E-2 #define BGC_FP64_RADIANS_IN_DEGREE 1.74532925199432958E-2
#define BGC_TURNS_IN_DEGREE_FP64 2.77777777777777778E-3 #define BGC_FP64_TURNS_IN_DEGREE 2.77777777777777778E-3
typedef enum { #define BGC_ANGLE_UNIT_RADIANS 1
BGC_ANGLE_UNIT_RADIANS = 1, #define BGC_ANGLE_UNIT_DEGREES 2
BGC_ANGLE_UNIT_DEGREES = 2, #define BGC_ANGLE_UNIT_TURNS 3
BGC_ANGLE_UNIT_TURNS = 3
} BgcAngleUnitEnum;
typedef enum { /**
/** * The measure of an angle with a range of:
* The measure of an angle with a range of: * [0, 360) degrees, [0, 2xPI) radians, [0, 1) turns, [0, 400) gradians
* [0, 360) degrees, [0, 2xPI) radians, [0, 1) turns, [0, 400) gradians */
*/ #define BGC_ANGLE_RANGE_UNSIGNED 1
BGC_ANGLE_RANGE_UNSIGNED = 1,
/** /**
* The measure of an angle with a range of: * The measure of an angle with a range of:
* (-180, 180] degrees, (-PI, PI] radians, (-0.5, 0.5] turns, (-200, 200] gradians * (-180, 180] degrees, (-PI, PI] radians, (-0.5, 0.5] turns, (-200, 200] gradians
*/ */
BGC_ANGLE_RANGE_SIGNED = 2 #define BGC_ANGLE_RANGE_SIGNED 2
} BgcAngleRangeEnum;
// !================= Radians ==================! // // !================= Radians ==================! //
// ========= Convert radians to degrees ========= // // ========= Convert radians to degrees ========= //
inline float bgc_radians_to_degrees_fp32(const float radians) inline float bgc_fp32_radians_to_degrees(const float radians)
{ {
return radians * BGC_DEGREES_IN_RADIAN_FP32; return radians * BGC_FP32_DEGREES_IN_RADIAN;
} }
inline double bgc_radians_to_degrees_fp64(const double radians) inline double bgc_fp64_radians_to_degrees(const double radians)
{ {
return radians * BGC_DEGREES_IN_RADIAN_FP64; return radians * BGC_FP64_DEGREES_IN_RADIAN;
} }
// ========== Convert radians to turns ========== // // ========== Convert radians to turns ========== //
inline float bgc_radians_to_turns_fp32(const float radians) inline float bgc_fp32_radians_to_turns(const float radians)
{ {
return radians * BGC_TURNS_IN_RADIAN_FP32; return radians * BGC_FP32_TURNS_IN_RADIAN;
} }
inline double bgc_radians_to_turns_fp64(const double radians) inline double bgc_fp64_radians_to_turns(const double radians)
{ {
return radians * BGC_TURNS_IN_RADIAN_FP64; return radians * BGC_FP64_TURNS_IN_RADIAN;
} }
// ========= Convert radians to any unit ======== // // ========= Convert radians to any unit ======== //
inline float bgc_radians_to_units_fp32(const float radians, const BgcAngleUnitEnum to_unit) inline float bgc_fp32_radians_to_units(const float radians, const int angle_unit)
{ {
if (to_unit == BGC_ANGLE_UNIT_DEGREES) { if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return radians * BGC_DEGREES_IN_RADIAN_FP32; return radians * BGC_FP32_DEGREES_IN_RADIAN;
} }
if (to_unit == BGC_ANGLE_UNIT_TURNS) { if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return radians * BGC_TURNS_IN_RADIAN_FP32; return radians * BGC_FP32_TURNS_IN_RADIAN;
} }
return radians; return radians;
} }
inline double bgc_radians_to_units_fp64(const double radians, const BgcAngleUnitEnum to_unit) inline double bgc_fp64_radians_to_units(const double radians, const int angle_unit)
{ {
if (to_unit == BGC_ANGLE_UNIT_DEGREES) { if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return radians * BGC_DEGREES_IN_RADIAN_FP64; return radians * BGC_FP64_DEGREES_IN_RADIAN;
} }
if (to_unit == BGC_ANGLE_UNIT_TURNS) { if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return radians * BGC_TURNS_IN_RADIAN_FP64; return radians * BGC_FP64_TURNS_IN_RADIAN;
} }
return radians; return radians;
@ -104,103 +100,103 @@ inline double bgc_radians_to_units_fp64(const double radians, const BgcAngleUnit
// ============ Normalize radians ============= // // ============ Normalize radians ============= //
inline float bgc_radians_normalize_fp32(const float radians, const BgcAngleRangeEnum range) inline float bgc_fp32_normalize_radians(const float radians, const int angle_range)
{ {
if (range == BGC_ANGLE_RANGE_UNSIGNED) { if (angle_range == BGC_ANGLE_RANGE_UNSIGNED) {
if (0.0f <= radians && radians < BGC_TWO_PI_FP32) { if (0.0f <= radians && radians < BGC_FP32_TWO_PI) {
return radians; return radians;
} }
} }
else { else {
if (-BGC_PI_FP32 < radians && radians <= BGC_PI_FP32) { if (-BGC_FP32_PI < radians && radians <= BGC_FP32_PI) {
return radians; return radians;
} }
} }
float turns = radians * BGC_TURNS_IN_RADIAN_FP32; float turns = radians * BGC_FP32_TURNS_IN_RADIAN;
turns -= floorf(turns); turns -= floorf(turns);
if (range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5f) { if (angle_range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5f) {
turns -= 1.0f; turns -= 1.0f;
} }
return turns * BGC_TWO_PI_FP32; return turns * BGC_FP32_TWO_PI;
} }
inline double bgc_radians_normalize_fp64(const double radians, const BgcAngleRangeEnum range) inline double bgc_fp64_normalize_radians(const double radians, const int angle_range)
{ {
if (range == BGC_ANGLE_RANGE_UNSIGNED) { if (angle_range == BGC_ANGLE_RANGE_UNSIGNED) {
if (0.0 <= radians && radians < BGC_TWO_PI_FP64) { if (0.0 <= radians && radians < BGC_FP64_TWO_PI) {
return radians; return radians;
} }
} }
else { else {
if (-BGC_PI_FP64 < radians && radians <= BGC_PI_FP64) { if (-BGC_FP64_PI < radians && radians <= BGC_FP64_PI) {
return radians; return radians;
} }
} }
double turns = radians * BGC_TURNS_IN_RADIAN_FP64; double turns = radians * BGC_FP64_TURNS_IN_RADIAN;
turns -= floor(turns); turns -= floor(turns);
if (range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5) { if (angle_range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5) {
turns -= 1.0; turns -= 1.0;
} }
return turns * BGC_TWO_PI_FP64; return turns * BGC_FP64_TWO_PI;
} }
// !================= Degrees ==================! // // !================= Degrees ==================! //
// ========= Convert degrees to radians ========= // // ========= Convert degrees to radians ========= //
inline float bgc_degrees_to_radians_fp32(const float degrees) inline float bgc_fp32_degrees_to_radians(const float degrees)
{ {
return degrees * BGC_RADIANS_IN_DEGREE_FP32; return degrees * BGC_FP32_RADIANS_IN_DEGREE;
} }
inline double bgc_degrees_to_radians_fp64(const double degrees) inline double bgc_fp64_degrees_to_radians(const double degrees)
{ {
return degrees * BGC_RADIANS_IN_DEGREE_FP64; return degrees * BGC_FP64_RADIANS_IN_DEGREE;
} }
// ========== Convert degrees to turns ========== // // ========== Convert degrees to turns ========== //
inline float bgc_degrees_to_turns_fp32(const float radians) inline float bgc_fp32_degrees_to_turns(const float radians)
{ {
return radians * BGC_TURNS_IN_DEGREE_FP32; return radians * BGC_FP32_TURNS_IN_DEGREE;
} }
inline double bgc_degrees_to_turns_fp64(const double radians) inline double bgc_fp64_degrees_to_turns(const double radians)
{ {
return radians * BGC_TURNS_IN_DEGREE_FP64; return radians * BGC_FP64_TURNS_IN_DEGREE;
} }
// ========= Convert degreess to any unit ======== // // ========= Convert degreess to any unit ======== //
inline float bgc_degrees_to_units_fp32(const float degrees, const BgcAngleUnitEnum to_unit) inline float bgc_fp32_degrees_to_units(const float degrees, const int angle_unit)
{ {
if (to_unit == BGC_ANGLE_UNIT_RADIANS) { if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
return degrees * BGC_RADIANS_IN_DEGREE_FP32; return degrees * BGC_FP32_RADIANS_IN_DEGREE;
} }
if (to_unit == BGC_ANGLE_UNIT_TURNS) { if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return degrees * BGC_TURNS_IN_DEGREE_FP32; return degrees * BGC_FP32_TURNS_IN_DEGREE;
} }
return degrees; return degrees;
} }
inline double bgc_degrees_to_units_fp64(const double degrees, const BgcAngleUnitEnum to_unit) inline double bgc_fp64_degrees_to_units(const double degrees, const int angle_unit)
{ {
if (to_unit == BGC_ANGLE_UNIT_RADIANS) { if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
return degrees * BGC_RADIANS_IN_DEGREE_FP64; return degrees * BGC_FP64_RADIANS_IN_DEGREE;
} }
if (to_unit == BGC_ANGLE_UNIT_TURNS) { if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return degrees * BGC_TURNS_IN_DEGREE_FP64; return degrees * BGC_FP64_TURNS_IN_DEGREE;
} }
return degrees; return degrees;
@ -208,9 +204,9 @@ inline double bgc_degrees_to_units_fp64(const double degrees, const BgcAngleUnit
// ============ Normalize degrees ============= // // ============ Normalize degrees ============= //
inline float bgc_degrees_normalize_fp32(const float degrees, const BgcAngleRangeEnum range) inline float bgc_fp32_normalize_degrees(const float degrees, const int angle_range)
{ {
if (range == BGC_ANGLE_RANGE_UNSIGNED) { if (angle_range == BGC_ANGLE_RANGE_UNSIGNED) {
if (0.0f <= degrees && degrees < 360.0f) { if (0.0f <= degrees && degrees < 360.0f) {
return degrees; return degrees;
} }
@ -221,20 +217,20 @@ inline float bgc_degrees_normalize_fp32(const float degrees, const BgcAngleRange
} }
} }
float turns = degrees * BGC_TURNS_IN_DEGREE_FP32; float turns = degrees * BGC_FP32_TURNS_IN_DEGREE;
turns -= floorf(turns); turns -= floorf(turns);
if (range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5f) { if (angle_range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5f) {
turns -= 1.0f; turns -= 1.0f;
} }
return turns * 360.0f; return turns * 360.0f;
} }
inline double bgc_degrees_normalize_fp64(const double degrees, const BgcAngleRangeEnum range) inline double bgc_fp64_degrees_normalize(const double degrees, const int angle_range)
{ {
if (range == BGC_ANGLE_RANGE_UNSIGNED) { if (angle_range == BGC_ANGLE_RANGE_UNSIGNED) {
if (0.0 <= degrees && degrees < 360.0) { if (0.0 <= degrees && degrees < 360.0) {
return degrees; return degrees;
} }
@ -245,11 +241,11 @@ inline double bgc_degrees_normalize_fp64(const double degrees, const BgcAngleRan
} }
} }
double turns = degrees * BGC_TURNS_IN_DEGREE_FP64; double turns = degrees * BGC_FP64_TURNS_IN_DEGREE;
turns -= floor(turns); turns -= floor(turns);
if (range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5) { if (angle_range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5) {
turns -= 1.0; turns -= 1.0;
} }
@ -260,50 +256,50 @@ inline double bgc_degrees_normalize_fp64(const double degrees, const BgcAngleRan
// ========== Convert turns to radians ========== // // ========== Convert turns to radians ========== //
inline float bgc_turns_to_radians_fp32(const float turns) inline float bgc_fp32_turns_to_radians(const float turns)
{ {
return turns * BGC_TWO_PI_FP32; return turns * BGC_FP32_TWO_PI;
} }
inline double bgc_turns_to_radians_fp64(const double turns) inline double bgc_fp64_turns_to_radians(const double turns)
{ {
return turns * BGC_TWO_PI_FP64; return turns * BGC_FP64_TWO_PI;
} }
// ========== Convert turns to degrees ========== // // ========== Convert turns to degrees ========== //
inline float bgc_turns_to_degrees_fp32(const float turns) inline float bgc_fp32_turns_to_degrees(const float turns)
{ {
return turns * 360.0f; return turns * 360.0f;
} }
inline double bgc_turns_to_degrees_fp64(const double turns) inline double bgc_fp64_turns_to_degrees(const double turns)
{ {
return turns * 360.0; return turns * 360.0;
} }
// ========= Convert turns to any unit ======== // // ========= Convert turns to any unit ======== //
inline float bgc_turns_to_units_fp32(const float turns, const BgcAngleUnitEnum to_unit) inline float bgc_fp32_turns_to_units(const float turns, const int angle_unit)
{ {
if (to_unit == BGC_ANGLE_UNIT_RADIANS) { if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
return turns * BGC_TWO_PI_FP32; return turns * BGC_FP32_TWO_PI;
} }
if (to_unit == BGC_ANGLE_UNIT_DEGREES) { if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return turns * 360.0f; return turns * 360.0f;
} }
return turns; return turns;
} }
inline double bgc_turns_to_units_fp64(const double turns, const BgcAngleUnitEnum to_unit) inline double bgc_fp64_turns_to_units(const double turns, const int angle_unit)
{ {
if (to_unit == BGC_ANGLE_UNIT_RADIANS) { if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
return turns * BGC_TWO_PI_FP64; return turns * BGC_FP64_TWO_PI;
} }
if (to_unit == BGC_ANGLE_UNIT_DEGREES) { if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return turns * 360.0; return turns * 360.0;
} }
@ -312,9 +308,9 @@ inline double bgc_turns_to_units_fp64(const double turns, const BgcAngleUnitEnum
// ============= Normalize turns ============== // // ============= Normalize turns ============== //
inline float bgc_turns_normalize_fp32(const float turns, const BgcAngleRangeEnum range) inline float bgc_fp32_normalize_turns(const float turns, const int angle_range)
{ {
if (range == BGC_ANGLE_RANGE_UNSIGNED) { if (angle_range == BGC_ANGLE_RANGE_UNSIGNED) {
if (0.0f <= turns && turns < 1.0f) { if (0.0f <= turns && turns < 1.0f) {
return turns; return turns;
} }
@ -327,16 +323,16 @@ inline float bgc_turns_normalize_fp32(const float turns, const BgcAngleRangeEnum
float rest = turns - floorf(turns); float rest = turns - floorf(turns);
if (range == BGC_ANGLE_RANGE_SIGNED && rest > 0.5f) { if (angle_range == BGC_ANGLE_RANGE_SIGNED && rest > 0.5f) {
return rest - 1.0f; return rest - 1.0f;
} }
return rest; return rest;
} }
inline double bgc_turns_normalize_fp64(const double turns, const BgcAngleRangeEnum range) inline double bgc_fp64_normalize_turns(const double turns, const int angle_range)
{ {
if (range == BGC_ANGLE_RANGE_UNSIGNED) { if (angle_range == BGC_ANGLE_RANGE_UNSIGNED) {
if (0.0 <= turns && turns < 1.0) { if (0.0 <= turns && turns < 1.0) {
return turns; return turns;
} }
@ -349,7 +345,7 @@ inline double bgc_turns_normalize_fp64(const double turns, const BgcAngleRangeEn
double rest = turns - floor(turns); double rest = turns - floor(turns);
if (range == BGC_ANGLE_RANGE_SIGNED && rest > 0.5) { if (angle_range == BGC_ANGLE_RANGE_SIGNED && rest > 0.5) {
return rest - 1.0; return rest - 1.0;
} }
@ -360,27 +356,27 @@ inline double bgc_turns_normalize_fp64(const double turns, const BgcAngleRangeEn
// ========= Convert any unit to radians ======== // // ========= Convert any unit to radians ======== //
inline float bgc_angle_to_radians_fp32(const float angle, const BgcAngleUnitEnum unit) inline float bgc_fp32_angle_to_radians(const float angle, const int angle_unit)
{ {
if (unit == BGC_ANGLE_UNIT_DEGREES) { if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return angle * BGC_RADIANS_IN_DEGREE_FP32; return angle * BGC_FP32_RADIANS_IN_DEGREE;
} }
if (unit == BGC_ANGLE_UNIT_TURNS) { if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return angle * BGC_TWO_PI_FP32; return angle * BGC_FP32_TWO_PI;
} }
return angle; return angle;
} }
inline double bgc_angle_to_radians_fp64(const double angle, const BgcAngleUnitEnum unit) inline double bgc_fp64_angle_to_radians(const double angle, const int angle_unit)
{ {
if (unit == BGC_ANGLE_UNIT_DEGREES) { if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return angle * BGC_RADIANS_IN_DEGREE_FP64; return angle * BGC_FP64_RADIANS_IN_DEGREE;
} }
if (unit == BGC_ANGLE_UNIT_TURNS) { if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return angle * BGC_TWO_PI_FP64; return angle * BGC_FP64_TWO_PI;
} }
return angle; return angle;
@ -388,26 +384,26 @@ inline double bgc_angle_to_radians_fp64(const double angle, const BgcAngleUnitEn
// ========= Convert any unit to degreess ======== // // ========= Convert any unit to degreess ======== //
inline float bgc_angle_to_degrees_fp32(const float angle, const BgcAngleUnitEnum unit) inline float bgc_fp32_angle_to_degrees(const float angle, const int angle_unit)
{ {
if (unit == BGC_ANGLE_UNIT_RADIANS) { if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
return angle * BGC_DEGREES_IN_RADIAN_FP32; return angle * BGC_FP32_DEGREES_IN_RADIAN;
} }
if (unit == BGC_ANGLE_UNIT_TURNS) { if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return angle * 360.0f; return angle * 360.0f;
} }
return angle; return angle;
} }
inline double bgc_angle_to_degrees_fp64(const double angle, const BgcAngleUnitEnum unit) inline double bgc_fp64_angle_to_degrees(const double angle, const int angle_unit)
{ {
if (unit == BGC_ANGLE_UNIT_RADIANS) { if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
return angle * BGC_DEGREES_IN_RADIAN_FP64; return angle * BGC_FP64_DEGREES_IN_RADIAN;
} }
if (unit == BGC_ANGLE_UNIT_TURNS) { if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return angle * 360.0; return angle * 360.0;
} }
@ -416,27 +412,27 @@ inline double bgc_angle_to_degrees_fp64(const double angle, const BgcAngleUnitEn
// ========= Convert any unit to turns ======== // // ========= Convert any unit to turns ======== //
inline float bgc_angle_to_turns_fp32(const float angle, const BgcAngleUnitEnum unit) inline float bgc_fp32_angle_to_turns(const float angle, const int angle_unit)
{ {
if (unit == BGC_ANGLE_UNIT_RADIANS) { if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
return angle * BGC_TURNS_IN_RADIAN_FP32; return angle * BGC_FP32_TURNS_IN_RADIAN;
} }
if (unit == BGC_ANGLE_UNIT_DEGREES) { if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return angle * BGC_TURNS_IN_DEGREE_FP32; return angle * BGC_FP32_TURNS_IN_DEGREE;
} }
return angle; return angle;
} }
inline double bgc_angle_to_turns_fp64(const double angle, const BgcAngleUnitEnum unit) inline double bgc_fp64_angle_to_turns(const double angle, const int angle_unit)
{ {
if (unit == BGC_ANGLE_UNIT_RADIANS) { if (angle_unit == BGC_ANGLE_UNIT_RADIANS) {
return angle * BGC_TURNS_IN_RADIAN_FP64; return angle * BGC_FP64_TURNS_IN_RADIAN;
} }
if (unit == BGC_ANGLE_UNIT_DEGREES) { if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return angle * BGC_TURNS_IN_DEGREE_FP64; return angle * BGC_FP64_TURNS_IN_DEGREE;
} }
return angle; return angle;
@ -444,114 +440,58 @@ inline double bgc_angle_to_turns_fp64(const double angle, const BgcAngleUnitEnum
// ============= Get Full Circle ============== // // ============= Get Full Circle ============== //
inline float bgc_angle_get_full_circle_fp32(const BgcAngleUnitEnum unit) inline float bgc_fp32_full_circle(const int angle_unit)
{ {
if (unit == BGC_ANGLE_UNIT_DEGREES) { if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return 360.0f; return 360.0f;
} }
if (unit == BGC_ANGLE_UNIT_TURNS) { if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return 1.0f; return 1.0f;
} }
return BGC_TWO_PI_FP32; return BGC_FP32_TWO_PI;
} }
inline double bgc_angle_get_full_circle_fp64(const BgcAngleUnitEnum unit) inline double bgc_fp64_full_circle(const int angle_unit)
{ {
if (unit == BGC_ANGLE_UNIT_DEGREES) { if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return 360.0; return 360.0;
} }
if (unit == BGC_ANGLE_UNIT_TURNS) { if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return 1.0; return 1.0;
} }
return BGC_TWO_PI_FP64; return BGC_FP64_TWO_PI;
}
// ============= Get Half Circle ============== //
inline float bgc_angle_get_half_circle_fp32(const BgcAngleUnitEnum unit)
{
if (unit == BGC_ANGLE_UNIT_DEGREES) {
return 180.0f;
}
if (unit == BGC_ANGLE_UNIT_TURNS) {
return 0.5f;
}
return BGC_PI_FP32;
}
inline double bgc_angle_get_half_circle_fp64(const BgcAngleUnitEnum unit)
{
if (unit == BGC_ANGLE_UNIT_DEGREES) {
return 180.0;
}
if (unit == BGC_ANGLE_UNIT_TURNS) {
return 0.5;
}
return BGC_PI_FP64;
}
// ============= Get Half Circle ============== //
inline float bgc_angle_get_quater_circle_fp32(const BgcAngleUnitEnum unit)
{
if (unit == BGC_ANGLE_UNIT_DEGREES) {
return 90.0f;
}
if (unit == BGC_ANGLE_UNIT_TURNS) {
return 0.25f;
}
return BGC_HALF_OF_PI_FP32;
}
inline double bgc_angle_get_quater_circle_fp64(const BgcAngleUnitEnum unit)
{
if (unit == BGC_ANGLE_UNIT_DEGREES) {
return 90.0;
}
if (unit == BGC_ANGLE_UNIT_TURNS) {
return 0.25;
}
return BGC_HALF_OF_PI_FP64;
} }
// ================ Normalize ================= // // ================ Normalize ================= //
inline float bgc_angle_normalize_fp32(const float angle, const BgcAngleUnitEnum unit, const BgcAngleRangeEnum range) inline float bgc_fp32_normalize_angle(const float angle, const int angle_unit, const int angle_range)
{ {
if (unit == BGC_ANGLE_UNIT_DEGREES) { if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return bgc_degrees_normalize_fp32(angle, range); return bgc_fp32_normalize_degrees(angle, angle_range);
} }
if (unit == BGC_ANGLE_UNIT_TURNS) { if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return bgc_turns_normalize_fp32(angle, range); return bgc_fp32_normalize_turns(angle, angle_range);
} }
return bgc_radians_normalize_fp32(angle, range); return bgc_fp32_normalize_radians(angle, angle_range);
} }
inline double bgc_angle_normalize_fp64(const double angle, const BgcAngleUnitEnum unit, const BgcAngleRangeEnum range) inline double bgc_fp64_normalize_angle(const double angle, const int angle_unit, const int angle_range)
{ {
if (unit == BGC_ANGLE_UNIT_DEGREES) { if (angle_unit == BGC_ANGLE_UNIT_DEGREES) {
return bgc_degrees_normalize_fp64(angle, range); return bgc_fp64_degrees_normalize(angle, angle_range);
} }
if (unit == BGC_ANGLE_UNIT_TURNS) { if (angle_unit == BGC_ANGLE_UNIT_TURNS) {
return bgc_turns_normalize_fp64(angle, range); return bgc_fp64_normalize_turns(angle, angle_range);
} }
return bgc_radians_normalize_fp64(angle, range); return bgc_fp64_normalize_radians(angle, angle_range);
} }
#endif #endif

View file

@ -100,6 +100,10 @@
<Option compilerVar="CC" /> <Option compilerVar="CC" />
</Unit> </Unit>
<Unit filename="rotation3.h" /> <Unit filename="rotation3.h" />
<Unit filename="slerp.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="slerp.h" />
<Unit filename="utilities.c"> <Unit filename="utilities.c">
<Option compilerVar="CC" /> <Option compilerVar="CC" />
</Unit> </Unit>

View file

@ -1,96 +1,96 @@
#include "./complex.h" #include "./complex.h"
extern inline void bgc_complex_reset_fp32(BgcComplexFP32* complex); extern inline void bgc_fp32_complex_reset(BGC_FP32_Complex* complex);
extern inline void bgc_complex_reset_fp64(BgcComplexFP64* complex); extern inline void bgc_fp64_complex_reset(BGC_FP64_Complex* complex);
extern inline void bgc_complex_set_values_fp32(const float real, const float imaginary, BgcComplexFP32* destination); extern inline void bgc_fp32_complex_make(const float real, const float imaginary, BGC_FP32_Complex* complex);
extern inline void bgc_complex_set_values_fp64(const double real, const double imaginary, BgcComplexFP64* destination); extern inline void bgc_fp64_complex_make(const double real, const double imaginary, BGC_FP64_Complex* complex);
extern inline float bgc_complex_get_square_modulus_fp32(const BgcComplexFP32* number); extern inline float bgc_fp32_complex_get_square_modulus(const BGC_FP32_Complex* number);
extern inline double bgc_complex_get_square_modulus_fp64(const BgcComplexFP64* number); extern inline double bgc_fp64_complex_get_square_modulus(const BGC_FP64_Complex* number);
extern inline float bgc_complex_get_modulus_fp32(const BgcComplexFP32* number); extern inline float bgc_fp32_complex_get_modulus(const BGC_FP32_Complex* number);
extern inline double bgc_complex_get_modulus_fp64(const BgcComplexFP64* number); extern inline double bgc_fp64_complex_get_modulus(const BGC_FP64_Complex* number);
extern inline int bgc_complex_is_zero_fp32(const BgcComplexFP32* number); extern inline int bgc_fp32_complex_is_zero(const BGC_FP32_Complex* number);
extern inline int bgc_complex_is_zero_fp64(const BgcComplexFP64* number); extern inline int bgc_fp64_complex_is_zero(const BGC_FP64_Complex* number);
extern inline int bgc_complex_is_unit_fp32(const BgcComplexFP32* number); extern inline int bgc_fp32_complex_is_unit(const BGC_FP32_Complex* number);
extern inline int bgc_complex_is_unit_fp64(const BgcComplexFP64* number); extern inline int bgc_fp64_complex_is_unit(const BGC_FP64_Complex* number);
extern inline void bgc_complex_copy_fp32(const BgcComplexFP32* source, BgcComplexFP32* destination); extern inline void bgc_fp32_complex_copy(const BGC_FP32_Complex* source, BGC_FP32_Complex* destination);
extern inline void bgc_complex_copy_fp64(const BgcComplexFP64* source, BgcComplexFP64* destination); extern inline void bgc_fp64_complex_copy(const BGC_FP64_Complex* source, BGC_FP64_Complex* destination);
extern inline void bgc_complex_swap_fp32(BgcComplexFP32* number1, BgcComplexFP32* number2); extern inline void bgc_fp32_complex_swap(BGC_FP32_Complex* number1, BGC_FP32_Complex* number2);
extern inline void bgc_complex_swap_fp64(BgcComplexFP64* number1, BgcComplexFP64* number2); extern inline void bgc_fp64_complex_swap(BGC_FP64_Complex* number1, BGC_FP64_Complex* number2);
extern inline void bgc_complex_convert_fp64_to_fp32(const BgcComplexFP64* source, BgcComplexFP32* destination); extern inline void bgc_fp64_complex_convert_to_fp32(const BGC_FP64_Complex* source, BGC_FP32_Complex* destination);
extern inline void bgc_complex_convert_fp32_to_fp64(const BgcComplexFP32* source, BgcComplexFP64* destination); extern inline void bgc_fp32_complex_convert_to_fp64(const BGC_FP32_Complex* source, BGC_FP64_Complex* destination);
extern inline void bgc_complex_make_opposite_fp32(BgcComplexFP32* number); extern inline void bgc_fp32_complex_revert(BGC_FP32_Complex* number);
extern inline void bgc_complex_make_opposite_fp64(BgcComplexFP64* number); extern inline void bgc_fp64_complex_revert(BGC_FP64_Complex* number);
extern inline void bgc_complex_get_opposite_fp32(const BgcComplexFP32* number, BgcComplexFP32* opposite); extern inline void bgc_fp32_complex_get_reverse(const BGC_FP32_Complex* number, BGC_FP32_Complex* opposite);
extern inline void bgc_complex_get_opposite_fp64(const BgcComplexFP64* number, BgcComplexFP64* opposite); extern inline void bgc_fp64_complex_get_reverse(const BGC_FP64_Complex* number, BGC_FP64_Complex* opposite);
extern inline int bgc_complex_normalize_fp32(BgcComplexFP32* number); extern inline int bgc_fp32_complex_normalize(BGC_FP32_Complex* number);
extern inline int bgc_complex_normalize_fp64(BgcComplexFP64* number); extern inline int bgc_fp64_complex_normalize(BGC_FP64_Complex* number);
extern inline int bgc_complex_get_normalized_fp32(const BgcComplexFP32* number, BgcComplexFP32* normalized); extern inline int bgc_fp32_complex_get_normalized(const BGC_FP32_Complex* number, BGC_FP32_Complex* normalized);
extern inline int bgc_complex_get_normalized_fp64(const BgcComplexFP64* number, BgcComplexFP64* normalized); extern inline int bgc_fp64_complex_get_normalized(const BGC_FP64_Complex* number, BGC_FP64_Complex* normalized);
extern inline void bgc_complex_conjugate_fp32(BgcComplexFP32* number); extern inline void bgc_fp32_complex_conjugate(BGC_FP32_Complex* number);
extern inline void bgc_complex_conjugate_fp64(BgcComplexFP64* number); extern inline void bgc_fp64_complex_conjugate(BGC_FP64_Complex* number);
extern inline void bgc_complex_get_conjugate_fp32(const BgcComplexFP32* number, BgcComplexFP32* conjugate); extern inline void bgc_fp32_complex_get_conjugate(const BGC_FP32_Complex* number, BGC_FP32_Complex* conjugate);
extern inline void bgc_complex_get_conjugate_fp64(const BgcComplexFP64* number, BgcComplexFP64* conjugate); extern inline void bgc_fp64_complex_get_conjugate(const BGC_FP64_Complex* number, BGC_FP64_Complex* conjugate);
extern inline int bgc_complex_invert_fp32(BgcComplexFP32* number); extern inline int bgc_fp32_complex_invert(BGC_FP32_Complex* number);
extern inline int bgc_complex_invert_fp64(BgcComplexFP64* number); extern inline int bgc_fp64_complex_invert(BGC_FP64_Complex* number);
extern inline int bgc_complex_get_inverse_fp32(const BgcComplexFP32* number, BgcComplexFP32* inverse); extern inline int bgc_fp32_complex_get_inverse(const BGC_FP32_Complex* number, BGC_FP32_Complex* inverse);
extern inline int bgc_complex_get_inverse_fp64(const BgcComplexFP64* number, BgcComplexFP64* inverse); extern inline int bgc_fp64_complex_get_inverse(const BGC_FP64_Complex* number, BGC_FP64_Complex* inverse);
extern inline void bgc_complex_multiply_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, BgcComplexFP32* result); extern inline void bgc_fp32_complex_get_product(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, BGC_FP32_Complex* product);
extern inline void bgc_complex_multiply_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, BgcComplexFP64* result); extern inline void bgc_fp64_complex_get_product(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* product);
extern inline int bgc_complex_devide_fp32(const BgcComplexFP32* divident, const BgcComplexFP32* divisor, BgcComplexFP32* quotient); extern inline int bgc_fp32_complex_get_ratio(const BGC_FP32_Complex* divident, const BGC_FP32_Complex* divisor, BGC_FP32_Complex* quotient);
extern inline int bgc_complex_devide_fp64(const BgcComplexFP64* divident, const BgcComplexFP64* divisor, BgcComplexFP64* quotient); extern inline int bgc_fp64_complex_get_ratio(const BGC_FP64_Complex* divident, const BGC_FP64_Complex* divisor, BGC_FP64_Complex* quotient);
extern inline void bgc_complex_add_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, BgcComplexFP32* sum); extern inline void bgc_fp32_complex_add(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, BGC_FP32_Complex* sum);
extern inline void bgc_complex_add_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, BgcComplexFP64* sum); extern inline void bgc_fp64_complex_add(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* sum);
extern inline void bgc_complex_add_scaled_fp32(const BgcComplexFP32* basic_number, const BgcComplexFP32* scalable_number, const float scale, BgcComplexFP32* sum); extern inline void bgc_fp32_complex_add_scaled(const BGC_FP32_Complex* basic_number, const BGC_FP32_Complex* scalable_number, const float scale, BGC_FP32_Complex* sum);
extern inline void bgc_complex_add_scaled_fp64(const BgcComplexFP64* basic_number, const BgcComplexFP64* scalable_number, const double scale, BgcComplexFP64* sum); extern inline void bgc_fp64_complex_add_scaled(const BGC_FP64_Complex* basic_number, const BGC_FP64_Complex* scalable_number, const double scale, BGC_FP64_Complex* sum);
extern inline void bgc_complex_subtract_fp32(const BgcComplexFP32* minuend, const BgcComplexFP32* subtrahend, BgcComplexFP32* difference); extern inline void bgc_fp32_complex_subtract(const BGC_FP32_Complex* minuend, const BGC_FP32_Complex* subtrahend, BGC_FP32_Complex* difference);
extern inline void bgc_complex_subtract_fp64(const BgcComplexFP64* minuend, const BgcComplexFP64* subtrahend, BgcComplexFP64* difference); extern inline void bgc_fp64_complex_subtract(const BGC_FP64_Complex* minuend, const BGC_FP64_Complex* subtrahend, BGC_FP64_Complex* difference);
extern inline void bgc_complex_multiply_by_number_fp32(const BgcComplexFP32* multiplicand, const float multiplier, BgcComplexFP32* product); extern inline void bgc_fp32_complex_multiply(const BGC_FP32_Complex* multiplicand, const float multiplier, BGC_FP32_Complex* product);
extern inline void bgc_complex_multiply_by_number_fp64(const BgcComplexFP64* multiplicand, const double multiplier, BgcComplexFP64* product); extern inline void bgc_fp64_complex_multiply(const BGC_FP64_Complex* multiplicand, const double multiplier, BGC_FP64_Complex* product);
extern inline void bgc_complex_divide_by_number_fp32(const BgcComplexFP32* dividend, const float divisor, BgcComplexFP32* quotient); extern inline void bgc_fp32_complex_divide(const BGC_FP32_Complex* dividend, const float divisor, BGC_FP32_Complex* quotient);
extern inline void bgc_complex_divide_by_number_fp64(const BgcComplexFP64* dividend, const double divisor, BgcComplexFP64* quotient); extern inline void bgc_fp64_complex_divide(const BGC_FP64_Complex* dividend, const double divisor, BGC_FP64_Complex* quotient);
extern inline void bgc_complex_get_mean_of_two_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, BgcComplexFP32* mean); extern inline void bgc_fp32_complex_get_mean2(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, BGC_FP32_Complex* mean);
extern inline void bgc_complex_get_mean_of_two_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, BgcComplexFP64* mean); extern inline void bgc_fp64_complex_get_mean2(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* mean);
extern inline void bgc_complex_get_mean_of_three_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, const BgcComplexFP32* number3, BgcComplexFP32* mean); extern inline void bgc_fp32_complex_get_mean3(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, const BGC_FP32_Complex* number3, BGC_FP32_Complex* mean);
extern inline void bgc_complex_get_mean_of_three_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, const BgcComplexFP64* number3, BgcComplexFP64* mean); extern inline void bgc_fp64_complex_get_mean3(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, const BGC_FP64_Complex* number3, BGC_FP64_Complex* mean);
extern inline void bgc_complex_interpolate_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, const float phase, BgcComplexFP32* interpolation); extern inline void bgc_fp32_complex_interpolate(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, const float phase, BGC_FP32_Complex* interpolation);
extern inline void bgc_complex_interpolate_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, const double phase, BgcComplexFP64* interpolation); extern inline void bgc_fp64_complex_interpolate(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, const double phase, BGC_FP64_Complex* interpolation);
extern inline int bgc_complex_are_close_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2); extern inline int bgc_fp32_complex_are_close(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2);
extern inline int bgc_complex_are_close_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2); extern inline int bgc_fp64_complex_are_close(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2);
// =============== Get Exponation =============== // // =============== Get Exponation =============== //
void bgc_complex_get_exponation_fp32(const BgcComplexFP32* base, const float real_exponent, const float imaginary_exponent, BgcComplexFP32* power) void bgc_fp32_complex_get_exponation(const BGC_FP32_Complex* base, const float real_exponent, const float imaginary_exponent, BGC_FP32_Complex* power)
{ {
const float square_modulus = bgc_complex_get_square_modulus_fp32(base); const float square_modulus = bgc_fp32_complex_get_square_modulus(base);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32) { if (square_modulus <= BGC_FP32_SQUARE_EPSYLON) {
power->real = 0.0f; power->real = 0.0f;
power->imaginary = 0.0f; power->imaginary = 0.0f;
return; return;
@ -106,11 +106,11 @@ void bgc_complex_get_exponation_fp32(const BgcComplexFP32* base, const float rea
power->imaginary = power_modulus * sinf(power_angle); power->imaginary = power_modulus * sinf(power_angle);
} }
void bgc_complex_get_exponation_fp64(const BgcComplexFP64* base, const double real_exponent, const double imaginary_exponent, BgcComplexFP64* power) void bgc_fp64_complex_get_exponation(const BGC_FP64_Complex* base, const double real_exponent, const double imaginary_exponent, BGC_FP64_Complex* power)
{ {
const double square_modulus = bgc_complex_get_square_modulus_fp64(base); const double square_modulus = bgc_fp64_complex_get_square_modulus(base);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64) { if (square_modulus <= BGC_FP64_SQUARE_EPSYLON) {
power->real = 0.0; power->real = 0.0;
power->imaginary = 0.0; power->imaginary = 0.0;
return; return;

View file

@ -9,22 +9,22 @@
typedef struct typedef struct
{ {
float real, imaginary; float real, imaginary;
} BgcComplexFP32; } BGC_FP32_Complex;
typedef struct typedef struct
{ {
double real, imaginary; double real, imaginary;
} BgcComplexFP64; } BGC_FP64_Complex;
// =================== Reset ==================== // // =================== Reset ==================== //
inline void bgc_complex_reset_fp32(BgcComplexFP32* complex) inline void bgc_fp32_complex_reset(BGC_FP32_Complex* complex)
{ {
complex->real = 0.0f; complex->real = 0.0f;
complex->imaginary = 0.0f; complex->imaginary = 0.0f;
} }
inline void bgc_complex_reset_fp64(BgcComplexFP64* complex) inline void bgc_fp64_complex_reset(BGC_FP64_Complex* complex)
{ {
complex->real = 0.0; complex->real = 0.0;
complex->imaginary = 0.0; complex->imaginary = 0.0;
@ -32,71 +32,71 @@ inline void bgc_complex_reset_fp64(BgcComplexFP64* complex)
// ==================== Set ===================== // // ==================== Set ===================== //
inline void bgc_complex_set_values_fp32(const float real, const float imaginary, BgcComplexFP32* destination) inline void bgc_fp32_complex_make(const float real, const float imaginary, BGC_FP32_Complex* complex)
{ {
destination->real = real; complex->real = real;
destination->imaginary = imaginary; complex->imaginary = imaginary;
} }
inline void bgc_complex_set_values_fp64(const double real, const double imaginary, BgcComplexFP64* destination) inline void bgc_fp64_complex_make(const double real, const double imaginary, BGC_FP64_Complex* complex)
{ {
destination->real = real; complex->real = real;
destination->imaginary = imaginary; complex->imaginary = imaginary;
} }
// ================== Modulus =================== // // ================== Modulus =================== //
inline float bgc_complex_get_square_modulus_fp32(const BgcComplexFP32* number) inline float bgc_fp32_complex_get_square_modulus(const BGC_FP32_Complex* number)
{ {
return number->real * number->real + number->imaginary * number->imaginary; return number->real * number->real + number->imaginary * number->imaginary;
} }
inline double bgc_complex_get_square_modulus_fp64(const BgcComplexFP64* number) inline double bgc_fp64_complex_get_square_modulus(const BGC_FP64_Complex* number)
{ {
return number->real * number->real + number->imaginary * number->imaginary; return number->real * number->real + number->imaginary * number->imaginary;
} }
inline float bgc_complex_get_modulus_fp32(const BgcComplexFP32* number) inline float bgc_fp32_complex_get_modulus(const BGC_FP32_Complex* number)
{ {
return sqrtf(bgc_complex_get_square_modulus_fp32(number)); return sqrtf(bgc_fp32_complex_get_square_modulus(number));
} }
inline double bgc_complex_get_modulus_fp64(const BgcComplexFP64* number) inline double bgc_fp64_complex_get_modulus(const BGC_FP64_Complex* number)
{ {
return sqrt(bgc_complex_get_square_modulus_fp64(number)); return sqrt(bgc_fp64_complex_get_square_modulus(number));
} }
// ================= Comparison ================= // // ================= Comparison ================= //
inline int bgc_complex_is_zero_fp32(const BgcComplexFP32* number) inline int bgc_fp32_complex_is_zero(const BGC_FP32_Complex* number)
{ {
return bgc_complex_get_square_modulus_fp32(number) <= BGC_SQUARE_EPSYLON_FP32; return bgc_fp32_complex_get_square_modulus(number) <= BGC_FP32_SQUARE_EPSYLON;
} }
inline int bgc_complex_is_zero_fp64(const BgcComplexFP64* number) inline int bgc_fp64_complex_is_zero(const BGC_FP64_Complex* number)
{ {
return bgc_complex_get_square_modulus_fp64(number) <= BGC_SQUARE_EPSYLON_FP64; return bgc_fp64_complex_get_square_modulus(number) <= BGC_FP64_SQUARE_EPSYLON;
} }
inline int bgc_complex_is_unit_fp32(const BgcComplexFP32* number) inline int bgc_fp32_complex_is_unit(const BGC_FP32_Complex* number)
{ {
return bgc_is_sqare_unit_fp32(bgc_complex_get_square_modulus_fp32(number)); return bgc_fp32_is_square_unit(bgc_fp32_complex_get_square_modulus(number));
} }
inline int bgc_complex_is_unit_fp64(const BgcComplexFP64* number) inline int bgc_fp64_complex_is_unit(const BGC_FP64_Complex* number)
{ {
return bgc_is_sqare_unit_fp64(bgc_complex_get_square_modulus_fp64(number)); return bgc_fp64_is_square_unit(bgc_fp64_complex_get_square_modulus(number));
} }
// ==================== Copy ==================== // // ==================== Copy ==================== //
inline void bgc_complex_copy_fp32(const BgcComplexFP32* source, BgcComplexFP32* destination) inline void bgc_fp32_complex_copy(const BGC_FP32_Complex* source, BGC_FP32_Complex* destination)
{ {
destination->real = source->real; destination->real = source->real;
destination->imaginary = source->imaginary; destination->imaginary = source->imaginary;
} }
inline void bgc_complex_copy_fp64(const BgcComplexFP64* source, BgcComplexFP64* destination) inline void bgc_fp64_complex_copy(const BGC_FP64_Complex* source, BGC_FP64_Complex* destination)
{ {
destination->real = source->real; destination->real = source->real;
destination->imaginary = source->imaginary; destination->imaginary = source->imaginary;
@ -104,7 +104,7 @@ inline void bgc_complex_copy_fp64(const BgcComplexFP64* source, BgcComplexFP64*
// ==================== Swap ==================== // // ==================== Swap ==================== //
inline void bgc_complex_swap_fp32(BgcComplexFP32* number1, BgcComplexFP32* number2) inline void bgc_fp32_complex_swap(BGC_FP32_Complex* number1, BGC_FP32_Complex* number2)
{ {
const float real = number2->real; const float real = number2->real;
const float imaginary = number2->imaginary; const float imaginary = number2->imaginary;
@ -116,7 +116,7 @@ inline void bgc_complex_swap_fp32(BgcComplexFP32* number1, BgcComplexFP32* numbe
number1->imaginary = imaginary; number1->imaginary = imaginary;
} }
inline void bgc_complex_swap_fp64(BgcComplexFP64* number1, BgcComplexFP64* number2) inline void bgc_fp64_complex_swap(BGC_FP64_Complex* number1, BGC_FP64_Complex* number2)
{ {
const double real = number2->real; const double real = number2->real;
const double imaginary = number2->imaginary; const double imaginary = number2->imaginary;
@ -130,13 +130,13 @@ inline void bgc_complex_swap_fp64(BgcComplexFP64* number1, BgcComplexFP64* numbe
// ================== Convert =================== // // ================== Convert =================== //
inline void bgc_complex_convert_fp64_to_fp32(const BgcComplexFP64* source, BgcComplexFP32* destination) inline void bgc_fp64_complex_convert_to_fp32(const BGC_FP64_Complex* source, BGC_FP32_Complex* destination)
{ {
destination->real = (float)source->real; destination->real = (float)source->real;
destination->imaginary = (float)source->imaginary; destination->imaginary = (float)source->imaginary;
} }
inline void bgc_complex_convert_fp32_to_fp64(const BgcComplexFP32* source, BgcComplexFP64* destination) inline void bgc_fp32_complex_convert_to_fp64(const BGC_FP32_Complex* source, BGC_FP64_Complex* destination)
{ {
destination->real = source->real; destination->real = source->real;
destination->imaginary = source->imaginary; destination->imaginary = source->imaginary;
@ -144,25 +144,25 @@ inline void bgc_complex_convert_fp32_to_fp64(const BgcComplexFP32* source, BgcCo
// ================== Negative ================== // // ================== Negative ================== //
inline void bgc_complex_make_opposite_fp32(BgcComplexFP32* number) inline void bgc_fp32_complex_revert(BGC_FP32_Complex* number)
{ {
number->real = -number->real; number->real = -number->real;
number->imaginary = -number->imaginary; number->imaginary = -number->imaginary;
} }
inline void bgc_complex_make_opposite_fp64(BgcComplexFP64* number) inline void bgc_fp64_complex_revert(BGC_FP64_Complex* number)
{ {
number->real = -number->real; number->real = -number->real;
number->imaginary = -number->imaginary; number->imaginary = -number->imaginary;
} }
inline void bgc_complex_get_opposite_fp32(const BgcComplexFP32* number, BgcComplexFP32* opposite) inline void bgc_fp32_complex_get_reverse(const BGC_FP32_Complex* number, BGC_FP32_Complex* opposite)
{ {
opposite->real = -number->real; opposite->real = -number->real;
opposite->imaginary = -number->imaginary; opposite->imaginary = -number->imaginary;
} }
inline void bgc_complex_get_opposite_fp64(const BgcComplexFP64* number, BgcComplexFP64* opposite) inline void bgc_fp64_complex_get_reverse(const BGC_FP64_Complex* number, BGC_FP64_Complex* opposite)
{ {
opposite->real = -number->real; opposite->real = -number->real;
opposite->imaginary = -number->imaginary; opposite->imaginary = -number->imaginary;
@ -170,15 +170,15 @@ inline void bgc_complex_get_opposite_fp64(const BgcComplexFP64* number, BgcCompl
// ================= Normalize ================== // // ================= Normalize ================== //
inline int bgc_complex_normalize_fp32(BgcComplexFP32* number) inline int bgc_fp32_complex_normalize(BGC_FP32_Complex* number)
{ {
const float square_modulus = bgc_complex_get_square_modulus_fp32(number); const float square_modulus = bgc_fp32_complex_get_square_modulus(number);
if (bgc_is_sqare_unit_fp32(square_modulus)) { if (bgc_fp32_is_square_unit(square_modulus)) {
return 1; return 1;
} }
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
return 0; return 0;
} }
@ -190,15 +190,15 @@ inline int bgc_complex_normalize_fp32(BgcComplexFP32* number)
return 1; return 1;
} }
inline int bgc_complex_normalize_fp64(BgcComplexFP64* number) inline int bgc_fp64_complex_normalize(BGC_FP64_Complex* number)
{ {
const double square_modulus = bgc_complex_get_square_modulus_fp64(number); const double square_modulus = bgc_fp64_complex_get_square_modulus(number);
if (bgc_is_sqare_unit_fp64(square_modulus)) { if (bgc_fp64_is_square_unit(square_modulus)) {
return 1; return 1;
} }
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
return 0; return 0;
} }
@ -210,17 +210,17 @@ inline int bgc_complex_normalize_fp64(BgcComplexFP64* number)
return 1; return 1;
} }
inline int bgc_complex_get_normalized_fp32(const BgcComplexFP32* number, BgcComplexFP32* normalized) inline int bgc_fp32_complex_get_normalized(const BGC_FP32_Complex* number, BGC_FP32_Complex* normalized)
{ {
const float square_modulus = bgc_complex_get_square_modulus_fp32(number); const float square_modulus = bgc_fp32_complex_get_square_modulus(number);
if (bgc_is_sqare_unit_fp32(square_modulus)) { if (bgc_fp32_is_square_unit(square_modulus)) {
normalized->real = number->real; normalized->real = number->real;
normalized->imaginary = number->imaginary; normalized->imaginary = number->imaginary;
return 1; return 1;
} }
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
normalized->real = 0.0f; normalized->real = 0.0f;
normalized->imaginary = 0.0f; normalized->imaginary = 0.0f;
return 0; return 0;
@ -234,17 +234,17 @@ inline int bgc_complex_get_normalized_fp32(const BgcComplexFP32* number, BgcComp
return 1; return 1;
} }
inline int bgc_complex_get_normalized_fp64(const BgcComplexFP64* number, BgcComplexFP64* normalized) inline int bgc_fp64_complex_get_normalized(const BGC_FP64_Complex* number, BGC_FP64_Complex* normalized)
{ {
const double square_modulus = bgc_complex_get_square_modulus_fp64(number); const double square_modulus = bgc_fp64_complex_get_square_modulus(number);
if (bgc_is_sqare_unit_fp64(square_modulus)) { if (bgc_fp64_is_square_unit(square_modulus)) {
normalized->real = number->real; normalized->real = number->real;
normalized->imaginary = number->imaginary; normalized->imaginary = number->imaginary;
return 1; return 1;
} }
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
normalized->real = 0.0; normalized->real = 0.0;
normalized->imaginary = 0.0; normalized->imaginary = 0.0;
return 0; return 0;
@ -260,23 +260,23 @@ inline int bgc_complex_get_normalized_fp64(const BgcComplexFP64* number, BgcComp
// ================= Conjugate ================== // // ================= Conjugate ================== //
inline void bgc_complex_conjugate_fp32(BgcComplexFP32* number) inline void bgc_fp32_complex_conjugate(BGC_FP32_Complex* number)
{ {
number->imaginary = -number->imaginary; number->imaginary = -number->imaginary;
} }
inline void bgc_complex_conjugate_fp64(BgcComplexFP64* number) inline void bgc_fp64_complex_conjugate(BGC_FP64_Complex* number)
{ {
number->imaginary = -number->imaginary; number->imaginary = -number->imaginary;
} }
inline void bgc_complex_get_conjugate_fp32(const BgcComplexFP32* number, BgcComplexFP32* conjugate) inline void bgc_fp32_complex_get_conjugate(const BGC_FP32_Complex* number, BGC_FP32_Complex* conjugate)
{ {
conjugate->real = number->real; conjugate->real = number->real;
conjugate->imaginary = -number->imaginary; conjugate->imaginary = -number->imaginary;
} }
inline void bgc_complex_get_conjugate_fp64(const BgcComplexFP64* number, BgcComplexFP64* conjugate) inline void bgc_fp64_complex_get_conjugate(const BGC_FP64_Complex* number, BGC_FP64_Complex* conjugate)
{ {
conjugate->real = number->real; conjugate->real = number->real;
conjugate->imaginary = -number->imaginary; conjugate->imaginary = -number->imaginary;
@ -284,11 +284,11 @@ inline void bgc_complex_get_conjugate_fp64(const BgcComplexFP64* number, BgcComp
// =================== Invert =================== // // =================== Invert =================== //
inline int bgc_complex_get_inverse_fp32(const BgcComplexFP32* number, BgcComplexFP32* inverse) inline int bgc_fp32_complex_get_inverse(const BGC_FP32_Complex* number, BGC_FP32_Complex* inverse)
{ {
const float square_modulus = bgc_complex_get_square_modulus_fp32(number); const float square_modulus = bgc_fp32_complex_get_square_modulus(number);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
return 0; return 0;
} }
@ -300,11 +300,11 @@ inline int bgc_complex_get_inverse_fp32(const BgcComplexFP32* number, BgcComplex
return 1; return 1;
} }
inline int bgc_complex_get_inverse_fp64(const BgcComplexFP64* number, BgcComplexFP64* inverse) inline int bgc_fp64_complex_get_inverse(const BGC_FP64_Complex* number, BGC_FP64_Complex* inverse)
{ {
const double square_modulus = bgc_complex_get_square_modulus_fp64(number); const double square_modulus = bgc_fp64_complex_get_square_modulus(number);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
return 0; return 0;
} }
@ -316,31 +316,31 @@ inline int bgc_complex_get_inverse_fp64(const BgcComplexFP64* number, BgcComplex
return 1; return 1;
} }
inline int bgc_complex_invert_fp32(BgcComplexFP32* number) inline int bgc_fp32_complex_invert(BGC_FP32_Complex* number)
{ {
return bgc_complex_get_inverse_fp32(number, number); return bgc_fp32_complex_get_inverse(number, number);
} }
inline int bgc_complex_invert_fp64(BgcComplexFP64* number) inline int bgc_fp64_complex_invert(BGC_FP64_Complex* number)
{ {
return bgc_complex_get_inverse_fp64(number, number); return bgc_fp64_complex_get_inverse(number, number);
} }
// =============== Get Exponation =============== // // =============== Get Exponation =============== //
void bgc_complex_get_exponation_fp32(const BgcComplexFP32* base, const float real_exponent, const float imaginary_exponent, BgcComplexFP32* power); void bgc_fp32_complex_get_exponation(const BGC_FP32_Complex* base, const float real_exponent, const float imaginary_exponent, BGC_FP32_Complex* power);
void bgc_complex_get_exponation_fp64(const BgcComplexFP64* base, const double real_exponent, const double imaginary_exponent, BgcComplexFP64* power); void bgc_fp64_complex_get_exponation(const BGC_FP64_Complex* base, const double real_exponent, const double imaginary_exponent, BGC_FP64_Complex* power);
// ==================== Add ===================== // // ==================== Add ===================== //
inline void bgc_complex_add_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, BgcComplexFP32* sum) inline void bgc_fp32_complex_add(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, BGC_FP32_Complex* sum)
{ {
sum->real = number1->real + number2->real; sum->real = number1->real + number2->real;
sum->imaginary = number1->imaginary + number2->imaginary; sum->imaginary = number1->imaginary + number2->imaginary;
} }
inline void bgc_complex_add_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, BgcComplexFP64* sum) inline void bgc_fp64_complex_add(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* sum)
{ {
sum->real = number1->real + number2->real; sum->real = number1->real + number2->real;
sum->imaginary = number1->imaginary + number2->imaginary; sum->imaginary = number1->imaginary + number2->imaginary;
@ -348,13 +348,13 @@ inline void bgc_complex_add_fp64(const BgcComplexFP64* number1, const BgcComplex
// ================= Add scaled ================= // // ================= Add scaled ================= //
inline void bgc_complex_add_scaled_fp32(const BgcComplexFP32* basic_number, const BgcComplexFP32* scalable_number, const float scale, BgcComplexFP32* sum) inline void bgc_fp32_complex_add_scaled(const BGC_FP32_Complex* basic_number, const BGC_FP32_Complex* scalable_number, const float scale, BGC_FP32_Complex* sum)
{ {
sum->real = basic_number->real + scalable_number->real * scale; sum->real = basic_number->real + scalable_number->real * scale;
sum->imaginary = basic_number->imaginary + scalable_number->imaginary * scale; sum->imaginary = basic_number->imaginary + scalable_number->imaginary * scale;
} }
inline void bgc_complex_add_scaled_fp64(const BgcComplexFP64* basic_number, const BgcComplexFP64* scalable_number, const double scale, BgcComplexFP64* sum) inline void bgc_fp64_complex_add_scaled(const BGC_FP64_Complex* basic_number, const BGC_FP64_Complex* scalable_number, const double scale, BGC_FP64_Complex* sum)
{ {
sum->real = basic_number->real + scalable_number->real * scale; sum->real = basic_number->real + scalable_number->real * scale;
sum->imaginary = basic_number->imaginary + scalable_number->imaginary * scale; sum->imaginary = basic_number->imaginary + scalable_number->imaginary * scale;
@ -362,13 +362,13 @@ inline void bgc_complex_add_scaled_fp64(const BgcComplexFP64* basic_number, cons
// ================== Subtract ================== // // ================== Subtract ================== //
inline void bgc_complex_subtract_fp32(const BgcComplexFP32* minuend, const BgcComplexFP32* subtrahend, BgcComplexFP32* difference) inline void bgc_fp32_complex_subtract(const BGC_FP32_Complex* minuend, const BGC_FP32_Complex* subtrahend, BGC_FP32_Complex* difference)
{ {
difference->real = minuend->real - subtrahend->real; difference->real = minuend->real - subtrahend->real;
difference->imaginary = minuend->imaginary - subtrahend->imaginary; difference->imaginary = minuend->imaginary - subtrahend->imaginary;
} }
inline void bgc_complex_subtract_fp64(const BgcComplexFP64* minuend, const BgcComplexFP64* subtrahend, BgcComplexFP64* difference) inline void bgc_fp64_complex_subtract(const BGC_FP64_Complex* minuend, const BGC_FP64_Complex* subtrahend, BGC_FP64_Complex* difference)
{ {
difference->real = minuend->real - subtrahend->real; difference->real = minuend->real - subtrahend->real;
difference->imaginary = minuend->imaginary - subtrahend->imaginary; difference->imaginary = minuend->imaginary - subtrahend->imaginary;
@ -376,7 +376,7 @@ inline void bgc_complex_subtract_fp64(const BgcComplexFP64* minuend, const BgcCo
// ================== Multiply ================== // // ================== Multiply ================== //
inline void bgc_complex_multiply_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, BgcComplexFP32* product) inline void bgc_fp32_complex_get_product(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, BGC_FP32_Complex* product)
{ {
const float real = number1->real * number2->real - number1->imaginary * number2->imaginary; const float real = number1->real * number2->real - number1->imaginary * number2->imaginary;
const float imaginary = number1->real * number2->imaginary + number1->imaginary * number2->real; const float imaginary = number1->real * number2->imaginary + number1->imaginary * number2->real;
@ -385,7 +385,7 @@ inline void bgc_complex_multiply_fp32(const BgcComplexFP32* number1, const BgcCo
product->imaginary = imaginary; product->imaginary = imaginary;
} }
inline void bgc_complex_multiply_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, BgcComplexFP64* product) inline void bgc_fp64_complex_get_product(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* product)
{ {
const double real = number1->real * number2->real - number1->imaginary * number2->imaginary; const double real = number1->real * number2->real - number1->imaginary * number2->imaginary;
const double imaginary = number1->real * number2->imaginary + number1->imaginary * number2->real; const double imaginary = number1->real * number2->imaginary + number1->imaginary * number2->real;
@ -396,13 +396,13 @@ inline void bgc_complex_multiply_fp64(const BgcComplexFP64* number1, const BgcCo
// ============= Multiply By Number ============= // // ============= Multiply By Number ============= //
inline void bgc_complex_multiply_by_number_fp32(const BgcComplexFP32* multiplicand, const float multiplier, BgcComplexFP32* product) inline void bgc_fp32_complex_multiply(const BGC_FP32_Complex* multiplicand, const float multiplier, BGC_FP32_Complex* product)
{ {
product->real = multiplicand->real * multiplier; product->real = multiplicand->real * multiplier;
product->imaginary = multiplicand->imaginary * multiplier; product->imaginary = multiplicand->imaginary * multiplier;
} }
inline void bgc_complex_multiply_by_number_fp64(const BgcComplexFP64* multiplicand, const double multiplier, BgcComplexFP64* product) inline void bgc_fp64_complex_multiply(const BGC_FP64_Complex* multiplicand, const double multiplier, BGC_FP64_Complex* product)
{ {
product->real = multiplicand->real * multiplier; product->real = multiplicand->real * multiplier;
product->imaginary = multiplicand->imaginary * multiplier; product->imaginary = multiplicand->imaginary * multiplier;
@ -410,11 +410,11 @@ inline void bgc_complex_multiply_by_number_fp64(const BgcComplexFP64* multiplica
// =================== Divide =================== // // =================== Divide =================== //
inline int bgc_complex_devide_fp32(const BgcComplexFP32* divident, const BgcComplexFP32* divisor, BgcComplexFP32* quotient) inline int bgc_fp32_complex_get_ratio(const BGC_FP32_Complex* divident, const BGC_FP32_Complex* divisor, BGC_FP32_Complex* quotient)
{ {
const float square_modulus = bgc_complex_get_square_modulus_fp32(divisor); const float square_modulus = bgc_fp32_complex_get_square_modulus(divisor);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32) { if (square_modulus <= BGC_FP32_SQUARE_EPSYLON) {
return 0; return 0;
} }
@ -429,11 +429,11 @@ inline int bgc_complex_devide_fp32(const BgcComplexFP32* divident, const BgcComp
return 1; return 1;
} }
inline int bgc_complex_devide_fp64(const BgcComplexFP64* divident, const BgcComplexFP64* divisor, BgcComplexFP64* quotient) inline int bgc_fp64_complex_get_ratio(const BGC_FP64_Complex* divident, const BGC_FP64_Complex* divisor, BGC_FP64_Complex* quotient)
{ {
const double square_modulus = bgc_complex_get_square_modulus_fp64(divisor); const double square_modulus = bgc_fp64_complex_get_square_modulus(divisor);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64) { if (square_modulus <= BGC_FP64_SQUARE_EPSYLON) {
return 0; return 0;
} }
@ -450,25 +450,25 @@ inline int bgc_complex_devide_fp64(const BgcComplexFP64* divident, const BgcComp
// ============== Divide By Number ============== // // ============== Divide By Number ============== //
inline void bgc_complex_divide_by_number_fp32(const BgcComplexFP32* dividend, const float divisor, BgcComplexFP32* quotient) inline void bgc_fp32_complex_divide(const BGC_FP32_Complex* dividend, const float divisor, BGC_FP32_Complex* quotient)
{ {
bgc_complex_multiply_by_number_fp32(dividend, 1.0f / divisor, quotient); bgc_fp32_complex_multiply(dividend, 1.0f / divisor, quotient);
} }
inline void bgc_complex_divide_by_number_fp64(const BgcComplexFP64* dividend, const double divisor, BgcComplexFP64* quotient) inline void bgc_fp64_complex_divide(const BGC_FP64_Complex* dividend, const double divisor, BGC_FP64_Complex* quotient)
{ {
bgc_complex_multiply_by_number_fp64(dividend, 1.0 / divisor, quotient); bgc_fp64_complex_multiply(dividend, 1.0 / divisor, quotient);
} }
// ================== Average2 ================== // // ================== Average2 ================== //
inline void bgc_complex_get_mean_of_two_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, BgcComplexFP32* mean) inline void bgc_fp32_complex_get_mean2(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, BGC_FP32_Complex* mean)
{ {
mean->real = (number1->real + number2->real) * 0.5f; mean->real = (number1->real + number2->real) * 0.5f;
mean->imaginary = (number1->imaginary + number2->imaginary) * 0.5f; mean->imaginary = (number1->imaginary + number2->imaginary) * 0.5f;
} }
inline void bgc_complex_get_mean_of_two_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, BgcComplexFP64* mean) inline void bgc_fp64_complex_get_mean2(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* mean)
{ {
mean->real = (number1->real + number2->real) * 0.5; mean->real = (number1->real + number2->real) * 0.5;
mean->imaginary = (number1->imaginary + number2->imaginary) * 0.5; mean->imaginary = (number1->imaginary + number2->imaginary) * 0.5;
@ -476,70 +476,70 @@ inline void bgc_complex_get_mean_of_two_fp64(const BgcComplexFP64* number1, cons
// ================== Average3 ================== // // ================== Average3 ================== //
inline void bgc_complex_get_mean_of_three_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, const BgcComplexFP32* number3, BgcComplexFP32* mean) inline void bgc_fp32_complex_get_mean3(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, const BGC_FP32_Complex* number3, BGC_FP32_Complex* mean)
{ {
mean->real = (number1->real + number2->real + number3->real) * BGC_ONE_THIRD_FP32; mean->real = (number1->real + number2->real + number3->real) * BGC_FP32_ONE_THIRD;
mean->imaginary = (number1->imaginary + number2->imaginary + number3->imaginary) * BGC_ONE_THIRD_FP32; mean->imaginary = (number1->imaginary + number2->imaginary + number3->imaginary) * BGC_FP32_ONE_THIRD;
} }
inline void bgc_complex_get_mean_of_three_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, const BgcComplexFP64* number3, BgcComplexFP64* mean) inline void bgc_fp64_complex_get_mean3(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, const BGC_FP64_Complex* number3, BGC_FP64_Complex* mean)
{ {
mean->real = (number1->real + number2->real + number3->real) * BGC_ONE_THIRD_FP64; mean->real = (number1->real + number2->real + number3->real) * BGC_FP64_ONE_THIRD;
mean->imaginary = (number1->imaginary + number2->imaginary + number3->imaginary) * BGC_ONE_THIRD_FP64; mean->imaginary = (number1->imaginary + number2->imaginary + number3->imaginary) * BGC_FP64_ONE_THIRD;
} }
// =================== Linear =================== // // =================== Linear =================== //
inline void bgc_complex_interpolate_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2, const float phase, BgcComplexFP32* interpolation) inline void bgc_fp32_complex_interpolate(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, const float phase, BGC_FP32_Complex* interpolation)
{ {
const float counterphase = 1.0f - phase; const float counter_phase = 1.0f - phase;
interpolation->real = number1->real * counterphase + number2->real * phase; interpolation->real = number1->real * counter_phase + number2->real * phase;
interpolation->imaginary = number1->imaginary * counterphase + number2->imaginary * phase; interpolation->imaginary = number1->imaginary * counter_phase + number2->imaginary * phase;
} }
inline void bgc_complex_interpolate_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2, const double phase, BgcComplexFP64* interpolation) inline void bgc_fp64_complex_interpolate(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, const double phase, BGC_FP64_Complex* interpolation)
{ {
const double counterphase = 1.0 - phase; const double counter_phase = 1.0 - phase;
interpolation->real = number1->real * counterphase + number2->real * phase; interpolation->real = number1->real * counter_phase + number2->real * phase;
interpolation->imaginary = number1->imaginary * counterphase + number2->imaginary * phase; interpolation->imaginary = number1->imaginary * counter_phase + number2->imaginary * phase;
} }
// ================== Are Close ================= // // ================== Are Close ================= //
inline int bgc_complex_are_close_fp32(const BgcComplexFP32* number1, const BgcComplexFP32* number2) inline int bgc_fp32_complex_are_close(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2)
{ {
const float square_modulus1 = bgc_complex_get_square_modulus_fp32(number1); const float square_modulus1 = bgc_fp32_complex_get_square_modulus(number1);
const float square_modulus2 = bgc_complex_get_square_modulus_fp32(number2); const float square_modulus2 = bgc_fp32_complex_get_square_modulus(number2);
const float d_real = number1->real - number2->real; const float d_real = number1->real - number2->real;
const float d_imaginary = number1->imaginary - number2->imaginary; const float d_imaginary = number1->imaginary - number2->imaginary;
const float square_distance = d_real * d_real + d_imaginary * d_imaginary; const float square_distance = d_real * d_real + d_imaginary * d_imaginary;
if (square_modulus1 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32 || square_modulus2 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32) { if (square_modulus1 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT) {
return square_distance <= BGC_SQUARE_EPSYLON_FP32; return square_distance <= BGC_FP32_SQUARE_EPSYLON;
} }
return square_distance <= BGC_SQUARE_EPSYLON_FP32 * square_modulus1 && square_distance <= BGC_SQUARE_EPSYLON_FP32 * square_modulus2; return square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus2;
} }
inline int bgc_complex_are_close_fp64(const BgcComplexFP64* number1, const BgcComplexFP64* number2) inline int bgc_fp64_complex_are_close(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2)
{ {
const double square_modulus1 = bgc_complex_get_square_modulus_fp64(number1); const double square_modulus1 = bgc_fp64_complex_get_square_modulus(number1);
const double square_modulus2 = bgc_complex_get_square_modulus_fp64(number2); const double square_modulus2 = bgc_fp64_complex_get_square_modulus(number2);
const double d_real = number1->real - number2->real; const double d_real = number1->real - number2->real;
const double d_imaginary = number1->imaginary - number2->imaginary; const double d_imaginary = number1->imaginary - number2->imaginary;
const double square_distance = d_real * d_real + d_imaginary * d_imaginary; const double square_distance = d_real * d_real + d_imaginary * d_imaginary;
if (square_modulus1 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP64 || square_modulus2 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP64) { if (square_modulus1 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT) {
return square_distance <= BGC_SQUARE_EPSYLON_FP64; return square_distance <= BGC_FP64_SQUARE_EPSYLON;
} }
return square_distance <= BGC_SQUARE_EPSYLON_FP64 * square_modulus1 && square_distance <= BGC_SQUARE_EPSYLON_FP64 * square_modulus2; return square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus2;
} }
#endif #endif

View file

@ -1,71 +1,68 @@
#include "./cotes-number.h" #include "./cotes-number.h"
const BgcCotesNumberFP32 BGC_IDLE_COTES_NUMBER_FP32 = { 1.0f, 0.0f }; const BGC_FP32_CotesNumber BGC_FP32_IDLE_COTES_NUMBER = { 1.0f, 0.0f };
const BgcCotesNumberFP64 BGC_IDLE_COTES_NUMBER_FP64 = { 1.0, 0.0 }; const BGC_FP64_CotesNumber BGC_FP64_IDLE_COTES_NUMBER = { 1.0, 0.0 };
extern inline void bgc_cotes_number_reset_fp32(BgcCotesNumberFP32* number); extern inline void bgc_fp32_cotes_number_reset(BGC_FP32_CotesNumber* number);
extern inline void bgc_cotes_number_reset_fp64(BgcCotesNumberFP64* number); extern inline void bgc_fp64_cotes_number_reset(BGC_FP64_CotesNumber* number);
extern inline void bgc_cotes_number_set_values_fp32(const float x1, const float x2, BgcCotesNumberFP32* number); extern inline void bgc_fp32_cotes_number_make(const float x1, const float x2, BGC_FP32_CotesNumber* number);
extern inline void bgc_cotes_number_set_values_fp64(const double x1, const double x2, BgcCotesNumberFP64* number); extern inline void bgc_fp64_cotes_number_make(const double x1, const double x2, BGC_FP64_CotesNumber* number);
extern inline void bgc_cotes_number_set_turn_fp32(const float angle, const BgcAngleUnitEnum unit, BgcCotesNumberFP32* number); extern inline void bgc_fp32_cotes_number_make_for_angle(const float angle, const int angle_unit, BGC_FP32_CotesNumber* number);
extern inline void bgc_cotes_number_set_turn_fp64(const double angle, const BgcAngleUnitEnum unit, BgcCotesNumberFP64* number); extern inline void bgc_fp64_cotes_number_make_for_angle(const double angle, const int angle_unit, BGC_FP64_CotesNumber* number);
extern inline float bgc_cotes_number_get_angle_fp32(const BgcCotesNumberFP32* number, const BgcAngleUnitEnum unit); extern inline int bgc_fp32_cotes_number_is_idle(const BGC_FP32_CotesNumber* number);
extern inline double bgc_cotes_number_get_angle_fp64(const BgcCotesNumberFP64* number, const BgcAngleUnitEnum unit); extern inline int bgc_fp64_cotes_number_is_idle(const BGC_FP64_CotesNumber* number);
extern inline void bgc_cotes_number_copy_fp32(const BgcCotesNumberFP32* source, BgcCotesNumberFP32* destination); extern inline float bgc_fp32_cotes_number_get_angle(const BGC_FP32_CotesNumber* number, const int angle_unit);
extern inline void bgc_cotes_number_copy_fp64(const BgcCotesNumberFP64* source, BgcCotesNumberFP64* destination); extern inline double bgc_fp64_cotes_number_get_angle(const BGC_FP64_CotesNumber* number, const int angle_unit);
extern inline void bgc_cotes_number_swap_fp32(BgcCotesNumberFP32* number1, BgcCotesNumberFP32* number2); extern inline void bgc_fp32_cotes_number_copy(const BGC_FP32_CotesNumber* source, BGC_FP32_CotesNumber* destination);
extern inline void bgc_cotes_number_swap_fp64(BgcCotesNumberFP64* number1, BgcCotesNumberFP64* number2); extern inline void bgc_fp64_cotes_number_copy(const BGC_FP64_CotesNumber* source, BGC_FP64_CotesNumber* destination);
extern inline void bgc_cotes_number_convert_fp64_to_fp32(const BgcCotesNumberFP64* source, BgcCotesNumberFP32* destination); extern inline void bgc_fp32_cotes_number_swap(BGC_FP32_CotesNumber* number1, BGC_FP32_CotesNumber* number2);
extern inline void bgc_cotes_number_convert_fp32_to_fp64(const BgcCotesNumberFP32* source, BgcCotesNumberFP64* destination); extern inline void bgc_fp64_cotes_number_swap(BGC_FP64_CotesNumber* number1, BGC_FP64_CotesNumber* number2);
extern inline void bgc_cotes_number_make_opposite_fp32(BgcCotesNumberFP32* number); extern inline void bgc_fp64_cotes_number_convert_to_fp32(const BGC_FP64_CotesNumber* source, BGC_FP32_CotesNumber* destination);
extern inline void bgc_cotes_number_make_opposite_fp64(BgcCotesNumberFP64* number); extern inline void bgc_fp32_cotes_number_convert_to_fp64(const BGC_FP32_CotesNumber* source, BGC_FP64_CotesNumber* destination);
extern inline void bgc_cotes_number_get_opposite_fp32(const BgcCotesNumberFP32* number, BgcCotesNumberFP32* opposite); extern inline void bgc_fp32_cotes_number_revert(BGC_FP32_CotesNumber* number);
extern inline void bgc_cotes_number_get_opposite_fp64(const BgcCotesNumberFP64* number, BgcCotesNumberFP64* opposite); extern inline void bgc_fp64_cotes_number_revert(BGC_FP64_CotesNumber* number);
extern inline void bgc_cotes_number_invert_fp32(BgcCotesNumberFP32* number); extern inline void bgc_fp32_cotes_number_get_reverse(const BGC_FP32_CotesNumber* number, BGC_FP32_CotesNumber* inverse);
extern inline void bgc_cotes_number_invert_fp64(BgcCotesNumberFP64* number); extern inline void bgc_fp64_cotes_number_get_inverse(const BGC_FP64_CotesNumber* number, BGC_FP64_CotesNumber* inverse);
extern inline void bgc_cotes_number_get_inverse_fp32(const BgcCotesNumberFP32* number, BgcCotesNumberFP32* inverse); extern inline void bgc_fp32_cotes_number_get_exponation(const BGC_FP32_CotesNumber* base, const float exponent, BGC_FP32_CotesNumber* power);
extern inline void bgc_cotes_number_get_inverse_fp64(const BgcCotesNumberFP64* number, BgcCotesNumberFP64* inverse); extern inline void bgc_fp64_cotes_number_get_exponation(const BGC_FP64_CotesNumber* base, const double exponent, BGC_FP64_CotesNumber* power);
extern inline void bgc_cotes_number_get_exponation_fp32(const BgcCotesNumberFP32* base, const float exponent, BgcCotesNumberFP32* power); extern inline void bgc_fp32_cotes_number_combine(const BGC_FP32_CotesNumber* number1, const BGC_FP32_CotesNumber* number2, BGC_FP32_CotesNumber* result);
extern inline void bgc_cotes_number_get_exponation_fp64(const BgcCotesNumberFP64* base, const double exponent, BgcCotesNumberFP64* power); extern inline void bgc_fp64_cotes_number_combine(const BGC_FP64_CotesNumber* number1, const BGC_FP64_CotesNumber* number2, BGC_FP64_CotesNumber* result);
extern inline void bgc_cotes_number_combine_fp32(const BgcCotesNumberFP32* number1, const BgcCotesNumberFP32* number2, BgcCotesNumberFP32* result); extern inline void bgc_fp32_cotes_number_exclude(const BGC_FP32_CotesNumber* base, const BGC_FP32_CotesNumber* excludant, BGC_FP32_CotesNumber* difference);
extern inline void bgc_cotes_number_combine_fp64(const BgcCotesNumberFP64* number1, const BgcCotesNumberFP64* number2, BgcCotesNumberFP64* result); extern inline void bgc_fp64_cotes_number_exclude(const BGC_FP64_CotesNumber* base, const BGC_FP64_CotesNumber* excludant, BGC_FP64_CotesNumber* difference);
extern inline void bgc_cotes_number_exclude_fp32(const BgcCotesNumberFP32* base, const BgcCotesNumberFP32* excludant, BgcCotesNumberFP32* difference); extern inline void bgc_fp32_cotes_number_get_rotation_matrix(const BGC_FP32_CotesNumber* number, BGC_FP32_Matrix2x2* matrix);
extern inline void bgc_cotes_number_exclude_fp64(const BgcCotesNumberFP64* base, const BgcCotesNumberFP64* excludant, BgcCotesNumberFP64* difference); extern inline void bgc_fp64_cotes_number_get_rotation_matrix(const BGC_FP64_CotesNumber* number, BGC_FP64_Matrix2x2* matrix);
extern inline void bgc_cotes_number_get_rotation_matrix_fp32(const BgcCotesNumberFP32* number, BgcMatrix2x2FP32* matrix); extern inline void bgc_fp32_cotes_number_get_reverse_matrix(const BGC_FP32_CotesNumber* number, BGC_FP32_Matrix2x2* matrix);
extern inline void bgc_cotes_number_get_rotation_matrix_fp64(const BgcCotesNumberFP64* number, BgcMatrix2x2FP64* matrix); extern inline void bgc_fp64_cotes_number_get_reverse_matrix(const BGC_FP64_CotesNumber* number, BGC_FP64_Matrix2x2* matrix);
extern inline void bgc_cotes_number_get_reverse_matrix_fp32(const BgcCotesNumberFP32* number, BgcMatrix2x2FP32* matrix); extern inline void bgc_fp32_cotes_number_turn_vector(const BGC_FP32_CotesNumber* number, const BGC_FP32_Vector2* vector, BGC_FP32_Vector2* result);
extern inline void bgc_cotes_number_get_reverse_matrix_fp64(const BgcCotesNumberFP64* number, BgcMatrix2x2FP64* matrix); extern inline void bgc_fp64_cotes_number_turn_vector(const BGC_FP64_CotesNumber* number, const BGC_FP64_Vector2* vector, BGC_FP64_Vector2* result);
extern inline void bgc_cotes_number_turn_vector_fp32(const BgcCotesNumberFP32* number, const BgcVector2FP32* vector, BgcVector2FP32* result); extern inline void bgc_fp32_cotes_number_turn_vector_back(const BGC_FP32_CotesNumber* number, const BGC_FP32_Vector2* vector, BGC_FP32_Vector2* result);
extern inline void bgc_cotes_number_turn_vector_fp64(const BgcCotesNumberFP64* number, const BgcVector2FP64* vector, BgcVector2FP64* result); extern inline void bgc_fp64_cotes_number_turn_vector_back(const BGC_FP64_CotesNumber* number, const BGC_FP64_Vector2* vector, BGC_FP64_Vector2* result);
extern inline void bgc_cotes_number_turn_vector_back_fp32(const BgcCotesNumberFP32* number, const BgcVector2FP32* vector, BgcVector2FP32* result); extern inline int bgc_fp32_cotes_number_are_close(const BGC_FP32_CotesNumber* number1, const BGC_FP32_CotesNumber* number2);
extern inline void bgc_cotes_number_turn_vector_back_fp64(const BgcCotesNumberFP64* number, const BgcVector2FP64* vector, BgcVector2FP64* result); extern inline int bgc_fp64_cotes_number_are_close(const BGC_FP64_CotesNumber* number1, const BGC_FP64_CotesNumber* number2);
extern inline int bgc_cotes_number_are_close_fp32(const BgcCotesNumberFP32* number1, const BgcCotesNumberFP32* number2); void _bgc_fp32_cotes_number_normalize(BGC_FP32_CotesNumber* number)
extern inline int bgc_cotes_number_are_close_fp64(const BgcCotesNumberFP64* number1, const BgcCotesNumberFP64* number2);
void _bgc_cotes_number_normalize_fp32(const float square_modulus, BgcCotesNumberFP32* number)
{ {
// (square_modulus != square_modulus) is true when square_modulus is NaN const float square_modulus = number->_cos * number->_cos + number->_sin * number->_sin;
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
number->_cos = 1.0f; number->_cos = 1.0f;
number->_sin = 0.0f; number->_sin = 0.0f;
return; return;
@ -77,11 +74,11 @@ void _bgc_cotes_number_normalize_fp32(const float square_modulus, BgcCotesNumber
number->_sin *= multiplier; number->_sin *= multiplier;
} }
void _bgc_cotes_number_normalize_fp64(const double square_modulus, BgcCotesNumberFP64* number) void _bgc_fp64_cotes_number_normalize(BGC_FP64_CotesNumber* number)
{ {
// (square_modulus != square_modulus) is true when square_modulus is NaN const double square_modulus = number->_cos * number->_cos + number->_sin * number->_sin;
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
number->_cos = 1.0; number->_cos = 1.0;
number->_sin = 0.0; number->_sin = 0.0;
return; return;

View file

@ -13,101 +13,114 @@
typedef struct typedef struct
{ {
float _cos, _sin; float _cos, _sin;
} BgcCotesNumberFP32; } BGC_FP32_CotesNumber;
typedef struct typedef struct
{ {
double _cos, _sin; double _cos, _sin;
} BgcCotesNumberFP64; } BGC_FP64_CotesNumber;
// ================= Constants ================== // // ================= Constants ================== //
extern const BgcCotesNumberFP32 BGC_IDLE_COTES_NUMBER_FP32; extern const BGC_FP32_CotesNumber BGC_FP32_IDLE_COTES_NUMBER;
extern const BgcCotesNumberFP64 BGC_IDLE_COTES_NUMBER_FP64; extern const BGC_FP64_CotesNumber BGC_FP64_IDLE_COTES_NUMBER;
// =================== Reset ==================== // // =================== Reset ==================== //
inline void bgc_cotes_number_reset_fp32(BgcCotesNumberFP32* number) inline void bgc_fp32_cotes_number_reset(BGC_FP32_CotesNumber* number)
{ {
number->_cos = 1.0f; number->_cos = 1.0f;
number->_sin = 0.0f; number->_sin = 0.0f;
} }
inline void bgc_cotes_number_reset_fp64(BgcCotesNumberFP64* number) inline void bgc_fp64_cotes_number_reset(BGC_FP64_CotesNumber* number)
{ {
number->_cos = 1.0; number->_cos = 1.0;
number->_sin = 0.0; number->_sin = 0.0;
} }
// ================== Set Turn ================== //
inline void bgc_fp32_cotes_number_make_for_angle(const float angle, const int angle_unit, BGC_FP32_CotesNumber* number)
{
const float radians = bgc_fp32_angle_to_radians(angle, angle_unit);
number->_cos = cosf(radians);
number->_sin = sinf(radians);
}
inline void bgc_fp64_cotes_number_make_for_angle(const double angle, const int angle_unit, BGC_FP64_CotesNumber* number)
{
const double radians = bgc_fp64_angle_to_radians(angle, angle_unit);
number->_cos = cos(radians);
number->_sin = sin(radians);
}
// ================== Set Turn ================== //
inline int bgc_fp32_cotes_number_is_idle(const BGC_FP32_CotesNumber* number)
{
return bgc_fp32_is_unit(number->_cos) && bgc_fp32_is_zero(number->_sin);
}
inline int bgc_fp64_cotes_number_is_idle(const BGC_FP64_CotesNumber* number)
{
return bgc_fp64_is_unit(number->_cos) && bgc_fp64_is_zero(number->_sin);
}
// ==================== Set ===================== // // ==================== Set ===================== //
void _bgc_cotes_number_normalize_fp32(const float square_modulus, BgcCotesNumberFP32* twin); void _bgc_fp32_cotes_number_normalize(BGC_FP32_CotesNumber* twin);
void _bgc_cotes_number_normalize_fp64(const double square_modulus, BgcCotesNumberFP64* twin); void _bgc_fp64_cotes_number_normalize(BGC_FP64_CotesNumber* twin);
inline void bgc_cotes_number_set_values_fp32(const float x1, const float x2, BgcCotesNumberFP32* number) inline void bgc_fp32_cotes_number_make(const float x1, const float x2, BGC_FP32_CotesNumber* number)
{ {
const float square_modulus = x1 * x1 + x2 * x2; const float square_modulus = x1 * x1 + x2 * x2;
number->_cos = x1; number->_cos = x1;
number->_sin = x2; number->_sin = x2;
if (!bgc_is_sqare_unit_fp32(square_modulus)) { if (!bgc_fp32_is_square_unit(square_modulus)) {
_bgc_cotes_number_normalize_fp32(square_modulus, number); _bgc_fp32_cotes_number_normalize(number);
} }
} }
inline void bgc_cotes_number_set_values_fp64(const double x1, const double x2, BgcCotesNumberFP64* number) inline void bgc_fp64_cotes_number_make(const double x1, const double x2, BGC_FP64_CotesNumber* number)
{ {
const double square_modulus = x1 * x1 + x2 * x2; const double square_modulus = x1 * x1 + x2 * x2;
number->_cos = x1; number->_cos = x1;
number->_sin = x2; number->_sin = x2;
if (!bgc_is_sqare_unit_fp64(square_modulus)) { if (!bgc_fp64_is_square_unit(square_modulus)) {
_bgc_cotes_number_normalize_fp64(square_modulus, number); _bgc_fp64_cotes_number_normalize(number);
} }
} }
// ================== Set Turn ================== //
inline void bgc_cotes_number_set_turn_fp32(const float angle, const BgcAngleUnitEnum unit, BgcCotesNumberFP32* number)
{
const float radians = bgc_angle_to_radians_fp32(angle, unit);
number->_cos = cosf(radians);
number->_sin = sinf(radians);
}
inline void bgc_cotes_number_set_turn_fp64(const double angle, const BgcAngleUnitEnum unit, BgcCotesNumberFP64* number)
{
const double radians = bgc_angle_to_radians_fp64(angle, unit);
number->_cos = cos(radians);
number->_sin = sin(radians);
}
// =================== Angle =================== // // =================== Angle =================== //
inline float bgc_cotes_number_get_angle_fp32(const BgcCotesNumberFP32* number, const BgcAngleUnitEnum unit) inline float bgc_fp32_cotes_number_get_angle(const BGC_FP32_CotesNumber* number, const int angle_unit)
{ {
return bgc_radians_to_units_fp32(atan2f(number->_sin, number->_cos), unit); return bgc_fp32_radians_to_units(atan2f(number->_sin, number->_cos), angle_unit);
} }
inline double bgc_cotes_number_get_angle_fp64(const BgcCotesNumberFP64* number, const BgcAngleUnitEnum unit) inline double bgc_fp64_cotes_number_get_angle(const BGC_FP64_CotesNumber* number, const int angle_unit)
{ {
return bgc_radians_to_units_fp64(atan2(number->_sin, number->_cos), unit); return bgc_fp64_radians_to_units(atan2(number->_sin, number->_cos), angle_unit);
} }
// ==================== Copy ==================== // // ==================== Copy ==================== //
inline void bgc_cotes_number_copy_fp32(const BgcCotesNumberFP32* source, BgcCotesNumberFP32* destination) inline void bgc_fp32_cotes_number_copy(const BGC_FP32_CotesNumber* source, BGC_FP32_CotesNumber* destination)
{ {
destination->_cos = source->_cos; destination->_cos = source->_cos;
destination->_sin = source->_sin; destination->_sin = source->_sin;
} }
inline void bgc_cotes_number_copy_fp64(const BgcCotesNumberFP64* source, BgcCotesNumberFP64* destination) inline void bgc_fp64_cotes_number_copy(const BGC_FP64_CotesNumber* source, BGC_FP64_CotesNumber* destination)
{ {
destination->_cos = source->_cos; destination->_cos = source->_cos;
destination->_sin = source->_sin; destination->_sin = source->_sin;
@ -115,7 +128,7 @@ inline void bgc_cotes_number_copy_fp64(const BgcCotesNumberFP64* source, BgcCote
// ==================== Swap ==================== // // ==================== Swap ==================== //
inline void bgc_cotes_number_swap_fp32(BgcCotesNumberFP32* number1, BgcCotesNumberFP32* number2) inline void bgc_fp32_cotes_number_swap(BGC_FP32_CotesNumber* number1, BGC_FP32_CotesNumber* number2)
{ {
const float cos = number1->_cos; const float cos = number1->_cos;
const float sin = number1->_sin; const float sin = number1->_sin;
@ -127,7 +140,7 @@ inline void bgc_cotes_number_swap_fp32(BgcCotesNumberFP32* number1, BgcCotesNumb
number2->_sin = sin; number2->_sin = sin;
} }
inline void bgc_cotes_number_swap_fp64(BgcCotesNumberFP64* number1, BgcCotesNumberFP64* number2) inline void bgc_fp64_cotes_number_swap(BGC_FP64_CotesNumber* number1, BGC_FP64_CotesNumber* number2)
{ {
const double cos = number1->_cos; const double cos = number1->_cos;
const double sin = number1->_sin; const double sin = number1->_sin;
@ -141,61 +154,35 @@ inline void bgc_cotes_number_swap_fp64(BgcCotesNumberFP64* number1, BgcCotesNumb
// ================== Convert =================== // // ================== Convert =================== //
inline void bgc_cotes_number_convert_fp64_to_fp32(const BgcCotesNumberFP64* source, BgcCotesNumberFP32* destination) inline void bgc_fp64_cotes_number_convert_to_fp32(const BGC_FP64_CotesNumber* source, BGC_FP32_CotesNumber* destination)
{ {
bgc_cotes_number_set_values_fp32((float)source->_cos, (float)source->_sin, destination); bgc_fp32_cotes_number_make((float)source->_cos, (float)source->_sin, destination);
} }
inline void bgc_cotes_number_convert_fp32_to_fp64(const BgcCotesNumberFP32* source, BgcCotesNumberFP64* destination) inline void bgc_fp32_cotes_number_convert_to_fp64(const BGC_FP32_CotesNumber* source, BGC_FP64_CotesNumber* destination)
{ {
bgc_cotes_number_set_values_fp64((double)source->_cos, (double)source->_sin, destination); bgc_fp64_cotes_number_make((double)source->_cos, (double)source->_sin, destination);
} }
// ================== Negative ================== // // =================== Revert =================== //
inline void bgc_cotes_number_make_opposite_fp32(BgcCotesNumberFP32* number) inline void bgc_fp32_cotes_number_revert(BGC_FP32_CotesNumber* number)
{
number->_cos = -number->_cos;
number->_sin = -number->_sin;
}
inline void bgc_cotes_number_make_opposite_fp64(BgcCotesNumberFP64* number)
{
number->_cos = -number->_cos;
number->_sin = -number->_sin;
}
inline void bgc_cotes_number_get_opposite_fp32(const BgcCotesNumberFP32* number, BgcCotesNumberFP32* opposite)
{
opposite->_cos = -number->_cos;
opposite->_sin = -number->_sin;
}
inline void bgc_cotes_number_get_opposite_fp64(const BgcCotesNumberFP64* number, BgcCotesNumberFP64* opposite)
{
opposite->_cos = -number->_cos;
opposite->_sin = -number->_sin;
}
// =================== Invert =================== //
inline void bgc_cotes_number_invert_fp32(BgcCotesNumberFP32* number)
{ {
number->_sin = -number->_sin; number->_sin = -number->_sin;
} }
inline void bgc_cotes_number_invert_fp64(BgcCotesNumberFP64* number) inline void bgc_fp64_cotes_number_revert(BGC_FP64_CotesNumber* number)
{ {
number->_sin = -number->_sin; number->_sin = -number->_sin;
} }
inline void bgc_cotes_number_get_inverse_fp32(const BgcCotesNumberFP32* number, BgcCotesNumberFP32* inverse) inline void bgc_fp32_cotes_number_get_reverse(const BGC_FP32_CotesNumber* number, BGC_FP32_CotesNumber* inverse)
{ {
inverse->_cos = number->_cos; inverse->_cos = number->_cos;
inverse->_sin = -number->_sin; inverse->_sin = -number->_sin;
} }
inline void bgc_cotes_number_get_inverse_fp64(const BgcCotesNumberFP64* number, BgcCotesNumberFP64* inverse) inline void bgc_fp64_cotes_number_get_inverse(const BGC_FP64_CotesNumber* number, BGC_FP64_CotesNumber* inverse)
{ {
inverse->_cos = number->_cos; inverse->_cos = number->_cos;
inverse->_sin = -number->_sin; inverse->_sin = -number->_sin;
@ -203,7 +190,7 @@ inline void bgc_cotes_number_get_inverse_fp64(const BgcCotesNumberFP64* number,
// ================= Exponation ================= // // ================= Exponation ================= //
inline void bgc_cotes_number_get_exponation_fp32(const BgcCotesNumberFP32* base, const float exponent, BgcCotesNumberFP32* power) inline void bgc_fp32_cotes_number_get_exponation(const BGC_FP32_CotesNumber* base, const float exponent, BGC_FP32_CotesNumber* power)
{ {
const float power_angle = exponent * atan2f(base->_sin, base->_cos); const float power_angle = exponent * atan2f(base->_sin, base->_cos);
@ -211,7 +198,7 @@ inline void bgc_cotes_number_get_exponation_fp32(const BgcCotesNumberFP32* base,
power->_sin = sinf(power_angle); power->_sin = sinf(power_angle);
} }
inline void bgc_cotes_number_get_exponation_fp64(const BgcCotesNumberFP64* base, const double exponent, BgcCotesNumberFP64* power) inline void bgc_fp64_cotes_number_get_exponation(const BGC_FP64_CotesNumber* base, const double exponent, BGC_FP64_CotesNumber* power)
{ {
const double power_angle = exponent * atan2(base->_sin, base->_cos); const double power_angle = exponent * atan2(base->_sin, base->_cos);
@ -221,18 +208,18 @@ inline void bgc_cotes_number_get_exponation_fp64(const BgcCotesNumberFP64* base,
// ================ Combination ================= // // ================ Combination ================= //
inline void bgc_cotes_number_combine_fp32(const BgcCotesNumberFP32* number1, const BgcCotesNumberFP32* number2, BgcCotesNumberFP32* result) inline void bgc_fp32_cotes_number_combine(const BGC_FP32_CotesNumber* number1, const BGC_FP32_CotesNumber* number2, BGC_FP32_CotesNumber* result)
{ {
bgc_cotes_number_set_values_fp32( bgc_fp32_cotes_number_make(
number1->_cos * number2->_cos - number1->_sin * number2->_sin, number1->_cos * number2->_cos - number1->_sin * number2->_sin,
number1->_cos * number2->_sin + number1->_sin * number2->_cos, number1->_cos * number2->_sin + number1->_sin * number2->_cos,
result result
); );
} }
inline void bgc_cotes_number_combine_fp64(const BgcCotesNumberFP64* number1, const BgcCotesNumberFP64* number2, BgcCotesNumberFP64* result) inline void bgc_fp64_cotes_number_combine(const BGC_FP64_CotesNumber* number1, const BGC_FP64_CotesNumber* number2, BGC_FP64_CotesNumber* result)
{ {
bgc_cotes_number_set_values_fp64( bgc_fp64_cotes_number_make(
number1->_cos * number2->_cos - number1->_sin * number2->_sin, number1->_cos * number2->_cos - number1->_sin * number2->_sin,
number1->_cos * number2->_sin + number1->_sin * number2->_cos, number1->_cos * number2->_sin + number1->_sin * number2->_cos,
result result
@ -241,18 +228,18 @@ inline void bgc_cotes_number_combine_fp64(const BgcCotesNumberFP64* number1, con
// ================= Exclusion ================== // // ================= Exclusion ================== //
inline void bgc_cotes_number_exclude_fp32(const BgcCotesNumberFP32* base, const BgcCotesNumberFP32* excludant, BgcCotesNumberFP32* difference) inline void bgc_fp32_cotes_number_exclude(const BGC_FP32_CotesNumber* base, const BGC_FP32_CotesNumber* excludant, BGC_FP32_CotesNumber* difference)
{ {
bgc_cotes_number_set_values_fp32( bgc_fp32_cotes_number_make(
base->_cos * excludant->_cos + base->_sin * excludant->_sin, base->_cos * excludant->_cos + base->_sin * excludant->_sin,
base->_sin * excludant->_cos - base->_cos * excludant->_sin, base->_sin * excludant->_cos - base->_cos * excludant->_sin,
difference difference
); );
} }
inline void bgc_cotes_number_exclude_fp64(const BgcCotesNumberFP64* base, const BgcCotesNumberFP64* excludant, BgcCotesNumberFP64* difference) inline void bgc_fp64_cotes_number_exclude(const BGC_FP64_CotesNumber* base, const BGC_FP64_CotesNumber* excludant, BGC_FP64_CotesNumber* difference)
{ {
bgc_cotes_number_set_values_fp64( bgc_fp64_cotes_number_make(
base->_cos * excludant->_cos + base->_sin * excludant->_sin, base->_cos * excludant->_cos + base->_sin * excludant->_sin,
base->_sin * excludant->_cos - base->_cos * excludant->_sin, base->_sin * excludant->_cos - base->_cos * excludant->_sin,
difference difference
@ -261,7 +248,7 @@ inline void bgc_cotes_number_exclude_fp64(const BgcCotesNumberFP64* base, const
// ============== Rotation Matrix =============== // // ============== Rotation Matrix =============== //
inline void bgc_cotes_number_get_rotation_matrix_fp32(const BgcCotesNumberFP32* number, BgcMatrix2x2FP32* matrix) inline void bgc_fp32_cotes_number_get_rotation_matrix(const BGC_FP32_CotesNumber* number, BGC_FP32_Matrix2x2* matrix)
{ {
matrix->r1c1 = number->_cos; matrix->r1c1 = number->_cos;
matrix->r1c2 = -number->_sin; matrix->r1c2 = -number->_sin;
@ -269,7 +256,7 @@ inline void bgc_cotes_number_get_rotation_matrix_fp32(const BgcCotesNumberFP32*
matrix->r2c2 = number->_cos; matrix->r2c2 = number->_cos;
} }
inline void bgc_cotes_number_get_rotation_matrix_fp64(const BgcCotesNumberFP64* number, BgcMatrix2x2FP64* matrix) inline void bgc_fp64_cotes_number_get_rotation_matrix(const BGC_FP64_CotesNumber* number, BGC_FP64_Matrix2x2* matrix)
{ {
matrix->r1c1 = number->_cos; matrix->r1c1 = number->_cos;
matrix->r1c2 = -number->_sin; matrix->r1c2 = -number->_sin;
@ -279,7 +266,7 @@ inline void bgc_cotes_number_get_rotation_matrix_fp64(const BgcCotesNumberFP64*
// ============== Reverse Matrix ================ // // ============== Reverse Matrix ================ //
inline void bgc_cotes_number_get_reverse_matrix_fp32(const BgcCotesNumberFP32* number, BgcMatrix2x2FP32* matrix) inline void bgc_fp32_cotes_number_get_reverse_matrix(const BGC_FP32_CotesNumber* number, BGC_FP32_Matrix2x2* matrix)
{ {
matrix->r1c1 = number->_cos; matrix->r1c1 = number->_cos;
matrix->r1c2 = number->_sin; matrix->r1c2 = number->_sin;
@ -287,7 +274,7 @@ inline void bgc_cotes_number_get_reverse_matrix_fp32(const BgcCotesNumberFP32* n
matrix->r2c2 = number->_cos; matrix->r2c2 = number->_cos;
} }
inline void bgc_cotes_number_get_reverse_matrix_fp64(const BgcCotesNumberFP64* number, BgcMatrix2x2FP64* matrix) inline void bgc_fp64_cotes_number_get_reverse_matrix(const BGC_FP64_CotesNumber* number, BGC_FP64_Matrix2x2* matrix)
{ {
matrix->r1c1 = number->_cos; matrix->r1c1 = number->_cos;
matrix->r1c2 = number->_sin; matrix->r1c2 = number->_sin;
@ -297,7 +284,7 @@ inline void bgc_cotes_number_get_reverse_matrix_fp64(const BgcCotesNumberFP64* n
// ================ Turn Vector ================= // // ================ Turn Vector ================= //
inline void bgc_cotes_number_turn_vector_fp32(const BgcCotesNumberFP32* number, const BgcVector2FP32* vector, BgcVector2FP32* result) inline void bgc_fp32_cotes_number_turn_vector(const BGC_FP32_CotesNumber* number, const BGC_FP32_Vector2* vector, BGC_FP32_Vector2* result)
{ {
const float x1 = number->_cos * vector->x1 - number->_sin * vector->x2; const float x1 = number->_cos * vector->x1 - number->_sin * vector->x2;
const float x2 = number->_sin * vector->x1 + number->_cos * vector->x2; const float x2 = number->_sin * vector->x1 + number->_cos * vector->x2;
@ -306,7 +293,7 @@ inline void bgc_cotes_number_turn_vector_fp32(const BgcCotesNumberFP32* number,
result->x2 = x2; result->x2 = x2;
} }
inline void bgc_cotes_number_turn_vector_fp64(const BgcCotesNumberFP64* number, const BgcVector2FP64* vector, BgcVector2FP64* result) inline void bgc_fp64_cotes_number_turn_vector(const BGC_FP64_CotesNumber* number, const BGC_FP64_Vector2* vector, BGC_FP64_Vector2* result)
{ {
const double x1 = number->_cos * vector->x1 - number->_sin * vector->x2; const double x1 = number->_cos * vector->x1 - number->_sin * vector->x2;
const double x2 = number->_sin * vector->x1 + number->_cos * vector->x2; const double x2 = number->_sin * vector->x1 + number->_cos * vector->x2;
@ -317,7 +304,7 @@ inline void bgc_cotes_number_turn_vector_fp64(const BgcCotesNumberFP64* number,
// ============ Turn Vector Backward ============ // // ============ Turn Vector Backward ============ //
inline void bgc_cotes_number_turn_vector_back_fp32(const BgcCotesNumberFP32* number, const BgcVector2FP32* vector, BgcVector2FP32* result) inline void bgc_fp32_cotes_number_turn_vector_back(const BGC_FP32_CotesNumber* number, const BGC_FP32_Vector2* vector, BGC_FP32_Vector2* result)
{ {
const float x1 = number->_sin * vector->x2 + number->_cos * vector->x1; const float x1 = number->_sin * vector->x2 + number->_cos * vector->x1;
const float x2 = number->_cos * vector->x2 - number->_sin * vector->x1; const float x2 = number->_cos * vector->x2 - number->_sin * vector->x1;
@ -326,7 +313,7 @@ inline void bgc_cotes_number_turn_vector_back_fp32(const BgcCotesNumberFP32* num
result->x2 = x2; result->x2 = x2;
} }
inline void bgc_cotes_number_turn_vector_back_fp64(const BgcCotesNumberFP64* number, const BgcVector2FP64* vector, BgcVector2FP64* result) inline void bgc_fp64_cotes_number_turn_vector_back(const BGC_FP64_CotesNumber* number, const BGC_FP64_Vector2* vector, BGC_FP64_Vector2* result)
{ {
const double x1 = number->_sin * vector->x2 + number->_cos * vector->x1; const double x1 = number->_sin * vector->x2 + number->_cos * vector->x1;
const double x2 = number->_cos * vector->x2 - number->_sin * vector->x1; const double x2 = number->_cos * vector->x2 - number->_sin * vector->x1;
@ -337,20 +324,20 @@ inline void bgc_cotes_number_turn_vector_back_fp64(const BgcCotesNumberFP64* num
// ================== Are Close ================= // // ================== Are Close ================= //
inline int bgc_cotes_number_are_close_fp32(const BgcCotesNumberFP32* number1, const BgcCotesNumberFP32* number2) inline int bgc_fp32_cotes_number_are_close(const BGC_FP32_CotesNumber* number1, const BGC_FP32_CotesNumber* number2)
{ {
const float d_cos = number1->_cos - number2->_cos; const float d_cos = number1->_cos - number2->_cos;
const float d_sin = number1->_sin - number2->_sin; const float d_sin = number1->_sin - number2->_sin;
return d_cos * d_cos + d_sin * d_sin <= BGC_SQUARE_EPSYLON_FP32; return d_cos * d_cos + d_sin * d_sin <= BGC_FP32_SQUARE_EPSYLON;
} }
inline int bgc_cotes_number_are_close_fp64(const BgcCotesNumberFP64* number1, const BgcCotesNumberFP64* number2) inline int bgc_fp64_cotes_number_are_close(const BGC_FP64_CotesNumber* number1, const BGC_FP64_CotesNumber* number2)
{ {
const double d_cos = number1->_cos - number2->_cos; const double d_cos = number1->_cos - number2->_cos;
const double d_sin = number1->_sin - number2->_sin; const double d_sin = number1->_sin - number2->_sin;
return d_cos * d_cos + d_sin * d_sin <= BGC_SQUARE_EPSYLON_FP64; return d_cos * d_cos + d_sin * d_sin <= BGC_FP64_SQUARE_EPSYLON;
} }
#endif #endif

View file

@ -1,73 +1,82 @@
#include "matrix2x2.h" #include "matrix2x2.h"
extern inline void bgc_matrix2x2_reset_fp32(BgcMatrix2x2FP32* matrix); extern inline void bgc_fp32_matrix2x2_reset(BGC_FP32_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_reset_fp64(BgcMatrix2x2FP64* matrix); extern inline void bgc_fp64_matrix2x2_reset(BGC_FP64_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_set_to_identity_fp32(BgcMatrix2x2FP32* matrix); extern inline void bgc_fp32_matrix2x2_make_identity(BGC_FP32_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_set_to_identity_fp64(BgcMatrix2x2FP64* matrix); extern inline void bgc_fp64_matrix2x2_make_identity(BGC_FP64_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_set_to_diagonal_fp32(const float d1, const float d2, BgcMatrix2x2FP32* matrix); extern inline void bgc_fp32_matrix2x2_make_diagonal(const float d1, const float d2, BGC_FP32_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_set_to_diagonal_fp64(const double d1, const double d2, BgcMatrix2x2FP64* matrix); extern inline void bgc_fp64_matrix2x2_make_diagonal(const double d1, const double d2, BGC_FP64_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_set_turn_fp32(const float angle, const BgcAngleUnitEnum unit, BgcMatrix2x2FP32* matrix); extern inline void bgc_fp32_matrix2x2_make_for_turn(const float angle, const int angle_unit, BGC_FP32_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_set_turn_fp64(const double angle, const BgcAngleUnitEnum unit, BgcMatrix2x2FP64* matrix); extern inline void bgc_fp64_matrix2x2_make_for_turn(const double angle, const int angle_unit, BGC_FP64_Matrix2x2* matrix);
extern inline float bgc_matrix2x2_get_determinant_fp32(const BgcMatrix2x2FP32* matrix); extern inline float bgc_fp32_matrix2x2_get_determinant(const BGC_FP32_Matrix2x2* matrix);
extern inline double bgc_matrix2x2_get_determinant_fp64(const BgcMatrix2x2FP64* matrix); extern inline double bgc_fp64_matrix2x2_get_determinant(const BGC_FP64_Matrix2x2* matrix);
extern inline int bgc_matrix2x2_is_singular_fp32(const BgcMatrix2x2FP32* matrix); extern inline int bgc_fp32_matrix2x2_is_identity(const BGC_FP32_Matrix2x2* matrix);
extern inline int bgc_matrix2x2_is_singular_fp64(const BgcMatrix2x2FP64* matrix); extern inline int bgc_fp64_matrix2x2_is_identity(const BGC_FP64_Matrix2x2* matrix);
extern inline int bgc_matrix2x2_is_rotation_fp32(const BgcMatrix2x2FP32* matrix); extern inline int bgc_fp32_matrix2x2_is_singular(const BGC_FP32_Matrix2x2* matrix);
extern inline int bgc_matrix2x2_is_rotation_fp64(const BgcMatrix2x2FP64* matrix); extern inline int bgc_fp64_matrix2x2_is_singular(const BGC_FP64_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_copy_fp32(const BgcMatrix2x2FP32* source, BgcMatrix2x2FP32* destination); extern inline int bgc_fp32_matrix2x2_is_rotation(const BGC_FP32_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_copy_fp64(const BgcMatrix2x2FP64* source, BgcMatrix2x2FP64* destination); extern inline int bgc_fp64_matrix2x2_is_rotation(const BGC_FP64_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_swap_fp32(BgcMatrix2x2FP32* matrix1, BgcMatrix2x2FP32* matrix2); extern inline void bgc_fp32_matrix2x2_copy(const BGC_FP32_Matrix2x2* source, BGC_FP32_Matrix2x2* destination);
extern inline void bgc_matrix2x2_swap_fp64(BgcMatrix2x2FP64* matrix1, BgcMatrix2x2FP64* matrix2); extern inline void bgc_fp64_matrix2x2_copy(const BGC_FP64_Matrix2x2* source, BGC_FP64_Matrix2x2* destination);
extern inline void bgc_matrix2x2_convert_fp64_to_fp32(const BgcMatrix2x2FP64* source, BgcMatrix2x2FP32* destination); extern inline void bgc_fp32_matrix2x2_swap(BGC_FP32_Matrix2x2* matrix1, BGC_FP32_Matrix2x2* matrix2);
extern inline void bgc_matrix2x2_convert_fp32_to_fp64(const BgcMatrix2x2FP32* source, BgcMatrix2x2FP64* destination); extern inline void bgc_fp64_matrix2x2_swap(BGC_FP64_Matrix2x2* matrix1, BGC_FP64_Matrix2x2* matrix2);
extern inline int bgc_matrix2x2_invert_fp32(const BgcMatrix2x2FP32* matrix, BgcMatrix2x2FP32* inverted); extern inline void bgc_fp64_matrix2x2_convert_to_fp32(const BGC_FP64_Matrix2x2* source, BGC_FP32_Matrix2x2* destination);
extern inline int bgc_matrix2x2_invert_fp64(const BgcMatrix2x2FP64* matrix, BgcMatrix2x2FP64* inverted); extern inline void bgc_fp32_matrix2x2_convert_to_fp64(const BGC_FP32_Matrix2x2* source, BGC_FP64_Matrix2x2* destination);
extern inline void bgc_matrix2x2_transpose_fp32(const BgcMatrix2x2FP32* matrix, BgcMatrix2x2FP32* transposed); extern inline int bgc_fp32_matrix2x2_get_inverse(const BGC_FP32_Matrix2x2* matrix, BGC_FP32_Matrix2x2* inverse);
extern inline void bgc_matrix2x2_transpose_fp64(const BgcMatrix2x2FP64* matrix, BgcMatrix2x2FP64* transposed); extern inline int bgc_fp64_matrix2x2_get_inverse(const BGC_FP64_Matrix2x2* matrix, BGC_FP64_Matrix2x2* inverse);
extern inline void bgc_matrix2x2_set_row1_fp32(const float c1, const float c2, BgcMatrix2x2FP32* matrix); extern inline int bgc_fp32_matrix2x2_invert(BGC_FP32_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_set_row1_fp64(const double c1, const double c2, BgcMatrix2x2FP64* matrix); extern inline int bgc_fp64_matrix2x2_invert(BGC_FP64_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_set_row2_fp32(const float c1, const float c2, BgcMatrix2x2FP32* matrix); extern inline void bgc_fp32_matrix2x2_transpose(BGC_FP32_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_set_row2_fp64(const double c1, const double c2, BgcMatrix2x2FP64* matrix); extern inline void bgc_fp64_matrix2x2_transpose(BGC_FP64_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_set_column1_fp32(const float r1, const float r2, BgcMatrix2x2FP32* matrix); extern inline void bgc_fp32_matrix2x2_get_transposed(const BGC_FP32_Matrix2x2* matrix, BGC_FP32_Matrix2x2* transposed);
extern inline void bgc_matrix2x2_set_column1_fp64(const double r1, const double r2, BgcMatrix2x2FP64* matrix); extern inline void bgc_fp64_matrix2x2_get_transposed(const BGC_FP64_Matrix2x2* matrix, BGC_FP64_Matrix2x2* transposed);
extern inline void bgc_matrix2x2_set_column2_fp32(const float r1, const float r2, BgcMatrix2x2FP32* matrix); extern inline void bgc_fp32_matrix2x2_get_row(const int number, const BGC_FP32_Matrix2x2* matrix, BGC_FP32_Vector2* row);
extern inline void bgc_matrix2x2_set_column2_fp64(const double r1, const double r2, BgcMatrix2x2FP64* matrix); extern inline void bgc_fp64_matrix2x2_get_row(const int number, const BGC_FP64_Matrix2x2* matrix, BGC_FP64_Vector2* row);
extern inline void bgc_matrix2x2_add_fp32(const BgcMatrix2x2FP32* matrix1, const BgcMatrix2x2FP32* matrix2, BgcMatrix2x2FP32* sum); extern inline void bgc_fp32_matrix2x2_set_row(const int number, const BGC_FP32_Vector2* row, BGC_FP32_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_add_fp64(const BgcMatrix2x2FP64* matrix1, const BgcMatrix2x2FP64* matrix2, BgcMatrix2x2FP64* sum); extern inline void bgc_fp64_matrix2x2_set_row(const int number, const BGC_FP64_Vector2* row, BGC_FP64_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_add_scaled_fp32(const BgcMatrix2x2FP32* basic_matrix, const BgcMatrix2x2FP32* scalable_matrix, const float scale, BgcMatrix2x2FP32* sum); extern inline void bgc_fp32_matrix2x2_get_column(const int number, const BGC_FP32_Matrix2x2* matrix, BGC_FP32_Vector2* column);
extern inline void bgc_matrix2x2_add_scaled_fp64(const BgcMatrix2x2FP64* basic_matrix, const BgcMatrix2x2FP64* scalable_matrix, const double scale, BgcMatrix2x2FP64* sum); extern inline void bgc_fp64_matrix2x2_get_column(const int number, const BGC_FP64_Matrix2x2* matrix, BGC_FP64_Vector2* column);
extern inline void bgc_matrix2x2_subtract_fp32(const BgcMatrix2x2FP32* minuend, const BgcMatrix2x2FP32* subtrahend, BgcMatrix2x2FP32* difference); extern inline void bgc_fp32_matrix2x2_set_column(const int number, const BGC_FP32_Vector2* column, BGC_FP32_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_subtract_fp64(const BgcMatrix2x2FP64* minuend, const BgcMatrix2x2FP64* subtrahend, BgcMatrix2x2FP64* difference); extern inline void bgc_fp64_matrix2x2_set_column(const int number, const BGC_FP64_Vector2* column, BGC_FP64_Matrix2x2* matrix);
extern inline void bgc_matrix2x2_subtract_scaled_fp32(const BgcMatrix2x2FP32* basic_matrix, const BgcMatrix2x2FP32* scalable_matrix, const float scale, BgcMatrix2x2FP32* difference); extern inline void bgc_fp32_matrix2x2_add(const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2, BGC_FP32_Matrix2x2* sum);
extern inline void bgc_matrix2x2_subtract_scaled_fp64(const BgcMatrix2x2FP64* basic_matrix, const BgcMatrix2x2FP64* scalable_matrix, const double scale, BgcMatrix2x2FP64* difference); extern inline void bgc_fp64_matrix2x2_add(const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2, BGC_FP64_Matrix2x2* sum);
extern inline void bgc_matrix2x2_multiply_fp32(const BgcMatrix2x2FP32* multiplicand, const float multiplier, BgcMatrix2x2FP32* product); extern inline void bgc_fp32_matrix2x2_add_scaled(const BGC_FP32_Matrix2x2* basic_matrix, const BGC_FP32_Matrix2x2* scalable_matrix, const float scale, BGC_FP32_Matrix2x2* sum);
extern inline void bgc_matrix2x2_multiply_fp64(const BgcMatrix2x2FP64* multiplicand, const double multiplier, BgcMatrix2x2FP64* product); extern inline void bgc_fp64_matrix2x2_add_scaled(const BGC_FP64_Matrix2x2* basic_matrix, const BGC_FP64_Matrix2x2* scalable_matrix, const double scale, BGC_FP64_Matrix2x2* sum);
extern inline void bgc_matrix2x2_divide_fp32(const BgcMatrix2x2FP32* dividend, const float divisor, BgcMatrix2x2FP32* quotient); extern inline void bgc_fp32_matrix2x2_subtract(const BGC_FP32_Matrix2x2* minuend, const BGC_FP32_Matrix2x2* subtrahend, BGC_FP32_Matrix2x2* difference);
extern inline void bgc_matrix2x2_divide_fp64(const BgcMatrix2x2FP64* dividend, const double divisor, BgcMatrix2x2FP64* quotient); extern inline void bgc_fp64_matrix2x2_subtract(const BGC_FP64_Matrix2x2* minuend, const BGC_FP64_Matrix2x2* subtrahend, BGC_FP64_Matrix2x2* difference);
extern inline void bgc_matrix2x2_get_left_product_fp32(const BgcVector2FP32* vector, const BgcMatrix2x2FP32* matrix, BgcVector2FP32* product); extern inline void bgc_fp32_matrix2x2_multiply(const BGC_FP32_Matrix2x2* multiplicand, const float multiplier, BGC_FP32_Matrix2x2* product);
extern inline void bgc_matrix2x2_get_left_product_fp64(const BgcVector2FP64* vector, const BgcMatrix2x2FP64* matrix, BgcVector2FP64* product); extern inline void bgc_fp64_matrix2x2_multiply(const BGC_FP64_Matrix2x2* multiplicand, const double multiplier, BGC_FP64_Matrix2x2* product);
extern inline void bgc_matrix2x2_get_right_product_fp32(const BgcMatrix2x2FP32* matrix, const BgcVector2FP32* vector, BgcVector2FP32* product); extern inline void bgc_fp32_matrix2x2_divide(const BGC_FP32_Matrix2x2* dividend, const float divisor, BGC_FP32_Matrix2x2* quotient);
extern inline void bgc_matrix2x2_get_right_product_fp64(const BgcMatrix2x2FP64* matrix, const BgcVector2FP64* vector, BgcVector2FP64* product); extern inline void bgc_fp64_matrix2x2_divide(const BGC_FP64_Matrix2x2* dividend, const double divisor, BGC_FP64_Matrix2x2* quotient);
extern inline void bgc_fp32_matrix2x2_interpolate(const BGC_FP32_Matrix2x2* first, const BGC_FP32_Matrix2x2* second, const float phase, BGC_FP32_Matrix2x2* interpolation);
extern inline void bgc_fp64_matrix2x2_interpolate(const BGC_FP64_Matrix2x2* first, const BGC_FP64_Matrix2x2* second, const double phase, BGC_FP64_Matrix2x2* interpolation);
extern inline void bgc_fp32_multiply_matrix2x2_by_vector2(const BGC_FP32_Matrix2x2* matrix, const BGC_FP32_Vector2* vector, BGC_FP32_Vector2* product);
extern inline void bgc_fp64_multiply_matrix2x2_by_vector2(const BGC_FP64_Matrix2x2* matrix, const BGC_FP64_Vector2* vector, BGC_FP64_Vector2* product);
extern inline void bgc_fp32_multiply_vector2_by_matrix2x2(const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix2x2* matrix, BGC_FP32_Vector2* product);
extern inline void bgc_fp64_multiply_vector2_by_matrix2x2(const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix2x2* matrix, BGC_FP64_Vector2* product);

View file

@ -7,7 +7,7 @@
// =================== Reset ==================== // // =================== Reset ==================== //
inline void bgc_matrix2x2_reset_fp32(BgcMatrix2x2FP32* matrix) inline void bgc_fp32_matrix2x2_reset(BGC_FP32_Matrix2x2* matrix)
{ {
matrix->r1c1 = 0.0f; matrix->r1c1 = 0.0f;
matrix->r1c2 = 0.0f; matrix->r1c2 = 0.0f;
@ -15,7 +15,7 @@ inline void bgc_matrix2x2_reset_fp32(BgcMatrix2x2FP32* matrix)
matrix->r2c2 = 0.0f; matrix->r2c2 = 0.0f;
} }
inline void bgc_matrix2x2_reset_fp64(BgcMatrix2x2FP64* matrix) inline void bgc_fp64_matrix2x2_reset(BGC_FP64_Matrix2x2* matrix)
{ {
matrix->r1c1 = 0.0; matrix->r1c1 = 0.0;
matrix->r1c2 = 0.0; matrix->r1c2 = 0.0;
@ -25,7 +25,7 @@ inline void bgc_matrix2x2_reset_fp64(BgcMatrix2x2FP64* matrix)
// ================== Identity ================== // // ================== Identity ================== //
inline void bgc_matrix2x2_set_to_identity_fp32(BgcMatrix2x2FP32* matrix) inline void bgc_fp32_matrix2x2_make_identity(BGC_FP32_Matrix2x2* matrix)
{ {
matrix->r1c1 = 1.0f; matrix->r1c1 = 1.0f;
matrix->r1c2 = 0.0f; matrix->r1c2 = 0.0f;
@ -33,7 +33,7 @@ inline void bgc_matrix2x2_set_to_identity_fp32(BgcMatrix2x2FP32* matrix)
matrix->r2c2 = 1.0f; matrix->r2c2 = 1.0f;
} }
inline void bgc_matrix2x2_set_to_identity_fp64(BgcMatrix2x2FP64* matrix) inline void bgc_fp64_matrix2x2_make_identity(BGC_FP64_Matrix2x2* matrix)
{ {
matrix->r1c1 = 1.0; matrix->r1c1 = 1.0;
matrix->r1c2 = 0.0; matrix->r1c2 = 0.0;
@ -43,7 +43,7 @@ inline void bgc_matrix2x2_set_to_identity_fp64(BgcMatrix2x2FP64* matrix)
// ================ Set Diagonal ================ // // ================ Set Diagonal ================ //
inline void bgc_matrix2x2_set_to_diagonal_fp32(const float d1, const float d2, BgcMatrix2x2FP32* matrix) inline void bgc_fp32_matrix2x2_make_diagonal(const float d1, const float d2, BGC_FP32_Matrix2x2* matrix)
{ {
matrix->r1c1 = d1; matrix->r1c1 = d1;
matrix->r1c2 = 0.0f; matrix->r1c2 = 0.0f;
@ -51,7 +51,7 @@ inline void bgc_matrix2x2_set_to_diagonal_fp32(const float d1, const float d2, B
matrix->r2c2 = d2; matrix->r2c2 = d2;
} }
inline void bgc_matrix2x2_set_to_diagonal_fp64(const double d1, const double d2, BgcMatrix2x2FP64* matrix) inline void bgc_fp64_matrix2x2_make_diagonal(const double d1, const double d2, BGC_FP64_Matrix2x2* matrix)
{ {
matrix->r1c1 = d1; matrix->r1c1 = d1;
matrix->r1c2 = 0.0; matrix->r1c2 = 0.0;
@ -61,9 +61,9 @@ inline void bgc_matrix2x2_set_to_diagonal_fp64(const double d1, const double d2,
// ============== Rotation Matrix =============== // // ============== Rotation Matrix =============== //
inline void bgc_matrix2x2_set_turn_fp32(const float angle, const BgcAngleUnitEnum unit, BgcMatrix2x2FP32* matrix) inline void bgc_fp32_matrix2x2_make_for_turn(const float angle, const int angle_unit, BGC_FP32_Matrix2x2* matrix)
{ {
const float radians = bgc_angle_to_radians_fp32(angle, unit); const float radians = bgc_fp32_angle_to_radians(angle, angle_unit);
const float cosine = cosf(radians); const float cosine = cosf(radians);
const float sine = sinf(radians); const float sine = sinf(radians);
@ -73,9 +73,9 @@ inline void bgc_matrix2x2_set_turn_fp32(const float angle, const BgcAngleUnitEnu
matrix->r2c2 = cosine; matrix->r2c2 = cosine;
} }
inline void bgc_matrix2x2_set_turn_fp64(const double angle, const BgcAngleUnitEnum unit, BgcMatrix2x2FP64* matrix) inline void bgc_fp64_matrix2x2_make_for_turn(const double angle, const int angle_unit, BGC_FP64_Matrix2x2* matrix)
{ {
const double radians = bgc_angle_to_radians_fp64(angle, unit); const double radians = bgc_fp64_angle_to_radians(angle, angle_unit);
const double cosine = cos(radians); const double cosine = cos(radians);
const double sine = sin(radians); const double sine = sin(radians);
@ -87,65 +87,73 @@ inline void bgc_matrix2x2_set_turn_fp64(const double angle, const BgcAngleUnitEn
// ================ Determinant ================= // // ================ Determinant ================= //
inline float bgc_matrix2x2_get_determinant_fp32(const BgcMatrix2x2FP32* matrix) inline float bgc_fp32_matrix2x2_get_determinant(const BGC_FP32_Matrix2x2* matrix)
{ {
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1; return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
} }
inline double bgc_matrix2x2_get_determinant_fp64(const BgcMatrix2x2FP64* matrix) inline double bgc_fp64_matrix2x2_get_determinant(const BGC_FP64_Matrix2x2* matrix)
{ {
return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1; return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1;
} }
// ================== Singular ================== // // ================ Is Identity ================= //
inline int bgc_matrix2x2_is_singular_fp32(const BgcMatrix2x2FP32* matrix) inline int bgc_fp32_matrix2x2_is_identity(const BGC_FP32_Matrix2x2* matrix)
{ {
return bgc_is_zero_fp32(bgc_matrix2x2_get_determinant_fp32(matrix)); return bgc_fp32_is_unit(matrix->r1c1) && bgc_fp32_is_zero(matrix->r1c2)
&& bgc_fp32_is_zero(matrix->r2c1) && bgc_fp32_is_unit(matrix->r2c2);
} }
inline int bgc_matrix2x2_is_singular_fp64(const BgcMatrix2x2FP64* matrix) inline int bgc_fp64_matrix2x2_is_identity(const BGC_FP64_Matrix2x2* matrix)
{ {
return bgc_is_zero_fp64(bgc_matrix2x2_get_determinant_fp64(matrix)); return bgc_fp64_is_unit(matrix->r1c1) && bgc_fp64_is_zero(matrix->r1c2)
&& bgc_fp64_is_zero(matrix->r2c1) && bgc_fp64_is_unit(matrix->r2c2);
}
// ================ Is Singular ================= //
inline int bgc_fp32_matrix2x2_is_singular(const BGC_FP32_Matrix2x2* matrix)
{
return bgc_fp32_is_zero(bgc_fp32_matrix2x2_get_determinant(matrix));
}
inline int bgc_fp64_matrix2x2_is_singular(const BGC_FP64_Matrix2x2* matrix)
{
return bgc_fp64_is_zero(bgc_fp64_matrix2x2_get_determinant(matrix));
} }
// ================ Is Rotation ================= // // ================ Is Rotation ================= //
inline int bgc_matrix2x2_is_rotation_fp32(const BgcMatrix2x2FP32* matrix) inline int bgc_fp32_matrix2x2_is_rotation(const BGC_FP32_Matrix2x2* matrix)
{ {
if (!bgc_is_unit_fp32(bgc_matrix2x2_get_determinant_fp32(matrix))) { BGC_FP32_Matrix2x2 product;
return 0;
}
const float product_r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1; product.r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1;
const float product_r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2; product.r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2;
const float product_r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1; product.r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1;
const float product_r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2; product.r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2;
return bgc_is_unit_fp32(product_r1c1) && bgc_is_zero_fp32(product_r1c2) return bgc_fp32_matrix2x2_is_identity(&product);
&& bgc_is_zero_fp32(product_r2c1) && bgc_is_unit_fp32(product_r2c2);
} }
inline int bgc_matrix2x2_is_rotation_fp64(const BgcMatrix2x2FP64* matrix) inline int bgc_fp64_matrix2x2_is_rotation(const BGC_FP64_Matrix2x2* matrix)
{ {
if (!bgc_is_unit_fp64(bgc_matrix2x2_get_determinant_fp64(matrix))) { BGC_FP64_Matrix2x2 product;
return 0;
}
const double product_r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1; product.r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1;
const double product_r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2; product.r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2;
const double product_r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1; product.r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1;
const double product_r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2; product.r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2;
return bgc_is_unit_fp64(product_r1c1) && bgc_is_zero_fp64(product_r1c2) return bgc_fp64_matrix2x2_is_identity(&product);
&& bgc_is_zero_fp64(product_r2c1) && bgc_is_unit_fp64(product_r2c2);
} }
// ==================== Copy ==================== // // ==================== Copy ==================== //
inline void bgc_matrix2x2_copy_fp32(const BgcMatrix2x2FP32* source, BgcMatrix2x2FP32* destination) inline void bgc_fp32_matrix2x2_copy(const BGC_FP32_Matrix2x2* source, BGC_FP32_Matrix2x2* destination)
{ {
destination->r1c1 = source->r1c1; destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2; destination->r1c2 = source->r1c2;
@ -154,7 +162,7 @@ inline void bgc_matrix2x2_copy_fp32(const BgcMatrix2x2FP32* source, BgcMatrix2x2
destination->r2c2 = source->r2c2; destination->r2c2 = source->r2c2;
} }
inline void bgc_matrix2x2_copy_fp64(const BgcMatrix2x2FP64* source, BgcMatrix2x2FP64* destination) inline void bgc_fp64_matrix2x2_copy(const BGC_FP64_Matrix2x2* source, BGC_FP64_Matrix2x2* destination)
{ {
destination->r1c1 = source->r1c1; destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2; destination->r1c2 = source->r1c2;
@ -165,7 +173,7 @@ inline void bgc_matrix2x2_copy_fp64(const BgcMatrix2x2FP64* source, BgcMatrix2x2
// ==================== Swap ==================== // // ==================== Swap ==================== //
inline void bgc_matrix2x2_swap_fp32(BgcMatrix2x2FP32* matrix1, BgcMatrix2x2FP32* matrix2) inline void bgc_fp32_matrix2x2_swap(BGC_FP32_Matrix2x2* matrix1, BGC_FP32_Matrix2x2* matrix2)
{ {
const float r1c1 = matrix2->r1c1; const float r1c1 = matrix2->r1c1;
const float r1c2 = matrix2->r1c2; const float r1c2 = matrix2->r1c2;
@ -186,7 +194,7 @@ inline void bgc_matrix2x2_swap_fp32(BgcMatrix2x2FP32* matrix1, BgcMatrix2x2FP32*
matrix1->r2c2 = r2c2; matrix1->r2c2 = r2c2;
} }
inline void bgc_matrix2x2_swap_fp64(BgcMatrix2x2FP64* matrix1, BgcMatrix2x2FP64* matrix2) inline void bgc_fp64_matrix2x2_swap(BGC_FP64_Matrix2x2* matrix1, BGC_FP64_Matrix2x2* matrix2)
{ {
const double r1c1 = matrix2->r1c1; const double r1c1 = matrix2->r1c1;
const double r1c2 = matrix2->r1c2; const double r1c2 = matrix2->r1c2;
@ -209,7 +217,7 @@ inline void bgc_matrix2x2_swap_fp64(BgcMatrix2x2FP64* matrix1, BgcMatrix2x2FP64*
// ================== Convert =================== // // ================== Convert =================== //
inline void bgc_matrix2x2_convert_fp64_to_fp32(const BgcMatrix2x2FP64* source, BgcMatrix2x2FP32* destination) inline void bgc_fp64_matrix2x2_convert_to_fp32(const BGC_FP64_Matrix2x2* source, BGC_FP32_Matrix2x2* destination)
{ {
destination->r1c1 = (float)source->r1c1; destination->r1c1 = (float)source->r1c1;
destination->r1c2 = (float)source->r1c2; destination->r1c2 = (float)source->r1c2;
@ -218,7 +226,7 @@ inline void bgc_matrix2x2_convert_fp64_to_fp32(const BgcMatrix2x2FP64* source, B
destination->r2c2 = (float)source->r2c2; destination->r2c2 = (float)source->r2c2;
} }
inline void bgc_matrix2x2_convert_fp32_to_fp64(const BgcMatrix2x2FP32* source, BgcMatrix2x2FP64* destination) inline void bgc_fp32_matrix2x2_convert_to_fp64(const BGC_FP32_Matrix2x2* source, BGC_FP64_Matrix2x2* destination)
{ {
destination->r1c1 = source->r1c1; destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2; destination->r1c2 = source->r1c2;
@ -227,13 +235,13 @@ inline void bgc_matrix2x2_convert_fp32_to_fp64(const BgcMatrix2x2FP32* source, B
destination->r2c2 = source->r2c2; destination->r2c2 = source->r2c2;
} }
// =================== Invert =================== // // ================ Get Inverse ================= //
inline int bgc_matrix2x2_invert_fp32(const BgcMatrix2x2FP32* matrix, BgcMatrix2x2FP32* inverted) inline int bgc_fp32_matrix2x2_get_inverse(const BGC_FP32_Matrix2x2* matrix, BGC_FP32_Matrix2x2* inverse)
{ {
const float determinant = bgc_matrix2x2_get_determinant_fp32(matrix); const float determinant = bgc_fp32_matrix2x2_get_determinant(matrix);
if (bgc_is_zero_fp32(determinant)) { if (bgc_fp32_is_zero(determinant)) {
return 0; return 0;
} }
@ -245,20 +253,20 @@ inline int bgc_matrix2x2_invert_fp32(const BgcMatrix2x2FP32* matrix, BgcMatrix2x
const float multiplier = 1.0f / determinant; const float multiplier = 1.0f / determinant;
inverted->r1c1 = r1c1 * multiplier; inverse->r1c1 = r1c1 * multiplier;
inverted->r1c2 = r1c2 * multiplier; inverse->r1c2 = r1c2 * multiplier;
inverted->r2c1 = r2c1 * multiplier; inverse->r2c1 = r2c1 * multiplier;
inverted->r2c2 = r2c2 * multiplier; inverse->r2c2 = r2c2 * multiplier;
return 1; return 1;
} }
inline int bgc_matrix2x2_invert_fp64(const BgcMatrix2x2FP64* matrix, BgcMatrix2x2FP64* inverted) inline int bgc_fp64_matrix2x2_get_inverse(const BGC_FP64_Matrix2x2* matrix, BGC_FP64_Matrix2x2* inverse)
{ {
const double determinant = bgc_matrix2x2_get_determinant_fp64(matrix); const double determinant = bgc_fp64_matrix2x2_get_determinant(matrix);
if (bgc_is_zero_fp64(determinant)) { if (bgc_fp64_is_zero(determinant)) {
return 0; return 0;
} }
@ -270,18 +278,46 @@ inline int bgc_matrix2x2_invert_fp64(const BgcMatrix2x2FP64* matrix, BgcMatrix2x
const double multiplier = 1.0 / determinant; const double multiplier = 1.0 / determinant;
inverted->r1c1 = r1c1 * multiplier; inverse->r1c1 = r1c1 * multiplier;
inverted->r1c2 = r1c2 * multiplier; inverse->r1c2 = r1c2 * multiplier;
inverted->r2c1 = r2c1 * multiplier; inverse->r2c1 = r2c1 * multiplier;
inverted->r2c2 = r2c2 * multiplier; inverse->r2c2 = r2c2 * multiplier;
return 1; return 1;
} }
// =================== Invert =================== //
inline int bgc_fp32_matrix2x2_invert(BGC_FP32_Matrix2x2* matrix)
{
return bgc_fp32_matrix2x2_get_inverse(matrix, matrix);
}
inline int bgc_fp64_matrix2x2_invert(BGC_FP64_Matrix2x2* matrix)
{
return bgc_fp64_matrix2x2_get_inverse(matrix, matrix);
}
// ================= Transpose ================== // // ================= Transpose ================== //
inline void bgc_matrix2x2_transpose_fp32(const BgcMatrix2x2FP32* matrix, BgcMatrix2x2FP32* transposed) inline void bgc_fp32_matrix2x2_transpose(BGC_FP32_Matrix2x2* matrix)
{
const float r1c2 = matrix->r1c2;
matrix->r1c2 = matrix->r2c1;
matrix->r2c1 = r1c2;
}
inline void bgc_fp64_matrix2x2_transpose(BGC_FP64_Matrix2x2* matrix)
{
const double r1c2 = matrix->r1c2;
matrix->r1c2 = matrix->r2c1;
matrix->r2c1 = r1c2;
}
// =============== Get Transpose ================ //
inline void bgc_fp32_matrix2x2_get_transposed(const BGC_FP32_Matrix2x2* matrix, BGC_FP32_Matrix2x2* transposed)
{ {
const float r1c2 = matrix->r1c2; const float r1c2 = matrix->r1c2;
@ -292,7 +328,7 @@ inline void bgc_matrix2x2_transpose_fp32(const BgcMatrix2x2FP32* matrix, BgcMatr
transposed->r2c2 = matrix->r2c2; transposed->r2c2 = matrix->r2c2;
} }
inline void bgc_matrix2x2_transpose_fp64(const BgcMatrix2x2FP64* matrix, BgcMatrix2x2FP64* transposed) inline void bgc_fp64_matrix2x2_get_transposed(const BGC_FP64_Matrix2x2* matrix, BGC_FP64_Matrix2x2* transposed)
{ {
const double r1c2 = matrix->r1c2; const double r1c2 = matrix->r1c2;
@ -303,65 +339,145 @@ inline void bgc_matrix2x2_transpose_fp64(const BgcMatrix2x2FP64* matrix, BgcMatr
transposed->r2c2 = matrix->r2c2; transposed->r2c2 = matrix->r2c2;
} }
// ================= Set Row 1 ================== // // ================== Get Row =================== //
inline void bgc_matrix2x2_set_row1_fp32(const float c1, const float c2, BgcMatrix2x2FP32* matrix) inline void bgc_fp32_matrix2x2_get_row(const int number, const BGC_FP32_Matrix2x2* matrix, BGC_FP32_Vector2* row)
{ {
matrix->r1c1 = c1; if (number == 1) {
matrix->r1c2 = c2; row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
return;
}
if (number == 2) {
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
return;
}
row->x1 = 0.0f;
row->x2 = 0.0f;
} }
inline void bgc_matrix2x2_set_row1_fp64(const double c1, const double c2, BgcMatrix2x2FP64* matrix) inline void bgc_fp64_matrix2x2_get_row(const int number, const BGC_FP64_Matrix2x2* matrix, BGC_FP64_Vector2* row)
{ {
matrix->r1c1 = c1; if (number == 1) {
matrix->r1c2 = c2; row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
return;
}
if (number == 2) {
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
return;
}
row->x1 = 0.0;
row->x2 = 0.0;
} }
// ================= Set Row 2 ================== // // ================== Set Row =================== //
inline void bgc_matrix2x2_set_row2_fp32(const float c1, const float c2, BgcMatrix2x2FP32* matrix) inline void bgc_fp32_matrix2x2_set_row(const int number, const BGC_FP32_Vector2* row, BGC_FP32_Matrix2x2* matrix)
{ {
matrix->r2c1 = c1; if (number == 1) {
matrix->r2c2 = c2; matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
return;
}
if (number == 2) {
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
}
} }
inline void bgc_matrix2x2_set_row2_fp64(const double c1, const double c2, BgcMatrix2x2FP64* matrix) inline void bgc_fp64_matrix2x2_set_row(const int number, const BGC_FP64_Vector2* row, BGC_FP64_Matrix2x2* matrix)
{ {
matrix->r2c1 = c1; if (number == 1) {
matrix->r2c2 = c2; matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
return;
}
if (number == 2) {
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
}
} }
// ================ Set Column 1 ================ // // ================= Get Column ================= //
inline void bgc_matrix2x2_set_column1_fp32(const float r1, const float r2, BgcMatrix2x2FP32* matrix) inline void bgc_fp32_matrix2x2_get_column(const int number, const BGC_FP32_Matrix2x2* matrix, BGC_FP32_Vector2* column)
{ {
matrix->r1c1 = r1; if (number == 1) {
matrix->r2c1 = r2; column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
return;
}
if (number == 2) {
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
return;
}
column->x1 = 0.0f;
column->x2 = 0.0f;
} }
inline void bgc_matrix2x2_set_column1_fp64(const double r1, const double r2, BgcMatrix2x2FP64* matrix) inline void bgc_fp64_matrix2x2_get_column(const int number, const BGC_FP64_Matrix2x2* matrix, BGC_FP64_Vector2* column)
{ {
matrix->r1c1 = r1; if (number == 1) {
matrix->r2c1 = r2; column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
return;
}
if (number == 2) {
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
return;
}
column->x1 = 0.0;
column->x2 = 0.0;
} }
// ================ Set Column 2 ================ // // ================= Set Column ================= //
inline void bgc_matrix2x2_set_column2_fp32(const float r1, const float r2, BgcMatrix2x2FP32* matrix) inline void bgc_fp32_matrix2x2_set_column(const int number, const BGC_FP32_Vector2* column, BGC_FP32_Matrix2x2* matrix)
{ {
matrix->r1c2 = r1; if (number == 1) {
matrix->r2c2 = r2; matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
return;
}
if (number == 2) {
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
}
} }
inline void bgc_matrix2x2_set_column2_fp64(const double r1, const double r2, BgcMatrix2x2FP64* matrix) inline void bgc_fp64_matrix2x2_set_column(const int number, const BGC_FP64_Vector2* column, BGC_FP64_Matrix2x2* matrix)
{ {
matrix->r1c2 = r1; if (number == 1) {
matrix->r2c2 = r2; matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
return;
}
if (number == 2) {
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
}
} }
// ==================== Add ===================== // // ==================== Add ===================== //
inline void bgc_matrix2x2_add_fp32(const BgcMatrix2x2FP32* matrix1, const BgcMatrix2x2FP32* matrix2, BgcMatrix2x2FP32* sum) inline void bgc_fp32_matrix2x2_add(const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2, BGC_FP32_Matrix2x2* sum)
{ {
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
@ -370,7 +486,7 @@ inline void bgc_matrix2x2_add_fp32(const BgcMatrix2x2FP32* matrix1, const BgcMat
sum->r2c2 = matrix1->r2c2 + matrix2->r2c2; sum->r2c2 = matrix1->r2c2 + matrix2->r2c2;
} }
inline void bgc_matrix2x2_add_fp64(const BgcMatrix2x2FP64* matrix1, const BgcMatrix2x2FP64* matrix2, BgcMatrix2x2FP64* sum) inline void bgc_fp64_matrix2x2_add(const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2, BGC_FP64_Matrix2x2* sum)
{ {
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
@ -381,7 +497,7 @@ inline void bgc_matrix2x2_add_fp64(const BgcMatrix2x2FP64* matrix1, const BgcMat
// ================= Add scaled ================= // // ================= Add scaled ================= //
inline void bgc_matrix2x2_add_scaled_fp32(const BgcMatrix2x2FP32* basic_matrix, const BgcMatrix2x2FP32* scalable_matrix, const float scale, BgcMatrix2x2FP32* sum) inline void bgc_fp32_matrix2x2_add_scaled(const BGC_FP32_Matrix2x2* basic_matrix, const BGC_FP32_Matrix2x2* scalable_matrix, const float scale, BGC_FP32_Matrix2x2* sum)
{ {
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
@ -390,7 +506,7 @@ inline void bgc_matrix2x2_add_scaled_fp32(const BgcMatrix2x2FP32* basic_matrix,
sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale; sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale;
} }
inline void bgc_matrix2x2_add_scaled_fp64(const BgcMatrix2x2FP64* basic_matrix, const BgcMatrix2x2FP64* scalable_matrix, const double scale, BgcMatrix2x2FP64* sum) inline void bgc_fp64_matrix2x2_add_scaled(const BGC_FP64_Matrix2x2* basic_matrix, const BGC_FP64_Matrix2x2* scalable_matrix, const double scale, BGC_FP64_Matrix2x2* sum)
{ {
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
@ -401,7 +517,7 @@ inline void bgc_matrix2x2_add_scaled_fp64(const BgcMatrix2x2FP64* basic_matrix,
// ================== Subtract ================== // // ================== Subtract ================== //
inline void bgc_matrix2x2_subtract_fp32(const BgcMatrix2x2FP32* minuend, const BgcMatrix2x2FP32* subtrahend, BgcMatrix2x2FP32* difference) inline void bgc_fp32_matrix2x2_subtract(const BGC_FP32_Matrix2x2* minuend, const BGC_FP32_Matrix2x2* subtrahend, BGC_FP32_Matrix2x2* difference)
{ {
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
@ -410,7 +526,7 @@ inline void bgc_matrix2x2_subtract_fp32(const BgcMatrix2x2FP32* minuend, const B
difference->r2c2 = minuend->r2c2 - subtrahend->r2c2; difference->r2c2 = minuend->r2c2 - subtrahend->r2c2;
} }
inline void bgc_matrix2x2_subtract_fp64(const BgcMatrix2x2FP64* minuend, const BgcMatrix2x2FP64* subtrahend, BgcMatrix2x2FP64* difference) inline void bgc_fp64_matrix2x2_subtract(const BGC_FP64_Matrix2x2* minuend, const BGC_FP64_Matrix2x2* subtrahend, BGC_FP64_Matrix2x2* difference)
{ {
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
@ -419,29 +535,9 @@ inline void bgc_matrix2x2_subtract_fp64(const BgcMatrix2x2FP64* minuend, const B
difference->r2c2 = minuend->r2c2 - subtrahend->r2c2; difference->r2c2 = minuend->r2c2 - subtrahend->r2c2;
} }
// ============== Subtract scaled =============== //
inline void bgc_matrix2x2_subtract_scaled_fp32(const BgcMatrix2x2FP32* basic_matrix, const BgcMatrix2x2FP32* scalable_matrix, const float scale, BgcMatrix2x2FP32* difference)
{
difference->r1c1 = basic_matrix->r1c1 - scalable_matrix->r1c1 * scale;
difference->r1c2 = basic_matrix->r1c2 - scalable_matrix->r1c2 * scale;
difference->r2c1 = basic_matrix->r2c1 - scalable_matrix->r2c1 * scale;
difference->r2c2 = basic_matrix->r2c2 - scalable_matrix->r2c2 * scale;
}
inline void bgc_matrix2x2_subtract_scaled_fp64(const BgcMatrix2x2FP64* basic_matrix, const BgcMatrix2x2FP64* scalable_matrix, const double scale, BgcMatrix2x2FP64* difference)
{
difference->r1c1 = basic_matrix->r1c1 - scalable_matrix->r1c1 * scale;
difference->r1c2 = basic_matrix->r1c2 - scalable_matrix->r1c2 * scale;
difference->r2c1 = basic_matrix->r2c1 - scalable_matrix->r2c1 * scale;
difference->r2c2 = basic_matrix->r2c2 - scalable_matrix->r2c2 * scale;
}
// ================== Multiply ================== // // ================== Multiply ================== //
inline void bgc_matrix2x2_multiply_fp32(const BgcMatrix2x2FP32* multiplicand, const float multiplier, BgcMatrix2x2FP32* product) inline void bgc_fp32_matrix2x2_multiply(const BGC_FP32_Matrix2x2* multiplicand, const float multiplier, BGC_FP32_Matrix2x2* product)
{ {
product->r1c1 = multiplicand->r1c1 * multiplier; product->r1c1 = multiplicand->r1c1 * multiplier;
product->r1c2 = multiplicand->r1c2 * multiplier; product->r1c2 = multiplicand->r1c2 * multiplier;
@ -450,7 +546,7 @@ inline void bgc_matrix2x2_multiply_fp32(const BgcMatrix2x2FP32* multiplicand, co
product->r2c2 = multiplicand->r2c2 * multiplier; product->r2c2 = multiplicand->r2c2 * multiplier;
} }
inline void bgc_matrix2x2_multiply_fp64(const BgcMatrix2x2FP64* multiplicand, const double multiplier, BgcMatrix2x2FP64* product) inline void bgc_fp64_matrix2x2_multiply(const BGC_FP64_Matrix2x2* multiplicand, const double multiplier, BGC_FP64_Matrix2x2* product)
{ {
product->r1c1 = multiplicand->r1c1 * multiplier; product->r1c1 = multiplicand->r1c1 * multiplier;
product->r1c2 = multiplicand->r1c2 * multiplier; product->r1c2 = multiplicand->r1c2 * multiplier;
@ -461,39 +557,43 @@ inline void bgc_matrix2x2_multiply_fp64(const BgcMatrix2x2FP64* multiplicand, co
// =================== Divide =================== // // =================== Divide =================== //
inline void bgc_matrix2x2_divide_fp32(const BgcMatrix2x2FP32* dividend, const float divisor, BgcMatrix2x2FP32* quotient) inline void bgc_fp32_matrix2x2_divide(const BGC_FP32_Matrix2x2* dividend, const float divisor, BGC_FP32_Matrix2x2* quotient)
{ {
bgc_matrix2x2_multiply_fp32(dividend, 1.0f / divisor, quotient); bgc_fp32_matrix2x2_multiply(dividend, 1.0f / divisor, quotient);
} }
inline void bgc_matrix2x2_divide_fp64(const BgcMatrix2x2FP64* dividend, const double divisor, BgcMatrix2x2FP64* quotient) inline void bgc_fp64_matrix2x2_divide(const BGC_FP64_Matrix2x2* dividend, const double divisor, BGC_FP64_Matrix2x2* quotient)
{ {
bgc_matrix2x2_multiply_fp64(dividend, 1.0 / divisor, quotient); bgc_fp64_matrix2x2_multiply(dividend, 1.0 / divisor, quotient);
} }
// ============ Left Vector Product ============= // // ================ Interpolate ================= //
inline void bgc_matrix2x2_get_left_product_fp32(const BgcVector2FP32* vector, const BgcMatrix2x2FP32* matrix, BgcVector2FP32* product) inline void bgc_fp32_matrix2x2_interpolate(const BGC_FP32_Matrix2x2* first, const BGC_FP32_Matrix2x2* second, const float phase, BGC_FP32_Matrix2x2* interpolation)
{ {
const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1; const float counter_phase = 1.0f - phase;
const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
product->x1 = x1; interpolation->r1c1 = first->r1c1 * counter_phase + second->r1c1 * phase;
product->x2 = x2; interpolation->r1c2 = first->r1c2 * counter_phase + second->r1c2 * phase;
interpolation->r2c1 = first->r2c1 * counter_phase + second->r2c1 * phase;
interpolation->r2c2 = first->r2c2 * counter_phase + second->r2c2 * phase;
} }
inline void bgc_matrix2x2_get_left_product_fp64(const BgcVector2FP64* vector, const BgcMatrix2x2FP64* matrix, BgcVector2FP64* product) inline void bgc_fp64_matrix2x2_interpolate(const BGC_FP64_Matrix2x2* first, const BGC_FP64_Matrix2x2* second, const double phase, BGC_FP64_Matrix2x2* interpolation)
{ {
const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1; const double counter_phase = 1.0 - phase;
const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
product->x1 = x1; interpolation->r1c1 = first->r1c1 * counter_phase + second->r1c1 * phase;
product->x2 = x2; interpolation->r1c2 = first->r1c2 * counter_phase + second->r1c2 * phase;
interpolation->r2c1 = first->r2c1 * counter_phase + second->r2c1 * phase;
interpolation->r2c2 = first->r2c2 * counter_phase + second->r2c2 * phase;
} }
// ============ Right Vector Product ============ // // ============ Right Vector Product ============ //
inline void bgc_matrix2x2_get_right_product_fp32(const BgcMatrix2x2FP32* matrix, const BgcVector2FP32* vector, BgcVector2FP32* product) inline void bgc_fp32_multiply_matrix2x2_by_vector2(const BGC_FP32_Matrix2x2* matrix, const BGC_FP32_Vector2* vector, BGC_FP32_Vector2* product)
{ {
const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2; const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2; const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
@ -502,7 +602,7 @@ inline void bgc_matrix2x2_get_right_product_fp32(const BgcMatrix2x2FP32* matrix,
product->x2 = x2; product->x2 = x2;
} }
inline void bgc_matrix2x2_get_right_product_fp64(const BgcMatrix2x2FP64* matrix, const BgcVector2FP64* vector, BgcVector2FP64* product) inline void bgc_fp64_multiply_matrix2x2_by_vector2(const BGC_FP64_Matrix2x2* matrix, const BGC_FP64_Vector2* vector, BGC_FP64_Vector2* product)
{ {
const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2; const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2; const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
@ -511,4 +611,24 @@ inline void bgc_matrix2x2_get_right_product_fp64(const BgcMatrix2x2FP64* matrix,
product->x2 = x2; product->x2 = x2;
} }
// ============ Left Vector Product ============= //
inline void bgc_fp32_multiply_vector2_by_matrix2x2(const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix2x2* matrix, BGC_FP32_Vector2* product)
{
const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
product->x1 = x1;
product->x2 = x2;
}
inline void bgc_fp64_multiply_vector2_by_matrix2x2(const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix2x2* matrix, BGC_FP64_Vector2* product)
{
const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
product->x1 = x1;
product->x2 = x2;
}
#endif #endif

View file

@ -1,55 +1,52 @@
#include "matrix2x3.h" #include "matrix2x3.h"
extern inline void bgc_matrix2x3_reset_fp32(BgcMatrix2x3FP32* matrix); extern inline void bgc_fp32_matrix2x3_reset(BGC_FP32_Matrix2x3* matrix);
extern inline void bgc_matrix2x3_reset_fp64(BgcMatrix2x3FP64* matrix); extern inline void bgc_fp64_matrix2x3_reset(BGC_FP64_Matrix2x3* matrix);
extern inline void bgc_matrix2x3_copy_fp32(const BgcMatrix2x3FP32* source, BgcMatrix2x3FP32* destination); extern inline void bgc_fp32_matrix2x3_copy(const BGC_FP32_Matrix2x3* source, BGC_FP32_Matrix2x3* destination);
extern inline void bgc_matrix2x3_copy_fp64(const BgcMatrix2x3FP64* source, BgcMatrix2x3FP64* destination); extern inline void bgc_fp64_matrix2x3_copy(const BGC_FP64_Matrix2x3* source, BGC_FP64_Matrix2x3* destination);
extern inline void bgc_matrix2x3_swap_fp32(BgcMatrix2x3FP32* matrix1, BgcMatrix2x3FP32* matrix2); extern inline void bgc_fp32_matrix2x3_swap(BGC_FP32_Matrix2x3* matrix1, BGC_FP32_Matrix2x3* matrix2);
extern inline void bgc_matrix2x3_swap_fp64(BgcMatrix2x3FP64* matrix1, BgcMatrix2x3FP64* matrix2); extern inline void bgc_fp64_matrix2x3_swap(BGC_FP64_Matrix2x3* matrix1, BGC_FP64_Matrix2x3* matrix2);
extern inline void bgc_matrix2x3_convert_fp64_to_fp32(const BgcMatrix2x3FP64* source, BgcMatrix2x3FP32* destination); extern inline void bgc_fp64_matrix2x3_convert_to_fp32(const BGC_FP64_Matrix2x3* source, BGC_FP32_Matrix2x3* destination);
extern inline void bgc_matrix2x3_convert_fp32_to_fp64(const BgcMatrix2x3FP32* source, BgcMatrix2x3FP64* destination); extern inline void bgc_fp32_matrix2x3_convert_to_fp64(const BGC_FP32_Matrix2x3* source, BGC_FP64_Matrix2x3* destination);
extern inline void bgc_matrix2x3_transpose_fp32(const BgcMatrix3x2FP32* matrix, BgcMatrix2x3FP32* transposed); extern inline void bgc_fp32_matrix2x3_get_transposed(const BGC_FP32_Matrix3x2* matrix, BGC_FP32_Matrix2x3* transposed);
extern inline void bgc_matrix2x3_transpose_fp64(const BgcMatrix3x2FP64* matrix, BgcMatrix2x3FP64* transposed); extern inline void bgc_fp64_matrix2x3_get_transposed(const BGC_FP64_Matrix3x2* matrix, BGC_FP64_Matrix2x3* transposed);
extern inline void bgc_matrix2x3_set_row1_fp32(const float c1, const float c2, BgcMatrix2x3FP32* matrix); extern inline void bgc_fp32_matrix2x3_get_row(const int number, const BGC_FP32_Matrix2x3* matrix, BGC_FP32_Vector2* row);
extern inline void bgc_matrix2x3_set_row1_fp64(const double c1, const double c2, BgcMatrix2x3FP64* matrix); extern inline void bgc_fp64_matrix2x3_get_row(const int number, const BGC_FP64_Matrix2x3* matrix, BGC_FP64_Vector2* row);
extern inline void bgc_matrix2x3_set_row2_fp32(const float c1, const float c2, BgcMatrix2x3FP32* matrix); extern inline void bgc_fp32_matrix2x3_set_row(const int number, const BGC_FP32_Vector2* row, BGC_FP32_Matrix2x3* matrix);
extern inline void bgc_matrix2x3_set_row2_fp64(const double c1, const double c2, BgcMatrix2x3FP64* matrix); extern inline void bgc_fp64_matrix2x3_set_row(const int number, const BGC_FP64_Vector2* row, BGC_FP64_Matrix2x3* matrix);
extern inline void bgc_matrix2x3_set_row3_fp32(const float c1, const float c2, BgcMatrix2x3FP32* matrix); extern inline void bgc_fp32_matrix2x3_get_column(const int number, const BGC_FP32_Matrix2x3* matrix, BGC_FP32_Vector3* column);
extern inline void bgc_matrix2x3_set_row3_fp64(const double c1, const double c2, BgcMatrix2x3FP64* matrix); extern inline void bgc_fp64_matrix2x3_get_column(const int number, const BGC_FP64_Matrix2x3* matrix, BGC_FP64_Vector3* column);
extern inline void bgc_matrix2x3_set_column1_fp32(const float r1, const float r2, const float r3, BgcMatrix2x3FP32* matrix); extern inline void bgc_fp32_matrix2x3_set_column(const int number, const BGC_FP32_Vector3* column, BGC_FP32_Matrix2x3* matrix);
extern inline void bgc_matrix2x3_set_column1_fp64(const double r1, const double r2, const double r3, BgcMatrix2x3FP64* matrix); extern inline void bgc_fp64_matrix2x3_set_column(const int number, const BGC_FP64_Vector3* column, BGC_FP64_Matrix2x3* matrix);
extern inline void bgc_matrix2x3_set_column2_fp32(const float r1, const float r2, const float r3, BgcMatrix2x3FP32* matrix); extern inline void bgc_fp32_matrix2x3_add(const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x3* matrix2, BGC_FP32_Matrix2x3* sum);
extern inline void bgc_matrix2x3_set_column2_fp64(const double r1, const double r2, const double r3, BgcMatrix2x3FP64* matrix); extern inline void bgc_fp64_matrix2x3_add(const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x3* matrix2, BGC_FP64_Matrix2x3* sum);
extern inline void bgc_matrix2x3_add_fp32(const BgcMatrix2x3FP32* matrix1, const BgcMatrix2x3FP32* matrix2, BgcMatrix2x3FP32* sum); extern inline void bgc_fp32_matrix2x3_add_scaled(const BGC_FP32_Matrix2x3* basic_matrix, const BGC_FP32_Matrix2x3* scalable_matrix, const float scale, BGC_FP32_Matrix2x3* sum);
extern inline void bgc_matrix2x3_add_fp64(const BgcMatrix2x3FP64* matrix1, const BgcMatrix2x3FP64* matrix2, BgcMatrix2x3FP64* sum); extern inline void bgc_fp64_matrix2x3_add_scaled(const BGC_FP64_Matrix2x3* basic_matrix, const BGC_FP64_Matrix2x3* scalable_matrix, const double scale, BGC_FP64_Matrix2x3* sum);
extern inline void bgc_matrix2x3_add_scaled_fp32(const BgcMatrix2x3FP32* basic_matrix, const BgcMatrix2x3FP32* scalable_matrix, const float scale, BgcMatrix2x3FP32* sum); extern inline void bgc_fp32_matrix2x3_subtract(const BGC_FP32_Matrix2x3* minuend, const BGC_FP32_Matrix2x3* subtrahend, BGC_FP32_Matrix2x3* difference);
extern inline void bgc_matrix2x3_add_scaled_fp64(const BgcMatrix2x3FP64* basic_matrix, const BgcMatrix2x3FP64* scalable_matrix, const double scale, BgcMatrix2x3FP64* sum); extern inline void bgc_fp64_matrix2x3_subtract(const BGC_FP64_Matrix2x3* minuend, const BGC_FP64_Matrix2x3* subtrahend, BGC_FP64_Matrix2x3* difference);
extern inline void bgc_matrix2x3_subtract_fp32(const BgcMatrix2x3FP32* minuend, const BgcMatrix2x3FP32* subtrahend, BgcMatrix2x3FP32* difference); extern inline void bgc_fp32_matrix2x3_multiply(const BGC_FP32_Matrix2x3* multiplicand, const float multiplier, BGC_FP32_Matrix2x3* product);
extern inline void bgc_matrix2x3_subtract_fp64(const BgcMatrix2x3FP64* minuend, const BgcMatrix2x3FP64* subtrahend, BgcMatrix2x3FP64* difference); extern inline void bgc_fp64_matrix2x3_multiply(const BGC_FP64_Matrix2x3* multiplicand, const double multiplier, BGC_FP64_Matrix2x3* product);
extern inline void bgc_matrix2x3_subtract_scaled_fp32(const BgcMatrix2x3FP32* basic_matrix, const BgcMatrix2x3FP32* scalable_matrix, const float scale, BgcMatrix2x3FP32* difference); extern inline void bgc_fp32_matrix2x3_divide(const BGC_FP32_Matrix2x3* dividend, const float divisor, BGC_FP32_Matrix2x3* quotient);
extern inline void bgc_matrix2x3_subtract_scaled_fp64(const BgcMatrix2x3FP64* basic_matrix, const BgcMatrix2x3FP64* scalable_matrix, const double scale, BgcMatrix2x3FP64* difference); extern inline void bgc_fp64_matrix2x3_divide(const BGC_FP64_Matrix2x3* dividend, const double divisor, BGC_FP64_Matrix2x3* quotient);
extern inline void bgc_matrix2x3_multiply_fp32(const BgcMatrix2x3FP32* multiplicand, const float multiplier, BgcMatrix2x3FP32* product); extern inline void bgc_fp32_matrix2x3_interpolate(const BGC_FP32_Matrix2x3* first, const BGC_FP32_Matrix2x3* second, const float phase, BGC_FP32_Matrix2x3* interpolation);
extern inline void bgc_matrix2x3_multiply_fp64(const BgcMatrix2x3FP64* multiplicand, const double multiplier, BgcMatrix2x3FP64* product); extern inline void bgc_fp64_matrix2x3_interpolate(const BGC_FP64_Matrix2x3* first, const BGC_FP64_Matrix2x3* second, const double phase, BGC_FP64_Matrix2x3* interpolation);
extern inline void bgc_matrix2x3_divide_fp32(const BgcMatrix2x3FP32* dividend, const float divisor, BgcMatrix2x3FP32* quotient); extern inline void bgc_fp32_multiply_vector3_by_matrix2x3(const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix2x3* matrix, BGC_FP32_Vector2* product);
extern inline void bgc_matrix2x3_divide_fp64(const BgcMatrix2x3FP64* dividend, const double divisor, BgcMatrix2x3FP64* quotient); extern inline void bgc_fp64_multiply_vector3_by_matrix2x3(const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix2x3* matrix, BGC_FP64_Vector2* product);
extern inline void bgc_matrix2x3_get_left_product_fp32(const BgcVector3FP32* vector, const BgcMatrix2x3FP32* matrix, BgcVector2FP32* result); extern inline void bgc_fp32_multiply_matrix2x3_by_vector2(const BGC_FP32_Matrix2x3* matrix, const BGC_FP32_Vector2* vector, BGC_FP32_Vector3* product);
extern inline void bgc_matrix2x3_get_left_product_fp64(const BgcVector3FP64* vector, const BgcMatrix2x3FP64* matrix, BgcVector2FP64* result); extern inline void bgc_fp64_multiply_matrix2x3_by_vector2(const BGC_FP64_Matrix2x3* matrix, const BGC_FP64_Vector2* vector, BGC_FP64_Vector3* product);
extern inline void bgc_matrix2x3_get_right_product_fp32(const BgcMatrix2x3FP32* matrix, const BgcVector2FP32* vector, BgcVector3FP32* result);
extern inline void bgc_matrix2x3_get_right_product_fp64(const BgcMatrix2x3FP64* matrix, const BgcVector2FP64* vector, BgcVector3FP64* result);

View file

@ -7,7 +7,7 @@
// =================== Reset ==================== // // =================== Reset ==================== //
inline void bgc_matrix2x3_reset_fp32(BgcMatrix2x3FP32* matrix) inline void bgc_fp32_matrix2x3_reset(BGC_FP32_Matrix2x3* matrix)
{ {
matrix->r1c1 = 0.0f; matrix->r1c1 = 0.0f;
matrix->r1c2 = 0.0f; matrix->r1c2 = 0.0f;
@ -19,7 +19,7 @@ inline void bgc_matrix2x3_reset_fp32(BgcMatrix2x3FP32* matrix)
matrix->r3c2 = 0.0f; matrix->r3c2 = 0.0f;
} }
inline void bgc_matrix2x3_reset_fp64(BgcMatrix2x3FP64* matrix) inline void bgc_fp64_matrix2x3_reset(BGC_FP64_Matrix2x3* matrix)
{ {
matrix->r1c1 = 0.0; matrix->r1c1 = 0.0;
matrix->r1c2 = 0.0; matrix->r1c2 = 0.0;
@ -33,7 +33,7 @@ inline void bgc_matrix2x3_reset_fp64(BgcMatrix2x3FP64* matrix)
// ==================== Copy ==================== // // ==================== Copy ==================== //
inline void bgc_matrix2x3_copy_fp32(const BgcMatrix2x3FP32* source, BgcMatrix2x3FP32* destination) inline void bgc_fp32_matrix2x3_copy(const BGC_FP32_Matrix2x3* source, BGC_FP32_Matrix2x3* destination)
{ {
destination->r1c1 = source->r1c1; destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2; destination->r1c2 = source->r1c2;
@ -45,7 +45,7 @@ inline void bgc_matrix2x3_copy_fp32(const BgcMatrix2x3FP32* source, BgcMatrix2x3
destination->r3c2 = source->r3c2; destination->r3c2 = source->r3c2;
} }
inline void bgc_matrix2x3_copy_fp64(const BgcMatrix2x3FP64* source, BgcMatrix2x3FP64* destination) inline void bgc_fp64_matrix2x3_copy(const BGC_FP64_Matrix2x3* source, BGC_FP64_Matrix2x3* destination)
{ {
destination->r1c1 = source->r1c1; destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2; destination->r1c2 = source->r1c2;
@ -59,7 +59,7 @@ inline void bgc_matrix2x3_copy_fp64(const BgcMatrix2x3FP64* source, BgcMatrix2x3
// ==================== Swap ==================== // // ==================== Swap ==================== //
inline void bgc_matrix2x3_swap_fp32(BgcMatrix2x3FP32* matrix1, BgcMatrix2x3FP32* matrix2) inline void bgc_fp32_matrix2x3_swap(BGC_FP32_Matrix2x3* matrix1, BGC_FP32_Matrix2x3* matrix2)
{ {
const float r1c1 = matrix2->r1c1; const float r1c1 = matrix2->r1c1;
const float r1c2 = matrix2->r1c2; const float r1c2 = matrix2->r1c2;
@ -89,7 +89,7 @@ inline void bgc_matrix2x3_swap_fp32(BgcMatrix2x3FP32* matrix1, BgcMatrix2x3FP32*
matrix1->r3c2 = r3c2; matrix1->r3c2 = r3c2;
} }
inline void bgc_matrix2x3_swap_fp64(BgcMatrix2x3FP64* matrix1, BgcMatrix2x3FP64* matrix2) inline void bgc_fp64_matrix2x3_swap(BGC_FP64_Matrix2x3* matrix1, BGC_FP64_Matrix2x3* matrix2)
{ {
const double r1c1 = matrix2->r1c1; const double r1c1 = matrix2->r1c1;
const double r1c2 = matrix2->r1c2; const double r1c2 = matrix2->r1c2;
@ -121,7 +121,7 @@ inline void bgc_matrix2x3_swap_fp64(BgcMatrix2x3FP64* matrix1, BgcMatrix2x3FP64*
// ================== Convert =================== // // ================== Convert =================== //
inline void bgc_matrix2x3_convert_fp64_to_fp32(const BgcMatrix2x3FP64* source, BgcMatrix2x3FP32* destination) inline void bgc_fp64_matrix2x3_convert_to_fp32(const BGC_FP64_Matrix2x3* source, BGC_FP32_Matrix2x3* destination)
{ {
destination->r1c1 = (float)source->r1c1; destination->r1c1 = (float)source->r1c1;
destination->r1c2 = (float)source->r1c2; destination->r1c2 = (float)source->r1c2;
@ -133,7 +133,7 @@ inline void bgc_matrix2x3_convert_fp64_to_fp32(const BgcMatrix2x3FP64* source, B
destination->r3c2 = (float)source->r3c2; destination->r3c2 = (float)source->r3c2;
} }
inline void bgc_matrix2x3_convert_fp32_to_fp64(const BgcMatrix2x3FP32* source, BgcMatrix2x3FP64* destination) inline void bgc_fp32_matrix2x3_convert_to_fp64(const BGC_FP32_Matrix2x3* source, BGC_FP64_Matrix2x3* destination)
{ {
destination->r1c1 = source->r1c1; destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2; destination->r1c2 = source->r1c2;
@ -147,7 +147,7 @@ inline void bgc_matrix2x3_convert_fp32_to_fp64(const BgcMatrix2x3FP32* source, B
// ================= Transpose ================== // // ================= Transpose ================== //
inline void bgc_matrix2x3_transpose_fp32(const BgcMatrix3x2FP32* matrix, BgcMatrix2x3FP32* transposed) inline void bgc_fp32_matrix2x3_get_transposed(const BGC_FP32_Matrix3x2* matrix, BGC_FP32_Matrix2x3* transposed)
{ {
transposed->r1c1 = matrix->r1c1; transposed->r1c1 = matrix->r1c1;
transposed->r1c2 = matrix->r2c1; transposed->r1c2 = matrix->r2c1;
@ -159,7 +159,7 @@ inline void bgc_matrix2x3_transpose_fp32(const BgcMatrix3x2FP32* matrix, BgcMatr
transposed->r3c2 = matrix->r2c3; transposed->r3c2 = matrix->r2c3;
} }
inline void bgc_matrix2x3_transpose_fp64(const BgcMatrix3x2FP64* matrix, BgcMatrix2x3FP64* transposed) inline void bgc_fp64_matrix2x3_get_transposed(const BGC_FP64_Matrix3x2* matrix, BGC_FP64_Matrix2x3* transposed)
{ {
transposed->r1c1 = matrix->r1c1; transposed->r1c1 = matrix->r1c1;
transposed->r1c2 = matrix->r2c1; transposed->r1c2 = matrix->r2c1;
@ -171,83 +171,169 @@ inline void bgc_matrix2x3_transpose_fp64(const BgcMatrix3x2FP64* matrix, BgcMatr
transposed->r3c2 = matrix->r2c3; transposed->r3c2 = matrix->r2c3;
} }
// ================= Set Row 1 ================== // // ================== Get Row =================== //
inline void bgc_matrix2x3_set_row1_fp32(const float c1, const float c2, BgcMatrix2x3FP32* matrix) inline void bgc_fp32_matrix2x3_get_row(const int number, const BGC_FP32_Matrix2x3* matrix, BGC_FP32_Vector2* row)
{ {
matrix->r1c1 = c1; if (number == 1) {
matrix->r1c2 = c2; row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
return;
}
if (number == 2) {
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
return;
}
if (number == 3) {
row->x1 = matrix->r3c1;
row->x2 = matrix->r3c2;
return;
}
row->x1 = 0.0f;
row->x2 = 0.0f;
} }
inline void bgc_matrix2x3_set_row1_fp64(const double c1, const double c2, BgcMatrix2x3FP64* matrix) inline void bgc_fp64_matrix2x3_get_row(const int number, const BGC_FP64_Matrix2x3* matrix, BGC_FP64_Vector2* row)
{ {
matrix->r1c1 = c1; if (number == 1) {
matrix->r1c2 = c2; row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
return;
}
if (number == 2) {
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
return;
}
if (number == 3) {
row->x1 = matrix->r3c1;
row->x2 = matrix->r3c2;
return;
}
row->x1 = 0.0f;
row->x2 = 0.0f;
} }
// ================= Set Row 2 ================== // // ================== Set Row =================== //
inline void bgc_matrix2x3_set_row2_fp32(const float c1, const float c2, BgcMatrix2x3FP32* matrix) inline void bgc_fp32_matrix2x3_set_row(const int number, const BGC_FP32_Vector2* row, BGC_FP32_Matrix2x3* matrix)
{ {
matrix->r2c1 = c1; if (number == 1) {
matrix->r2c2 = c2; matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
return;
}
if (number == 2) {
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
return;
}
if (number == 3) {
matrix->r3c1 = row->x1;
matrix->r3c2 = row->x2;
}
} }
inline void bgc_matrix2x3_set_row2_fp64(const double c1, const double c2, BgcMatrix2x3FP64* matrix) inline void bgc_fp64_matrix2x3_set_row(const int number, const BGC_FP64_Vector2* row, BGC_FP64_Matrix2x3* matrix)
{ {
matrix->r2c1 = c1; if (number == 1) {
matrix->r2c2 = c2; matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
return;
}
if (number == 2) {
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
return;
}
if (number == 3) {
matrix->r3c1 = row->x1;
matrix->r3c2 = row->x2;
}
} }
// ================= Set Row 3 ================== // // ================= Get Column ================= //
inline void bgc_matrix2x3_set_row3_fp32(const float c1, const float c2, BgcMatrix2x3FP32* matrix) inline void bgc_fp32_matrix2x3_get_column(const int number, const BGC_FP32_Matrix2x3* matrix, BGC_FP32_Vector3* column)
{ {
matrix->r3c1 = c1; if (number == 1) {
matrix->r3c2 = c2; column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
column->x3 = matrix->r3c1;
return;
}
if (number == 2) {
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
column->x3 = matrix->r3c2;
}
} }
inline void bgc_matrix2x3_set_row3_fp64(const double c1, const double c2, BgcMatrix2x3FP64* matrix) inline void bgc_fp64_matrix2x3_get_column(const int number, const BGC_FP64_Matrix2x3* matrix, BGC_FP64_Vector3* column)
{ {
matrix->r3c1 = c1; if (number == 1) {
matrix->r3c2 = c2; column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
column->x3 = matrix->r3c1;
return;
}
if (number == 2) {
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
column->x3 = matrix->r3c2;
}
} }
// ================ Set Column 1 ================ // // ================= Set Column ================= //
inline void bgc_matrix2x3_set_column1_fp32(const float r1, const float r2, const float r3, BgcMatrix2x3FP32* matrix) inline void bgc_fp32_matrix2x3_set_column(const int number, const BGC_FP32_Vector3* column, BGC_FP32_Matrix2x3* matrix)
{ {
matrix->r1c1 = r1; if (number == 1) {
matrix->r2c1 = r2; matrix->r1c1 = column->x1;
matrix->r3c1 = r3; matrix->r2c1 = column->x2;
matrix->r3c1 = column->x3;
return;
}
if (number == 2) {
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
matrix->r3c2 = column->x3;
}
} }
inline void bgc_matrix2x3_set_column1_fp64(const double r1, const double r2, const double r3, BgcMatrix2x3FP64* matrix) inline void bgc_fp64_matrix2x3_set_column(const int number, const BGC_FP64_Vector3* column, BGC_FP64_Matrix2x3* matrix)
{ {
matrix->r1c1 = r1; if (number == 1) {
matrix->r2c1 = r2; matrix->r1c1 = column->x1;
matrix->r3c1 = r3; matrix->r2c1 = column->x2;
} matrix->r3c1 = column->x3;
return;
}
// ================ Set Column 2 ================ // if (number == 2) {
matrix->r1c2 = column->x1;
inline void bgc_matrix2x3_set_column2_fp32(const float r1, const float r2, const float r3, BgcMatrix2x3FP32* matrix) matrix->r2c2 = column->x2;
{ matrix->r3c2 = column->x3;
matrix->r1c2 = r1; }
matrix->r2c2 = r2;
matrix->r3c2 = r3;
}
inline void bgc_matrix2x3_set_column2_fp64(const double r1, const double r2, const double r3, BgcMatrix2x3FP64* matrix)
{
matrix->r1c2 = r1;
matrix->r2c2 = r2;
matrix->r3c2 = r3;
} }
// ==================== Add ===================== // // ==================== Add ===================== //
inline void bgc_matrix2x3_add_fp32(const BgcMatrix2x3FP32* matrix1, const BgcMatrix2x3FP32* matrix2, BgcMatrix2x3FP32* sum) inline void bgc_fp32_matrix2x3_add(const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x3* matrix2, BGC_FP32_Matrix2x3* sum)
{ {
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
@ -259,7 +345,7 @@ inline void bgc_matrix2x3_add_fp32(const BgcMatrix2x3FP32* matrix1, const BgcMat
sum->r3c2 = matrix1->r3c2 + matrix2->r3c2; sum->r3c2 = matrix1->r3c2 + matrix2->r3c2;
} }
inline void bgc_matrix2x3_add_fp64(const BgcMatrix2x3FP64* matrix1, const BgcMatrix2x3FP64* matrix2, BgcMatrix2x3FP64* sum) inline void bgc_fp64_matrix2x3_add(const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x3* matrix2, BGC_FP64_Matrix2x3* sum)
{ {
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
@ -273,7 +359,7 @@ inline void bgc_matrix2x3_add_fp64(const BgcMatrix2x3FP64* matrix1, const BgcMat
// ================= Add scaled ================= // // ================= Add scaled ================= //
inline void bgc_matrix2x3_add_scaled_fp32(const BgcMatrix2x3FP32* basic_matrix, const BgcMatrix2x3FP32* scalable_matrix, const float scale, BgcMatrix2x3FP32* sum) inline void bgc_fp32_matrix2x3_add_scaled(const BGC_FP32_Matrix2x3* basic_matrix, const BGC_FP32_Matrix2x3* scalable_matrix, const float scale, BGC_FP32_Matrix2x3* sum)
{ {
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
@ -285,7 +371,7 @@ inline void bgc_matrix2x3_add_scaled_fp32(const BgcMatrix2x3FP32* basic_matrix,
sum->r3c2 = basic_matrix->r3c2 + scalable_matrix->r3c2 * scale; sum->r3c2 = basic_matrix->r3c2 + scalable_matrix->r3c2 * scale;
} }
inline void bgc_matrix2x3_add_scaled_fp64(const BgcMatrix2x3FP64* basic_matrix, const BgcMatrix2x3FP64* scalable_matrix, const double scale, BgcMatrix2x3FP64* sum) inline void bgc_fp64_matrix2x3_add_scaled(const BGC_FP64_Matrix2x3* basic_matrix, const BGC_FP64_Matrix2x3* scalable_matrix, const double scale, BGC_FP64_Matrix2x3* sum)
{ {
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
@ -299,7 +385,7 @@ inline void bgc_matrix2x3_add_scaled_fp64(const BgcMatrix2x3FP64* basic_matrix,
// ================== Subtract ================== // // ================== Subtract ================== //
inline void bgc_matrix2x3_subtract_fp32(const BgcMatrix2x3FP32* minuend, const BgcMatrix2x3FP32* subtrahend, BgcMatrix2x3FP32* difference) inline void bgc_fp32_matrix2x3_subtract(const BGC_FP32_Matrix2x3* minuend, const BGC_FP32_Matrix2x3* subtrahend, BGC_FP32_Matrix2x3* difference)
{ {
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
@ -311,7 +397,7 @@ inline void bgc_matrix2x3_subtract_fp32(const BgcMatrix2x3FP32* minuend, const B
difference->r3c2 = minuend->r3c2 - subtrahend->r3c2; difference->r3c2 = minuend->r3c2 - subtrahend->r3c2;
} }
inline void bgc_matrix2x3_subtract_fp64(const BgcMatrix2x3FP64* minuend, const BgcMatrix2x3FP64* subtrahend, BgcMatrix2x3FP64* difference) inline void bgc_fp64_matrix2x3_subtract(const BGC_FP64_Matrix2x3* minuend, const BGC_FP64_Matrix2x3* subtrahend, BGC_FP64_Matrix2x3* difference)
{ {
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
@ -323,35 +409,9 @@ inline void bgc_matrix2x3_subtract_fp64(const BgcMatrix2x3FP64* minuend, const B
difference->r3c2 = minuend->r3c2 - subtrahend->r3c2; difference->r3c2 = minuend->r3c2 - subtrahend->r3c2;
} }
// ============== Subtract scaled =============== //
inline void bgc_matrix2x3_subtract_scaled_fp32(const BgcMatrix2x3FP32* basic_matrix, const BgcMatrix2x3FP32* scalable_matrix, const float scale, BgcMatrix2x3FP32* difference)
{
difference->r1c1 = basic_matrix->r1c1 - scalable_matrix->r1c1 * scale;
difference->r1c2 = basic_matrix->r1c2 - scalable_matrix->r1c2 * scale;
difference->r2c1 = basic_matrix->r2c1 - scalable_matrix->r2c1 * scale;
difference->r2c2 = basic_matrix->r2c2 - scalable_matrix->r2c2 * scale;
difference->r3c1 = basic_matrix->r3c1 - scalable_matrix->r3c1 * scale;
difference->r3c2 = basic_matrix->r3c2 - scalable_matrix->r3c2 * scale;
}
inline void bgc_matrix2x3_subtract_scaled_fp64(const BgcMatrix2x3FP64* basic_matrix, const BgcMatrix2x3FP64* scalable_matrix, const double scale, BgcMatrix2x3FP64* difference)
{
difference->r1c1 = basic_matrix->r1c1 - scalable_matrix->r1c1 * scale;
difference->r1c2 = basic_matrix->r1c2 - scalable_matrix->r1c2 * scale;
difference->r2c1 = basic_matrix->r2c1 - scalable_matrix->r2c1 * scale;
difference->r2c2 = basic_matrix->r2c2 - scalable_matrix->r2c2 * scale;
difference->r3c1 = basic_matrix->r3c1 - scalable_matrix->r3c1 * scale;
difference->r3c2 = basic_matrix->r3c2 - scalable_matrix->r3c2 * scale;
}
// ================== Multiply ================== // // ================== Multiply ================== //
inline void bgc_matrix2x3_multiply_fp32(const BgcMatrix2x3FP32* multiplicand, const float multiplier, BgcMatrix2x3FP32* product) inline void bgc_fp32_matrix2x3_multiply(const BGC_FP32_Matrix2x3* multiplicand, const float multiplier, BGC_FP32_Matrix2x3* product)
{ {
product->r1c1 = multiplicand->r1c1 * multiplier; product->r1c1 = multiplicand->r1c1 * multiplier;
product->r1c2 = multiplicand->r1c2 * multiplier; product->r1c2 = multiplicand->r1c2 * multiplier;
@ -363,7 +423,7 @@ inline void bgc_matrix2x3_multiply_fp32(const BgcMatrix2x3FP32* multiplicand, co
product->r3c2 = multiplicand->r3c2 * multiplier; product->r3c2 = multiplicand->r3c2 * multiplier;
} }
inline void bgc_matrix2x3_multiply_fp64(const BgcMatrix2x3FP64* multiplicand, const double multiplier, BgcMatrix2x3FP64* product) inline void bgc_fp64_matrix2x3_multiply(const BGC_FP64_Matrix2x3* multiplicand, const double multiplier, BGC_FP64_Matrix2x3* product)
{ {
product->r1c1 = multiplicand->r1c1 * multiplier; product->r1c1 = multiplicand->r1c1 * multiplier;
product->r1c2 = multiplicand->r1c2 * multiplier; product->r1c2 = multiplicand->r1c2 * multiplier;
@ -377,44 +437,74 @@ inline void bgc_matrix2x3_multiply_fp64(const BgcMatrix2x3FP64* multiplicand, co
// =================== Divide =================== // // =================== Divide =================== //
inline void bgc_matrix2x3_divide_fp32(const BgcMatrix2x3FP32* dividend, const float divisor, BgcMatrix2x3FP32* quotient) inline void bgc_fp32_matrix2x3_divide(const BGC_FP32_Matrix2x3* dividend, const float divisor, BGC_FP32_Matrix2x3* quotient)
{ {
bgc_matrix2x3_multiply_fp32(dividend, 1.0f / divisor, quotient); bgc_fp32_matrix2x3_multiply(dividend, 1.0f / divisor, quotient);
} }
inline void bgc_matrix2x3_divide_fp64(const BgcMatrix2x3FP64* dividend, const double divisor, BgcMatrix2x3FP64* quotient) inline void bgc_fp64_matrix2x3_divide(const BGC_FP64_Matrix2x3* dividend, const double divisor, BGC_FP64_Matrix2x3* quotient)
{ {
bgc_matrix2x3_multiply_fp64(dividend, 1.0 / divisor, quotient); bgc_fp64_matrix2x3_multiply(dividend, 1.0 / divisor, quotient);
}
// ================ Interpolate ================= //
inline void bgc_fp32_matrix2x3_interpolate(const BGC_FP32_Matrix2x3* first, const BGC_FP32_Matrix2x3* second, const float phase, BGC_FP32_Matrix2x3* interpolation)
{
const float couter_phase = 1.0f - phase;
interpolation->r1c1 = first->r1c1 * couter_phase + second->r1c1 * phase;
interpolation->r1c2 = first->r1c2 * couter_phase + second->r1c2 * phase;
interpolation->r2c1 = first->r2c1 * couter_phase + second->r2c1 * phase;
interpolation->r2c2 = first->r2c2 * couter_phase + second->r2c2 * phase;
interpolation->r3c1 = first->r3c1 * couter_phase + second->r3c1 * phase;
interpolation->r3c2 = first->r3c2 * couter_phase + second->r3c2 * phase;
}
inline void bgc_fp64_matrix2x3_interpolate(const BGC_FP64_Matrix2x3* first, const BGC_FP64_Matrix2x3* second, const double phase, BGC_FP64_Matrix2x3* interpolation)
{
const double couter_phase = 1.0 - phase;
interpolation->r1c1 = first->r1c1 * couter_phase + second->r1c1 * phase;
interpolation->r1c2 = first->r1c2 * couter_phase + second->r1c2 * phase;
interpolation->r2c1 = first->r2c1 * couter_phase + second->r2c1 * phase;
interpolation->r2c2 = first->r2c2 * couter_phase + second->r2c2 * phase;
interpolation->r3c1 = first->r3c1 * couter_phase + second->r3c1 * phase;
interpolation->r3c2 = first->r3c2 * couter_phase + second->r3c2 * phase;
} }
// ============ Left Vector Product ============= // // ============ Left Vector Product ============= //
inline void bgc_matrix2x3_get_left_product_fp32(const BgcVector3FP32* vector, const BgcMatrix2x3FP32* matrix, BgcVector2FP32* result) inline void bgc_fp32_multiply_vector3_by_matrix2x3(const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix2x3* matrix, BGC_FP32_Vector2* product)
{ {
result->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1; product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
result->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2; product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
} }
inline void bgc_matrix2x3_get_left_product_fp64(const BgcVector3FP64* vector, const BgcMatrix2x3FP64* matrix, BgcVector2FP64* result) inline void bgc_fp64_multiply_vector3_by_matrix2x3(const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix2x3* matrix, BGC_FP64_Vector2* product)
{ {
result->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1; product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
result->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2; product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
} }
// ============ Right Vector Product ============ // // ============ Right Vector Product ============ //
inline void bgc_matrix2x3_get_right_product_fp32(const BgcMatrix2x3FP32* matrix, const BgcVector2FP32* vector, BgcVector3FP32* result) inline void bgc_fp32_multiply_matrix2x3_by_vector2(const BGC_FP32_Matrix2x3* matrix, const BGC_FP32_Vector2* vector, BGC_FP32_Vector3* product)
{ {
result->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2; product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
result->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2; product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
result->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2; product->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2;
} }
inline void bgc_matrix2x3_get_right_product_fp64(const BgcMatrix2x3FP64* matrix, const BgcVector2FP64* vector, BgcVector3FP64* result) inline void bgc_fp64_multiply_matrix2x3_by_vector2(const BGC_FP64_Matrix2x3* matrix, const BGC_FP64_Vector2* vector, BGC_FP64_Vector3* product)
{ {
result->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2; product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2;
result->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2; product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2;
result->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2; product->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2;
} }
#endif #endif

View file

@ -1,55 +1,52 @@
#include "matrix3x2.h" #include "matrix3x2.h"
extern inline void bgc_matrix3x2_reset_fp32(BgcMatrix3x2FP32* matrix); extern inline void bgc_fp32_matrix3x2_reset(BGC_FP32_Matrix3x2* matrix);
extern inline void bgc_matrix3x2_reset_fp64(BgcMatrix3x2FP64* matrix); extern inline void bgc_fp64_matrix3x2_reset(BGC_FP64_Matrix3x2* matrix);
extern inline void bgc_matrix3x2_copy_fp32(const BgcMatrix3x2FP32* source, BgcMatrix3x2FP32* destination); extern inline void bgc_fp32_matrix3x2_copy(const BGC_FP32_Matrix3x2* source, BGC_FP32_Matrix3x2* destination);
extern inline void bgc_matrix3x2_copy_fp64(const BgcMatrix3x2FP64* source, BgcMatrix3x2FP64* destination); extern inline void bgc_fp64_matrix3x2_copy(const BGC_FP64_Matrix3x2* source, BGC_FP64_Matrix3x2* destination);
extern inline void bgc_matrix3x2_swap_fp32(BgcMatrix3x2FP32* matrix1, BgcMatrix3x2FP32* matrix2); extern inline void bgc_fp32_matrix3x2_swap(BGC_FP32_Matrix3x2* matrix1, BGC_FP32_Matrix3x2* matrix2);
extern inline void bgc_matrix3x2_swap_fp64(BgcMatrix3x2FP64* matrix1, BgcMatrix3x2FP64* matrix2); extern inline void bgc_fp64_matrix3x2_swap(BGC_FP64_Matrix3x2* matrix1, BGC_FP64_Matrix3x2* matrix2);
extern inline void bgc_matrix3x2_convert_fp64_to_fp32(const BgcMatrix3x2FP64* source, BgcMatrix3x2FP32* destination); extern inline void bgc_fp64_matrix3x2_convert_to_fp32(const BGC_FP64_Matrix3x2* source, BGC_FP32_Matrix3x2* destination);
extern inline void bgc_matrix3x2_convert_fp32_to_fp64(const BgcMatrix3x2FP32* source, BgcMatrix3x2FP64* destination); extern inline void bgc_fp32_matrix3x2_convert_to_fp64(const BGC_FP32_Matrix3x2* source, BGC_FP64_Matrix3x2* destination);
extern inline void bgc_matrix3x2_transpose_fp32(const BgcMatrix2x3FP32* matrix, BgcMatrix3x2FP32* transposed); extern inline void bgc_fp32_matrix3x2_get_transposed(const BGC_FP32_Matrix2x3* matrix, BGC_FP32_Matrix3x2* transposed);
extern inline void bgc_matrix3x2_transpose_fp64(const BgcMatrix2x3FP64* matrix, BgcMatrix3x2FP64* transposed); extern inline void bgc_fp64_matrix3x2_get_transposed(const BGC_FP64_Matrix2x3* matrix, BGC_FP64_Matrix3x2* transposed);
extern inline void bgc_matrix3x2_set_row1_fp32(const float c1, const float c2, const float c3, BgcMatrix3x2FP32* matrix); extern inline void bgc_fp32_matrix3x2_get_row(const int number, const BGC_FP32_Matrix3x2* matrix, BGC_FP32_Vector3* row);
extern inline void bgc_matrix3x2_set_row1_fp64(const double c1, const double c2, const double c3, BgcMatrix3x2FP64* matrix); extern inline void bgc_fp64_matrix3x2_get_row(const int number, const BGC_FP64_Matrix3x2* matrix, BGC_FP64_Vector3* row);
extern inline void bgc_matrix3x2_set_row2_fp32(const float c1, const float c2, const float c3, BgcMatrix3x2FP32* matrix); extern inline void bgc_fp32_matrix3x2_set_row(const int number, const BGC_FP32_Vector3* row, BGC_FP32_Matrix3x2* matrix);
extern inline void bgc_matrix3x2_set_row2_fp64(const double c1, const double c2, const double c3, BgcMatrix3x2FP64* matrix); extern inline void bgc_fp64_matrix3x2_set_row(const int number, const BGC_FP64_Vector3* row, BGC_FP64_Matrix3x2* matrix);
extern inline void bgc_matrix3x2_set_column1_fp32(const float r1, const float r2, BgcMatrix3x2FP32* matrix); extern inline void bgc_fp32_matrix3x2_get_column(const int number, const BGC_FP32_Matrix3x2* matrix, BGC_FP32_Vector2* column);
extern inline void bgc_matrix3x2_set_column1_fp64(const double r1, const double r2, BgcMatrix3x2FP64* matrix); extern inline void bgc_fp64_matrix3x2_get_column(const int number, const BGC_FP64_Matrix3x2* matrix, BGC_FP64_Vector2* column);
extern inline void bgc_matrix3x2_set_column2_fp32(const float r1, const float r2, BgcMatrix3x2FP32* matrix); extern inline void bgc_fp32_matrix3x2_set_column(const int number, const BGC_FP32_Vector2* column, BGC_FP32_Matrix3x2* matrix);
extern inline void bgc_matrix3x2_set_column2_fp64(const double r1, const double r2, BgcMatrix3x2FP64* matrix); extern inline void bgc_fp64_matrix3x2_set_column(const int number, const BGC_FP64_Vector2* column, BGC_FP64_Matrix3x2* matrix);
extern inline void bgc_matrix3x2_set_column3_fp32(const float r1, const float r2, BgcMatrix3x2FP32* matrix); extern inline void bgc_fp32_matrix3x2_add(const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x2* matrix2, BGC_FP32_Matrix3x2* sum);
extern inline void bgc_matrix3x2_set_column3_fp64(const double r1, const double r2, BgcMatrix3x2FP64* matrix); extern inline void bgc_fp64_matrix3x2_add(const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x2* matrix2, BGC_FP64_Matrix3x2* sum);
extern inline void bgc_matrix3x2_add_fp32(const BgcMatrix3x2FP32* matrix1, const BgcMatrix3x2FP32* matrix2, BgcMatrix3x2FP32* sum); extern inline void bgc_fp32_matrix3x2_add_scaled(const BGC_FP32_Matrix3x2* basic_matrix, const BGC_FP32_Matrix3x2* scalable_matrix, const float scale, BGC_FP32_Matrix3x2* sum);
extern inline void bgc_matrix3x2_add_fp64(const BgcMatrix3x2FP64* matrix1, const BgcMatrix3x2FP64* matrix2, BgcMatrix3x2FP64* sum); extern inline void bgc_fp64_matrix3x2_add_scaled(const BGC_FP64_Matrix3x2* basic_matrix, const BGC_FP64_Matrix3x2* scalable_matrix, const double scale, BGC_FP64_Matrix3x2* sum);
extern inline void bgc_matrix3x2_add_scaled_fp32(const BgcMatrix3x2FP32* basic_matrix, const BgcMatrix3x2FP32* scalable_matrix, const float scale, BgcMatrix3x2FP32* sum); extern inline void bgc_fp32_matrix3x2_subtract(const BGC_FP32_Matrix3x2* minuend, const BGC_FP32_Matrix3x2* subtrahend, BGC_FP32_Matrix3x2* difference);
extern inline void bgc_matrix3x2_add_scaled_fp64(const BgcMatrix3x2FP64* basic_matrix, const BgcMatrix3x2FP64* scalable_matrix, const double scale, BgcMatrix3x2FP64* sum); extern inline void bgc_fp64_matrix3x2_subtract(const BGC_FP64_Matrix3x2* minuend, const BGC_FP64_Matrix3x2* subtrahend, BGC_FP64_Matrix3x2* difference);
extern inline void bgc_matrix3x2_subtract_fp32(const BgcMatrix3x2FP32* minuend, const BgcMatrix3x2FP32* subtrahend, BgcMatrix3x2FP32* difference); extern inline void bgc_fp32_matrix3x2_multiply(const BGC_FP32_Matrix3x2* multiplicand, const float multiplier, BGC_FP32_Matrix3x2* product);
extern inline void bgc_matrix3x2_subtract_fp64(const BgcMatrix3x2FP64* minuend, const BgcMatrix3x2FP64* subtrahend, BgcMatrix3x2FP64* difference); extern inline void bgc_fp64_matrix3x2_multiply(const BGC_FP64_Matrix3x2* multiplicand, const double multiplier, BGC_FP64_Matrix3x2* product);
extern inline void bgc_matrix3x2_subtract_scaled_fp32(const BgcMatrix3x2FP32* basic_matrix, const BgcMatrix3x2FP32* scalable_matrix, const float scale, BgcMatrix3x2FP32* difference); extern inline void bgc_fp32_matrix3x2_divide(const BGC_FP32_Matrix3x2* dividend, const float divisor, BGC_FP32_Matrix3x2* quotient);
extern inline void bgc_matrix3x2_subtract_scaled_fp64(const BgcMatrix3x2FP64* basic_matrix, const BgcMatrix3x2FP64* scalable_matrix, const double scale, BgcMatrix3x2FP64* difference); extern inline void bgc_fp64_matrix3x2_divide(const BGC_FP64_Matrix3x2* dividend, const double divisor, BGC_FP64_Matrix3x2* quotient);
extern inline void bgc_matrix3x2_multiply_fp32(const BgcMatrix3x2FP32* multiplicand, const float multiplier, BgcMatrix3x2FP32* product); extern inline void bgc_fp32_matrix3x2_interpolate(const BGC_FP32_Matrix3x2* first, const BGC_FP32_Matrix3x2* second, const float phase, BGC_FP32_Matrix3x2* interpolation);
extern inline void bgc_matrix3x2_multiply_fp64(const BgcMatrix3x2FP64* multiplicand, const double multiplier, BgcMatrix3x2FP64* product); extern inline void bgc_fp64_matrix3x2_interpolate(const BGC_FP64_Matrix3x2* first, const BGC_FP64_Matrix3x2* second, const double phase, BGC_FP64_Matrix3x2* interpolation);
extern inline void bgc_matrix3x2_divide_fp32(const BgcMatrix3x2FP32* dividend, const float divisor, BgcMatrix3x2FP32* quotient); extern inline void bgc_fp32_multiply_vector2_by_matrix3x2(const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix3x2* matrix, BGC_FP32_Vector3* product);
extern inline void bgc_matrix3x2_divide_fp64(const BgcMatrix3x2FP64* dividend, const double divisor, BgcMatrix3x2FP64* quotient); extern inline void bgc_fp64_multiply_vector2_by_matrix3x2(const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix3x2* matrix, BGC_FP64_Vector3* product);
extern inline void bgc_matrix3x2_get_left_product_fp32(const BgcVector2FP32* vector, const BgcMatrix3x2FP32* matrix, BgcVector3FP32* result); extern inline void bgc_fp32_multiply_matrix3x2_by_vector3(const BGC_FP32_Matrix3x2* matrix, const BGC_FP32_Vector3* vector, BGC_FP32_Vector2* product);
extern inline void bgc_matrix3x2_get_left_product_fp64(const BgcVector2FP64* vector, const BgcMatrix3x2FP64* matrix, BgcVector3FP64* result); extern inline void bgc_fp64_multiply_matrix3x2_by_vector3(const BGC_FP64_Matrix3x2* matrix, const BGC_FP64_Vector3* vector, BGC_FP64_Vector2* product);
extern inline void bgc_matrix3x2_get_right_product_fp32(const BgcMatrix3x2FP32* matrix, const BgcVector3FP32* vector, BgcVector2FP32* result);
extern inline void bgc_matrix3x2_get_right_product_fp64(const BgcMatrix3x2FP64* matrix, const BgcVector3FP64* vector, BgcVector2FP64* result);

View file

@ -7,7 +7,7 @@
// =================== Reset ==================== // // =================== Reset ==================== //
inline void bgc_matrix3x2_reset_fp32(BgcMatrix3x2FP32* matrix) inline void bgc_fp32_matrix3x2_reset(BGC_FP32_Matrix3x2* matrix)
{ {
matrix->r1c1 = 0.0f; matrix->r1c1 = 0.0f;
matrix->r1c2 = 0.0f; matrix->r1c2 = 0.0f;
@ -18,7 +18,7 @@ inline void bgc_matrix3x2_reset_fp32(BgcMatrix3x2FP32* matrix)
matrix->r2c3 = 0.0f; matrix->r2c3 = 0.0f;
} }
inline void bgc_matrix3x2_reset_fp64(BgcMatrix3x2FP64* matrix) inline void bgc_fp64_matrix3x2_reset(BGC_FP64_Matrix3x2* matrix)
{ {
matrix->r1c1 = 0.0; matrix->r1c1 = 0.0;
matrix->r1c2 = 0.0; matrix->r1c2 = 0.0;
@ -31,7 +31,7 @@ inline void bgc_matrix3x2_reset_fp64(BgcMatrix3x2FP64* matrix)
// ==================== Copy ==================== // // ==================== Copy ==================== //
inline void bgc_matrix3x2_copy_fp32(const BgcMatrix3x2FP32* source, BgcMatrix3x2FP32* destination) inline void bgc_fp32_matrix3x2_copy(const BGC_FP32_Matrix3x2* source, BGC_FP32_Matrix3x2* destination)
{ {
destination->r1c1 = source->r1c1; destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2; destination->r1c2 = source->r1c2;
@ -42,7 +42,7 @@ inline void bgc_matrix3x2_copy_fp32(const BgcMatrix3x2FP32* source, BgcMatrix3x2
destination->r2c3 = source->r2c3; destination->r2c3 = source->r2c3;
} }
inline void bgc_matrix3x2_copy_fp64(const BgcMatrix3x2FP64* source, BgcMatrix3x2FP64* destination) inline void bgc_fp64_matrix3x2_copy(const BGC_FP64_Matrix3x2* source, BGC_FP64_Matrix3x2* destination)
{ {
destination->r1c1 = source->r1c1; destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2; destination->r1c2 = source->r1c2;
@ -55,7 +55,7 @@ inline void bgc_matrix3x2_copy_fp64(const BgcMatrix3x2FP64* source, BgcMatrix3x2
// ==================== Swap ==================== // // ==================== Swap ==================== //
inline void bgc_matrix3x2_swap_fp32(BgcMatrix3x2FP32* matrix1, BgcMatrix3x2FP32* matrix2) inline void bgc_fp32_matrix3x2_swap(BGC_FP32_Matrix3x2* matrix1, BGC_FP32_Matrix3x2* matrix2)
{ {
const float r1c1 = matrix2->r1c1; const float r1c1 = matrix2->r1c1;
const float r1c2 = matrix2->r1c2; const float r1c2 = matrix2->r1c2;
@ -82,7 +82,7 @@ inline void bgc_matrix3x2_swap_fp32(BgcMatrix3x2FP32* matrix1, BgcMatrix3x2FP32*
matrix1->r2c3 = r2c3; matrix1->r2c3 = r2c3;
} }
inline void bgc_matrix3x2_swap_fp64(BgcMatrix3x2FP64* matrix1, BgcMatrix3x2FP64* matrix2) inline void bgc_fp64_matrix3x2_swap(BGC_FP64_Matrix3x2* matrix1, BGC_FP64_Matrix3x2* matrix2)
{ {
const double r1c1 = matrix2->r1c1; const double r1c1 = matrix2->r1c1;
const double r1c2 = matrix2->r1c2; const double r1c2 = matrix2->r1c2;
@ -111,7 +111,7 @@ inline void bgc_matrix3x2_swap_fp64(BgcMatrix3x2FP64* matrix1, BgcMatrix3x2FP64*
// ================== Convert =================== // // ================== Convert =================== //
inline void bgc_matrix3x2_convert_fp64_to_fp32(const BgcMatrix3x2FP64* source, BgcMatrix3x2FP32* destination) inline void bgc_fp64_matrix3x2_convert_to_fp32(const BGC_FP64_Matrix3x2* source, BGC_FP32_Matrix3x2* destination)
{ {
destination->r1c1 = (float)source->r1c1; destination->r1c1 = (float)source->r1c1;
destination->r1c2 = (float)source->r1c2; destination->r1c2 = (float)source->r1c2;
@ -122,7 +122,7 @@ inline void bgc_matrix3x2_convert_fp64_to_fp32(const BgcMatrix3x2FP64* source, B
destination->r2c3 = (float)source->r2c3; destination->r2c3 = (float)source->r2c3;
} }
inline void bgc_matrix3x2_convert_fp32_to_fp64(const BgcMatrix3x2FP32* source, BgcMatrix3x2FP64* destination) inline void bgc_fp32_matrix3x2_convert_to_fp64(const BGC_FP32_Matrix3x2* source, BGC_FP64_Matrix3x2* destination)
{ {
destination->r1c1 = source->r1c1; destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2; destination->r1c2 = source->r1c2;
@ -135,7 +135,7 @@ inline void bgc_matrix3x2_convert_fp32_to_fp64(const BgcMatrix3x2FP32* source, B
// ================= Transpose ================== // // ================= Transpose ================== //
inline void bgc_matrix3x2_transpose_fp32(const BgcMatrix2x3FP32* matrix, BgcMatrix3x2FP32* transposed) inline void bgc_fp32_matrix3x2_get_transposed(const BGC_FP32_Matrix2x3* matrix, BGC_FP32_Matrix3x2* transposed)
{ {
transposed->r1c1 = matrix->r1c1; transposed->r1c1 = matrix->r1c1;
transposed->r1c2 = matrix->r2c1; transposed->r1c2 = matrix->r2c1;
@ -146,7 +146,7 @@ inline void bgc_matrix3x2_transpose_fp32(const BgcMatrix2x3FP32* matrix, BgcMatr
transposed->r2c3 = matrix->r3c2; transposed->r2c3 = matrix->r3c2;
} }
inline void bgc_matrix3x2_transpose_fp64(const BgcMatrix2x3FP64* matrix, BgcMatrix3x2FP64* transposed) inline void bgc_fp64_matrix3x2_get_transposed(const BGC_FP64_Matrix2x3* matrix, BGC_FP64_Matrix3x2* transposed)
{ {
transposed->r1c1 = matrix->r1c1; transposed->r1c1 = matrix->r1c1;
transposed->r1c2 = matrix->r2c1; transposed->r1c2 = matrix->r2c1;
@ -157,83 +157,199 @@ inline void bgc_matrix3x2_transpose_fp64(const BgcMatrix2x3FP64* matrix, BgcMatr
transposed->r2c3 = matrix->r3c2; transposed->r2c3 = matrix->r3c2;
} }
// ================= Set Row 1 ================== // // ================== Get Row =================== //
inline void bgc_matrix3x2_set_row1_fp32(const float c1, const float c2, const float c3, BgcMatrix3x2FP32* matrix) inline void bgc_fp32_matrix3x2_get_row(const int number, const BGC_FP32_Matrix3x2* matrix, BGC_FP32_Vector3* row)
{ {
matrix->r1c1 = c1; if (number == 1)
matrix->r1c2 = c2; {
matrix->r1c3 = c3; row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
row->x3 = matrix->r1c3;
return;
}
if (number == 2)
{
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
row->x3 = matrix->r2c3;
return;
}
row->x1 = 0.0f;
row->x2 = 0.0f;
row->x3 = 0.0f;
} }
inline void bgc_matrix3x2_set_row1_fp64(const double c1, const double c2, const double c3, BgcMatrix3x2FP64* matrix) inline void bgc_fp64_matrix3x2_get_row(const int number, const BGC_FP64_Matrix3x2* matrix, BGC_FP64_Vector3* row)
{ {
matrix->r1c1 = c1; if (number == 1)
matrix->r1c2 = c2; {
matrix->r1c3 = c3; row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
row->x3 = matrix->r1c3;
return;
}
if (number == 2)
{
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
row->x3 = matrix->r2c3;
return;
}
row->x1 = 0.0f;
row->x2 = 0.0f;
row->x3 = 0.0f;
} }
// ================= Set Row 2 ================== // // ================== Set Row =================== //
inline void bgc_matrix3x2_set_row2_fp32(const float c1, const float c2, const float c3, BgcMatrix3x2FP32* matrix) inline void bgc_fp32_matrix3x2_set_row(const int number, const BGC_FP32_Vector3* row, BGC_FP32_Matrix3x2* matrix)
{ {
matrix->r2c1 = c1; if (number == 1)
matrix->r2c2 = c2; {
matrix->r2c3 = c3; matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
matrix->r1c3 = row->x3;
return;
}
if (number == 2)
{
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
matrix->r2c3 = row->x3;
}
} }
inline void bgc_matrix3x2_set_row2_fp64(const double c1, const double c2, const double c3, BgcMatrix3x2FP64* matrix) inline void bgc_fp64_matrix3x2_set_row(const int number, const BGC_FP64_Vector3* row, BGC_FP64_Matrix3x2* matrix)
{ {
matrix->r2c1 = c1; if (number == 1)
matrix->r2c2 = c2; {
matrix->r2c3 = c3; matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
matrix->r1c3 = row->x3;
return;
}
if (number == 2)
{
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
matrix->r2c3 = row->x3;
}
} }
// ================ Set Column 1 ================ // // ================= Get Column ================= //
inline void bgc_matrix3x2_set_column1_fp32(const float r1, const float r2, BgcMatrix3x2FP32* matrix) inline void bgc_fp32_matrix3x2_get_column(const int number, const BGC_FP32_Matrix3x2* matrix, BGC_FP32_Vector2* column)
{ {
matrix->r1c1 = r1; if (number == 1)
matrix->r2c1 = r2; {
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
return;
}
if (number == 2)
{
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
return;
}
if (number == 3)
{
column->x1 = matrix->r1c3;
column->x2 = matrix->r2c3;
return;
}
column->x1 = 0.0f;
column->x2 = 0.0f;
} }
inline void bgc_matrix3x2_set_column1_fp64(const double r1, const double r2, BgcMatrix3x2FP64* matrix) inline void bgc_fp64_matrix3x2_get_column(const int number, const BGC_FP64_Matrix3x2* matrix, BGC_FP64_Vector2* column)
{ {
matrix->r1c1 = r1; if (number == 1)
matrix->r2c1 = r2; {
column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
return;
}
if (number == 2)
{
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
return;
}
if (number == 3)
{
column->x1 = matrix->r1c3;
column->x2 = matrix->r2c3;
return;
}
column->x1 = 0.0;
column->x2 = 0.0;
} }
// ================ Set Column 2 ================ // // ================= Set Column ================= //
inline void bgc_matrix3x2_set_column2_fp32(const float r1, const float r2, BgcMatrix3x2FP32* matrix) inline void bgc_fp32_matrix3x2_set_column(const int number, const BGC_FP32_Vector2* column, BGC_FP32_Matrix3x2* matrix)
{ {
matrix->r1c2 = r1; if (number == 1)
matrix->r2c2 = r2; {
matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
return;
}
if (number == 2)
{
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
return;
}
if (number == 3)
{
matrix->r1c3 = column->x1;
matrix->r2c3 = column->x2;
}
} }
inline void bgc_matrix3x2_set_column2_fp64(const double r1, const double r2, BgcMatrix3x2FP64* matrix) inline void bgc_fp64_matrix3x2_set_column(const int number, const BGC_FP64_Vector2* column, BGC_FP64_Matrix3x2* matrix)
{ {
matrix->r1c2 = r1; if (number == 1)
matrix->r2c2 = r2; {
} matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
return;
}
// ================ Set Column 3 ================ // if (number == 2)
{
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
return;
}
inline void bgc_matrix3x2_set_column3_fp32(const float r1, const float r2, BgcMatrix3x2FP32* matrix) if (number == 3)
{ {
matrix->r1c3 = r1; matrix->r1c3 = column->x1;
matrix->r2c3 = r2; matrix->r2c3 = column->x2;
} }
inline void bgc_matrix3x2_set_column3_fp64(const double r1, const double r2, BgcMatrix3x2FP64* matrix)
{
matrix->r1c3 = r1;
matrix->r2c3 = r2;
} }
// ==================== Add ===================== // // ==================== Add ===================== //
inline void bgc_matrix3x2_add_fp32(const BgcMatrix3x2FP32* matrix1, const BgcMatrix3x2FP32* matrix2, BgcMatrix3x2FP32* sum) inline void bgc_fp32_matrix3x2_add(const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x2* matrix2, BGC_FP32_Matrix3x2* sum)
{ {
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
@ -244,7 +360,7 @@ inline void bgc_matrix3x2_add_fp32(const BgcMatrix3x2FP32* matrix1, const BgcMat
sum->r2c3 = matrix1->r2c3 + matrix2->r2c3; sum->r2c3 = matrix1->r2c3 + matrix2->r2c3;
} }
inline void bgc_matrix3x2_add_fp64(const BgcMatrix3x2FP64* matrix1, const BgcMatrix3x2FP64* matrix2, BgcMatrix3x2FP64* sum) inline void bgc_fp64_matrix3x2_add(const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x2* matrix2, BGC_FP64_Matrix3x2* sum)
{ {
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
@ -257,7 +373,7 @@ inline void bgc_matrix3x2_add_fp64(const BgcMatrix3x2FP64* matrix1, const BgcMat
// ================= Add scaled ================= // // ================= Add scaled ================= //
inline void bgc_matrix3x2_add_scaled_fp32(const BgcMatrix3x2FP32* basic_matrix, const BgcMatrix3x2FP32* scalable_matrix, const float scale, BgcMatrix3x2FP32* sum) inline void bgc_fp32_matrix3x2_add_scaled(const BGC_FP32_Matrix3x2* basic_matrix, const BGC_FP32_Matrix3x2* scalable_matrix, const float scale, BGC_FP32_Matrix3x2* sum)
{ {
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
@ -268,7 +384,7 @@ inline void bgc_matrix3x2_add_scaled_fp32(const BgcMatrix3x2FP32* basic_matrix,
sum->r2c3 = basic_matrix->r2c3 + scalable_matrix->r2c3 * scale; sum->r2c3 = basic_matrix->r2c3 + scalable_matrix->r2c3 * scale;
} }
inline void bgc_matrix3x2_add_scaled_fp64(const BgcMatrix3x2FP64* basic_matrix, const BgcMatrix3x2FP64* scalable_matrix, const double scale, BgcMatrix3x2FP64* sum) inline void bgc_fp64_matrix3x2_add_scaled(const BGC_FP64_Matrix3x2* basic_matrix, const BGC_FP64_Matrix3x2* scalable_matrix, const double scale, BGC_FP64_Matrix3x2* sum)
{ {
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
@ -281,7 +397,7 @@ inline void bgc_matrix3x2_add_scaled_fp64(const BgcMatrix3x2FP64* basic_matrix,
// ================== Subtract ================== // // ================== Subtract ================== //
inline void bgc_matrix3x2_subtract_fp32(const BgcMatrix3x2FP32* minuend, const BgcMatrix3x2FP32* subtrahend, BgcMatrix3x2FP32* difference) inline void bgc_fp32_matrix3x2_subtract(const BGC_FP32_Matrix3x2* minuend, const BGC_FP32_Matrix3x2* subtrahend, BGC_FP32_Matrix3x2* difference)
{ {
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
@ -292,7 +408,7 @@ inline void bgc_matrix3x2_subtract_fp32(const BgcMatrix3x2FP32* minuend, const B
difference->r2c3 = minuend->r2c3 - subtrahend->r2c3; difference->r2c3 = minuend->r2c3 - subtrahend->r2c3;
} }
inline void bgc_matrix3x2_subtract_fp64(const BgcMatrix3x2FP64* minuend, const BgcMatrix3x2FP64* subtrahend, BgcMatrix3x2FP64* difference) inline void bgc_fp64_matrix3x2_subtract(const BGC_FP64_Matrix3x2* minuend, const BGC_FP64_Matrix3x2* subtrahend, BGC_FP64_Matrix3x2* difference)
{ {
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
@ -303,33 +419,9 @@ inline void bgc_matrix3x2_subtract_fp64(const BgcMatrix3x2FP64* minuend, const B
difference->r2c3 = minuend->r2c3 - subtrahend->r2c3; difference->r2c3 = minuend->r2c3 - subtrahend->r2c3;
} }
// ============== Subtract scaled =============== //
inline void bgc_matrix3x2_subtract_scaled_fp32(const BgcMatrix3x2FP32* basic_matrix, const BgcMatrix3x2FP32* scalable_matrix, const float scale, BgcMatrix3x2FP32* difference)
{
difference->r1c1 = basic_matrix->r1c1 - scalable_matrix->r1c1 * scale;
difference->r1c2 = basic_matrix->r1c2 - scalable_matrix->r1c2 * scale;
difference->r1c3 = basic_matrix->r1c3 - scalable_matrix->r1c3 * scale;
difference->r2c1 = basic_matrix->r2c1 - scalable_matrix->r2c1 * scale;
difference->r2c2 = basic_matrix->r2c2 - scalable_matrix->r2c2 * scale;
difference->r2c3 = basic_matrix->r2c3 - scalable_matrix->r2c3 * scale;
}
inline void bgc_matrix3x2_subtract_scaled_fp64(const BgcMatrix3x2FP64* basic_matrix, const BgcMatrix3x2FP64* scalable_matrix, const double scale, BgcMatrix3x2FP64* difference)
{
difference->r1c1 = basic_matrix->r1c1 - scalable_matrix->r1c1 * scale;
difference->r1c2 = basic_matrix->r1c2 - scalable_matrix->r1c2 * scale;
difference->r1c3 = basic_matrix->r1c3 - scalable_matrix->r1c3 * scale;
difference->r2c1 = basic_matrix->r2c1 - scalable_matrix->r2c1 * scale;
difference->r2c2 = basic_matrix->r2c2 - scalable_matrix->r2c2 * scale;
difference->r2c3 = basic_matrix->r2c3 - scalable_matrix->r2c3 * scale;
}
// ================== Multiply ================== // // ================== Multiply ================== //
inline void bgc_matrix3x2_multiply_fp32(const BgcMatrix3x2FP32* multiplicand, const float multiplier, BgcMatrix3x2FP32* product) inline void bgc_fp32_matrix3x2_multiply(const BGC_FP32_Matrix3x2* multiplicand, const float multiplier, BGC_FP32_Matrix3x2* product)
{ {
product->r1c1 = multiplicand->r1c1 * multiplier; product->r1c1 = multiplicand->r1c1 * multiplier;
product->r1c2 = multiplicand->r1c2 * multiplier; product->r1c2 = multiplicand->r1c2 * multiplier;
@ -340,7 +432,7 @@ inline void bgc_matrix3x2_multiply_fp32(const BgcMatrix3x2FP32* multiplicand, co
product->r2c3 = multiplicand->r2c3 * multiplier; product->r2c3 = multiplicand->r2c3 * multiplier;
} }
inline void bgc_matrix3x2_multiply_fp64(const BgcMatrix3x2FP64* multiplicand, const double multiplier, BgcMatrix3x2FP64* product) inline void bgc_fp64_matrix3x2_multiply(const BGC_FP64_Matrix3x2* multiplicand, const double multiplier, BGC_FP64_Matrix3x2* product)
{ {
product->r1c1 = multiplicand->r1c1 * multiplier; product->r1c1 = multiplicand->r1c1 * multiplier;
product->r1c2 = multiplicand->r1c2 * multiplier; product->r1c2 = multiplicand->r1c2 * multiplier;
@ -353,44 +445,72 @@ inline void bgc_matrix3x2_multiply_fp64(const BgcMatrix3x2FP64* multiplicand, co
// =================== Divide =================== // // =================== Divide =================== //
inline void bgc_matrix3x2_divide_fp32(const BgcMatrix3x2FP32* dividend, const float divisor, BgcMatrix3x2FP32* quotient) inline void bgc_fp32_matrix3x2_divide(const BGC_FP32_Matrix3x2* dividend, const float divisor, BGC_FP32_Matrix3x2* quotient)
{ {
bgc_matrix3x2_multiply_fp32(dividend, 1.0f / divisor, quotient); bgc_fp32_matrix3x2_multiply(dividend, 1.0f / divisor, quotient);
} }
inline void bgc_matrix3x2_divide_fp64(const BgcMatrix3x2FP64* dividend, const double divisor, BgcMatrix3x2FP64* quotient) inline void bgc_fp64_matrix3x2_divide(const BGC_FP64_Matrix3x2* dividend, const double divisor, BGC_FP64_Matrix3x2* quotient)
{ {
bgc_matrix3x2_multiply_fp64(dividend, 1.0 / divisor, quotient); bgc_fp64_matrix3x2_multiply(dividend, 1.0 / divisor, quotient);
}
// ================ Interpolate ================= //
inline void bgc_fp32_matrix3x2_interpolate(const BGC_FP32_Matrix3x2* first, const BGC_FP32_Matrix3x2* second, const float phase, BGC_FP32_Matrix3x2* interpolation)
{
const float couter_phase = 1.0f - phase;
interpolation->r1c1 = first->r1c1 * couter_phase + second->r1c1 * phase;
interpolation->r1c2 = first->r1c2 * couter_phase + second->r1c2 * phase;
interpolation->r1c3 = first->r1c3 * couter_phase + second->r1c3 * phase;
interpolation->r2c1 = first->r2c1 * couter_phase + second->r2c1 * phase;
interpolation->r2c2 = first->r2c2 * couter_phase + second->r2c2 * phase;
interpolation->r2c3 = first->r2c3 * couter_phase + second->r2c3 * phase;
}
inline void bgc_fp64_matrix3x2_interpolate(const BGC_FP64_Matrix3x2* first, const BGC_FP64_Matrix3x2* second, const double phase, BGC_FP64_Matrix3x2* interpolation)
{
const double couter_phase = 1.0 - phase;
interpolation->r1c1 = first->r1c1 * couter_phase + second->r1c1 * phase;
interpolation->r1c2 = first->r1c2 * couter_phase + second->r1c2 * phase;
interpolation->r1c3 = first->r1c3 * couter_phase + second->r1c3 * phase;
interpolation->r2c1 = first->r2c1 * couter_phase + second->r2c1 * phase;
interpolation->r2c2 = first->r2c2 * couter_phase + second->r2c2 * phase;
interpolation->r2c3 = first->r2c3 * couter_phase + second->r2c3 * phase;
} }
// ============ Left Vector Product ============= // // ============ Left Vector Product ============= //
inline void bgc_matrix3x2_get_left_product_fp32(const BgcVector2FP32* vector, const BgcMatrix3x2FP32* matrix, BgcVector3FP32* result) inline void bgc_fp32_multiply_vector2_by_matrix3x2(const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix3x2* matrix, BGC_FP32_Vector3* product)
{ {
result->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1; product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
result->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2; product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
result->x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3; product->x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3;
} }
inline void bgc_matrix3x2_get_left_product_fp64(const BgcVector2FP64* vector, const BgcMatrix3x2FP64* matrix, BgcVector3FP64* result) inline void bgc_fp64_multiply_vector2_by_matrix3x2(const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix3x2* matrix, BGC_FP64_Vector3* product)
{ {
result->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1; product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1;
result->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2; product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2;
result->x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3; product->x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3;
} }
// ============ Right Vector Product ============ // // ============ Right Vector Product ============ //
inline void bgc_matrix3x2_get_right_product_fp32(const BgcMatrix3x2FP32* matrix, const BgcVector3FP32* vector, BgcVector2FP32* result) inline void bgc_fp32_multiply_matrix3x2_by_vector3(const BGC_FP32_Matrix3x2* matrix, const BGC_FP32_Vector3* vector, BGC_FP32_Vector2* product)
{ {
result->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3; product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
result->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3; product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
} }
inline void bgc_matrix3x2_get_right_product_fp64(const BgcMatrix3x2FP64* matrix, const BgcVector3FP64* vector, BgcVector2FP64* result) inline void bgc_fp64_multiply_matrix3x2_by_vector3(const BGC_FP64_Matrix3x2* matrix, const BGC_FP64_Vector3* vector, BGC_FP64_Vector2* product)
{ {
result->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3; product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
result->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3; product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
} }
#endif #endif

View file

@ -1,84 +1,87 @@
#include "matrix3x3.h" #include "matrix3x3.h"
extern inline void bgc_matrix3x3_reset_fp32(BgcMatrix3x3FP32* matrix); extern inline void bgc_fp32_matrix3x3_reset(BGC_FP32_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_reset_fp64(BgcMatrix3x3FP64* matrix); extern inline void bgc_fp64_matrix3x3_reset(BGC_FP64_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_set_to_identity_fp32(BgcMatrix3x3FP32* matrix); extern inline void bgc_fp32_matrix3x3_make_identity(BGC_FP32_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_set_to_identity_fp64(BgcMatrix3x3FP64* matrix); extern inline void bgc_fp64_matrix3x3_make_identity(BGC_FP64_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_set_to_diagonal_fp32(const float d1, const float d2, const float d3, BgcMatrix3x3FP32* matrix); extern inline void bgc_fp32_matrix3x3_make_diagonal(const float d1, const float d2, const float d3, BGC_FP32_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_set_to_diagonal_fp64(const double d1, const double d2, const double d3, BgcMatrix3x3FP64* matrix); extern inline void bgc_fp64_matrix3x3_make_diagonal(const double d1, const double d2, const double d3, BGC_FP64_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_copy_fp32(const BgcMatrix3x3FP32* source, BgcMatrix3x3FP32* destination); extern inline void bgc_fp32_matrix3x3_copy(const BGC_FP32_Matrix3x3* source, BGC_FP32_Matrix3x3* destination);
extern inline void bgc_matrix3x3_copy_fp64(const BgcMatrix3x3FP64* source, BgcMatrix3x3FP64* destination); extern inline void bgc_fp64_matrix3x3_copy(const BGC_FP64_Matrix3x3* source, BGC_FP64_Matrix3x3* destination);
extern inline void bgc_matrix3x3_swap_fp32(BgcMatrix3x3FP32* matrix1, BgcMatrix3x3FP32* matrix2); extern inline void bgc_fp32_matrix3x3_swap(BGC_FP32_Matrix3x3* matrix1, BGC_FP32_Matrix3x3* matrix2);
extern inline void bgc_matrix3x3_swap_fp64(BgcMatrix3x3FP64* matrix1, BgcMatrix3x3FP64* matrix2); extern inline void bgc_fp64_matrix3x3_swap(BGC_FP64_Matrix3x3* matrix1, BGC_FP64_Matrix3x3* matrix2);
extern inline void bgc_matrix3x3_convert_fp64_to_fp32(const BgcMatrix3x3FP64* source, BgcMatrix3x3FP32* destination); extern inline void bgc_fp64_matrix3x3_convert_to_fp32(const BGC_FP64_Matrix3x3* source, BGC_FP32_Matrix3x3* destination);
extern inline void bgc_matrix3x3_convert_fp32_to_fp64(const BgcMatrix3x3FP32* source, BgcMatrix3x3FP64* destination); extern inline void bgc_fp32_matrix3x3_convert_to_fp64(const BGC_FP32_Matrix3x3* source, BGC_FP64_Matrix3x3* destination);
extern inline float bgc_matrix3x3_get_determinant_fp32(const BgcMatrix3x3FP32* matrix); extern inline float bgc_fp32_matrix3x3_get_determinant(const BGC_FP32_Matrix3x3* matrix);
extern inline double bgc_matrix3x3_get_determinant_fp64(const BgcMatrix3x3FP64* matrix); extern inline double bgc_fp64_matrix3x3_get_determinant(const BGC_FP64_Matrix3x3* matrix);
extern inline int bgc_matrix3x3_is_singular_fp32(const BgcMatrix3x3FP32* matrix); extern inline int bgc_fp32_matrix3x3_is_identity(const BGC_FP32_Matrix3x3* matrix);
extern inline int bgc_matrix3x3_is_singular_fp64(const BgcMatrix3x3FP64* matrix); extern inline int bgc_fp64_matrix3x3_is_identity(const BGC_FP64_Matrix3x3* matrix);
extern inline int bgc_matrix3x3_is_rotation_fp32(const BgcMatrix3x3FP32* matrix); extern inline int bgc_fp32_matrix3x3_is_singular(const BGC_FP32_Matrix3x3* matrix);
extern inline int bgc_matrix3x3_is_rotation_fp64(const BgcMatrix3x3FP64* matrix); extern inline int bgc_fp64_matrix3x3_is_singular(const BGC_FP64_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_transpose_fp32(const BgcMatrix3x3FP32* matrix, BgcMatrix3x3FP32* transposed); extern inline int bgc_fp32_matrix3x3_is_rotation(const BGC_FP32_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_transpose_fp64(const BgcMatrix3x3FP64* matrix, BgcMatrix3x3FP64* transposed); extern inline int bgc_fp64_matrix3x3_is_rotation(const BGC_FP64_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_set_row1_fp32(const float c1, const float c2, const float c3, BgcMatrix3x3FP32* matrix); extern inline int bgc_fp32_matrix3x3_invert(BGC_FP32_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_set_row1_fp64(const double c1, const double c2, const double c3, BgcMatrix3x3FP64* matrix); extern inline int bgc_fp64_matrix3x3_invert(BGC_FP64_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_set_row2_fp32(const float c1, const float c2, const float c3, BgcMatrix3x3FP32* matrix); extern inline void bgc_fp32_matrix3x3_transpose(BGC_FP32_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_set_row2_fp64(const double c1, const double c2, const double c3, BgcMatrix3x3FP64* matrix); extern inline void bgc_fp64_matrix3x3_transpose(BGC_FP64_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_set_row3_fp32(const float c1, const float c2, const float c3, BgcMatrix3x3FP32* matrix); extern inline void bgc_fp32_matrix3x3_get_transposed(const BGC_FP32_Matrix3x3* matrix, BGC_FP32_Matrix3x3* transposed);
extern inline void bgc_matrix3x3_set_row3_fp64(const double c1, const double c2, const double c3, BgcMatrix3x3FP64* matrix); extern inline void bgc_fp64_matrix3x3_get_transposed(const BGC_FP64_Matrix3x3* matrix, BGC_FP64_Matrix3x3* transposed);
extern inline void bgc_matrix3x3_set_column1_fp32(const float r1, const float r2, const float r3, BgcMatrix3x3FP32* matrix); extern inline void bgc_fp32_matrix3x3_get_row(const int number, const BGC_FP32_Matrix3x3* matrix, BGC_FP32_Vector3* row);
extern inline void bgc_matrix3x3_set_column1_fp64(const double r1, const double r2, const double r3, BgcMatrix3x3FP64* matrix); extern inline void bgc_fp64_matrix3x3_get_row(const int number, const BGC_FP64_Matrix3x3* matrix, BGC_FP64_Vector3* row);
extern inline void bgc_matrix3x3_set_column2_fp32(const float r1, const float r2, const float r3, BgcMatrix3x3FP32* matrix); extern inline void bgc_fp32_matrix3x3_set_row(const int number, const BGC_FP32_Vector3* row, BGC_FP32_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_set_column2_fp64(const double r1, const double r2, const double r3, BgcMatrix3x3FP64* matrix); extern inline void bgc_fp64_matrix3x3_set_row(const int number, const BGC_FP64_Vector3* row, BGC_FP64_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_set_column3_fp32(const float r1, const float r2, const float r3, BgcMatrix3x3FP32* matrix); extern inline void bgc_fp32_matrix3x3_get_column(const int number, const BGC_FP32_Matrix3x3* matrix, BGC_FP32_Vector3* column);
extern inline void bgc_matrix3x3_set_column3_fp64(const double r1, const double r2, const double r3, BgcMatrix3x3FP64* matrix); extern inline void bgc_fp64_matrix3x3_get_column(const int number, const BGC_FP64_Matrix3x3* matrix, BGC_FP64_Vector3* column);
extern inline void bgc_matrix3x3_add_fp32(const BgcMatrix3x3FP32* matrix1, const BgcMatrix3x3FP32* matrix2, BgcMatrix3x3FP32* sum); extern inline void bgc_fp32_matrix3x3_set_column(const int number, const BGC_FP32_Vector3* column, BGC_FP32_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_add_fp64(const BgcMatrix3x3FP64* matrix1, const BgcMatrix3x3FP64* matrix2, BgcMatrix3x3FP64* sum); extern inline void bgc_fp64_matrix3x3_set_column(const int number, const BGC_FP64_Vector3* column, BGC_FP64_Matrix3x3* matrix);
extern inline void bgc_matrix3x3_add_scaled_fp32(const BgcMatrix3x3FP32* basic_matrix, const BgcMatrix3x3FP32* scalable_matrix, const float scale, BgcMatrix3x3FP32* sum); extern inline void bgc_fp32_matrix3x3_add(const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2, BGC_FP32_Matrix3x3* sum);
extern inline void bgc_matrix3x3_add_scaled_fp64(const BgcMatrix3x3FP64* basic_matrix, const BgcMatrix3x3FP64* scalable_matrix, const double scale, BgcMatrix3x3FP64* sum); extern inline void bgc_fp64_matrix3x3_add(const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2, BGC_FP64_Matrix3x3* sum);
extern inline void bgc_matrix3x3_subtract_fp32(const BgcMatrix3x3FP32* minuend, const BgcMatrix3x3FP32* subtrahend, BgcMatrix3x3FP32* difference); extern inline void bgc_fp32_matrix3x3_add_scaled(const BGC_FP32_Matrix3x3* basic_matrix, const BGC_FP32_Matrix3x3* scalable_matrix, const float scale, BGC_FP32_Matrix3x3* sum);
extern inline void bgc_matrix3x3_subtract_fp64(const BgcMatrix3x3FP64* minuend, const BgcMatrix3x3FP64* subtrahend, BgcMatrix3x3FP64* difference); extern inline void bgc_fp64_matrix3x3_add_scaled(const BGC_FP64_Matrix3x3* basic_matrix, const BGC_FP64_Matrix3x3* scalable_matrix, const double scale, BGC_FP64_Matrix3x3* sum);
extern inline void bgc_matrix3x3_subtract_scaled_fp32(const BgcMatrix3x3FP32* basic_matrix, const BgcMatrix3x3FP32* scalable_matrix, const float scale, BgcMatrix3x3FP32* difference); extern inline void bgc_fp32_matrix3x3_subtract(const BGC_FP32_Matrix3x3* minuend, const BGC_FP32_Matrix3x3* subtrahend, BGC_FP32_Matrix3x3* difference);
extern inline void bgc_matrix3x3_subtract_scaled_fp64(const BgcMatrix3x3FP64* basic_matrix, const BgcMatrix3x3FP64* scalable_matrix, const double scale, BgcMatrix3x3FP64* difference); extern inline void bgc_fp64_matrix3x3_subtract(const BGC_FP64_Matrix3x3* minuend, const BGC_FP64_Matrix3x3* subtrahend, BGC_FP64_Matrix3x3* difference);
extern inline void bgc_matrix3x3_multiply_fp32(const BgcMatrix3x3FP32* multiplicand, const float multiplier, BgcMatrix3x3FP32* product); extern inline void bgc_fp32_matrix3x3_multiply(const BGC_FP32_Matrix3x3* multiplicand, const float multiplier, BGC_FP32_Matrix3x3* product);
extern inline void bgc_matrix3x3_multiply_fp64(const BgcMatrix3x3FP64* multiplicand, const double multiplier, BgcMatrix3x3FP64* product); extern inline void bgc_fp64_matrix3x3_multiply(const BGC_FP64_Matrix3x3* multiplicand, const double multiplier, BGC_FP64_Matrix3x3* product);
extern inline void bgc_matrix3x3_divide_fp32(const BgcMatrix3x3FP32* dividend, const float divisor, BgcMatrix3x3FP32* quotient); extern inline void bgc_fp32_matrix3x3_divide(const BGC_FP32_Matrix3x3* dividend, const float divisor, BGC_FP32_Matrix3x3* quotient);
extern inline void bgc_matrix3x3_divide_fp64(const BgcMatrix3x3FP64* dividend, const double divisor, BgcMatrix3x3FP64* quotient); extern inline void bgc_fp64_matrix3x3_divide(const BGC_FP64_Matrix3x3* dividend, const double divisor, BGC_FP64_Matrix3x3* quotient);
extern inline void bgc_matrix3x3_get_left_product_fp32(const BgcVector3FP32* vector, const BgcMatrix3x3FP32* matrix, BgcVector3FP32* result); extern inline void bgc_fp32_matrix3x3_interpolate(const BGC_FP32_Matrix3x3* first, const BGC_FP32_Matrix3x3* second, const float phase, BGC_FP32_Matrix3x3* interpolation);
extern inline void bgc_matrix3x3_get_left_product_fp64(const BgcVector3FP64* vector, const BgcMatrix3x3FP64* matrix, BgcVector3FP64* result); extern inline void bgc_fp64_matrix3x3_interpolate(const BGC_FP64_Matrix3x3* first, const BGC_FP64_Matrix3x3* second, const double phase, BGC_FP64_Matrix3x3* interpolation);
extern inline void bgc_matrix3x3_get_right_product_fp32(const BgcMatrix3x3FP32* matrix, const BgcVector3FP32* vector, BgcVector3FP32* result); extern inline void bgc_fp32_multiply_vector3_by_matrix3x3(const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix3x3* matrix, BGC_FP32_Vector3* result);
extern inline void bgc_matrix3x3_get_right_product_fp64(const BgcMatrix3x3FP64* matrix, const BgcVector3FP64* vector, BgcVector3FP64* result); extern inline void bgc_fp64_multiply_vector3_by_matrix3x3(const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix3x3* matrix, BGC_FP64_Vector3* result);
// =================== Invert =================== // extern inline void bgc_fp32_multiply_matrix3x3_by_vector3(const BGC_FP32_Matrix3x3* matrix, const BGC_FP32_Vector3* vector, BGC_FP32_Vector3* result);
extern inline void bgc_fp64_multiply_matrix3x3_by_vector3(const BGC_FP64_Matrix3x3* matrix, const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* result);
int bgc_matrix3x3_invert_fp32(const BgcMatrix3x3FP32* matrix, BgcMatrix3x3FP32* inverted) // ================ Get Inverse ================= //
int bgc_fp32_matrix3x3_get_inverse(const BGC_FP32_Matrix3x3* matrix, BGC_FP32_Matrix3x3* inverse)
{ {
const float determinant = bgc_matrix3x3_get_determinant_fp32(matrix); const float determinant = bgc_fp32_matrix3x3_get_determinant(matrix);
if (bgc_is_zero_fp32(determinant)) { if (bgc_fp32_is_zero(determinant)) {
return 0; return 0;
} }
@ -96,26 +99,26 @@ int bgc_matrix3x3_invert_fp32(const BgcMatrix3x3FP32* matrix, BgcMatrix3x3FP32*
const float multiplier = 1.0f / determinant; const float multiplier = 1.0f / determinant;
inverted->r1c1 = r1c1 * multiplier; inverse->r1c1 = r1c1 * multiplier;
inverted->r1c2 = r1c2 * multiplier; inverse->r1c2 = r1c2 * multiplier;
inverted->r1c3 = r1c3 * multiplier; inverse->r1c3 = r1c3 * multiplier;
inverted->r2c1 = r2c1 * multiplier; inverse->r2c1 = r2c1 * multiplier;
inverted->r2c2 = r2c2 * multiplier; inverse->r2c2 = r2c2 * multiplier;
inverted->r2c3 = r2c3 * multiplier; inverse->r2c3 = r2c3 * multiplier;
inverted->r3c1 = r3c1 * multiplier; inverse->r3c1 = r3c1 * multiplier;
inverted->r3c2 = r3c2 * multiplier; inverse->r3c2 = r3c2 * multiplier;
inverted->r3c3 = r3c3 * multiplier; inverse->r3c3 = r3c3 * multiplier;
return 1; return 1;
} }
int bgc_matrix3x3_invert_fp64(const BgcMatrix3x3FP64* matrix, BgcMatrix3x3FP64* inverted) int bgc_fp64_matrix3x3_get_inverse(const BGC_FP64_Matrix3x3* matrix, BGC_FP64_Matrix3x3* inverse)
{ {
const double determinant = bgc_matrix3x3_get_determinant_fp64(matrix); const double determinant = bgc_fp64_matrix3x3_get_determinant(matrix);
if (bgc_is_zero_fp64(determinant)) { if (bgc_fp64_is_zero(determinant)) {
return 0; return 0;
} }
@ -133,17 +136,17 @@ int bgc_matrix3x3_invert_fp64(const BgcMatrix3x3FP64* matrix, BgcMatrix3x3FP64*
const double multiplier = 1.0 / determinant; const double multiplier = 1.0 / determinant;
inverted->r1c1 = r1c1 * multiplier; inverse->r1c1 = r1c1 * multiplier;
inverted->r1c2 = r1c2 * multiplier; inverse->r1c2 = r1c2 * multiplier;
inverted->r1c3 = r1c3 * multiplier; inverse->r1c3 = r1c3 * multiplier;
inverted->r2c1 = r2c1 * multiplier; inverse->r2c1 = r2c1 * multiplier;
inverted->r2c2 = r2c2 * multiplier; inverse->r2c2 = r2c2 * multiplier;
inverted->r2c3 = r2c3 * multiplier; inverse->r2c3 = r2c3 * multiplier;
inverted->r3c1 = r3c1 * multiplier; inverse->r3c1 = r3c1 * multiplier;
inverted->r3c2 = r3c2 * multiplier; inverse->r3c2 = r3c2 * multiplier;
inverted->r3c3 = r3c3 * multiplier; inverse->r3c3 = r3c3 * multiplier;
return 1; return 1;
} }

View file

@ -6,7 +6,7 @@
// =================== Reset ==================== // // =================== Reset ==================== //
inline void bgc_matrix3x3_reset_fp32(BgcMatrix3x3FP32* matrix) inline void bgc_fp32_matrix3x3_reset(BGC_FP32_Matrix3x3* matrix)
{ {
matrix->r1c1 = 0.0f; matrix->r1c1 = 0.0f;
matrix->r1c2 = 0.0f; matrix->r1c2 = 0.0f;
@ -21,7 +21,7 @@ inline void bgc_matrix3x3_reset_fp32(BgcMatrix3x3FP32* matrix)
matrix->r3c3 = 0.0f; matrix->r3c3 = 0.0f;
} }
inline void bgc_matrix3x3_reset_fp64(BgcMatrix3x3FP64* matrix) inline void bgc_fp64_matrix3x3_reset(BGC_FP64_Matrix3x3* matrix)
{ {
matrix->r1c1 = 0.0; matrix->r1c1 = 0.0;
matrix->r1c2 = 0.0; matrix->r1c2 = 0.0;
@ -38,7 +38,7 @@ inline void bgc_matrix3x3_reset_fp64(BgcMatrix3x3FP64* matrix)
// ================== Identity ================== // // ================== Identity ================== //
inline void bgc_matrix3x3_set_to_identity_fp32(BgcMatrix3x3FP32* matrix) inline void bgc_fp32_matrix3x3_make_identity(BGC_FP32_Matrix3x3* matrix)
{ {
matrix->r1c1 = 1.0f; matrix->r1c1 = 1.0f;
matrix->r1c2 = 0.0f; matrix->r1c2 = 0.0f;
@ -53,7 +53,7 @@ inline void bgc_matrix3x3_set_to_identity_fp32(BgcMatrix3x3FP32* matrix)
matrix->r3c3 = 1.0f; matrix->r3c3 = 1.0f;
} }
inline void bgc_matrix3x3_set_to_identity_fp64(BgcMatrix3x3FP64* matrix) inline void bgc_fp64_matrix3x3_make_identity(BGC_FP64_Matrix3x3* matrix)
{ {
matrix->r1c1 = 1.0; matrix->r1c1 = 1.0;
matrix->r1c2 = 0.0; matrix->r1c2 = 0.0;
@ -70,7 +70,7 @@ inline void bgc_matrix3x3_set_to_identity_fp64(BgcMatrix3x3FP64* matrix)
// ================ Set Diagonal ================ // // ================ Set Diagonal ================ //
inline void bgc_matrix3x3_set_to_diagonal_fp32(const float d1, const float d2, const float d3, BgcMatrix3x3FP32* matrix) inline void bgc_fp32_matrix3x3_make_diagonal(const float d1, const float d2, const float d3, BGC_FP32_Matrix3x3* matrix)
{ {
matrix->r1c1 = d1; matrix->r1c1 = d1;
matrix->r1c2 = 0.0f; matrix->r1c2 = 0.0f;
@ -85,7 +85,7 @@ inline void bgc_matrix3x3_set_to_diagonal_fp32(const float d1, const float d2, c
matrix->r3c3 = d2; matrix->r3c3 = d2;
} }
inline void bgc_matrix3x3_set_to_diagonal_fp64(const double d1, const double d2, const double d3, BgcMatrix3x3FP64* matrix) inline void bgc_fp64_matrix3x3_make_diagonal(const double d1, const double d2, const double d3, BGC_FP64_Matrix3x3* matrix)
{ {
matrix->r1c1 = d1; matrix->r1c1 = d1;
matrix->r1c2 = 0.0; matrix->r1c2 = 0.0;
@ -102,7 +102,7 @@ inline void bgc_matrix3x3_set_to_diagonal_fp64(const double d1, const double d2,
// ==================== Copy ==================== // // ==================== Copy ==================== //
inline void bgc_matrix3x3_copy_fp32(const BgcMatrix3x3FP32* source, BgcMatrix3x3FP32* destination) inline void bgc_fp32_matrix3x3_copy(const BGC_FP32_Matrix3x3* source, BGC_FP32_Matrix3x3* destination)
{ {
destination->r1c1 = source->r1c1; destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2; destination->r1c2 = source->r1c2;
@ -117,7 +117,7 @@ inline void bgc_matrix3x3_copy_fp32(const BgcMatrix3x3FP32* source, BgcMatrix3x3
destination->r3c3 = source->r3c3; destination->r3c3 = source->r3c3;
} }
inline void bgc_matrix3x3_copy_fp64(const BgcMatrix3x3FP64* source, BgcMatrix3x3FP64* destination) inline void bgc_fp64_matrix3x3_copy(const BGC_FP64_Matrix3x3* source, BGC_FP64_Matrix3x3* destination)
{ {
destination->r1c1 = source->r1c1; destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2; destination->r1c2 = source->r1c2;
@ -134,7 +134,7 @@ inline void bgc_matrix3x3_copy_fp64(const BgcMatrix3x3FP64* source, BgcMatrix3x3
// ==================== Swap ==================== // // ==================== Swap ==================== //
inline void bgc_matrix3x3_swap_fp32(BgcMatrix3x3FP32* matrix1, BgcMatrix3x3FP32* matrix2) inline void bgc_fp32_matrix3x3_swap(BGC_FP32_Matrix3x3* matrix1, BGC_FP32_Matrix3x3* matrix2)
{ {
const float r1c1 = matrix2->r1c1; const float r1c1 = matrix2->r1c1;
const float r1c2 = matrix2->r1c2; const float r1c2 = matrix2->r1c2;
@ -173,7 +173,7 @@ inline void bgc_matrix3x3_swap_fp32(BgcMatrix3x3FP32* matrix1, BgcMatrix3x3FP32*
matrix1->r3c3 = r3c3; matrix1->r3c3 = r3c3;
} }
inline void bgc_matrix3x3_swap_fp64(BgcMatrix3x3FP64* matrix1, BgcMatrix3x3FP64* matrix2) inline void bgc_fp64_matrix3x3_swap(BGC_FP64_Matrix3x3* matrix1, BGC_FP64_Matrix3x3* matrix2)
{ {
const double r1c1 = matrix2->r1c1; const double r1c1 = matrix2->r1c1;
const double r1c2 = matrix2->r1c2; const double r1c2 = matrix2->r1c2;
@ -214,7 +214,7 @@ inline void bgc_matrix3x3_swap_fp64(BgcMatrix3x3FP64* matrix1, BgcMatrix3x3FP64*
// ================== Convert =================== // // ================== Convert =================== //
inline void bgc_matrix3x3_convert_fp64_to_fp32(const BgcMatrix3x3FP64* source, BgcMatrix3x3FP32* destination) inline void bgc_fp64_matrix3x3_convert_to_fp32(const BGC_FP64_Matrix3x3* source, BGC_FP32_Matrix3x3* destination)
{ {
destination->r1c1 = (float)source->r1c1; destination->r1c1 = (float)source->r1c1;
destination->r1c2 = (float)source->r1c2; destination->r1c2 = (float)source->r1c2;
@ -229,7 +229,7 @@ inline void bgc_matrix3x3_convert_fp64_to_fp32(const BgcMatrix3x3FP64* source, B
destination->r3c3 = (float)source->r3c3; destination->r3c3 = (float)source->r3c3;
} }
inline void bgc_matrix3x3_convert_fp32_to_fp64(const BgcMatrix3x3FP32* source, BgcMatrix3x3FP64* destination) inline void bgc_fp32_matrix3x3_convert_to_fp64(const BGC_FP32_Matrix3x3* source, BGC_FP64_Matrix3x3* destination)
{ {
destination->r1c1 = source->r1c1; destination->r1c1 = source->r1c1;
destination->r1c2 = source->r1c2; destination->r1c2 = source->r1c2;
@ -246,89 +246,141 @@ inline void bgc_matrix3x3_convert_fp32_to_fp64(const BgcMatrix3x3FP32* source, B
// ================ Determinant ================= // // ================ Determinant ================= //
inline float bgc_matrix3x3_get_determinant_fp32(const BgcMatrix3x3FP32* matrix) inline float bgc_fp32_matrix3x3_get_determinant(const BGC_FP32_Matrix3x3* matrix)
{ {
return matrix->r1c1 * (matrix->r2c2 * matrix->r3c3 - matrix->r2c3 * matrix->r3c2) return matrix->r1c1 * (matrix->r2c2 * matrix->r3c3 - matrix->r2c3 * matrix->r3c2)
+ matrix->r1c2 * (matrix->r2c3 * matrix->r3c1 - matrix->r2c1 * matrix->r3c3) + matrix->r1c2 * (matrix->r2c3 * matrix->r3c1 - matrix->r2c1 * matrix->r3c3)
+ matrix->r1c3 * (matrix->r2c1 * matrix->r3c2 - matrix->r2c2 * matrix->r3c1); + matrix->r1c3 * (matrix->r2c1 * matrix->r3c2 - matrix->r2c2 * matrix->r3c1);
} }
inline double bgc_matrix3x3_get_determinant_fp64(const BgcMatrix3x3FP64* matrix) inline double bgc_fp64_matrix3x3_get_determinant(const BGC_FP64_Matrix3x3* matrix)
{ {
return matrix->r1c1 * (matrix->r2c2 * matrix->r3c3 - matrix->r2c3 * matrix->r3c2) return matrix->r1c1 * (matrix->r2c2 * matrix->r3c3 - matrix->r2c3 * matrix->r3c2)
+ matrix->r1c2 * (matrix->r2c3 * matrix->r3c1 - matrix->r2c1 * matrix->r3c3) + matrix->r1c2 * (matrix->r2c3 * matrix->r3c1 - matrix->r2c1 * matrix->r3c3)
+ matrix->r1c3 * (matrix->r2c1 * matrix->r3c2 - matrix->r2c2 * matrix->r3c1); + matrix->r1c3 * (matrix->r2c1 * matrix->r3c2 - matrix->r2c2 * matrix->r3c1);
} }
// ================== Singular ================== // // ================ Is Identity ================= //
inline int bgc_matrix3x3_is_singular_fp32(const BgcMatrix3x3FP32* matrix) inline int bgc_fp32_matrix3x3_is_identity(const BGC_FP32_Matrix3x3* matrix)
{ {
return bgc_is_zero_fp32(bgc_matrix3x3_get_determinant_fp32(matrix)); return bgc_fp32_is_unit(matrix->r1c1) && bgc_fp32_is_zero(matrix->r1c2) && bgc_fp32_is_zero(matrix->r1c3)
&& bgc_fp32_is_zero(matrix->r2c1) && bgc_fp32_is_unit(matrix->r2c2) && bgc_fp32_is_zero(matrix->r2c3)
&& bgc_fp32_is_zero(matrix->r3c1) && bgc_fp32_is_zero(matrix->r3c2) && bgc_fp32_is_unit(matrix->r3c3);
} }
inline int bgc_matrix3x3_is_singular_fp64(const BgcMatrix3x3FP64* matrix) inline int bgc_fp64_matrix3x3_is_identity(const BGC_FP64_Matrix3x3* matrix)
{ {
return bgc_is_zero_fp64(bgc_matrix3x3_get_determinant_fp64(matrix)); return bgc_fp64_is_unit(matrix->r1c1) && bgc_fp64_is_zero(matrix->r1c2) && bgc_fp64_is_zero(matrix->r1c3)
&& bgc_fp64_is_zero(matrix->r2c1) && bgc_fp64_is_unit(matrix->r2c2) && bgc_fp64_is_zero(matrix->r2c3)
&& bgc_fp64_is_zero(matrix->r3c1) && bgc_fp64_is_zero(matrix->r3c2) && bgc_fp64_is_unit(matrix->r3c3);
}
// ================ Is Singular ================= //
inline int bgc_fp32_matrix3x3_is_singular(const BGC_FP32_Matrix3x3* matrix)
{
return bgc_fp32_is_zero(bgc_fp32_matrix3x3_get_determinant(matrix));
}
inline int bgc_fp64_matrix3x3_is_singular(const BGC_FP64_Matrix3x3* matrix)
{
return bgc_fp64_is_zero(bgc_fp64_matrix3x3_get_determinant(matrix));
} }
// ================ Is Rotation ================= // // ================ Is Rotation ================= //
inline int bgc_matrix3x3_is_rotation_fp32(const BgcMatrix3x3FP32* matrix) inline int bgc_fp32_matrix3x3_is_rotation(const BGC_FP32_Matrix3x3* matrix)
{ {
if (!bgc_is_unit_fp32(bgc_matrix3x3_get_determinant_fp32(matrix))) { BGC_FP32_Matrix3x3 product;
return 0;
}
const float product_r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1 + matrix->r1c3 * matrix->r3c1; product.r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1 + matrix->r1c3 * matrix->r3c1;
const float product_r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2 + matrix->r1c3 * matrix->r3c2; product.r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2 + matrix->r1c3 * matrix->r3c2;
const float product_r1c3 = matrix->r1c1 * matrix->r1c3 + matrix->r1c2 * matrix->r2c3 + matrix->r1c3 * matrix->r3c3; product.r1c3 = matrix->r1c1 * matrix->r1c3 + matrix->r1c2 * matrix->r2c3 + matrix->r1c3 * matrix->r3c3;
const float product_r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1 + matrix->r2c3 * matrix->r3c1; product.r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1 + matrix->r2c3 * matrix->r3c1;
const float product_r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2 + matrix->r2c3 * matrix->r3c2; product.r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2 + matrix->r2c3 * matrix->r3c2;
const float product_r2c3 = matrix->r2c1 * matrix->r1c3 + matrix->r2c2 * matrix->r2c3 + matrix->r2c3 * matrix->r3c3; product.r2c3 = matrix->r2c1 * matrix->r1c3 + matrix->r2c2 * matrix->r2c3 + matrix->r2c3 * matrix->r3c3;
const float product_r3c1 = matrix->r3c1 * matrix->r1c1 + matrix->r3c2 * matrix->r2c1 + matrix->r3c3 * matrix->r3c1; product.r3c1 = matrix->r3c1 * matrix->r1c1 + matrix->r3c2 * matrix->r2c1 + matrix->r3c3 * matrix->r3c1;
const float product_r3c2 = matrix->r3c1 * matrix->r1c2 + matrix->r3c2 * matrix->r2c2 + matrix->r3c3 * matrix->r3c2; product.r3c2 = matrix->r3c1 * matrix->r1c2 + matrix->r3c2 * matrix->r2c2 + matrix->r3c3 * matrix->r3c2;
const float product_r3c3 = matrix->r3c1 * matrix->r1c3 + matrix->r3c2 * matrix->r2c3 + matrix->r3c3 * matrix->r3c3; product.r3c3 = matrix->r3c1 * matrix->r1c3 + matrix->r3c2 * matrix->r2c3 + matrix->r3c3 * matrix->r3c3;
return bgc_is_unit_fp32(product_r1c1) && bgc_is_zero_fp32(product_r1c2) && bgc_is_zero_fp32(product_r1c3) return bgc_fp32_matrix3x3_is_identity(&product);
&& bgc_is_zero_fp32(product_r2c1) && bgc_is_unit_fp32(product_r2c2) && bgc_is_zero_fp32(product_r2c3)
&& bgc_is_zero_fp32(product_r3c1) && bgc_is_zero_fp32(product_r3c2) && bgc_is_unit_fp32(product_r3c3);
} }
inline int bgc_matrix3x3_is_rotation_fp64(const BgcMatrix3x3FP64* matrix) inline int bgc_fp64_matrix3x3_is_rotation(const BGC_FP64_Matrix3x3* matrix)
{ {
if (!bgc_is_unit_fp64(bgc_matrix3x3_get_determinant_fp64(matrix))) { BGC_FP64_Matrix3x3 product;
return 0;
}
const double product_r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1 + matrix->r1c3 * matrix->r3c1; product.r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1 + matrix->r1c3 * matrix->r3c1;
const double product_r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2 + matrix->r1c3 * matrix->r3c2; product.r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2 + matrix->r1c3 * matrix->r3c2;
const double product_r1c3 = matrix->r1c1 * matrix->r1c3 + matrix->r1c2 * matrix->r2c3 + matrix->r1c3 * matrix->r3c3; product.r1c3 = matrix->r1c1 * matrix->r1c3 + matrix->r1c2 * matrix->r2c3 + matrix->r1c3 * matrix->r3c3;
const double product_r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1 + matrix->r2c3 * matrix->r3c1; product.r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1 + matrix->r2c3 * matrix->r3c1;
const double product_r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2 + matrix->r2c3 * matrix->r3c2; product.r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2 + matrix->r2c3 * matrix->r3c2;
const double product_r2c3 = matrix->r2c1 * matrix->r1c3 + matrix->r2c2 * matrix->r2c3 + matrix->r2c3 * matrix->r3c3; product.r2c3 = matrix->r2c1 * matrix->r1c3 + matrix->r2c2 * matrix->r2c3 + matrix->r2c3 * matrix->r3c3;
const double product_r3c1 = matrix->r3c1 * matrix->r1c1 + matrix->r3c2 * matrix->r2c1 + matrix->r3c3 * matrix->r3c1; product.r3c1 = matrix->r3c1 * matrix->r1c1 + matrix->r3c2 * matrix->r2c1 + matrix->r3c3 * matrix->r3c1;
const double product_r3c2 = matrix->r3c1 * matrix->r1c2 + matrix->r3c2 * matrix->r2c2 + matrix->r3c3 * matrix->r3c2; product.r3c2 = matrix->r3c1 * matrix->r1c2 + matrix->r3c2 * matrix->r2c2 + matrix->r3c3 * matrix->r3c2;
const double product_r3c3 = matrix->r3c1 * matrix->r1c3 + matrix->r3c2 * matrix->r2c3 + matrix->r3c3 * matrix->r3c3; product.r3c3 = matrix->r3c1 * matrix->r1c3 + matrix->r3c2 * matrix->r2c3 + matrix->r3c3 * matrix->r3c3;
return bgc_is_unit_fp64(product_r1c1) && bgc_is_zero_fp64(product_r1c2) && bgc_is_zero_fp64(product_r1c3) return bgc_fp64_matrix3x3_is_identity(&product);
&& bgc_is_zero_fp64(product_r2c1) && bgc_is_unit_fp64(product_r2c2) && bgc_is_zero_fp64(product_r2c3)
&& bgc_is_zero_fp64(product_r3c1) && bgc_is_zero_fp64(product_r3c2) && bgc_is_unit_fp64(product_r3c3);
} }
// ================ Get Inverse ================= //
int bgc_fp32_matrix3x3_get_inverse(const BGC_FP32_Matrix3x3* matrix, BGC_FP32_Matrix3x3* inverse);
int bgc_fp64_matrix3x3_get_inverse(const BGC_FP64_Matrix3x3* matrix, BGC_FP64_Matrix3x3* inverse);
// =================== Invert =================== // // =================== Invert =================== //
int bgc_matrix3x3_invert_fp32(const BgcMatrix3x3FP32* matrix, BgcMatrix3x3FP32* inverted); inline int bgc_fp32_matrix3x3_invert(BGC_FP32_Matrix3x3* matrix)
{
return bgc_fp32_matrix3x3_get_inverse(matrix, matrix);
}
int bgc_matrix3x3_invert_fp64(const BgcMatrix3x3FP64* matrix, BgcMatrix3x3FP64* inverted); inline int bgc_fp64_matrix3x3_invert(BGC_FP64_Matrix3x3* matrix)
{
return bgc_fp64_matrix3x3_get_inverse(matrix, matrix);
}
// ================= Transpose ================== // // ================= Transpose ================== //
inline void bgc_matrix3x3_transpose_fp32(const BgcMatrix3x3FP32* matrix, BgcMatrix3x3FP32* transposed) inline void bgc_fp32_matrix3x3_transpose(BGC_FP32_Matrix3x3* matrix)
{
const float r1c2 = matrix->r1c2;
const float r1c3 = matrix->r1c3;
const float r2c3 = matrix->r2c3;
matrix->r1c2 = matrix->r2c1;
matrix->r1c3 = matrix->r3c1;
matrix->r2c3 = matrix->r3c2;
matrix->r2c1 = r1c2;
matrix->r3c1 = r1c3;
matrix->r3c2 = r2c3;
}
inline void bgc_fp64_matrix3x3_transpose(BGC_FP64_Matrix3x3* matrix)
{
const double r1c2 = matrix->r1c2;
const double r1c3 = matrix->r1c3;
const double r2c3 = matrix->r2c3;
matrix->r1c2 = matrix->r2c1;
matrix->r1c3 = matrix->r3c1;
matrix->r2c3 = matrix->r3c2;
matrix->r2c1 = r1c2;
matrix->r3c1 = r1c3;
matrix->r3c2 = r2c3;
}
// =============== Get Transpose ================ //
inline void bgc_fp32_matrix3x3_get_transposed(const BGC_FP32_Matrix3x3* matrix, BGC_FP32_Matrix3x3* transposed)
{ {
transposed->r1c1 = matrix->r1c1; transposed->r1c1 = matrix->r1c1;
transposed->r2c2 = matrix->r2c2; transposed->r2c2 = matrix->r2c2;
@ -347,7 +399,7 @@ inline void bgc_matrix3x3_transpose_fp32(const BgcMatrix3x3FP32* matrix, BgcMatr
transposed->r3c2 = r2c3; transposed->r3c2 = r2c3;
} }
inline void bgc_matrix3x3_transpose_fp64(const BgcMatrix3x3FP64* matrix, BgcMatrix3x3FP64* transposed) inline void bgc_fp64_matrix3x3_get_transposed(const BGC_FP64_Matrix3x3* matrix, BGC_FP64_Matrix3x3* transposed)
{ {
transposed->r1c1 = matrix->r1c1; transposed->r1c1 = matrix->r1c1;
transposed->r2c2 = matrix->r2c2; transposed->r2c2 = matrix->r2c2;
@ -366,105 +418,245 @@ inline void bgc_matrix3x3_transpose_fp64(const BgcMatrix3x3FP64* matrix, BgcMatr
transposed->r3c2 = r2c3; transposed->r3c2 = r2c3;
} }
// ================= Set Row 1 ================== // // ================== Get Row -================== //
inline void bgc_matrix3x3_set_row1_fp32(const float c1, const float c2, const float c3, BgcMatrix3x3FP32* matrix) inline void bgc_fp32_matrix3x3_get_row(const int number, const BGC_FP32_Matrix3x3* matrix, BGC_FP32_Vector3* row)
{ {
matrix->r1c1 = c1; if (number == 1)
matrix->r1c2 = c2; {
matrix->r1c3 = c3; row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
row->x3 = matrix->r1c3;
return;
}
if (number == 2)
{
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
row->x3 = matrix->r2c3;
return;
}
if (number == 3)
{
row->x1 = matrix->r3c1;
row->x2 = matrix->r3c2;
row->x3 = matrix->r3c3;
return;
}
row->x1 = 0.0f;
row->x2 = 0.0f;
row->x3 = 0.0f;
} }
inline void bgc_matrix3x3_set_row1_fp64(const double c1, const double c2, const double c3, BgcMatrix3x3FP64* matrix) inline void bgc_fp64_matrix3x3_get_row(const int number, const BGC_FP64_Matrix3x3* matrix, BGC_FP64_Vector3* row)
{ {
matrix->r1c1 = c1; if (number == 1)
matrix->r1c2 = c2; {
matrix->r1c3 = c3; row->x1 = matrix->r1c1;
row->x2 = matrix->r1c2;
row->x3 = matrix->r1c3;
return;
}
if (number == 2)
{
row->x1 = matrix->r2c1;
row->x2 = matrix->r2c2;
row->x3 = matrix->r2c3;
return;
}
if (number == 3)
{
row->x1 = matrix->r3c1;
row->x2 = matrix->r3c2;
row->x3 = matrix->r3c3;
return;
}
row->x1 = 0.0;
row->x2 = 0.0;
row->x3 = 0.0;
} }
// ================= Set Row 2 ================== // // ================== Set Row =================== //
inline void bgc_matrix3x3_set_row2_fp32(const float c1, const float c2, const float c3, BgcMatrix3x3FP32* matrix) inline void bgc_fp32_matrix3x3_set_row(const int number, const BGC_FP32_Vector3* row, BGC_FP32_Matrix3x3* matrix)
{ {
matrix->r2c1 = c1; if (number == 1)
matrix->r2c2 = c2; {
matrix->r2c3 = c3; matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
matrix->r1c3 = row->x3;
return;
}
if (number == 2)
{
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
matrix->r2c3 = row->x3;
return;
}
if (number == 3)
{
matrix->r3c1 = row->x1;
matrix->r3c2 = row->x2;
matrix->r3c3 = row->x3;
}
} }
inline void bgc_matrix3x3_set_row2_fp64(const double c1, const double c2, const double c3, BgcMatrix3x3FP64* matrix) inline void bgc_fp64_matrix3x3_set_row(const int number, const BGC_FP64_Vector3* row, BGC_FP64_Matrix3x3* matrix)
{ {
matrix->r2c1 = c1; if (number == 1)
matrix->r2c2 = c2; {
matrix->r2c3 = c3; matrix->r1c1 = row->x1;
matrix->r1c2 = row->x2;
matrix->r1c3 = row->x3;
return;
}
if (number == 2)
{
matrix->r2c1 = row->x1;
matrix->r2c2 = row->x2;
matrix->r2c3 = row->x3;
return;
}
if (number == 3)
{
matrix->r3c1 = row->x1;
matrix->r3c2 = row->x2;
matrix->r3c3 = row->x3;
}
} }
// ================= Set Row 3 ================== // // ================= Get Column ================= //
inline void bgc_matrix3x3_set_row3_fp32(const float c1, const float c2, const float c3, BgcMatrix3x3FP32* matrix) inline void bgc_fp32_matrix3x3_get_column(const int number, const BGC_FP32_Matrix3x3* matrix, BGC_FP32_Vector3* column)
{ {
matrix->r3c1 = c1; if (number == 1)
matrix->r3c2 = c2; {
matrix->r3c3 = c3; column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
column->x3 = matrix->r3c1;
return;
}
if (number == 2)
{
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
column->x3 = matrix->r3c2;
return;
}
if (number == 3)
{
column->x1 = matrix->r1c3;
column->x2 = matrix->r2c3;
column->x3 = matrix->r3c3;
return;
}
column->x1 = 0.0f;
column->x2 = 0.0f;
column->x3 = 0.0f;
} }
inline void bgc_matrix3x3_set_row3_fp64(const double c1, const double c2, const double c3, BgcMatrix3x3FP64* matrix) inline void bgc_fp64_matrix3x3_get_column(const int number, const BGC_FP64_Matrix3x3* matrix, BGC_FP64_Vector3* column)
{ {
matrix->r3c1 = c1; if (number == 1)
matrix->r3c2 = c2; {
matrix->r3c3 = c3; column->x1 = matrix->r1c1;
column->x2 = matrix->r2c1;
column->x3 = matrix->r3c1;
return;
}
if (number == 2)
{
column->x1 = matrix->r1c2;
column->x2 = matrix->r2c2;
column->x3 = matrix->r3c2;
return;
}
if (number == 3)
{
column->x1 = matrix->r1c3;
column->x2 = matrix->r2c3;
column->x3 = matrix->r3c3;
return;
}
column->x1 = 0.0;
column->x2 = 0.0;
column->x3 = 0.0;
} }
// ================ Set Column 1 ================ // // ================= Set Column ================= //
inline void bgc_matrix3x3_set_column1_fp32(const float r1, const float r2, const float r3, BgcMatrix3x3FP32* matrix) inline void bgc_fp32_matrix3x3_set_column(const int number, const BGC_FP32_Vector3* column, BGC_FP32_Matrix3x3* matrix)
{ {
matrix->r1c1 = r1; if (number == 1)
matrix->r2c1 = r2; {
matrix->r3c1 = r3; matrix->r1c1 = column->x1;
matrix->r2c1 = column->x2;
matrix->r3c1 = column->x3;
return;
}
if (number == 2)
{
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
matrix->r3c2 = column->x3;
return;
}
if (number == 3)
{
matrix->r1c3 = column->x1;
matrix->r2c3 = column->x2;
matrix->r3c3 = column->x3;
}
} }
inline void bgc_matrix3x3_set_column1_fp64(const double r1, const double r2, const double r3, BgcMatrix3x3FP64* matrix) inline void bgc_fp64_matrix3x3_set_column(const int number, const BGC_FP64_Vector3* column, BGC_FP64_Matrix3x3* matrix)
{ {
matrix->r1c1 = r1; if (number == 1)
matrix->r2c1 = r2; {
matrix->r3c1 = r3; matrix->r1c1 = column->x1;
} matrix->r2c1 = column->x2;
matrix->r3c1 = column->x3;
return;
}
// ================ Set Column 2 ================ // if (number == 2)
{
matrix->r1c2 = column->x1;
matrix->r2c2 = column->x2;
matrix->r3c2 = column->x3;
return;
}
inline void bgc_matrix3x3_set_column2_fp32(const float r1, const float r2, const float r3, BgcMatrix3x3FP32* matrix) if (number == 3)
{ {
matrix->r1c2 = r1; matrix->r1c3 = column->x1;
matrix->r2c2 = r2; matrix->r2c3 = column->x2;
matrix->r3c2 = r3; matrix->r3c3 = column->x3;
} }
inline void bgc_matrix3x3_set_column2_fp64(const double r1, const double r2, const double r3, BgcMatrix3x3FP64* matrix)
{
matrix->r1c2 = r1;
matrix->r2c2 = r2;
matrix->r3c2 = r3;
}
// ================ Set Column 3 ================ //
inline void bgc_matrix3x3_set_column3_fp32(const float r1, const float r2, const float r3, BgcMatrix3x3FP32* matrix)
{
matrix->r1c3 = r1;
matrix->r2c3 = r2;
matrix->r3c3 = r3;
}
inline void bgc_matrix3x3_set_column3_fp64(const double r1, const double r2, const double r3, BgcMatrix3x3FP64* matrix)
{
matrix->r1c3 = r1;
matrix->r2c3 = r2;
matrix->r3c3 = r3;
} }
// ==================== Add ===================== // // ==================== Add ===================== //
inline void bgc_matrix3x3_add_fp32(const BgcMatrix3x3FP32* matrix1, const BgcMatrix3x3FP32* matrix2, BgcMatrix3x3FP32* sum) inline void bgc_fp32_matrix3x3_add(const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2, BGC_FP32_Matrix3x3* sum)
{ {
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
@ -479,7 +671,7 @@ inline void bgc_matrix3x3_add_fp32(const BgcMatrix3x3FP32* matrix1, const BgcMat
sum->r3c3 = matrix1->r3c3 + matrix2->r3c3; sum->r3c3 = matrix1->r3c3 + matrix2->r3c3;
} }
inline void bgc_matrix3x3_add_fp64(const BgcMatrix3x3FP64* matrix1, const BgcMatrix3x3FP64* matrix2, BgcMatrix3x3FP64* sum) inline void bgc_fp64_matrix3x3_add(const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2, BGC_FP64_Matrix3x3* sum)
{ {
sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; sum->r1c1 = matrix1->r1c1 + matrix2->r1c1;
sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; sum->r1c2 = matrix1->r1c2 + matrix2->r1c2;
@ -496,7 +688,7 @@ inline void bgc_matrix3x3_add_fp64(const BgcMatrix3x3FP64* matrix1, const BgcMat
// ================= Add scaled ================= // // ================= Add scaled ================= //
inline void bgc_matrix3x3_add_scaled_fp32(const BgcMatrix3x3FP32* basic_matrix, const BgcMatrix3x3FP32* scalable_matrix, const float scale, BgcMatrix3x3FP32* sum) inline void bgc_fp32_matrix3x3_add_scaled(const BGC_FP32_Matrix3x3* basic_matrix, const BGC_FP32_Matrix3x3* scalable_matrix, const float scale, BGC_FP32_Matrix3x3* sum)
{ {
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
@ -511,7 +703,7 @@ inline void bgc_matrix3x3_add_scaled_fp32(const BgcMatrix3x3FP32* basic_matrix,
sum->r3c3 = basic_matrix->r3c3 + scalable_matrix->r3c3 * scale; sum->r3c3 = basic_matrix->r3c3 + scalable_matrix->r3c3 * scale;
} }
inline void bgc_matrix3x3_add_scaled_fp64(const BgcMatrix3x3FP64* basic_matrix, const BgcMatrix3x3FP64* scalable_matrix, const double scale, BgcMatrix3x3FP64* sum) inline void bgc_fp64_matrix3x3_add_scaled(const BGC_FP64_Matrix3x3* basic_matrix, const BGC_FP64_Matrix3x3* scalable_matrix, const double scale, BGC_FP64_Matrix3x3* sum)
{ {
sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale;
sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale;
@ -528,7 +720,7 @@ inline void bgc_matrix3x3_add_scaled_fp64(const BgcMatrix3x3FP64* basic_matrix,
// ================== Subtract ================== // // ================== Subtract ================== //
inline void bgc_matrix3x3_subtract_fp32(const BgcMatrix3x3FP32* minuend, const BgcMatrix3x3FP32* subtrahend, BgcMatrix3x3FP32* difference) inline void bgc_fp32_matrix3x3_subtract(const BGC_FP32_Matrix3x3* minuend, const BGC_FP32_Matrix3x3* subtrahend, BGC_FP32_Matrix3x3* difference)
{ {
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
@ -543,7 +735,7 @@ inline void bgc_matrix3x3_subtract_fp32(const BgcMatrix3x3FP32* minuend, const B
difference->r3c3 = minuend->r3c3 - subtrahend->r3c3; difference->r3c3 = minuend->r3c3 - subtrahend->r3c3;
} }
inline void bgc_matrix3x3_subtract_fp64(const BgcMatrix3x3FP64* minuend, const BgcMatrix3x3FP64* subtrahend, BgcMatrix3x3FP64* difference) inline void bgc_fp64_matrix3x3_subtract(const BGC_FP64_Matrix3x3* minuend, const BGC_FP64_Matrix3x3* subtrahend, BGC_FP64_Matrix3x3* difference)
{ {
difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; difference->r1c1 = minuend->r1c1 - subtrahend->r1c1;
difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; difference->r1c2 = minuend->r1c2 - subtrahend->r1c2;
@ -558,41 +750,9 @@ inline void bgc_matrix3x3_subtract_fp64(const BgcMatrix3x3FP64* minuend, const B
difference->r3c3 = minuend->r3c3 - subtrahend->r3c3; difference->r3c3 = minuend->r3c3 - subtrahend->r3c3;
} }
// ================= Add scaled ================= //
inline void bgc_matrix3x3_subtract_scaled_fp32(const BgcMatrix3x3FP32* basic_matrix, const BgcMatrix3x3FP32* scalable_matrix, const float scale, BgcMatrix3x3FP32* difference)
{
difference->r1c1 = basic_matrix->r1c1 - scalable_matrix->r1c1 * scale;
difference->r1c2 = basic_matrix->r1c2 - scalable_matrix->r1c2 * scale;
difference->r1c3 = basic_matrix->r1c3 - scalable_matrix->r1c3 * scale;
difference->r2c1 = basic_matrix->r2c1 - scalable_matrix->r2c1 * scale;
difference->r2c2 = basic_matrix->r2c2 - scalable_matrix->r2c2 * scale;
difference->r2c3 = basic_matrix->r2c3 - scalable_matrix->r2c3 * scale;
difference->r3c1 = basic_matrix->r3c1 - scalable_matrix->r3c1 * scale;
difference->r3c2 = basic_matrix->r3c2 - scalable_matrix->r3c2 * scale;
difference->r3c3 = basic_matrix->r3c3 - scalable_matrix->r3c3 * scale;
}
inline void bgc_matrix3x3_subtract_scaled_fp64(const BgcMatrix3x3FP64* basic_matrix, const BgcMatrix3x3FP64* scalable_matrix, const double scale, BgcMatrix3x3FP64* difference)
{
difference->r1c1 = basic_matrix->r1c1 - scalable_matrix->r1c1 * scale;
difference->r1c2 = basic_matrix->r1c2 - scalable_matrix->r1c2 * scale;
difference->r1c3 = basic_matrix->r1c3 - scalable_matrix->r1c3 * scale;
difference->r2c1 = basic_matrix->r2c1 - scalable_matrix->r2c1 * scale;
difference->r2c2 = basic_matrix->r2c2 - scalable_matrix->r2c2 * scale;
difference->r2c3 = basic_matrix->r2c3 - scalable_matrix->r2c3 * scale;
difference->r3c1 = basic_matrix->r3c1 - scalable_matrix->r3c1 * scale;
difference->r3c2 = basic_matrix->r3c2 - scalable_matrix->r3c2 * scale;
difference->r3c3 = basic_matrix->r3c3 - scalable_matrix->r3c3 * scale;
}
// ================== Multiply ================== // // ================== Multiply ================== //
inline void bgc_matrix3x3_multiply_fp32(const BgcMatrix3x3FP32* multiplicand, const float multiplier, BgcMatrix3x3FP32* product) inline void bgc_fp32_matrix3x3_multiply(const BGC_FP32_Matrix3x3* multiplicand, const float multiplier, BGC_FP32_Matrix3x3* product)
{ {
product->r1c1 = multiplicand->r1c1 * multiplier; product->r1c1 = multiplicand->r1c1 * multiplier;
product->r1c2 = multiplicand->r1c2 * multiplier; product->r1c2 = multiplicand->r1c2 * multiplier;
@ -607,7 +767,7 @@ inline void bgc_matrix3x3_multiply_fp32(const BgcMatrix3x3FP32* multiplicand, co
product->r3c3 = multiplicand->r3c3 * multiplier; product->r3c3 = multiplicand->r3c3 * multiplier;
} }
inline void bgc_matrix3x3_multiply_fp64(const BgcMatrix3x3FP64* multiplicand, const double multiplier, BgcMatrix3x3FP64* product) inline void bgc_fp64_matrix3x3_multiply(const BGC_FP64_Matrix3x3* multiplicand, const double multiplier, BGC_FP64_Matrix3x3* product)
{ {
product->r1c1 = multiplicand->r1c1 * multiplier; product->r1c1 = multiplicand->r1c1 * multiplier;
product->r1c2 = multiplicand->r1c2 * multiplier; product->r1c2 = multiplicand->r1c2 * multiplier;
@ -624,19 +784,55 @@ inline void bgc_matrix3x3_multiply_fp64(const BgcMatrix3x3FP64* multiplicand, co
// =================== Divide =================== // // =================== Divide =================== //
inline void bgc_matrix3x3_divide_fp32(const BgcMatrix3x3FP32* dividend, const float divisor, BgcMatrix3x3FP32* quotient) inline void bgc_fp32_matrix3x3_divide(const BGC_FP32_Matrix3x3* dividend, const float divisor, BGC_FP32_Matrix3x3* quotient)
{ {
bgc_matrix3x3_multiply_fp32(dividend, 1.0f / divisor, quotient); bgc_fp32_matrix3x3_multiply(dividend, 1.0f / divisor, quotient);
} }
inline void bgc_matrix3x3_divide_fp64(const BgcMatrix3x3FP64* dividend, const double divisor, BgcMatrix3x3FP64* quotient) inline void bgc_fp64_matrix3x3_divide(const BGC_FP64_Matrix3x3* dividend, const double divisor, BGC_FP64_Matrix3x3* quotient)
{ {
bgc_matrix3x3_multiply_fp64(dividend, 1.0 / divisor, quotient); bgc_fp64_matrix3x3_multiply(dividend, 1.0 / divisor, quotient);
}
// ================ Interpolate ================= //
inline void bgc_fp32_matrix3x3_interpolate(const BGC_FP32_Matrix3x3* first, const BGC_FP32_Matrix3x3* second, const float phase, BGC_FP32_Matrix3x3* interpolation)
{
const float counter_phase = 1.0f - phase;
interpolation->r1c1 = first->r1c1 * counter_phase + second->r1c1 * phase;
interpolation->r1c2 = first->r1c2 * counter_phase + second->r1c2 * phase;
interpolation->r1c3 = first->r1c3 * counter_phase + second->r1c3 * phase;
interpolation->r2c1 = first->r2c1 * counter_phase + second->r2c1 * phase;
interpolation->r2c2 = first->r2c2 * counter_phase + second->r2c2 * phase;
interpolation->r2c3 = first->r2c3 * counter_phase + second->r2c3 * phase;
interpolation->r3c1 = first->r3c1 * counter_phase + second->r3c1 * phase;
interpolation->r3c2 = first->r3c2 * counter_phase + second->r3c2 * phase;
interpolation->r3c3 = first->r3c3 * counter_phase + second->r3c3 * phase;
}
inline void bgc_fp64_matrix3x3_interpolate(const BGC_FP64_Matrix3x3* first, const BGC_FP64_Matrix3x3* second, const double phase, BGC_FP64_Matrix3x3* interpolation)
{
const double counter_phase = 1.0 - phase;
interpolation->r1c1 = first->r1c1 * counter_phase + second->r1c1 * phase;
interpolation->r1c2 = first->r1c2 * counter_phase + second->r1c2 * phase;
interpolation->r1c3 = first->r1c3 * counter_phase + second->r1c3 * phase;
interpolation->r2c1 = first->r2c1 * counter_phase + second->r2c1 * phase;
interpolation->r2c2 = first->r2c2 * counter_phase + second->r2c2 * phase;
interpolation->r2c3 = first->r2c3 * counter_phase + second->r2c3 * phase;
interpolation->r3c1 = first->r3c1 * counter_phase + second->r3c1 * phase;
interpolation->r3c2 = first->r3c2 * counter_phase + second->r3c2 * phase;
interpolation->r3c3 = first->r3c3 * counter_phase + second->r3c3 * phase;
} }
// ============ Left Vector Product ============= // // ============ Left Vector Product ============= //
inline void bgc_matrix3x3_get_left_product_fp32(const BgcVector3FP32* vector, const BgcMatrix3x3FP32* matrix, BgcVector3FP32* result) inline void bgc_fp32_multiply_vector3_by_matrix3x3(const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix3x3* matrix, BGC_FP32_Vector3* result)
{ {
const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1; const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2; const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
@ -647,7 +843,7 @@ inline void bgc_matrix3x3_get_left_product_fp32(const BgcVector3FP32* vector, co
result->x3 = x3; result->x3 = x3;
} }
inline void bgc_matrix3x3_get_left_product_fp64(const BgcVector3FP64* vector, const BgcMatrix3x3FP64* matrix, BgcVector3FP64* result) inline void bgc_fp64_multiply_vector3_by_matrix3x3(const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix3x3* matrix, BGC_FP64_Vector3* result)
{ {
const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1; const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1;
const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2; const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2;
@ -660,7 +856,7 @@ inline void bgc_matrix3x3_get_left_product_fp64(const BgcVector3FP64* vector, co
// ============ Right Vector Product ============ // // ============ Right Vector Product ============ //
inline void bgc_matrix3x3_get_right_product_fp32(const BgcMatrix3x3FP32* matrix, const BgcVector3FP32* vector, BgcVector3FP32* result) inline void bgc_fp32_multiply_matrix3x3_by_vector3(const BGC_FP32_Matrix3x3* matrix, const BGC_FP32_Vector3* vector, BGC_FP32_Vector3* result)
{ {
const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3; const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3; const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;
@ -671,7 +867,7 @@ inline void bgc_matrix3x3_get_right_product_fp32(const BgcMatrix3x3FP32* matrix,
result->x3 = x3; result->x3 = x3;
} }
inline void bgc_matrix3x3_get_right_product_fp64(const BgcMatrix3x3FP64* matrix, const BgcVector3FP64* vector, BgcVector3FP64* result) inline void bgc_fp64_multiply_matrix3x3_by_vector3(const BGC_FP64_Matrix3x3* matrix, const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* result)
{ {
const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3; const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3;
const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3; const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3;

View file

@ -1,280 +1,25 @@
#include "matrixes.h" #include "matrixes.h"
extern inline void bgc_matrix_product_2x2_at_2x2_fp32(const BgcMatrix2x2FP32* matrix1, const BgcMatrix2x2FP32* matrix2, BgcMatrix2x2FP32* result); extern inline void bgc_fp32_multiply_matrix2x2_by_matrix2x2(const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2, BGC_FP32_Matrix2x2* product);
extern inline void bgc_matrix_product_2x2_at_2x2_fp64(const BgcMatrix2x2FP64* matrix1, const BgcMatrix2x2FP64* matrix2, BgcMatrix2x2FP64* result); extern inline void bgc_fp64_multiply_matrix2x2_by_matrix2x2(const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2, BGC_FP64_Matrix2x2* product);
// ========== Matrix Product 2x2 at 3x2 ========= // extern inline void bgc_fp32_multiply_matrix2x2_by_matrix3x2(const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix3x2* matrix2, BGC_FP32_Matrix3x2* product);
extern inline void bgc_fp64_multiply_matrix2x2_by_matrix3x2(const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix3x2* matrix2, BGC_FP64_Matrix3x2* product);
void bgc_matrix_product_2x2_at_3x2_fp32(const BgcMatrix2x2FP32* matrix1, const BgcMatrix3x2FP32* matrix2, BgcMatrix3x2FP32* result) extern inline void bgc_fp32_multiply_matrix2x3_by_matrix2x2(const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x2* matrix2, BGC_FP32_Matrix2x3* product);
{ extern inline void bgc_fp64_multiply_matrix2x3_by_matrix2x2(const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x2* matrix2, BGC_FP64_Matrix2x3* product);
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1; extern inline void bgc_fp32_multiply_matrix2x3_by_matrix3x2(const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix3x2* matrix2, BGC_FP32_Matrix3x3* product);
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2; extern inline void bgc_fp64_multiply_matrix2x3_by_matrix3x2(const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix3x2* matrix2, BGC_FP64_Matrix3x3* product);
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
result->r1c1 = r1c1; extern inline void bgc_fp32_multiply_matrix3x2_by_matrix2x3(const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix2x3* matrix2, BGC_FP32_Matrix2x2* product);
result->r1c2 = r1c2; extern inline void bgc_fp64_multiply_matrix3x2_by_matrix2x3(const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix2x3* matrix2, BGC_FP64_Matrix2x2* product);
result->r1c3 = r1c3;
result->r2c1 = r2c1; extern inline void bgc_fp32_multiply_matrix3x2_by_matrix3x3(const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x3* matrix2, BGC_FP32_Matrix3x2* product);
result->r2c2 = r2c2; extern inline void bgc_fp64_multiply_matrix3x2_by_matrix3x3(const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x3* matrix2, BGC_FP64_Matrix3x2* product);
result->r2c3 = r2c3;
}
void bgc_matrix_product_2x2_at_3x2_fp64(const BgcMatrix2x2FP64* matrix1, const BgcMatrix3x2FP64* matrix2, BgcMatrix3x2FP64* result) extern inline void bgc_fp32_multiply_matrix3x3_by_matrix2x3(const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix2x3* matrix2, BGC_FP32_Matrix2x3* product);
{ extern inline void bgc_fp64_multiply_matrix3x3_by_matrix2x3(const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix2x3* matrix2, BGC_FP64_Matrix2x3* product);
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1; extern inline void bgc_fp32_multiply_matrix3x3_by_matrix3x3(const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2, BGC_FP32_Matrix3x3* product);
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2; extern inline void bgc_fp64_multiply_matrix3x3_by_matrix3x3(const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2, BGC_FP64_Matrix3x3* product);
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
result->r1c1 = r1c1;
result->r1c2 = r1c2;
result->r1c3 = r1c3;
result->r2c1 = r2c1;
result->r2c2 = r2c2;
result->r2c3 = r2c3;
}
// ========== Matrix Product 2x3 at 2x2 ========= //
void bgc_matrix_product_2x3_at_2x2_fp32(const BgcMatrix2x3FP32* matrix1, const BgcMatrix2x2FP32* matrix2, BgcMatrix2x3FP32* result)
{
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
result->r1c1 = r1c1;
result->r1c2 = r1c2;
result->r2c1 = r2c1;
result->r2c2 = r2c2;
result->r3c1 = r3c1;
result->r3c2 = r3c2;
}
void bgc_matrix_product_2x3_at_2x2_fp64(const BgcMatrix2x3FP64* matrix1, const BgcMatrix2x2FP64* matrix2, BgcMatrix2x3FP64* result)
{
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
result->r1c1 = r1c1;
result->r1c2 = r1c2;
result->r2c1 = r2c1;
result->r2c2 = r2c2;
result->r3c1 = r3c1;
result->r3c2 = r3c2;
}
// ========== Matrix Product 2x3 at 3x2 ========= //
void bgc_matrix_product_2x3_at_3x2_fp32(const BgcMatrix2x3FP32* matrix1, const BgcMatrix3x2FP32* matrix2, BgcMatrix3x3FP32* result)
{
result->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
result->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
result->r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
result->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
result->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
result->r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
result->r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
result->r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
result->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3;
}
void bgc_matrix_product_2x3_at_3x2_fp64(const BgcMatrix2x3FP64* matrix1, const BgcMatrix3x2FP64* matrix2, BgcMatrix3x3FP64* result)
{
result->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
result->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
result->r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
result->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
result->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
result->r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
result->r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
result->r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
result->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3;
}
// ========== Matrix Product 3x2 at 2x3 ========= //
void bgc_matrix_product_3x2_at_2x3_fp32(const BgcMatrix3x2FP32* matrix1, const BgcMatrix2x3FP32* matrix2, BgcMatrix2x2FP32* result)
{
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->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
result->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
}
void bgc_matrix_product_3x2_at_2x3_fp64(const BgcMatrix3x2FP64* matrix1, const BgcMatrix2x3FP64* matrix2, BgcMatrix2x2FP64* result)
{
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->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
result->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
}
// ========== Matrix Product 3x2 at 3x3 ========= //
void bgc_matrix_product_3x2_at_3x3_fp32(const BgcMatrix3x2FP32* matrix1, const BgcMatrix3x3FP32* matrix2, BgcMatrix3x2FP32* result)
{
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
result->r1c1 = r1c1;
result->r1c2 = r1c2;
result->r1c3 = r1c3;
result->r2c1 = r2c1;
result->r2c2 = r2c2;
result->r2c3 = r2c3;
}
void bgc_matrix_product_3x2_at_3x3_fp64(const BgcMatrix3x2FP64* matrix1, const BgcMatrix3x3FP64* matrix2, BgcMatrix3x2FP64* result)
{
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
result->r1c1 = r1c1;
result->r1c2 = r1c2;
result->r1c3 = r1c3;
result->r2c1 = r2c1;
result->r2c2 = r2c2;
result->r2c3 = r2c3;
}
// ========== Matrix Product 3x3 at 2x3 ========= //
void bgc_matrix_product_3x3_at_2x3_fp32(const BgcMatrix3x3FP32* matrix1, const BgcMatrix2x3FP32* matrix2, BgcMatrix2x3FP32* result)
{
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
result->r1c1 = r1c1;
result->r1c2 = r1c2;
result->r2c1 = r2c1;
result->r2c2 = r2c2;
result->r3c1 = r3c1;
result->r3c2 = r3c2;
}
void bgc_matrix_product_3x3_at_2x3_fp64(const BgcMatrix3x3FP64* matrix1, const BgcMatrix2x3FP64* matrix2, BgcMatrix2x3FP64* result)
{
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
result->r1c1 = r1c1;
result->r1c2 = r1c2;
result->r2c1 = r2c1;
result->r2c2 = r2c2;
result->r3c1 = r3c1;
result->r3c2 = r3c2;
}
// ========== Matrix Product 3x3 at 3x3 ========= //
void bgc_matrix_product_3x3_at_3x3_fp32(const BgcMatrix3x3FP32* matrix1, const BgcMatrix3x3FP32* matrix2, BgcMatrix3x3FP32* result)
{
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
const float r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3 + matrix1->r3c3 * matrix2->r3c3;
result->r1c1 = r1c1;
result->r1c2 = r1c2;
result->r1c3 = r1c3;
result->r2c1 = r2c1;
result->r2c2 = r2c2;
result->r2c3 = r2c3;
result->r3c1 = r3c1;
result->r3c2 = r3c2;
result->r3c3 = r3c3;
}
void bgc_matrix_product_3x3_at_3x3_fp64(const BgcMatrix3x3FP64* matrix1, const BgcMatrix3x3FP64* matrix2, BgcMatrix3x3FP64* result)
{
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
const double r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3 + matrix1->r3c3 * matrix2->r3c3;
result->r1c1 = r1c1;
result->r1c2 = r1c2;
result->r1c3 = r1c3;
result->r2c1 = r2c1;
result->r2c2 = r2c2;
result->r2c3 = r2c3;
result->r3c1 = r3c1;
result->r3c2 = r3c2;
result->r3c3 = r3c3;
}

View file

@ -6,12 +6,12 @@
typedef struct { typedef struct {
float r1c1, r1c2; float r1c1, r1c2;
float r2c1, r2c2; float r2c1, r2c2;
} BgcMatrix2x2FP32; } BGC_FP32_Matrix2x2;
typedef struct { typedef struct {
double r1c1, r1c2; double r1c1, r1c2;
double r2c1, r2c2; double r2c1, r2c2;
} BgcMatrix2x2FP64; } BGC_FP64_Matrix2x2;
// ================== Matrix2x3 ================= // // ================== Matrix2x3 ================= //
@ -19,25 +19,25 @@ typedef struct {
float r1c1, r1c2; float r1c1, r1c2;
float r2c1, r2c2; float r2c1, r2c2;
float r3c1, r3c2; float r3c1, r3c2;
} BgcMatrix2x3FP32; } BGC_FP32_Matrix2x3;
typedef struct { typedef struct {
double r1c1, r1c2; double r1c1, r1c2;
double r2c1, r2c2; double r2c1, r2c2;
double r3c1, r3c2; double r3c1, r3c2;
} BgcMatrix2x3FP64; } BGC_FP64_Matrix2x3;
// ================== Matrix3x2 ================= // // ================== Matrix3x2 ================= //
typedef struct { typedef struct {
float r1c1, r1c2, r1c3; float r1c1, r1c2, r1c3;
float r2c1, r2c2, r2c3; float r2c1, r2c2, r2c3;
} BgcMatrix3x2FP32; } BGC_FP32_Matrix3x2;
typedef struct { typedef struct {
double r1c1, r1c2, r1c3; double r1c1, r1c2, r1c3;
double r2c1, r2c2, r2c3; double r2c1, r2c2, r2c3;
} BgcMatrix3x2FP64; } BGC_FP64_Matrix3x2;
// ================== Matrix3x3 ================= // // ================== Matrix3x3 ================= //
@ -45,17 +45,17 @@ typedef struct {
float r1c1, r1c2, r1c3; float r1c1, r1c2, r1c3;
float r2c1, r2c2, r2c3; float r2c1, r2c2, r2c3;
float r3c1, r3c2, r3c3; float r3c1, r3c2, r3c3;
} BgcMatrix3x3FP32; } BGC_FP32_Matrix3x3;
typedef struct { typedef struct {
double r1c1, r1c2, r1c3; double r1c1, r1c2, r1c3;
double r2c1, r2c2, r2c3; double r2c1, r2c2, r2c3;
double r3c1, r3c2, r3c3; double r3c1, r3c2, r3c3;
} BgcMatrix3x3FP64; } BGC_FP64_Matrix3x3;
// ========== Matrix Product 2x2 at 2x2 ========= // // ========== Matrix Product 2x2 at 2x2 ========= //
inline void bgc_matrix_product_2x2_at_2x2_fp32(const BgcMatrix2x2FP32* matrix1, const BgcMatrix2x2FP32* matrix2, BgcMatrix2x2FP32* result) inline void bgc_fp32_multiply_matrix2x2_by_matrix2x2(const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2, BGC_FP32_Matrix2x2* product)
{ {
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1; const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2; const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
@ -63,14 +63,14 @@ inline void bgc_matrix_product_2x2_at_2x2_fp32(const BgcMatrix2x2FP32* matrix1,
const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1; const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2; const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
result->r1c1 = r1c1; product->r1c1 = r1c1;
result->r1c2 = r1c2; product->r1c2 = r1c2;
result->r2c1 = r2c1; product->r2c1 = r2c1;
result->r2c2 = r2c2; product->r2c2 = r2c2;
} }
inline void bgc_matrix_product_2x2_at_2x2_fp64(const BgcMatrix2x2FP64* matrix1, const BgcMatrix2x2FP64* matrix2, BgcMatrix2x2FP64* result) inline void bgc_fp64_multiply_matrix2x2_by_matrix2x2(const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2, BGC_FP64_Matrix2x2* product)
{ {
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1; const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2; const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
@ -78,53 +78,287 @@ inline void bgc_matrix_product_2x2_at_2x2_fp64(const BgcMatrix2x2FP64* matrix1,
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1; const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2; const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
result->r1c1 = r1c1; product->r1c1 = r1c1;
result->r1c2 = r1c2; product->r1c2 = r1c2;
result->r2c1 = r2c1; product->r2c1 = r2c1;
result->r2c2 = r2c2; product->r2c2 = r2c2;
} }
// ========== Matrix Product 2x2 at 3x2 ========= // // ========== Matrix Product 2x2 at 3x2 ========= //
void bgc_matrix_product_2x2_at_3x2_fp32(const BgcMatrix2x2FP32* matrix1, const BgcMatrix3x2FP32* matrix2, BgcMatrix3x2FP32* result); inline void bgc_fp32_multiply_matrix2x2_by_matrix3x2(const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix3x2* matrix2, BGC_FP32_Matrix3x2* product)
{
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
void bgc_matrix_product_2x2_at_3x2_fp64(const BgcMatrix2x2FP64* matrix1, const BgcMatrix3x2FP64* matrix2, BgcMatrix3x2FP64* result); const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r1c3 = r1c3;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r2c3 = r2c3;
}
inline void bgc_fp64_multiply_matrix2x2_by_matrix3x2(const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix3x2* matrix2, BGC_FP64_Matrix3x2* product)
{
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r1c3 = r1c3;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r2c3 = r2c3;
}
// ========== Matrix Product 2x3 at 2x2 ========= // // ========== Matrix Product 2x3 at 2x2 ========= //
void bgc_matrix_product_2x3_at_2x2_fp32(const BgcMatrix2x3FP32* matrix1, const BgcMatrix2x2FP32* matrix2, BgcMatrix2x3FP32* result); inline void bgc_fp32_multiply_matrix2x3_by_matrix2x2(const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x2* matrix2, BGC_FP32_Matrix2x3* product)
{
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
void bgc_matrix_product_2x3_at_2x2_fp64(const BgcMatrix2x3FP64* matrix1, const BgcMatrix2x2FP64* matrix2, BgcMatrix2x3FP64* result); const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r3c1 = r3c1;
product->r3c2 = r3c2;
}
inline void bgc_fp64_multiply_matrix2x3_by_matrix2x2(const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x2* matrix2, BGC_FP64_Matrix2x3* product)
{
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r3c1 = r3c1;
product->r3c2 = r3c2;
}
// ========== Matrix Product 2x3 at 3x2 ========= // // ========== Matrix Product 2x3 at 3x2 ========= //
void bgc_matrix_product_2x3_at_3x2_fp32(const BgcMatrix2x3FP32* matrix1, const BgcMatrix3x2FP32* matrix2, BgcMatrix3x3FP32* result); inline void bgc_fp32_multiply_matrix2x3_by_matrix3x2(const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix3x2* matrix2, BGC_FP32_Matrix3x3* product)
{
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
product->r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
void bgc_matrix_product_2x3_at_3x2_fp64(const BgcMatrix2x3FP64* matrix1, const BgcMatrix3x2FP64* matrix2, BgcMatrix3x3FP64* result); product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
product->r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
product->r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
product->r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
product->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3;
}
inline void bgc_fp64_multiply_matrix2x3_by_matrix3x2(const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix3x2* matrix2, BGC_FP64_Matrix3x3* product)
{
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1;
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2;
product->r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3;
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1;
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2;
product->r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3;
product->r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1;
product->r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2;
product->r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3;
}
// ========== Matrix Product 3x2 at 2x3 ========= // // ========== Matrix Product 3x2 at 2x3 ========= //
void bgc_matrix_product_3x2_at_2x3_fp32(const BgcMatrix3x2FP32* matrix1, const BgcMatrix2x3FP32* matrix2, BgcMatrix2x2FP32* result); inline void bgc_fp32_multiply_matrix3x2_by_matrix2x3(const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix2x3* matrix2, BGC_FP32_Matrix2x2* product)
{
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
void bgc_matrix_product_3x2_at_2x3_fp64(const BgcMatrix3x2FP64* matrix1, const BgcMatrix2x3FP64* matrix2, BgcMatrix2x2FP64* result); product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
}
inline void bgc_fp64_multiply_matrix3x2_by_matrix2x3(const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix2x3* matrix2, BGC_FP64_Matrix2x2* product)
{
product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
product->r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
product->r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
}
// ========== Matrix Product 3x2 at 3x3 ========= // // ========== Matrix Product 3x2 at 3x3 ========= //
void bgc_matrix_product_3x2_at_3x3_fp32(const BgcMatrix3x2FP32* matrix1, const BgcMatrix3x3FP32* matrix2, BgcMatrix3x2FP32* result); inline void bgc_fp32_multiply_matrix3x2_by_matrix3x3(const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x3* matrix2, BGC_FP32_Matrix3x2* product)
{
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
void bgc_matrix_product_3x2_at_3x3_fp64(const BgcMatrix3x2FP64* matrix1, const BgcMatrix3x3FP64* matrix2, BgcMatrix3x2FP64* result); const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r1c3 = r1c3;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r2c3 = r2c3;
}
inline void bgc_fp64_multiply_matrix3x2_by_matrix3x3(const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x3* matrix2, BGC_FP64_Matrix3x2* product)
{
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r1c3 = r1c3;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r2c3 = r2c3;
}
// ========== Matrix Product 3x3 at 2x3 ========= // // ========== Matrix Product 3x3 at 2x3 ========= //
void bgc_matrix_product_3x3_at_2x3_fp32(const BgcMatrix3x3FP32* matrix1, const BgcMatrix2x3FP32* matrix2, BgcMatrix2x3FP32* result); inline void bgc_fp32_multiply_matrix3x3_by_matrix2x3(const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix2x3* matrix2, BGC_FP32_Matrix2x3* product)
{
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
void bgc_matrix_product_3x3_at_2x3_fp64(const BgcMatrix3x3FP64* matrix1, const BgcMatrix2x3FP64* matrix2, BgcMatrix2x3FP64* result); const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r3c1 = r3c1;
product->r3c2 = r3c2;
}
inline void bgc_fp64_multiply_matrix3x3_by_matrix2x3(const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix2x3* matrix2, BGC_FP64_Matrix2x3* product)
{
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r3c1 = r3c1;
product->r3c2 = r3c2;
}
// ========== Matrix Product 3x3 at 3x3 ========= // // ========== Matrix Product 3x3 at 3x3 ========= //
void bgc_matrix_product_3x3_at_3x3_fp32(const BgcMatrix3x3FP32* matrix1, const BgcMatrix3x3FP32* matrix2, BgcMatrix3x3FP32* result); inline void bgc_fp32_multiply_matrix3x3_by_matrix3x3(const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2, BGC_FP32_Matrix3x3* product)
{
const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
const float r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
void bgc_matrix_product_3x3_at_3x3_fp64(const BgcMatrix3x3FP64* matrix1, const BgcMatrix3x3FP64* matrix2, BgcMatrix3x3FP64* result); const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const float r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
const float r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3 + matrix1->r3c3 * matrix2->r3c3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r1c3 = r1c3;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r2c3 = r2c3;
product->r3c1 = r3c1;
product->r3c2 = r3c2;
product->r3c3 = r3c3;
}
inline void bgc_fp64_multiply_matrix3x3_by_matrix3x3(const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2, BGC_FP64_Matrix3x3* product)
{
const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1 + matrix1->r1c3 * matrix2->r3c1;
const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2 + matrix1->r1c3 * matrix2->r3c2;
const double r1c3 = matrix1->r1c1 * matrix2->r1c3 + matrix1->r1c2 * matrix2->r2c3 + matrix1->r1c3 * matrix2->r3c3;
const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1 + matrix1->r2c3 * matrix2->r3c1;
const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2 + matrix1->r2c3 * matrix2->r3c2;
const double r2c3 = matrix1->r2c1 * matrix2->r1c3 + matrix1->r2c2 * matrix2->r2c3 + matrix1->r2c3 * matrix2->r3c3;
const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1 + matrix1->r3c3 * matrix2->r3c1;
const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2 + matrix1->r3c3 * matrix2->r3c2;
const double r3c3 = matrix1->r3c1 * matrix2->r1c3 + matrix1->r3c2 * matrix2->r2c3 + matrix1->r3c3 * matrix2->r3c3;
product->r1c1 = r1c1;
product->r1c2 = r1c2;
product->r1c3 = r1c3;
product->r2c1 = r2c1;
product->r2c2 = r2c2;
product->r2c3 = r2c3;
product->r3c1 = r3c1;
product->r3c2 = r3c2;
product->r3c3 = r3c3;
}
#endif // _BGC_MATRIX_TYPES_H_ #endif // _BGC_MATRIX_TYPES_H_

View file

@ -1,43 +1,49 @@
#include "position2.h" #include "position2.h"
extern inline void bgc_position2_reset_fp32(BgcPosition2FP32 * node); extern inline void bgc_fp32_position2_reset(BGC_FP32_Position2 * node);
extern inline void bgc_position2_reset_fp64(BgcPosition2FP64 * node); extern inline void bgc_fp64_position2_reset(BGC_FP64_Position2 * node);
extern inline void bgc_position2_make_fp32(const BgcCotesNumberFP32 * turn, const BgcVector2FP32 * shift, BgcPosition2FP32 * position); extern inline void bgc_fp32_position2_make(const BGC_FP32_CotesNumber * turn, const BGC_FP32_Vector2 * shift, BGC_FP32_Position2 * position);
extern inline void bgc_position2_make_fp64(const BgcCotesNumberFP64 * turn, const BgcVector2FP64 * shift, BgcPosition2FP64 * position); extern inline void bgc_fp64_position2_make(const BGC_FP64_CotesNumber * turn, const BGC_FP64_Vector2 * shift, BGC_FP64_Position2 * position);
extern inline void bgc_position2_copy_fp32(const BgcPosition2FP32 * source, BgcPosition2FP32 * destination); extern inline void bgc_fp32_position2_copy(const BGC_FP32_Position2 * source, BGC_FP32_Position2 * destination);
extern inline void bgc_position2_copy_fp64(const BgcPosition2FP64 * source, BgcPosition2FP64 * destination); extern inline void bgc_fp64_position2_copy(const BGC_FP64_Position2 * source, BGC_FP64_Position2 * destination);
extern inline void bgc_position2_convert_fp64_to_fp32(const BgcPosition2FP64 * source, BgcPosition2FP32 * destination); extern inline void bgc_fp32_position2_swap(BGC_FP32_Position2 * first, BGC_FP32_Position2 * second);
extern inline void bgc_position2_convert_fp32_to_fp64(const BgcPosition2FP32 * source, BgcPosition2FP64 * destination); extern inline void bgc_fp64_position2_swap(BGC_FP64_Position2 * first, BGC_FP64_Position2 * second);
extern inline void bgc_position2_invert_fp32(BgcPosition2FP32 * position); extern inline void bgc_fp64_position2_convert_to_fp32(const BGC_FP64_Position2 * source, BGC_FP32_Position2 * destination);
extern inline void bgc_position2_invert_fp64(BgcPosition2FP64 * position); extern inline void bgc_fp32_position2_convert_to_fp64(const BGC_FP32_Position2 * source, BGC_FP64_Position2 * destination);
extern inline void bgc_position2_get_inverse_fp32(const BgcPosition2FP32 * position, BgcPosition2FP32 * inverted); extern inline int bgc_fp32_position2_is_idle(const BGC_FP32_Position2 * position);
extern inline void bgc_position2_get_inverse_fp64(const BgcPosition2FP64 * position, BgcPosition2FP64 * inverted); extern inline int bgc_fp64_position2_is_idle(const BGC_FP64_Position2 * position);
extern inline void bgc_position2_combine_fp32(const BgcPosition2FP32 * first, const BgcPosition2FP32 * second, BgcPosition2FP32 * combination); extern inline void bgc_fp32_position2_invert(BGC_FP32_Position2 * position);
extern inline void bgc_position2_combine_fp64(const BgcPosition2FP64 * first, const BgcPosition2FP64 * second, BgcPosition2FP64 * combination); extern inline void bgc_fp64_position2_invert(BGC_FP64_Position2 * position);
extern inline void bgc_position2_exclude_fp32(const BgcPosition2FP32 * base, const BgcPosition2FP32 * excludand, BgcPosition2FP32 * difference); extern inline void bgc_fp32_position2_get_inverse(const BGC_FP32_Position2 * position, BGC_FP32_Position2 * inverted);
extern inline void bgc_position2_exclude_fp64(const BgcPosition2FP64 * base, const BgcPosition2FP64 * excludand, BgcPosition2FP64 * difference); extern inline void bgc_fp64_position2_get_inverse(const BGC_FP64_Position2 * position, BGC_FP64_Position2 * inverted);
extern inline void bgc_position2_get_outward_affine_fp32(const BgcPosition2FP32 * position, BgcAffine2FP32 * outward_affine_map); extern inline void bgc_fp32_position2_combine(const BGC_FP32_Position2 * first, const BGC_FP32_Position2 * second, BGC_FP32_Position2 * combination);
extern inline void bgc_position2_get_outward_affine_fp64(const BgcPosition2FP64 * position, BgcAffine2FP64 * outward_affine_map); extern inline void bgc_fp64_position2_combine(const BGC_FP64_Position2 * first, const BGC_FP64_Position2 * second, BGC_FP64_Position2 * combination);
extern inline void bgc_position2_get_inward_affine_fp32(const BgcPosition2FP32 * position, BgcAffine2FP32 * inward_affine_map); extern inline void bgc_fp32_position2_exclude(const BGC_FP32_Position2 * base, const BGC_FP32_Position2 * excludand, BGC_FP32_Position2 * difference);
extern inline void bgc_position2_get_inward_affine_fp64(const BgcPosition2FP64 * position, BgcAffine2FP64 * inward_affine_map); extern inline void bgc_fp64_position2_exclude(const BGC_FP64_Position2 * base, const BGC_FP64_Position2 * excludand, BGC_FP64_Position2 * difference);
extern inline void bgc_position2_transform_point_outwards_fp32(const BgcPosition2FP32 * position, const BgcVector2FP32 * inner_point, BgcVector2FP32 * outer_point); extern inline void bgc_fp32_position2_get_outward_affine(const BGC_FP32_Position2 * position, BGC_FP32_Affine2 * outward_affine_map);
extern inline void bgc_position2_transform_point_outwards_fp64(const BgcPosition2FP64 * position, const BgcVector2FP64 * inner_point, BgcVector2FP64 * outer_point); extern inline void bgc_fp64_position2_get_outward_affine(const BGC_FP64_Position2 * position, BGC_FP64_Affine2 * outward_affine_map);
extern inline void bgc_position2_transform_point_inwards_fp32(const BgcPosition2FP32 * position, const BgcVector2FP32 * outer_point, BgcVector2FP32 * inner_point); extern inline void bgc_fp32_position2_get_inward_affine(const BGC_FP32_Position2 * position, BGC_FP32_Affine2 * inward_affine_map);
extern inline void bgc_position2_transform_point_inwards_fp64(const BgcPosition2FP64 * position, const BgcVector2FP64 * outer_point, BgcVector2FP64 * inner_point); extern inline void bgc_fp64_position2_get_inward_affine(const BGC_FP64_Position2 * position, BGC_FP64_Affine2 * inward_affine_map);
extern inline void bgc_position2_transform_vector_outwards_fp32(const BgcPosition2FP32 * position, const BgcVector2FP32 * inner_vector, BgcVector2FP32 * outer_vector); extern inline void bgc_fp32_position2_transform_point_outwards(const BGC_FP32_Position2 * position, const BGC_FP32_Vector2 * inner_point, BGC_FP32_Vector2 * outer_point);
extern inline void bgc_position2_transform_vector_outwards_fp64(const BgcPosition2FP64 * position, const BgcVector2FP64 * inner_vector, BgcVector2FP64 * outer_vector); extern inline void bgc_fp64_position2_transform_point_outwards(const BGC_FP64_Position2 * position, const BGC_FP64_Vector2 * inner_point, BGC_FP64_Vector2 * outer_point);
extern inline void bgc_position2_transform_vector_inwards_fp32(const BgcPosition2FP32 * position, const BgcVector2FP32 * outer_vector, BgcVector2FP32 * inner_vector); extern inline void bgc_fp32_position2_transform_point_inwards(const BGC_FP32_Position2 * position, const BGC_FP32_Vector2 * outer_point, BGC_FP32_Vector2 * inner_point);
extern inline void bgc_position2_transform_vector_inwards_fp64(const BgcPosition2FP64 * position, const BgcVector2FP64 * outer_vector, BgcVector2FP64 * inner_vector); extern inline void bgc_fp64_position2_transform_point_inwards(const BGC_FP64_Position2 * position, const BGC_FP64_Vector2 * outer_point, BGC_FP64_Vector2 * inner_point);
extern inline void bgc_fp32_position2_transform_vector_outwards(const BGC_FP32_Position2 * position, const BGC_FP32_Vector2 * inner_vector, BGC_FP32_Vector2 * outer_vector);
extern inline void bgc_fp64_position2_transform_vector_outwards(const BGC_FP64_Position2 * position, const BGC_FP64_Vector2 * inner_vector, BGC_FP64_Vector2 * outer_vector);
extern inline void bgc_fp32_position2_transform_vector_inwards(const BGC_FP32_Position2 * position, const BGC_FP32_Vector2 * outer_vector, BGC_FP32_Vector2 * inner_vector);
extern inline void bgc_fp64_position2_transform_vector_inwards(const BGC_FP64_Position2 * position, const BGC_FP64_Vector2 * outer_vector, BGC_FP64_Vector2 * inner_vector);

View file

@ -8,226 +8,252 @@
// ==================== Types ==================== // // ==================== Types ==================== //
typedef struct { typedef struct {
BgcCotesNumberFP32 turn; BGC_FP32_CotesNumber turn;
BgcVector2FP32 shift; BGC_FP32_Vector2 shift;
} BgcPosition2FP32; } BGC_FP32_Position2;
typedef struct { typedef struct {
BgcCotesNumberFP64 turn; BGC_FP64_CotesNumber turn;
BgcVector2FP64 shift; BGC_FP64_Vector2 shift;
} BgcPosition2FP64; } BGC_FP64_Position2;
// ==================== Reset ==================== // // ==================== Reset ==================== //
inline void bgc_position2_reset_fp32(BgcPosition2FP32 * position) inline void bgc_fp32_position2_reset(BGC_FP32_Position2 * position)
{ {
bgc_cotes_number_reset_fp32(&position->turn); bgc_fp32_cotes_number_reset(&position->turn);
bgc_vector2_reset_fp32(&position->shift); bgc_fp32_vector2_reset(&position->shift);
} }
inline void bgc_position2_reset_fp64(BgcPosition2FP64 * position) inline void bgc_fp64_position2_reset(BGC_FP64_Position2 * position)
{ {
bgc_cotes_number_reset_fp64(&position->turn); bgc_fp64_cotes_number_reset(&position->turn);
bgc_vector2_reset_fp64(&position->shift); bgc_fp64_vector2_reset(&position->shift);
} }
// ==================== Make ===================== // // ==================== Make ===================== //
inline void bgc_position2_make_fp32(const BgcCotesNumberFP32 * turn, const BgcVector2FP32 * shift, BgcPosition2FP32 * position) inline void bgc_fp32_position2_make(const BGC_FP32_CotesNumber * turn, const BGC_FP32_Vector2 * shift, BGC_FP32_Position2 * position)
{ {
bgc_cotes_number_copy_fp32(turn, &position->turn); bgc_fp32_cotes_number_copy(turn, &position->turn);
bgc_vector2_copy_fp32(shift, &position->shift); bgc_fp32_vector2_copy(shift, &position->shift);
} }
inline void bgc_position2_make_fp64(const BgcCotesNumberFP64 * turn, const BgcVector2FP64 * shift, BgcPosition2FP64 * position) inline void bgc_fp64_position2_make(const BGC_FP64_CotesNumber * turn, const BGC_FP64_Vector2 * shift, BGC_FP64_Position2 * position)
{ {
bgc_cotes_number_copy_fp64(turn, &position->turn); bgc_fp64_cotes_number_copy(turn, &position->turn);
bgc_vector2_copy_fp64(shift, &position->shift); bgc_fp64_vector2_copy(shift, &position->shift);
} }
// ==================== Copy ===================== // // ==================== Copy ===================== //
inline void bgc_position2_copy_fp32(const BgcPosition2FP32 * source, BgcPosition2FP32 * destination) inline void bgc_fp32_position2_copy(const BGC_FP32_Position2 * source, BGC_FP32_Position2 * destination)
{ {
bgc_cotes_number_copy_fp32(&source->turn, &destination->turn); bgc_fp32_cotes_number_copy(&source->turn, &destination->turn);
bgc_vector2_copy_fp32(&source->shift, &destination->shift); bgc_fp32_vector2_copy(&source->shift, &destination->shift);
} }
inline void bgc_position2_copy_fp64(const BgcPosition2FP64 * source, BgcPosition2FP64 * destination) inline void bgc_fp64_position2_copy(const BGC_FP64_Position2 * source, BGC_FP64_Position2 * destination)
{ {
bgc_cotes_number_copy_fp64(&source->turn, &destination->turn); bgc_fp64_cotes_number_copy(&source->turn, &destination->turn);
bgc_vector2_copy_fp64(&source->shift, &destination->shift); bgc_fp64_vector2_copy(&source->shift, &destination->shift);
}
// ==================== Swap ===================== //
inline void bgc_fp32_position2_swap(BGC_FP32_Position2 * first, BGC_FP32_Position2 * second)
{
bgc_fp32_cotes_number_swap(&first->turn, &second->turn);
bgc_fp32_vector2_swap(&first->shift, &second->shift);
}
inline void bgc_fp64_position2_swap(BGC_FP64_Position2 * first, BGC_FP64_Position2 * second)
{
bgc_fp64_cotes_number_swap(&first->turn, &second->turn);
bgc_fp64_vector2_swap(&first->shift, &second->shift);
} }
// =================== Convert =================== // // =================== Convert =================== //
inline void bgc_position2_convert_fp64_to_fp32(const BgcPosition2FP64 * source, BgcPosition2FP32 * destination) inline void bgc_fp64_position2_convert_to_fp32(const BGC_FP64_Position2 * source, BGC_FP32_Position2 * destination)
{ {
bgc_cotes_number_convert_fp64_to_fp32(&source->turn, &destination->turn); bgc_fp64_cotes_number_convert_to_fp32(&source->turn, &destination->turn);
bgc_vector2_convert_fp64_to_fp32(&source->shift, &destination->shift); bgc_fp64_vector2_convert_to_fp32(&source->shift, &destination->shift);
} }
inline void bgc_position2_convert_fp32_to_fp64(const BgcPosition2FP32 * source, BgcPosition2FP64 * destination) inline void bgc_fp32_position2_convert_to_fp64(const BGC_FP32_Position2 * source, BGC_FP64_Position2 * destination)
{ {
bgc_cotes_number_convert_fp32_to_fp64(&source->turn, &destination->turn); bgc_fp32_cotes_number_convert_to_fp64(&source->turn, &destination->turn);
bgc_vector2_convert_fp32_to_fp64(&source->shift, &destination->shift); bgc_fp32_vector2_convert_to_fp64(&source->shift, &destination->shift);
}
// =================== Is Idle =================== //
inline int bgc_fp32_position2_is_idle(const BGC_FP32_Position2 * position)
{
return bgc_fp32_vector2_is_zero(&position->shift) && bgc_fp32_cotes_number_is_idle(&position->turn);
}
inline int bgc_fp64_position2_is_idle(const BGC_FP64_Position2 * position)
{
return bgc_fp64_vector2_is_zero(&position->shift) && bgc_fp64_cotes_number_is_idle(&position->turn);
} }
// =================== Invert ==================== // // =================== Invert ==================== //
inline void bgc_position2_invert_fp32(BgcPosition2FP32 * position) inline void bgc_fp32_position2_invert(BGC_FP32_Position2 * position)
{ {
bgc_cotes_number_turn_vector_back_fp32(&position->turn, &position->shift, &position->shift); bgc_fp32_cotes_number_turn_vector_back(&position->turn, &position->shift, &position->shift);
bgc_cotes_number_invert_fp32(&position->turn); bgc_fp32_cotes_number_revert(&position->turn);
bgc_vector2_make_opposite_fp32(&position->shift); bgc_fp32_vector2_revert(&position->shift);
} }
inline void bgc_position2_invert_fp64(BgcPosition2FP64 * position) inline void bgc_fp64_position2_invert(BGC_FP64_Position2 * position)
{ {
bgc_cotes_number_turn_vector_back_fp64(&position->turn, &position->shift, &position->shift); bgc_fp64_cotes_number_turn_vector_back(&position->turn, &position->shift, &position->shift);
bgc_cotes_number_invert_fp64(&position->turn); bgc_fp64_cotes_number_revert(&position->turn);
bgc_vector2_make_opposite_fp64(&position->shift); bgc_fp64_vector2_revert(&position->shift);
} }
// ================= Get Inverse ================= // // ================= Get Inverse ================= //
inline void bgc_position2_get_inverse_fp32(const BgcPosition2FP32 * position, BgcPosition2FP32 * inverted) inline void bgc_fp32_position2_get_inverse(const BGC_FP32_Position2 * position, BGC_FP32_Position2 * inverted)
{ {
bgc_cotes_number_turn_vector_back_fp32(&position->turn, &position->shift, &inverted->shift); bgc_fp32_cotes_number_turn_vector_back(&position->turn, &position->shift, &inverted->shift);
bgc_cotes_number_get_inverse_fp32(&position->turn, &inverted->turn); bgc_fp32_cotes_number_get_reverse(&position->turn, &inverted->turn);
bgc_vector2_make_opposite_fp32(&inverted->shift); bgc_fp32_vector2_revert(&inverted->shift);
} }
inline void bgc_position2_get_inverse_fp64(const BgcPosition2FP64 * position, BgcPosition2FP64 * inverted) inline void bgc_fp64_position2_get_inverse(const BGC_FP64_Position2 * position, BGC_FP64_Position2 * inverted)
{ {
bgc_cotes_number_turn_vector_back_fp64(&position->turn, &position->shift, &inverted->shift); bgc_fp64_cotes_number_turn_vector_back(&position->turn, &position->shift, &inverted->shift);
bgc_cotes_number_get_inverse_fp64(&position->turn, &inverted->turn); bgc_fp64_cotes_number_get_inverse(&position->turn, &inverted->turn);
bgc_vector2_make_opposite_fp64(&inverted->shift); bgc_fp64_vector2_revert(&inverted->shift);
} }
// =================== Combine =================== // // =================== Combine =================== //
inline void bgc_position2_combine_fp32(const BgcPosition2FP32 * first, const BgcPosition2FP32 * second, BgcPosition2FP32 * combination) inline void bgc_fp32_position2_combine(const BGC_FP32_Position2 * first, const BGC_FP32_Position2 * second, BGC_FP32_Position2 * combination)
{ {
BgcVector2FP32 relative_shift; BGC_FP32_Vector2 relative_shift;
bgc_cotes_number_turn_vector_fp32(&second->turn, &first->shift, &relative_shift); bgc_fp32_cotes_number_turn_vector(&second->turn, &first->shift, &relative_shift);
bgc_cotes_number_combine_fp32(&first->turn, &second->turn, &combination->turn); bgc_fp32_cotes_number_combine(&first->turn, &second->turn, &combination->turn);
bgc_vector2_add_fp32(&relative_shift, &second->shift, &combination->shift); bgc_fp32_vector2_add(&relative_shift, &second->shift, &combination->shift);
} }
inline void bgc_position2_combine_fp64(const BgcPosition2FP64 * first, const BgcPosition2FP64 * second, BgcPosition2FP64 * combination) inline void bgc_fp64_position2_combine(const BGC_FP64_Position2 * first, const BGC_FP64_Position2 * second, BGC_FP64_Position2 * combination)
{ {
BgcVector2FP64 relative_shift; BGC_FP64_Vector2 relative_shift;
bgc_cotes_number_turn_vector_fp64(&second->turn, &first->shift, &relative_shift); bgc_fp64_cotes_number_turn_vector(&second->turn, &first->shift, &relative_shift);
bgc_cotes_number_combine_fp64(&first->turn, &second->turn, &combination->turn); bgc_fp64_cotes_number_combine(&first->turn, &second->turn, &combination->turn);
bgc_vector2_add_fp64(&relative_shift, &second->shift, &combination->shift); bgc_fp64_vector2_add(&relative_shift, &second->shift, &combination->shift);
} }
// =================== Exclude =================== // // =================== Exclude =================== //
inline void bgc_position2_exclude_fp32(const BgcPosition2FP32 * base, const BgcPosition2FP32 * excludand, BgcPosition2FP32 * difference) inline void bgc_fp32_position2_exclude(const BGC_FP32_Position2 * base, const BGC_FP32_Position2 * excludand, BGC_FP32_Position2 * difference)
{ {
BgcVector2FP32 relative_shift; BGC_FP32_Vector2 relative_shift;
bgc_vector2_subtract_fp32(&base->shift, &excludand->shift, &relative_shift); bgc_fp32_vector2_subtract(&base->shift, &excludand->shift, &relative_shift);
bgc_cotes_number_turn_vector_back_fp32(&excludand->turn, &relative_shift, &difference->shift); bgc_fp32_cotes_number_turn_vector_back(&excludand->turn, &relative_shift, &difference->shift);
bgc_cotes_number_exclude_fp32(&base->turn, &excludand->turn, &difference->turn); bgc_fp32_cotes_number_exclude(&base->turn, &excludand->turn, &difference->turn);
} }
inline void bgc_position2_exclude_fp64(const BgcPosition2FP64 * base, const BgcPosition2FP64 * excludand, BgcPosition2FP64 * difference) inline void bgc_fp64_position2_exclude(const BGC_FP64_Position2 * base, const BGC_FP64_Position2 * excludand, BGC_FP64_Position2 * difference)
{ {
BgcVector2FP64 relative_shift; BGC_FP64_Vector2 relative_shift;
bgc_vector2_subtract_fp64(&base->shift, &excludand->shift, &relative_shift); bgc_fp64_vector2_subtract(&base->shift, &excludand->shift, &relative_shift);
bgc_cotes_number_turn_vector_back_fp64(&excludand->turn, &relative_shift, &difference->shift); bgc_fp64_cotes_number_turn_vector_back(&excludand->turn, &relative_shift, &difference->shift);
bgc_cotes_number_exclude_fp64(&base->turn, &excludand->turn, &difference->turn); bgc_fp64_cotes_number_exclude(&base->turn, &excludand->turn, &difference->turn);
} }
// ============= Get Outward Affine ============== // // ============= Get Outward Affine ============== //
inline void bgc_position2_get_outward_affine_fp32(const BgcPosition2FP32 * position, BgcAffine2FP32 * outward_affine_map) inline void bgc_fp32_position2_get_outward_affine(const BGC_FP32_Position2 * position, BGC_FP32_Affine2 * outward_affine_map)
{ {
bgc_cotes_number_get_rotation_matrix_fp32(&position->turn, &outward_affine_map->distortion); bgc_fp32_cotes_number_get_rotation_matrix(&position->turn, &outward_affine_map->distortion);
bgc_vector2_copy_fp32(&position->shift, &outward_affine_map->shift); bgc_fp32_vector2_copy(&position->shift, &outward_affine_map->shift);
} }
inline void bgc_position2_get_outward_affine_fp64(const BgcPosition2FP64 * position, BgcAffine2FP64 * outward_affine_map) inline void bgc_fp64_position2_get_outward_affine(const BGC_FP64_Position2 * position, BGC_FP64_Affine2 * outward_affine_map)
{ {
bgc_cotes_number_get_rotation_matrix_fp64(&position->turn, &outward_affine_map->distortion); bgc_fp64_cotes_number_get_rotation_matrix(&position->turn, &outward_affine_map->distortion);
bgc_vector2_copy_fp64(&position->shift, &outward_affine_map->shift); bgc_fp64_vector2_copy(&position->shift, &outward_affine_map->shift);
} }
// ============== Get Inward Affine ============== // // ============== Get Inward Affine ============== //
inline void bgc_position2_get_inward_affine_fp32(const BgcPosition2FP32 * position, BgcAffine2FP32 * inward_affine_map) inline void bgc_fp32_position2_get_inward_affine(const BGC_FP32_Position2 * position, BGC_FP32_Affine2 * inward_affine_map)
{ {
bgc_cotes_number_get_reverse_matrix_fp32(&position->turn, &inward_affine_map->distortion); bgc_fp32_cotes_number_get_reverse_matrix(&position->turn, &inward_affine_map->distortion);
bgc_matrix2x2_get_right_product_fp32(&inward_affine_map->distortion, &position->shift, &inward_affine_map->shift); bgc_fp32_multiply_matrix2x2_by_vector2(&inward_affine_map->distortion, &position->shift, &inward_affine_map->shift);
bgc_vector2_make_opposite_fp32(&inward_affine_map->shift); bgc_fp32_vector2_revert(&inward_affine_map->shift);
} }
inline void bgc_position2_get_inward_affine_fp64(const BgcPosition2FP64 * position, BgcAffine2FP64 * inward_affine_map) inline void bgc_fp64_position2_get_inward_affine(const BGC_FP64_Position2 * position, BGC_FP64_Affine2 * inward_affine_map)
{ {
bgc_cotes_number_get_reverse_matrix_fp64(&position->turn, &inward_affine_map->distortion); bgc_fp64_cotes_number_get_reverse_matrix(&position->turn, &inward_affine_map->distortion);
bgc_matrix2x2_get_right_product_fp64(&inward_affine_map->distortion, &position->shift, &inward_affine_map->shift); bgc_fp64_multiply_matrix2x2_by_vector2(&inward_affine_map->distortion, &position->shift, &inward_affine_map->shift);
bgc_vector2_make_opposite_fp64(&inward_affine_map->shift); bgc_fp64_vector2_revert(&inward_affine_map->shift);
} }
// ========== Transform Point Outwards =========== // // ========== Transform Point Outwards =========== //
inline void bgc_position2_transform_point_outwards_fp32(const BgcPosition2FP32 * position, const BgcVector2FP32 * inner_point, BgcVector2FP32 * outer_point) inline void bgc_fp32_position2_transform_point_outwards(const BGC_FP32_Position2 * position, const BGC_FP32_Vector2 * inner_point, BGC_FP32_Vector2 * outer_point)
{ {
BgcVector2FP32 turned_point; BGC_FP32_Vector2 turned_point;
bgc_cotes_number_turn_vector_fp32(&position->turn, inner_point, &turned_point); bgc_fp32_cotes_number_turn_vector(&position->turn, inner_point, &turned_point);
bgc_vector2_add_fp32(&position->shift, &turned_point, outer_point); bgc_fp32_vector2_add(&position->shift, &turned_point, outer_point);
} }
inline void bgc_position2_transform_point_outwards_fp64(const BgcPosition2FP64 * position, const BgcVector2FP64 * inner_point, BgcVector2FP64 * outer_point) inline void bgc_fp64_position2_transform_point_outwards(const BGC_FP64_Position2 * position, const BGC_FP64_Vector2 * inner_point, BGC_FP64_Vector2 * outer_point)
{ {
BgcVector2FP64 turned_point; BGC_FP64_Vector2 turned_point;
bgc_cotes_number_turn_vector_fp64(&position->turn, inner_point, &turned_point); bgc_fp64_cotes_number_turn_vector(&position->turn, inner_point, &turned_point);
bgc_vector2_add_fp64(&position->shift, &turned_point, outer_point); bgc_fp64_vector2_add(&position->shift, &turned_point, outer_point);
} }
// =========== Transform Point Inwards =========== // // =========== Transform Point Inwards =========== //
inline void bgc_position2_transform_point_inwards_fp32(const BgcPosition2FP32 * position, const BgcVector2FP32 * outer_point, BgcVector2FP32 * inner_point) inline void bgc_fp32_position2_transform_point_inwards(const BGC_FP32_Position2 * position, const BGC_FP32_Vector2 * outer_point, BGC_FP32_Vector2 * inner_point)
{ {
BgcVector2FP32 relative_point; BGC_FP32_Vector2 relative_point;
bgc_vector2_subtract_fp32(outer_point, &position->shift, &relative_point); bgc_fp32_vector2_subtract(outer_point, &position->shift, &relative_point);
bgc_cotes_number_turn_vector_back_fp32(&position->turn, &relative_point, inner_point); bgc_fp32_cotes_number_turn_vector_back(&position->turn, &relative_point, inner_point);
} }
inline void bgc_position2_transform_point_inwards_fp64(const BgcPosition2FP64 * position, const BgcVector2FP64 * outer_point, BgcVector2FP64 * inner_point) inline void bgc_fp64_position2_transform_point_inwards(const BGC_FP64_Position2 * position, const BGC_FP64_Vector2 * outer_point, BGC_FP64_Vector2 * inner_point)
{ {
BgcVector2FP64 relative_point; BGC_FP64_Vector2 relative_point;
bgc_vector2_subtract_fp64(outer_point, &position->shift, &relative_point); bgc_fp64_vector2_subtract(outer_point, &position->shift, &relative_point);
bgc_cotes_number_turn_vector_back_fp64(&position->turn, &relative_point, inner_point); bgc_fp64_cotes_number_turn_vector_back(&position->turn, &relative_point, inner_point);
} }
// ========== Transform Vector Outwards ========== // // ========== Transform Vector Outwards ========== //
inline void bgc_position2_transform_vector_outwards_fp32(const BgcPosition2FP32 * position, const BgcVector2FP32 * inner_vector, BgcVector2FP32 * outer_vector) inline void bgc_fp32_position2_transform_vector_outwards(const BGC_FP32_Position2 * position, const BGC_FP32_Vector2 * inner_vector, BGC_FP32_Vector2 * outer_vector)
{ {
bgc_cotes_number_turn_vector_fp32(&position->turn, inner_vector, outer_vector); bgc_fp32_cotes_number_turn_vector(&position->turn, inner_vector, outer_vector);
} }
inline void bgc_position2_transform_vector_outwards_fp64(const BgcPosition2FP64 * position, const BgcVector2FP64 * inner_vector, BgcVector2FP64 * outer_vector) inline void bgc_fp64_position2_transform_vector_outwards(const BGC_FP64_Position2 * position, const BGC_FP64_Vector2 * inner_vector, BGC_FP64_Vector2 * outer_vector)
{ {
bgc_cotes_number_turn_vector_fp64(&position->turn, inner_vector, outer_vector); bgc_fp64_cotes_number_turn_vector(&position->turn, inner_vector, outer_vector);
} }
// ========== Transform Vector Inwards =========== // // ========== Transform Vector Inwards =========== //
inline void bgc_position2_transform_vector_inwards_fp32(const BgcPosition2FP32 * position, const BgcVector2FP32 * outer_vector, BgcVector2FP32 * inner_vector) inline void bgc_fp32_position2_transform_vector_inwards(const BGC_FP32_Position2 * position, const BGC_FP32_Vector2 * outer_vector, BGC_FP32_Vector2 * inner_vector)
{ {
bgc_cotes_number_turn_vector_back_fp32(&position->turn, outer_vector, inner_vector); bgc_fp32_cotes_number_turn_vector_back(&position->turn, outer_vector, inner_vector);
} }
inline void bgc_position2_transform_vector_inwards_fp64(const BgcPosition2FP64 * position, const BgcVector2FP64 * outer_vector, BgcVector2FP64 * inner_vector) inline void bgc_fp64_position2_transform_vector_inwards(const BGC_FP64_Position2 * position, const BGC_FP64_Vector2 * outer_vector, BGC_FP64_Vector2 * inner_vector)
{ {
bgc_cotes_number_turn_vector_back_fp64(&position->turn, outer_vector, inner_vector); bgc_fp64_cotes_number_turn_vector_back(&position->turn, outer_vector, inner_vector);
} }
#endif #endif

View file

@ -1,43 +1,49 @@
#include "position3.h" #include "position3.h"
extern inline void bgc_position3_reset_fp32(BgcPosition3FP32 * node); extern inline void bgc_fp32_position3_reset(BGC_FP32_Position3 * node);
extern inline void bgc_position3_reset_fp64(BgcPosition3FP64 * node); extern inline void bgc_fp64_position3_reset(BGC_FP64_Position3 * node);
extern inline void bgc_position3_make_fp32(const BgcVersorFP32 * turn, const BgcVector3FP32 * shift, BgcPosition3FP32 * position); extern inline void bgc_fp32_position3_make(const BGC_FP32_Versor * turn, const BGC_FP32_Vector3 * shift, BGC_FP32_Position3 * position);
extern inline void bgc_position3_make_fp64(const BgcVersorFP64 * turn, const BgcVector3FP64 * shift, BgcPosition3FP64 * position); extern inline void bgc_fp64_position3_make(const BGC_FP64_Versor * turn, const BGC_FP64_Vector3 * shift, BGC_FP64_Position3 * position);
extern inline void bgc_position3_copy_fp32(const BgcPosition3FP32 * source, BgcPosition3FP32 * destination); extern inline void bgc_fp32_position3_copy(const BGC_FP32_Position3 * source, BGC_FP32_Position3 * destination);
extern inline void bgc_position3_copy_fp64(const BgcPosition3FP64 * source, BgcPosition3FP64 * destination); extern inline void bgc_fp64_position3_copy(const BGC_FP64_Position3 * source, BGC_FP64_Position3 * destination);
extern inline void bgc_position3_convert_fp64_to_fp32(const BgcPosition3FP64 * source, BgcPosition3FP32 * destination); extern inline void bgc_fp32_position3_swap(BGC_FP32_Position3 * first, BGC_FP32_Position3 * second);
extern inline void bgc_position3_convert_fp32_to_fp64(const BgcPosition3FP32 * source, BgcPosition3FP64 * destination); extern inline void bgc_fp64_position3_swap(BGC_FP64_Position3 * first, BGC_FP64_Position3 * second);
extern inline void bgc_position3_invert_fp32(BgcPosition3FP32 * position); extern inline void bgc_fp64_position3_convert_to_fp32(const BGC_FP64_Position3 * source, BGC_FP32_Position3 * destination);
extern inline void bgc_position3_invert_fp64(BgcPosition3FP64 * position); extern inline void bgc_fp32_position3_convert_to_fp64(const BGC_FP32_Position3 * source, BGC_FP64_Position3 * destination);
extern inline void bgc_position3_get_inverse_fp32(const BgcPosition3FP32 * position, BgcPosition3FP32 * inverted); extern inline int bgc_fp32_position3_is_idle(const BGC_FP32_Position3 * position);
extern inline void bgc_position3_get_inverse_fp64(const BgcPosition3FP64 * position, BgcPosition3FP64 * inverted); extern inline int bgc_fp64_position3_is_idle(const BGC_FP64_Position3 * position);
extern inline void bgc_position3_combine_fp32(const BgcPosition3FP32 * first, const BgcPosition3FP32 * second, BgcPosition3FP32 * combination); extern inline void bgc_fp32_position3_invert(BGC_FP32_Position3 * position);
extern inline void bgc_position3_combine_fp64(const BgcPosition3FP64 * first, const BgcPosition3FP64 * second, BgcPosition3FP64 * combination); extern inline void bgc_fp64_position3_invert(BGC_FP64_Position3 * position);
extern inline void bgc_position3_exclude_fp32(const BgcPosition3FP32 * base, const BgcPosition3FP32 * excludant, BgcPosition3FP32 * difference); extern inline void bgc_fp32_position3_get_inverse(const BGC_FP32_Position3 * position, BGC_FP32_Position3 * inverted);
extern inline void bgc_position3_exclude_fp64(const BgcPosition3FP64 * base, const BgcPosition3FP64 * excludant, BgcPosition3FP64 * difference); extern inline void bgc_fp64_position3_get_inverse(const BGC_FP64_Position3 * position, BGC_FP64_Position3 * inverted);
extern inline void bgc_position3_get_outward_affine_fp32(const BgcPosition3FP32 * position, BgcAffine3FP32 * outward_affine_map); extern inline void bgc_fp32_position3_combine(const BGC_FP32_Position3 * first, const BGC_FP32_Position3 * second, BGC_FP32_Position3 * combination);
extern inline void bgc_position3_get_outward_affine_fp64(const BgcPosition3FP64 * position, BgcAffine3FP64 * outward_affine_map); extern inline void bgc_fp64_position3_combine(const BGC_FP64_Position3 * first, const BGC_FP64_Position3 * second, BGC_FP64_Position3 * combination);
extern inline void bgc_position3_get_inward_affine_fp32(const BgcPosition3FP32 * position, BgcAffine3FP32 * inward_affine_map); extern inline void bgc_fp32_position3_exclude(const BGC_FP32_Position3 * base, const BGC_FP32_Position3 * excludant, BGC_FP32_Position3 * difference);
extern inline void bgc_position3_get_inward_affine_fp64(const BgcPosition3FP64 * position, BgcAffine3FP64 * inward_affine_map); extern inline void bgc_fp64_position3_exclude(const BGC_FP64_Position3 * base, const BGC_FP64_Position3 * excludant, BGC_FP64_Position3 * difference);
extern inline void bgc_position3_transform_point_outwards_fp32(const BgcPosition3FP32 * position, const BgcVector3FP32 * inner_point, BgcVector3FP32 * outer_point); extern inline void bgc_fp32_position3_get_outward_affine(const BGC_FP32_Position3 * position, BGC_FP32_Affine3 * outward_affine_map);
extern inline void bgc_position3_transform_point_outwards_fp64(const BgcPosition3FP64 * position, const BgcVector3FP64 * inner_point, BgcVector3FP64 * outer_point); extern inline void bgc_fp64_position3_get_outward_affine(const BGC_FP64_Position3 * position, BGC_FP64_Affine3 * outward_affine_map);
extern inline void bgc_position3_transform_point_inwards_fp32(const BgcPosition3FP32 * position, const BgcVector3FP32 * outer_point, BgcVector3FP32 * inner_point); extern inline void bgc_fp32_position3_get_inward_affine(const BGC_FP32_Position3 * position, BGC_FP32_Affine3 * inward_affine_map);
extern inline void bgc_position3_transform_point_inwards_fp64(const BgcPosition3FP64 * position, const BgcVector3FP64 * outer_point, BgcVector3FP64 * inner_point); extern inline void bgc_fp64_position3_get_inward_affine(const BGC_FP64_Position3 * position, BGC_FP64_Affine3 * inward_affine_map);
extern inline void bgc_position3_transform_vector_outwards_fp32(const BgcPosition3FP32 * position, const BgcVector3FP32 * inner_vector, BgcVector3FP32 * outer_vector); extern inline void bgc_fp32_position3_transform_point_outwards(const BGC_FP32_Position3 * position, const BGC_FP32_Vector3 * inner_point, BGC_FP32_Vector3 * outer_point);
extern inline void bgc_position3_transform_vector_outwards_fp64(const BgcPosition3FP64 * position, const BgcVector3FP64 * inner_vector, BgcVector3FP64 * outer_vector); extern inline void bgc_fp64_position3_transform_point_outwards(const BGC_FP64_Position3 * position, const BGC_FP64_Vector3 * inner_point, BGC_FP64_Vector3 * outer_point);
extern inline void bgc_position3_transform_vector_inwards_fp32(const BgcPosition3FP32 * position, const BgcVector3FP32 * outer_vector, BgcVector3FP32 * inner_vector); extern inline void bgc_fp32_position3_transform_point_inwards(const BGC_FP32_Position3 * position, const BGC_FP32_Vector3 * outer_point, BGC_FP32_Vector3 * inner_point);
extern inline void bgc_position3_transform_vector_inwards_fp64(const BgcPosition3FP64 * position, const BgcVector3FP64 * outer_vector, BgcVector3FP64 * inner_vector); extern inline void bgc_fp64_position3_transform_point_inwards(const BGC_FP64_Position3 * position, const BGC_FP64_Vector3 * outer_point, BGC_FP64_Vector3 * inner_point);
extern inline void bgc_fp32_position3_transform_vector_outwards(const BGC_FP32_Position3 * position, const BGC_FP32_Vector3 * inner_vector, BGC_FP32_Vector3 * outer_vector);
extern inline void bgc_fp64_position3_transform_vector_outwards(const BGC_FP64_Position3 * position, const BGC_FP64_Vector3 * inner_vector, BGC_FP64_Vector3 * outer_vector);
extern inline void bgc_fp32_position3_transform_vector_inwards(const BGC_FP32_Position3 * position, const BGC_FP32_Vector3 * outer_vector, BGC_FP32_Vector3 * inner_vector);
extern inline void bgc_fp64_position3_transform_vector_inwards(const BGC_FP64_Position3 * position, const BGC_FP64_Vector3 * outer_vector, BGC_FP64_Vector3 * inner_vector);

View file

@ -8,225 +8,251 @@
// ==================== Types ==================== // // ==================== Types ==================== //
typedef struct { typedef struct {
BgcVersorFP32 turn; BGC_FP32_Versor turn;
BgcVector3FP32 shift; BGC_FP32_Vector3 shift;
} BgcPosition3FP32; } BGC_FP32_Position3;
typedef struct { typedef struct {
BgcVersorFP64 turn; BGC_FP64_Versor turn;
BgcVector3FP64 shift; BGC_FP64_Vector3 shift;
} BgcPosition3FP64; } BGC_FP64_Position3;
// ==================== Reset ==================== // // ==================== Reset ==================== //
inline void bgc_position3_reset_fp32(BgcPosition3FP32 * position) inline void bgc_fp32_position3_reset(BGC_FP32_Position3 * position)
{ {
bgc_versor_reset_fp32(&position->turn); bgc_fp32_versor_reset(&position->turn);
bgc_vector3_reset_fp32(&position->shift); bgc_fp32_vector3_reset(&position->shift);
} }
inline void bgc_position3_reset_fp64(BgcPosition3FP64 * position) inline void bgc_fp64_position3_reset(BGC_FP64_Position3 * position)
{ {
bgc_versor_reset_fp64(&position->turn); bgc_fp64_versor_reset(&position->turn);
bgc_vector3_reset_fp64(&position->shift); bgc_fp64_vector3_reset(&position->shift);
} }
// ==================== Make ===================== // // ==================== Make ===================== //
inline void bgc_position3_make_fp32(const BgcVersorFP32 * turn, const BgcVector3FP32 * shift, BgcPosition3FP32 * position) inline void bgc_fp32_position3_make(const BGC_FP32_Versor * turn, const BGC_FP32_Vector3 * shift, BGC_FP32_Position3 * position)
{ {
bgc_versor_copy_fp32(turn, &position->turn); bgc_fp32_versor_copy(turn, &position->turn);
bgc_vector3_copy_fp32(shift, &position->shift); bgc_fp32_vector3_copy(shift, &position->shift);
} }
inline void bgc_position3_make_fp64(const BgcVersorFP64 * turn, const BgcVector3FP64 * shift, BgcPosition3FP64 * position) inline void bgc_fp64_position3_make(const BGC_FP64_Versor * turn, const BGC_FP64_Vector3 * shift, BGC_FP64_Position3 * position)
{ {
bgc_versor_copy_fp64(turn, &position->turn); bgc_fp64_versor_copy(turn, &position->turn);
bgc_vector3_copy_fp64(shift, &position->shift); bgc_fp64_vector3_copy(shift, &position->shift);
} }
// ==================== Copy ===================== // // ==================== Copy ===================== //
inline void bgc_position3_copy_fp32(const BgcPosition3FP32 * source, BgcPosition3FP32 * destination) inline void bgc_fp32_position3_copy(const BGC_FP32_Position3 * source, BGC_FP32_Position3 * destination)
{ {
bgc_versor_copy_fp32(&source->turn, &destination->turn); bgc_fp32_versor_copy(&source->turn, &destination->turn);
bgc_vector3_copy_fp32(&source->shift, &destination->shift); bgc_fp32_vector3_copy(&source->shift, &destination->shift);
} }
inline void bgc_position3_copy_fp64(const BgcPosition3FP64 * source, BgcPosition3FP64 * destination) inline void bgc_fp64_position3_copy(const BGC_FP64_Position3 * source, BGC_FP64_Position3 * destination)
{ {
bgc_versor_copy_fp64(&source->turn, &destination->turn); bgc_fp64_versor_copy(&source->turn, &destination->turn);
bgc_vector3_copy_fp64(&source->shift, &destination->shift); bgc_fp64_vector3_copy(&source->shift, &destination->shift);
}
// ==================== Swap ===================== //
inline void bgc_fp32_position3_swap(BGC_FP32_Position3 * first, BGC_FP32_Position3 * second)
{
bgc_fp32_versor_swap(&first->turn, &second->turn);
bgc_fp32_vector3_swap(&first->shift, &second->shift);
}
inline void bgc_fp64_position3_swap(BGC_FP64_Position3 * first, BGC_FP64_Position3 * second)
{
bgc_fp64_versor_swap(&first->turn, &second->turn);
bgc_fp64_vector3_swap(&first->shift, &second->shift);
} }
// =================== Convert =================== // // =================== Convert =================== //
inline void bgc_position3_convert_fp64_to_fp32(const BgcPosition3FP64 * source, BgcPosition3FP32 * destination) inline void bgc_fp64_position3_convert_to_fp32(const BGC_FP64_Position3 * source, BGC_FP32_Position3 * destination)
{ {
bgc_versor_convert_fp64_to_fp32(&source->turn, &destination->turn); bgc_fp64_versor_convert_to_fp32(&source->turn, &destination->turn);
bgc_vector3_convert_fp64_to_fp32(&source->shift, &destination->shift); bgc_fp64_vector3_convert_to_fp32(&source->shift, &destination->shift);
} }
inline void bgc_position3_convert_fp32_to_fp64(const BgcPosition3FP32 * source, BgcPosition3FP64 * destination) inline void bgc_fp32_position3_convert_to_fp64(const BGC_FP32_Position3 * source, BGC_FP64_Position3 * destination)
{ {
bgc_versor_convert_fp32_to_fp64(&source->turn, &destination->turn); bgc_fp32_versor_convert_to_fp64(&source->turn, &destination->turn);
bgc_vector3_convert_fp32_to_fp64(&source->shift, &destination->shift); bgc_fp32_vector3_convert_to_fp64(&source->shift, &destination->shift);
}
// =================== Is Idle =================== //
inline int bgc_fp32_position3_is_idle(const BGC_FP32_Position3 * position)
{
return bgc_fp32_vector3_is_zero(&position->shift) && bgc_fp32_versor_is_idle(&position->turn);
}
inline int bgc_fp64_position3_is_idle(const BGC_FP64_Position3 * position)
{
return bgc_fp64_vector3_is_zero(&position->shift) && bgc_fp64_versor_is_idle(&position->turn);
} }
// =================== Invert ==================== // // =================== Invert ==================== //
inline void bgc_position3_invert_fp32(BgcPosition3FP32 * position) inline void bgc_fp32_position3_invert(BGC_FP32_Position3 * position)
{ {
bgc_versor_turn_vector_back_fp32(&position->turn, &position->shift, &position->shift); bgc_fp32_versor_turn_vector_back(&position->turn, &position->shift, &position->shift);
bgc_versor_invert_fp32(&position->turn); bgc_fp32_versor_revert(&position->turn);
bgc_vector3_make_opposite_fp32(&position->shift); bgc_fp32_vector3_revert(&position->shift);
} }
inline void bgc_position3_invert_fp64(BgcPosition3FP64 * position) inline void bgc_fp64_position3_invert(BGC_FP64_Position3 * position)
{ {
bgc_versor_turn_vector_back_fp64(&position->turn, &position->shift, &position->shift); bgc_fp64_versor_turn_vector_back(&position->turn, &position->shift, &position->shift);
bgc_versor_invert_fp64(&position->turn); bgc_fp64_versor_revert(&position->turn);
bgc_vector3_make_opposite_fp64(&position->shift); bgc_fp64_vector3_revert(&position->shift);
} }
// ================= Get Inverse ================= // // ================= Get Inverse ================= //
inline void bgc_position3_get_inverse_fp32(const BgcPosition3FP32 * position, BgcPosition3FP32 * inverted) inline void bgc_fp32_position3_get_inverse(const BGC_FP32_Position3 * position, BGC_FP32_Position3 * inverted)
{ {
bgc_versor_turn_vector_back_fp32(&position->turn, &position->shift, &inverted->shift); bgc_fp32_versor_turn_vector_back(&position->turn, &position->shift, &inverted->shift);
bgc_versor_get_inverse_fp32(&position->turn, &inverted->turn); bgc_fp32_versor_get_reverse(&position->turn, &inverted->turn);
bgc_vector3_make_opposite_fp32(&inverted->shift); bgc_fp32_vector3_revert(&inverted->shift);
} }
inline void bgc_position3_get_inverse_fp64(const BgcPosition3FP64 * position, BgcPosition3FP64 * inverted) inline void bgc_fp64_position3_get_inverse(const BGC_FP64_Position3 * position, BGC_FP64_Position3 * inverted)
{ {
bgc_versor_turn_vector_back_fp64(&position->turn, &position->shift, &inverted->shift); bgc_fp64_versor_turn_vector_back(&position->turn, &position->shift, &inverted->shift);
bgc_versor_get_inverse_fp64(&position->turn, &inverted->turn); bgc_fp64_versor_get_reverse(&position->turn, &inverted->turn);
bgc_vector3_make_opposite_fp64(&inverted->shift); bgc_fp64_vector3_revert(&inverted->shift);
} }
// =================== Combine =================== // // =================== Combine =================== //
inline void bgc_position3_combine_fp32(const BgcPosition3FP32 * first, const BgcPosition3FP32 * second, BgcPosition3FP32 * combination) inline void bgc_fp32_position3_combine(const BGC_FP32_Position3 * first, const BGC_FP32_Position3 * second, BGC_FP32_Position3 * combination)
{ {
BgcVector3FP32 relative_shift; BGC_FP32_Vector3 relative_shift;
bgc_versor_turn_vector_fp32(&second->turn, &first->shift, &relative_shift); bgc_fp32_versor_turn_vector(&second->turn, &first->shift, &relative_shift);
bgc_versor_combine_fp32(&first->turn, &second->turn, &combination->turn); bgc_fp32_versor_combine(&first->turn, &second->turn, &combination->turn);
bgc_vector3_add_fp32(&relative_shift, &second->shift, &combination->shift); bgc_fp32_vector3_add(&relative_shift, &second->shift, &combination->shift);
} }
inline void bgc_position3_combine_fp64(const BgcPosition3FP64 * first, const BgcPosition3FP64 * second, BgcPosition3FP64 * combination) inline void bgc_fp64_position3_combine(const BGC_FP64_Position3 * first, const BGC_FP64_Position3 * second, BGC_FP64_Position3 * combination)
{ {
BgcVector3FP64 relative_shift; BGC_FP64_Vector3 relative_shift;
bgc_versor_turn_vector_fp64(&second->turn, &first->shift, &relative_shift); bgc_fp64_versor_turn_vector(&second->turn, &first->shift, &relative_shift);
bgc_versor_combine_fp64(&first->turn, &second->turn, &combination->turn); bgc_fp64_versor_combine(&first->turn, &second->turn, &combination->turn);
bgc_vector3_add_fp64(&relative_shift, &second->shift, &combination->shift); bgc_fp64_vector3_add(&relative_shift, &second->shift, &combination->shift);
} }
// =================== Exclude =================== // // =================== Exclude =================== //
inline void bgc_position3_exclude_fp32(const BgcPosition3FP32 * base, const BgcPosition3FP32 * excludant, BgcPosition3FP32 * difference) inline void bgc_fp32_position3_exclude(const BGC_FP32_Position3 * base, const BGC_FP32_Position3 * excludant, BGC_FP32_Position3 * difference)
{ {
BgcVector3FP32 relative_shift; BGC_FP32_Vector3 relative_shift;
bgc_vector3_subtract_fp32(&base->shift, &excludant->shift, &relative_shift); bgc_fp32_vector3_subtract(&base->shift, &excludant->shift, &relative_shift);
bgc_versor_turn_vector_back_fp32(&excludant->turn, &relative_shift, &difference->shift); bgc_fp32_versor_turn_vector_back(&excludant->turn, &relative_shift, &difference->shift);
bgc_versor_exclude_fp32(&base->turn, &excludant->turn, &difference->turn); bgc_fp32_versor_exclude(&base->turn, &excludant->turn, &difference->turn);
} }
inline void bgc_position3_exclude_fp64(const BgcPosition3FP64 * base, const BgcPosition3FP64 * excludant, BgcPosition3FP64 * difference) inline void bgc_fp64_position3_exclude(const BGC_FP64_Position3 * base, const BGC_FP64_Position3 * excludant, BGC_FP64_Position3 * difference)
{ {
BgcVector3FP64 relative_shift; BGC_FP64_Vector3 relative_shift;
bgc_vector3_subtract_fp64(&base->shift, &excludant->shift, &relative_shift); bgc_fp64_vector3_subtract(&base->shift, &excludant->shift, &relative_shift);
bgc_versor_turn_vector_back_fp64(&excludant->turn, &relative_shift, &difference->shift); bgc_fp64_versor_turn_vector_back(&excludant->turn, &relative_shift, &difference->shift);
bgc_versor_exclude_fp64(&base->turn, &excludant->turn, &difference->turn); bgc_fp64_versor_exclude(&base->turn, &excludant->turn, &difference->turn);
} }
// ============= Get Outward Affine ============== // // ============= Get Outward Affine ============== //
inline void bgc_position3_get_outward_affine_fp32(const BgcPosition3FP32 * position, BgcAffine3FP32 * outward_affine_map) inline void bgc_fp32_position3_get_outward_affine(const BGC_FP32_Position3 * position, BGC_FP32_Affine3 * outward_affine_map)
{ {
bgc_versor_get_rotation_matrix_fp32(&position->turn, &outward_affine_map->distortion); bgc_fp32_versor_get_rotation_matrix(&position->turn, &outward_affine_map->distortion);
bgc_vector3_copy_fp32(&position->shift, &outward_affine_map->shift); bgc_fp32_vector3_copy(&position->shift, &outward_affine_map->shift);
} }
inline void bgc_position3_get_outward_affine_fp64(const BgcPosition3FP64 * position, BgcAffine3FP64 * outward_affine_map) inline void bgc_fp64_position3_get_outward_affine(const BGC_FP64_Position3 * position, BGC_FP64_Affine3 * outward_affine_map)
{ {
bgc_versor_get_rotation_matrix_fp64(&position->turn, &outward_affine_map->distortion); bgc_fp64_versor_get_rotation_matrix(&position->turn, &outward_affine_map->distortion);
bgc_vector3_copy_fp64(&position->shift, &outward_affine_map->shift); bgc_fp64_vector3_copy(&position->shift, &outward_affine_map->shift);
} }
// ============== Get Inward Affine ============== // // ============== Get Inward Affine ============== //
inline void bgc_position3_get_inward_affine_fp32(const BgcPosition3FP32 * position, BgcAffine3FP32 * inward_affine_map) inline void bgc_fp32_position3_get_inward_affine(const BGC_FP32_Position3 * position, BGC_FP32_Affine3 * inward_affine_map)
{ {
bgc_versor_get_reverse_matrix_fp32(&position->turn, &inward_affine_map->distortion); bgc_fp32_versor_get_reverse_matrix(&position->turn, &inward_affine_map->distortion);
bgc_matrix3x3_get_right_product_fp32(&inward_affine_map->distortion, &position->shift, &inward_affine_map->shift); bgc_fp32_multiply_matrix3x3_by_vector3(&inward_affine_map->distortion, &position->shift, &inward_affine_map->shift);
bgc_vector3_make_opposite_fp32(&inward_affine_map->shift); bgc_fp32_vector3_revert(&inward_affine_map->shift);
} }
inline void bgc_position3_get_inward_affine_fp64(const BgcPosition3FP64 * position, BgcAffine3FP64 * inward_affine_map) inline void bgc_fp64_position3_get_inward_affine(const BGC_FP64_Position3 * position, BGC_FP64_Affine3 * inward_affine_map)
{ {
bgc_versor_get_reverse_matrix_fp64(&position->turn, &inward_affine_map->distortion); bgc_fp64_versor_get_reverse_matrix(&position->turn, &inward_affine_map->distortion);
bgc_matrix3x3_get_right_product_fp64(&inward_affine_map->distortion, &position->shift, &inward_affine_map->shift); bgc_fp64_multiply_matrix3x3_by_vector3(&inward_affine_map->distortion, &position->shift, &inward_affine_map->shift);
bgc_vector3_make_opposite_fp64(&inward_affine_map->shift); bgc_fp64_vector3_revert(&inward_affine_map->shift);
} }
// ========== Transform Point Outwards =========== // // ========== Transform Point Outwards =========== //
inline void bgc_position3_transform_point_outwards_fp32(const BgcPosition3FP32 * position, const BgcVector3FP32 * inner_point, BgcVector3FP32 * outer_point) inline void bgc_fp32_position3_transform_point_outwards(const BGC_FP32_Position3 * position, const BGC_FP32_Vector3 * inner_point, BGC_FP32_Vector3 * outer_point)
{ {
BgcVector3FP32 turned_point; BGC_FP32_Vector3 turned_point;
bgc_versor_turn_vector_fp32(&position->turn, inner_point, &turned_point); bgc_fp32_versor_turn_vector(&position->turn, inner_point, &turned_point);
bgc_vector3_add_fp32(&position->shift, &turned_point, outer_point); bgc_fp32_vector3_add(&position->shift, &turned_point, outer_point);
} }
inline void bgc_position3_transform_point_outwards_fp64(const BgcPosition3FP64 * position, const BgcVector3FP64 * inner_point, BgcVector3FP64 * outer_point) inline void bgc_fp64_position3_transform_point_outwards(const BGC_FP64_Position3 * position, const BGC_FP64_Vector3 * inner_point, BGC_FP64_Vector3 * outer_point)
{ {
BgcVector3FP64 turned_point; BGC_FP64_Vector3 turned_point;
bgc_versor_turn_vector_fp64(&position->turn, inner_point, &turned_point); bgc_fp64_versor_turn_vector(&position->turn, inner_point, &turned_point);
bgc_vector3_add_fp64(&position->shift, &turned_point, outer_point); bgc_fp64_vector3_add(&position->shift, &turned_point, outer_point);
} }
// =========== Transform Point Inwards =========== // // =========== Transform Point Inwards =========== //
inline void bgc_position3_transform_point_inwards_fp32(const BgcPosition3FP32 * position, const BgcVector3FP32 * outer_point, BgcVector3FP32 * inner_point) inline void bgc_fp32_position3_transform_point_inwards(const BGC_FP32_Position3 * position, const BGC_FP32_Vector3 * outer_point, BGC_FP32_Vector3 * inner_point)
{ {
BgcVector3FP32 relative_point; BGC_FP32_Vector3 relative_point;
bgc_vector3_subtract_fp32(outer_point, &position->shift, &relative_point); bgc_fp32_vector3_subtract(outer_point, &position->shift, &relative_point);
bgc_versor_turn_vector_back_fp32(&position->turn, &relative_point, inner_point); bgc_fp32_versor_turn_vector_back(&position->turn, &relative_point, inner_point);
} }
inline void bgc_position3_transform_point_inwards_fp64(const BgcPosition3FP64 * position, const BgcVector3FP64 * outer_point, BgcVector3FP64 * inner_point) inline void bgc_fp64_position3_transform_point_inwards(const BGC_FP64_Position3 * position, const BGC_FP64_Vector3 * outer_point, BGC_FP64_Vector3 * inner_point)
{ {
BgcVector3FP64 relative_point; BGC_FP64_Vector3 relative_point;
bgc_vector3_subtract_fp64(outer_point, &position->shift, &relative_point); bgc_fp64_vector3_subtract(outer_point, &position->shift, &relative_point);
bgc_versor_turn_vector_back_fp64(&position->turn, &relative_point, inner_point); bgc_fp64_versor_turn_vector_back(&position->turn, &relative_point, inner_point);
} }
// ========== Transform Vector Outwards ========== // // ========== Transform Vector Outwards ========== //
inline void bgc_position3_transform_vector_outwards_fp32(const BgcPosition3FP32 * position, const BgcVector3FP32 * inner_vector, BgcVector3FP32 * outer_vector) inline void bgc_fp32_position3_transform_vector_outwards(const BGC_FP32_Position3 * position, const BGC_FP32_Vector3 * inner_vector, BGC_FP32_Vector3 * outer_vector)
{ {
bgc_versor_turn_vector_fp32(&position->turn, inner_vector, outer_vector); bgc_fp32_versor_turn_vector(&position->turn, inner_vector, outer_vector);
} }
inline void bgc_position3_transform_vector_outwards_fp64(const BgcPosition3FP64 * position, const BgcVector3FP64 * inner_vector, BgcVector3FP64 * outer_vector) inline void bgc_fp64_position3_transform_vector_outwards(const BGC_FP64_Position3 * position, const BGC_FP64_Vector3 * inner_vector, BGC_FP64_Vector3 * outer_vector)
{ {
bgc_versor_turn_vector_fp64(&position->turn, inner_vector, outer_vector); bgc_fp64_versor_turn_vector(&position->turn, inner_vector, outer_vector);
} }
// ========== Transform Vector Inwards =========== // // ========== Transform Vector Inwards =========== //
inline void bgc_position3_transform_vector_inwards_fp32(const BgcPosition3FP32 * position, const BgcVector3FP32 * outer_vector, BgcVector3FP32 * inner_vector) inline void bgc_fp32_position3_transform_vector_inwards(const BGC_FP32_Position3 * position, const BGC_FP32_Vector3 * outer_vector, BGC_FP32_Vector3 * inner_vector)
{ {
bgc_versor_turn_vector_back_fp32(&position->turn, outer_vector, inner_vector); bgc_fp32_versor_turn_vector_back(&position->turn, outer_vector, inner_vector);
} }
inline void bgc_position3_transform_vector_inwards_fp64(const BgcPosition3FP64 * position, const BgcVector3FP64 * outer_vector, BgcVector3FP64 * inner_vector) inline void bgc_fp64_position3_transform_vector_inwards(const BGC_FP64_Position3 * position, const BGC_FP64_Vector3 * outer_vector, BGC_FP64_Vector3 * inner_vector)
{ {
bgc_versor_turn_vector_back_fp64(&position->turn, outer_vector, inner_vector); bgc_fp64_versor_turn_vector_back(&position->turn, outer_vector, inner_vector);
} }
#endif // _BGC_POSITION_H_INCLUDED_ #endif // _BGC_POSITION_H_INCLUDED_

View file

@ -1,105 +1,105 @@
#include <math.h> #include <math.h>
#include "quaternion.h" #include "quaternion.h"
extern inline void bgc_quaternion_reset_fp32(BgcQuaternionFP32* quaternion); extern inline void bgc_fp32_quaternion_reset(BGC_FP32_Quaternion* quaternion);
extern inline void bgc_quaternion_reset_fp64(BgcQuaternionFP64* quaternion); extern inline void bgc_fp64_quaternion_reset(BGC_FP64_Quaternion* quaternion);
extern inline void bgc_quaternion_make_unit_fp32(BgcQuaternionFP32* quaternion); extern inline void bgc_fp32_quaternion_make_unit(BGC_FP32_Quaternion* quaternion);
extern inline void bgc_quaternion_make_unit_fp64(BgcQuaternionFP64* quaternion); extern inline void bgc_fp64_quaternion_make_unit(BGC_FP64_Quaternion* quaternion);
extern inline void bgc_quaternion_set_values_fp32(const float s0, const float x1, const float x2, const float x3, BgcQuaternionFP32* quaternion); extern inline void bgc_fp32_quaternion_make(const float s0, const float x1, const float x2, const float x3, BGC_FP32_Quaternion* quaternion);
extern inline void bgc_quaternion_set_values_fp64(const double s0, const double x1, const double x2, const double x3, BgcQuaternionFP64* quaternion); extern inline void bgc_fp64_quaternion_make(const double s0, const double x1, const double x2, const double x3, BGC_FP64_Quaternion* quaternion);
extern inline float bgc_quaternion_get_square_modulus_fp32(const BgcQuaternionFP32* quaternion); extern inline float bgc_fp32_quaternion_get_square_modulus(const BGC_FP32_Quaternion* quaternion);
extern inline double bgc_quaternion_get_square_modulus_fp64(const BgcQuaternionFP64* quaternion); extern inline double bgc_fp64_quaternion_get_square_modulus(const BGC_FP64_Quaternion* quaternion);
extern inline float bgc_quaternion_get_modulus_fp32(const BgcQuaternionFP32* quaternion); extern inline float bgc_fp32_quaternion_get_modulus(const BGC_FP32_Quaternion* quaternion);
extern inline double bgc_quaternion_get_modulus_fp64(const BgcQuaternionFP64* quaternion); extern inline double bgc_fp64_quaternion_get_modulus(const BGC_FP64_Quaternion* quaternion);
extern inline int bgc_quaternion_is_zero_fp32(const BgcQuaternionFP32* quaternion); extern inline int bgc_fp32_quaternion_is_zero(const BGC_FP32_Quaternion* quaternion);
extern inline int bgc_quaternion_is_zero_fp64(const BgcQuaternionFP64* quaternion); extern inline int bgc_fp64_quaternion_is_zero(const BGC_FP64_Quaternion* quaternion);
extern inline int bgc_quaternion_is_unit_fp32(const BgcQuaternionFP32* quaternion); extern inline int bgc_fp32_quaternion_is_unit(const BGC_FP32_Quaternion* quaternion);
extern inline int bgc_quaternion_is_unit_fp64(const BgcQuaternionFP64* quaternion); extern inline int bgc_fp64_quaternion_is_unit(const BGC_FP64_Quaternion* quaternion);
extern inline void bgc_quaternion_copy_fp32(const BgcQuaternionFP32* source, BgcQuaternionFP32* destination); extern inline void bgc_fp32_quaternion_copy(const BGC_FP32_Quaternion* source, BGC_FP32_Quaternion* destination);
extern inline void bgc_quaternion_copy_fp64(const BgcQuaternionFP64* source, BgcQuaternionFP64* destination); extern inline void bgc_fp64_quaternion_copy(const BGC_FP64_Quaternion* source, BGC_FP64_Quaternion* destination);
extern inline void bgc_quaternion_swap_fp32(BgcQuaternionFP32* quarternion1, BgcQuaternionFP32* quarternion2); extern inline void bgc_fp32_quaternion_swap(BGC_FP32_Quaternion* quarternion1, BGC_FP32_Quaternion* quarternion2);
extern inline void bgc_quaternion_swap_fp64(BgcQuaternionFP64* quarternion1, BgcQuaternionFP64* quarternion2); extern inline void bgc_fp64_quaternion_swap(BGC_FP64_Quaternion* quarternion1, BGC_FP64_Quaternion* quarternion2);
extern inline void bgc_quaternion_convert_fp64_to_fp32(const BgcQuaternionFP64* source, BgcQuaternionFP32* destination); extern inline void bgc_fp64_quaternion_convert_to_fp32(const BGC_FP64_Quaternion* source, BGC_FP32_Quaternion* destination);
extern inline void bgc_quaternion_convert_fp32_to_fp64(const BgcQuaternionFP32* source, BgcQuaternionFP64* destination); extern inline void bgc_fp32_quaternion_convert_to_fp64(const BGC_FP32_Quaternion* source, BGC_FP64_Quaternion* destination);
extern inline void bgc_quaternion_add_fp32(const BgcQuaternionFP32* quaternion1, const BgcQuaternionFP32* quaternion2, BgcQuaternionFP32* sum); extern inline void bgc_fp32_quaternion_add(const BGC_FP32_Quaternion* quaternion1, const BGC_FP32_Quaternion* quaternion2, BGC_FP32_Quaternion* sum);
extern inline void bgc_quaternion_add_fp64(const BgcQuaternionFP64* quaternion1, const BgcQuaternionFP64* quaternion2, BgcQuaternionFP64* sum); extern inline void bgc_fp64_quaternion_add(const BGC_FP64_Quaternion* quaternion1, const BGC_FP64_Quaternion* quaternion2, BGC_FP64_Quaternion* sum);
extern inline void bgc_quaternion_add_scaled_fp32(const BgcQuaternionFP32* basic_quaternion, const BgcQuaternionFP32* scalable_quaternion, const float scale, BgcQuaternionFP32* sum); extern inline void bgc_fp32_quaternion_add_scaled(const BGC_FP32_Quaternion* basic_quaternion, const BGC_FP32_Quaternion* scalable_quaternion, const float scale, BGC_FP32_Quaternion* sum);
extern inline void bgc_quaternion_add_scaled_fp64(const BgcQuaternionFP64* basic_quaternion, const BgcQuaternionFP64* scalable_quaternion, const double scale, BgcQuaternionFP64* sum); extern inline void bgc_fp64_quaternion_add_scaled(const BGC_FP64_Quaternion* basic_quaternion, const BGC_FP64_Quaternion* scalable_quaternion, const double scale, BGC_FP64_Quaternion* sum);
extern inline void bgc_quaternion_subtract_fp32(const BgcQuaternionFP32* minuend, const BgcQuaternionFP32* subtrahend, BgcQuaternionFP32* difference); extern inline void bgc_fp32_quaternion_subtract(const BGC_FP32_Quaternion* minuend, const BGC_FP32_Quaternion* subtrahend, BGC_FP32_Quaternion* difference);
extern inline void bgc_quaternion_subtract_fp64(const BgcQuaternionFP64* minuend, const BgcQuaternionFP64* subtrahend, BgcQuaternionFP64* difference); extern inline void bgc_fp64_quaternion_subtract(const BGC_FP64_Quaternion* minuend, const BGC_FP64_Quaternion* subtrahend, BGC_FP64_Quaternion* difference);
extern inline void bgc_quaternion_multiply_fp32(const BgcQuaternionFP32* left, const BgcQuaternionFP32* right, BgcQuaternionFP32* product); extern inline void bgc_fp32_quaternion_get_product(const BGC_FP32_Quaternion* left, const BGC_FP32_Quaternion* right, BGC_FP32_Quaternion* product);
extern inline void bgc_quaternion_multiply_fp64(const BgcQuaternionFP64* left, const BgcQuaternionFP64* right, BgcQuaternionFP64* product); extern inline void bgc_fp64_quaternion_get_product(const BGC_FP64_Quaternion* left, const BGC_FP64_Quaternion* right, BGC_FP64_Quaternion* product);
extern inline void bgc_quaternion_multiply_by_number_fp32(const BgcQuaternionFP32* multiplicand, const float multipier, BgcQuaternionFP32* product); extern inline void bgc_fp32_quaternion_multiply(const BGC_FP32_Quaternion* multiplicand, const float multipier, BGC_FP32_Quaternion* product);
extern inline void bgc_quaternion_multiply_by_number_fp64(const BgcQuaternionFP64* multiplicand, const double multipier, BgcQuaternionFP64* product); extern inline void bgc_fp64_quaternion_multiply(const BGC_FP64_Quaternion* multiplicand, const double multipier, BGC_FP64_Quaternion* product);
extern inline int bgc_quaternion_divide_fp32(const BgcQuaternionFP32* divident, const BgcQuaternionFP32* divisor, BgcQuaternionFP32* quotient); extern inline int bgc_fp32_quaternion_get_ratio(const BGC_FP32_Quaternion* divident, const BGC_FP32_Quaternion* divisor, BGC_FP32_Quaternion* quotient);
extern inline int bgc_quaternion_divide_fp64(const BgcQuaternionFP64* divident, const BgcQuaternionFP64* divisor, BgcQuaternionFP64* quotient); extern inline int bgc_fp64_quaternion_get_ratio(const BGC_FP64_Quaternion* divident, const BGC_FP64_Quaternion* divisor, BGC_FP64_Quaternion* quotient);
extern inline void bgc_quaternion_divide_by_number_fp32(const BgcQuaternionFP32* dividend, const float divisor, BgcQuaternionFP32* quotient); extern inline void bgc_fp32_quaternion_divide(const BGC_FP32_Quaternion* dividend, const float divisor, BGC_FP32_Quaternion* quotient);
extern inline void bgc_quaternion_divide_by_number_fp64(const BgcQuaternionFP64* dividend, const double divisor, BgcQuaternionFP64* quotient); extern inline void bgc_fp64_quaternion_divide(const BGC_FP64_Quaternion* dividend, const double divisor, BGC_FP64_Quaternion* quotient);
extern inline void bgc_quaternion_get_mean_of_two_fp32(const BgcQuaternionFP32* vector1, const BgcQuaternionFP32* vector2, BgcQuaternionFP32* mean); extern inline void bgc_fp32_quaternion_get_mean2(const BGC_FP32_Quaternion* vector1, const BGC_FP32_Quaternion* vector2, BGC_FP32_Quaternion* mean);
extern inline void bgc_quaternion_get_mean_of_two_fp64(const BgcQuaternionFP64* vector1, const BgcQuaternionFP64* vector2, BgcQuaternionFP64* mean); extern inline void bgc_fp64_quaternion_get_mean2(const BGC_FP64_Quaternion* vector1, const BGC_FP64_Quaternion* vector2, BGC_FP64_Quaternion* mean);
extern inline void bgc_quaternion_get_mean_of_three_fp32(const BgcQuaternionFP32* vector1, const BgcQuaternionFP32* vector2, const BgcQuaternionFP32* vector3, BgcQuaternionFP32* mean); extern inline void bgc_fp32_quaternion_get_mean3(const BGC_FP32_Quaternion* vector1, const BGC_FP32_Quaternion* vector2, const BGC_FP32_Quaternion* vector3, BGC_FP32_Quaternion* mean);
extern inline void bgc_quaternion_get_mean_of_three_fp64(const BgcQuaternionFP64* vector1, const BgcQuaternionFP64* vector2, const BgcQuaternionFP64* vector3, BgcQuaternionFP64* mean); extern inline void bgc_fp64_quaternion_get_mean3(const BGC_FP64_Quaternion* vector1, const BGC_FP64_Quaternion* vector2, const BGC_FP64_Quaternion* vector3, BGC_FP64_Quaternion* mean);
extern inline void bgc_quaternion_interpolate_fp32(const BgcQuaternionFP32* vector1, const BgcQuaternionFP32* vector2, const float phase, BgcQuaternionFP32* interpolation); extern inline void bgc_fp32_quaternion_interpolate(const BGC_FP32_Quaternion* vector1, const BGC_FP32_Quaternion* vector2, const float phase, BGC_FP32_Quaternion* interpolation);
extern inline void bgc_quaternion_interpolate_fp64(const BgcQuaternionFP64* vector1, const BgcQuaternionFP64* vector2, const double phase, BgcQuaternionFP64* interpolation); extern inline void bgc_fp64_quaternion_interpolate(const BGC_FP64_Quaternion* vector1, const BGC_FP64_Quaternion* vector2, const double phase, BGC_FP64_Quaternion* interpolation);
extern inline void bgc_quaternion_conjugate_fp32(BgcQuaternionFP32* quaternion); extern inline void bgc_fp32_quaternion_conjugate(BGC_FP32_Quaternion* quaternion);
extern inline void bgc_quaternion_conjugate_fp64(BgcQuaternionFP64* quaternion); extern inline void bgc_fp64_quaternion_conjugate(BGC_FP64_Quaternion* quaternion);
extern inline void bgc_quaternion_get_conjugate_fp32(const BgcQuaternionFP32* quaternion, BgcQuaternionFP32* conjugate); extern inline void bgc_fp32_quaternion_get_conjugate(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Quaternion* conjugate);
extern inline void bgc_quaternion_get_conjugate_fp64(const BgcQuaternionFP64* quaternion, BgcQuaternionFP64* conjugate); extern inline void bgc_fp64_quaternion_get_conjugate(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Quaternion* conjugate);
extern inline void bgc_quaternion_make_opposite_fp32(BgcQuaternionFP32* quaternion); extern inline void bgc_fp32_quaternion_revert(BGC_FP32_Quaternion* quaternion);
extern inline void bgc_quaternion_make_opposite_fp64(BgcQuaternionFP64* quaternion); extern inline void bgc_fp64_quaternion_revert(BGC_FP64_Quaternion* quaternion);
extern inline void bgc_quaternion_get_opposite_fp32(const BgcQuaternionFP32* quaternion, BgcQuaternionFP32* opposite); extern inline void bgc_fp32_quaternion_get_reverse(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Quaternion* opposite);
extern inline void bgc_quaternion_get_opposite_fp64(const BgcQuaternionFP64* quaternion, BgcQuaternionFP64* opposite); extern inline void bgc_fp64_quaternion_get_reverse(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Quaternion* opposite);
extern inline int bgc_quaternion_invert_fp32(BgcQuaternionFP32* quaternion); extern inline int bgc_fp32_quaternion_invert(BGC_FP32_Quaternion* quaternion);
extern inline int bgc_quaternion_invert_fp64(BgcQuaternionFP64* quaternion); extern inline int bgc_fp64_quaternion_invert(BGC_FP64_Quaternion* quaternion);
extern inline int bgc_quaternion_get_inverse_fp32(const BgcQuaternionFP32* quaternion, BgcQuaternionFP32* inverse); extern inline int bgc_fp32_quaternion_get_inverse(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Quaternion* inverse);
extern inline int bgc_quaternion_get_inverse_fp64(const BgcQuaternionFP64* quaternion, BgcQuaternionFP64* inverse); extern inline int bgc_fp64_quaternion_get_inverse(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Quaternion* inverse);
extern inline int bgc_quaternion_normalize_fp32(BgcQuaternionFP32* quaternion); extern inline int bgc_fp32_quaternion_normalize(BGC_FP32_Quaternion* quaternion);
extern inline int bgc_quaternion_normalize_fp64(BgcQuaternionFP64* quaternion); extern inline int bgc_fp64_quaternion_normalize(BGC_FP64_Quaternion* quaternion);
extern inline int bgc_quaternion_get_normalized_fp32(const BgcQuaternionFP32* quaternion, BgcQuaternionFP32* normalized); extern inline int bgc_fp32_quaternion_get_normalized(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Quaternion* normalized);
extern inline int bgc_quaternion_get_normalized_fp64(const BgcQuaternionFP64* quaternion, BgcQuaternionFP64* normalized); extern inline int bgc_fp64_quaternion_get_normalized(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Quaternion* normalized);
extern inline int bgc_quaternion_get_rotation_matrix_fp32(const BgcQuaternionFP32* quaternion, BgcMatrix3x3FP32* rotation); extern inline int bgc_fp32_quaternion_get_rotation_matrix(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Matrix3x3* rotation);
extern inline int bgc_quaternion_get_rotation_matrix_fp64(const BgcQuaternionFP64* quaternion, BgcMatrix3x3FP64* rotation); extern inline int bgc_fp64_quaternion_get_rotation_matrix(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Matrix3x3* rotation);
extern inline int bgc_quaternion_get_reverse_matrix_fp32(const BgcQuaternionFP32* quaternion, BgcMatrix3x3FP32* reverse); extern inline int bgc_fp32_quaternion_get_reverse_matrix(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Matrix3x3* reverse);
extern inline int bgc_quaternion_get_reverse_matrix_fp64(const BgcQuaternionFP64* quaternion, BgcMatrix3x3FP64* reverse); extern inline int bgc_fp64_quaternion_get_reverse_matrix(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Matrix3x3* reverse);
extern inline int bgc_quaternion_get_both_matrices_fp32(const BgcQuaternionFP32* quaternion, BgcMatrix3x3FP32* rotation, BgcMatrix3x3FP32* reverse); extern inline int bgc_fp32_quaternion_get_both_matrices(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Matrix3x3* rotation, BGC_FP32_Matrix3x3* reverse);
extern inline int bgc_quaternion_get_both_matrices_fp64(const BgcQuaternionFP64* quaternion, BgcMatrix3x3FP64* rotation, BgcMatrix3x3FP64* reverse); extern inline int bgc_fp64_quaternion_get_both_matrices(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Matrix3x3* rotation, BGC_FP64_Matrix3x3* reverse);
extern inline int bgc_quaternion_are_close_fp32(const BgcQuaternionFP32* quaternion1, const BgcQuaternionFP32* quaternion2); extern inline int bgc_fp32_quaternion_are_close(const BGC_FP32_Quaternion* quaternion1, const BGC_FP32_Quaternion* quaternion2);
extern inline int bgc_quaternion_are_close_fp32(const BgcQuaternionFP32* quaternion1, const BgcQuaternionFP32* quaternion2); extern inline int bgc_fp64_quaternion_are_close(const BGC_FP64_Quaternion* quaternion1, const BGC_FP64_Quaternion* quaternion2);
// =============== Get Exponation =============== // // =============== Get Exponation =============== //
int bgc_quaternion_get_exponation_fp32(const BgcQuaternionFP32* base, const float exponent, BgcQuaternionFP32* power) int bgc_fp32_quaternion_get_exponation(const BGC_FP32_Quaternion* base, const float exponent, BGC_FP32_Quaternion* power)
{ {
const float s0s0 = base->s0 * base->s0; const float s0s0 = base->s0 * base->s0;
const float x1x1 = base->x1 * base->x1; const float x1x1 = base->x1 * base->x1;
@ -109,12 +109,12 @@ int bgc_quaternion_get_exponation_fp32(const BgcQuaternionFP32* base, const floa
const float square_vector = x1x1 + (x2x2 + x3x3); const float square_vector = x1x1 + (x2x2 + x3x3);
const float square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3); const float square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
// square_modulus != square_modulus means checking for NaN value at square_modulus // isnan(square_modulus) means checking for NaN value at square_modulus
if (square_modulus != square_modulus) { if (isnan(square_modulus)) {
return 0; return 0;
} }
if (square_vector <= BGC_SQUARE_EPSYLON_FP32) { if (square_vector <= BGC_FP32_SQUARE_EPSYLON) {
if (base->s0 < 0.0f) { if (base->s0 < 0.0f) {
return 0; return 0;
} }
@ -140,7 +140,7 @@ int bgc_quaternion_get_exponation_fp32(const BgcQuaternionFP32* base, const floa
return 1; return 1;
} }
int bgc_quaternion_get_exponation_fp64(const BgcQuaternionFP64* base, const double exponent, BgcQuaternionFP64* power) int bgc_fp64_quaternion_get_exponation(const BGC_FP64_Quaternion* base, const double exponent, BGC_FP64_Quaternion* power)
{ {
const double s0s0 = base->s0 * base->s0; const double s0s0 = base->s0 * base->s0;
const double x1x1 = base->x1 * base->x1; const double x1x1 = base->x1 * base->x1;
@ -150,12 +150,12 @@ int bgc_quaternion_get_exponation_fp64(const BgcQuaternionFP64* base, const doub
const double square_vector = x1x1 + (x2x2 + x3x3); const double square_vector = x1x1 + (x2x2 + x3x3);
const double square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3); const double square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
// square_modulus != square_modulus means checking for NaN value at square_modulus // isnan(square_modulus) means checking for NaN value at square_modulus
if (square_modulus != square_modulus) { if (isnan(square_modulus)) {
return 0; return 0;
} }
if (square_vector <= BGC_SQUARE_EPSYLON_FP64) { if (square_vector <= BGC_FP64_SQUARE_EPSYLON) {
if (base->s0 < 0.0) { if (base->s0 < 0.0) {
return 0; return 0;
} }

View file

@ -9,15 +9,15 @@
typedef struct { typedef struct {
float s0, x1, x2, x3; float s0, x1, x2, x3;
} BgcQuaternionFP32; } BGC_FP32_Quaternion;
typedef struct { typedef struct {
double s0, x1, x2, x3; double s0, x1, x2, x3;
} BgcQuaternionFP64; } BGC_FP64_Quaternion;
// ==================== Reset =================== // // ==================== Reset =================== //
inline void bgc_quaternion_reset_fp32(BgcQuaternionFP32 * quaternion) inline void bgc_fp32_quaternion_reset(BGC_FP32_Quaternion * quaternion)
{ {
quaternion->s0 = 0.0f; quaternion->s0 = 0.0f;
quaternion->x1 = 0.0f; quaternion->x1 = 0.0f;
@ -25,7 +25,7 @@ inline void bgc_quaternion_reset_fp32(BgcQuaternionFP32 * quaternion)
quaternion->x3 = 0.0f; quaternion->x3 = 0.0f;
} }
inline void bgc_quaternion_reset_fp64(BgcQuaternionFP64 * quaternion) inline void bgc_fp64_quaternion_reset(BGC_FP64_Quaternion * quaternion)
{ {
quaternion->s0 = 0.0; quaternion->s0 = 0.0;
quaternion->x1 = 0.0; quaternion->x1 = 0.0;
@ -35,7 +35,7 @@ inline void bgc_quaternion_reset_fp64(BgcQuaternionFP64 * quaternion)
// ================= Make Unit ================== // // ================= Make Unit ================== //
inline void bgc_quaternion_make_unit_fp32(BgcQuaternionFP32 * quaternion) inline void bgc_fp32_quaternion_make_unit(BGC_FP32_Quaternion * quaternion)
{ {
quaternion->s0 = 1.0f; quaternion->s0 = 1.0f;
quaternion->x1 = 0.0f; quaternion->x1 = 0.0f;
@ -43,7 +43,7 @@ inline void bgc_quaternion_make_unit_fp32(BgcQuaternionFP32 * quaternion)
quaternion->x3 = 0.0f; quaternion->x3 = 0.0f;
} }
inline void bgc_quaternion_make_unit_fp64(BgcQuaternionFP64 * quaternion) inline void bgc_fp64_quaternion_make_unit(BGC_FP64_Quaternion * quaternion)
{ {
quaternion->s0 = 1.0; quaternion->s0 = 1.0;
quaternion->x1 = 0.0; quaternion->x1 = 0.0;
@ -53,7 +53,7 @@ inline void bgc_quaternion_make_unit_fp64(BgcQuaternionFP64 * quaternion)
// ==================== Set ===================== // // ==================== Set ===================== //
inline void bgc_quaternion_set_values_fp32(const float s0, const float x1, const float x2, const float x3, BgcQuaternionFP32 * quaternion) inline void bgc_fp32_quaternion_make(const float s0, const float x1, const float x2, const float x3, BGC_FP32_Quaternion * quaternion)
{ {
quaternion->s0 = s0; quaternion->s0 = s0;
quaternion->x1 = x1; quaternion->x1 = x1;
@ -61,7 +61,7 @@ inline void bgc_quaternion_set_values_fp32(const float s0, const float x1, const
quaternion->x3 = x3; quaternion->x3 = x3;
} }
inline void bgc_quaternion_set_values_fp64(const double s0, const double x1, const double x2, const double x3, BgcQuaternionFP64 * quaternion) inline void bgc_fp64_quaternion_make(const double s0, const double x1, const double x2, const double x3, BGC_FP64_Quaternion * quaternion)
{ {
quaternion->s0 = s0; quaternion->s0 = s0;
quaternion->x1 = x1; quaternion->x1 = x1;
@ -71,55 +71,55 @@ inline void bgc_quaternion_set_values_fp64(const double s0, const double x1, con
// ============= Get Square Modulus ============= // // ============= Get Square Modulus ============= //
inline float bgc_quaternion_get_square_modulus_fp32(const BgcQuaternionFP32* quaternion) inline float bgc_fp32_quaternion_get_square_modulus(const BGC_FP32_Quaternion* quaternion)
{ {
return (quaternion->s0 * quaternion->s0 + quaternion->x1 * quaternion->x1) + (quaternion->x2 * quaternion->x2 + quaternion->x3 * quaternion->x3); return (quaternion->s0 * quaternion->s0 + quaternion->x1 * quaternion->x1) + (quaternion->x2 * quaternion->x2 + quaternion->x3 * quaternion->x3);
} }
inline double bgc_quaternion_get_square_modulus_fp64(const BgcQuaternionFP64* quaternion) inline double bgc_fp64_quaternion_get_square_modulus(const BGC_FP64_Quaternion* quaternion)
{ {
return (quaternion->s0 * quaternion->s0 + quaternion->x1 * quaternion->x1) + (quaternion->x2 * quaternion->x2 + quaternion->x3 * quaternion->x3); return (quaternion->s0 * quaternion->s0 + quaternion->x1 * quaternion->x1) + (quaternion->x2 * quaternion->x2 + quaternion->x3 * quaternion->x3);
} }
// ================ Get Modulus ================= // // ================ Get Modulus ================= //
inline float bgc_quaternion_get_modulus_fp32(const BgcQuaternionFP32* quaternion) inline float bgc_fp32_quaternion_get_modulus(const BGC_FP32_Quaternion* quaternion)
{ {
return sqrtf(bgc_quaternion_get_square_modulus_fp32(quaternion)); return sqrtf(bgc_fp32_quaternion_get_square_modulus(quaternion));
} }
inline double bgc_quaternion_get_modulus_fp64(const BgcQuaternionFP64* quaternion) inline double bgc_fp64_quaternion_get_modulus(const BGC_FP64_Quaternion* quaternion)
{ {
return sqrt(bgc_quaternion_get_square_modulus_fp64(quaternion)); return sqrt(bgc_fp64_quaternion_get_square_modulus(quaternion));
} }
// ================== Is Zero =================== // // ================== Is Zero =================== //
inline int bgc_quaternion_is_zero_fp32(const BgcQuaternionFP32* quaternion) inline int bgc_fp32_quaternion_is_zero(const BGC_FP32_Quaternion* quaternion)
{ {
return bgc_quaternion_get_square_modulus_fp32(quaternion) <= BGC_SQUARE_EPSYLON_FP32; return bgc_fp32_quaternion_get_square_modulus(quaternion) <= BGC_FP32_SQUARE_EPSYLON;
} }
inline int bgc_quaternion_is_zero_fp64(const BgcQuaternionFP64* quaternion) inline int bgc_fp64_quaternion_is_zero(const BGC_FP64_Quaternion* quaternion)
{ {
return bgc_quaternion_get_square_modulus_fp64(quaternion) <= BGC_SQUARE_EPSYLON_FP64; return bgc_fp64_quaternion_get_square_modulus(quaternion) <= BGC_FP64_SQUARE_EPSYLON;
} }
// ================== Is Unit =================== // // ================== Is Unit =================== //
inline int bgc_quaternion_is_unit_fp32(const BgcQuaternionFP32* quaternion) inline int bgc_fp32_quaternion_is_unit(const BGC_FP32_Quaternion* quaternion)
{ {
return bgc_is_sqare_unit_fp32(bgc_quaternion_get_square_modulus_fp32(quaternion)); return bgc_fp32_is_square_unit(bgc_fp32_quaternion_get_square_modulus(quaternion));
} }
inline int bgc_quaternion_is_unit_fp64(const BgcQuaternionFP64* quaternion) inline int bgc_fp64_quaternion_is_unit(const BGC_FP64_Quaternion* quaternion)
{ {
return bgc_is_sqare_unit_fp64(bgc_quaternion_get_square_modulus_fp64(quaternion)); return bgc_fp64_is_square_unit(bgc_fp64_quaternion_get_square_modulus(quaternion));
} }
// ==================== Copy ==================== // // ==================== Copy ==================== //
inline void bgc_quaternion_copy_fp32(const BgcQuaternionFP32* source, BgcQuaternionFP32* destination) inline void bgc_fp32_quaternion_copy(const BGC_FP32_Quaternion* source, BGC_FP32_Quaternion* destination)
{ {
destination->s0 = source->s0; destination->s0 = source->s0;
destination->x1 = source->x1; destination->x1 = source->x1;
@ -127,7 +127,7 @@ inline void bgc_quaternion_copy_fp32(const BgcQuaternionFP32* source, BgcQuatern
destination->x3 = source->x3; destination->x3 = source->x3;
} }
inline void bgc_quaternion_copy_fp64(const BgcQuaternionFP64* source, BgcQuaternionFP64* destination) inline void bgc_fp64_quaternion_copy(const BGC_FP64_Quaternion* source, BGC_FP64_Quaternion* destination)
{ {
destination->s0 = source->s0; destination->s0 = source->s0;
destination->x1 = source->x1; destination->x1 = source->x1;
@ -137,7 +137,7 @@ inline void bgc_quaternion_copy_fp64(const BgcQuaternionFP64* source, BgcQuatern
// ==================== Swap ==================== // // ==================== Swap ==================== //
inline void bgc_quaternion_swap_fp32(BgcQuaternionFP32* quarternion1, BgcQuaternionFP32* quarternion2) inline void bgc_fp32_quaternion_swap(BGC_FP32_Quaternion* quarternion1, BGC_FP32_Quaternion* quarternion2)
{ {
const float s0 = quarternion2->s0; const float s0 = quarternion2->s0;
const float x1 = quarternion2->x1; const float x1 = quarternion2->x1;
@ -155,7 +155,7 @@ inline void bgc_quaternion_swap_fp32(BgcQuaternionFP32* quarternion1, BgcQuatern
quarternion1->x3 = x3; quarternion1->x3 = x3;
} }
inline void bgc_quaternion_swap_fp64(BgcQuaternionFP64* quarternion1, BgcQuaternionFP64* quarternion2) inline void bgc_fp64_quaternion_swap(BGC_FP64_Quaternion* quarternion1, BGC_FP64_Quaternion* quarternion2)
{ {
const double s0 = quarternion2->s0; const double s0 = quarternion2->s0;
const double x1 = quarternion2->x1; const double x1 = quarternion2->x1;
@ -175,7 +175,7 @@ inline void bgc_quaternion_swap_fp64(BgcQuaternionFP64* quarternion1, BgcQuatern
// ================== Convert =================== // // ================== Convert =================== //
inline void bgc_quaternion_convert_fp64_to_fp32(const BgcQuaternionFP64* source, BgcQuaternionFP32* destination) inline void bgc_fp64_quaternion_convert_to_fp32(const BGC_FP64_Quaternion* source, BGC_FP32_Quaternion* destination)
{ {
destination->s0 = (float)source->s0; destination->s0 = (float)source->s0;
destination->x1 = (float)source->x1; destination->x1 = (float)source->x1;
@ -183,7 +183,7 @@ inline void bgc_quaternion_convert_fp64_to_fp32(const BgcQuaternionFP64* source,
destination->x3 = (float)source->x3; destination->x3 = (float)source->x3;
} }
inline void bgc_quaternion_convert_fp32_to_fp64(const BgcQuaternionFP32* source, BgcQuaternionFP64* destination) inline void bgc_fp32_quaternion_convert_to_fp64(const BGC_FP32_Quaternion* source, BGC_FP64_Quaternion* destination)
{ {
destination->s0 = source->s0; destination->s0 = source->s0;
destination->x1 = source->x1; destination->x1 = source->x1;
@ -193,7 +193,7 @@ inline void bgc_quaternion_convert_fp32_to_fp64(const BgcQuaternionFP32* source,
// ==================== Add ===================== // // ==================== Add ===================== //
inline void bgc_quaternion_add_fp32(const BgcQuaternionFP32 * quaternion1, const BgcQuaternionFP32 * quaternion2, BgcQuaternionFP32 * sum) inline void bgc_fp32_quaternion_add(const BGC_FP32_Quaternion * quaternion1, const BGC_FP32_Quaternion * quaternion2, BGC_FP32_Quaternion * sum)
{ {
sum->s0 = quaternion1->s0 + quaternion2->s0; sum->s0 = quaternion1->s0 + quaternion2->s0;
sum->x1 = quaternion1->x1 + quaternion2->x1; sum->x1 = quaternion1->x1 + quaternion2->x1;
@ -201,7 +201,7 @@ inline void bgc_quaternion_add_fp32(const BgcQuaternionFP32 * quaternion1, const
sum->x3 = quaternion1->x3 + quaternion2->x3; sum->x3 = quaternion1->x3 + quaternion2->x3;
} }
inline void bgc_quaternion_add_fp64(const BgcQuaternionFP64 * quaternion1, const BgcQuaternionFP64 * quaternion2, BgcQuaternionFP64 * sum) inline void bgc_fp64_quaternion_add(const BGC_FP64_Quaternion * quaternion1, const BGC_FP64_Quaternion * quaternion2, BGC_FP64_Quaternion * sum)
{ {
sum->s0 = quaternion1->s0 + quaternion2->s0; sum->s0 = quaternion1->s0 + quaternion2->s0;
sum->x1 = quaternion1->x1 + quaternion2->x1; sum->x1 = quaternion1->x1 + quaternion2->x1;
@ -211,7 +211,7 @@ inline void bgc_quaternion_add_fp64(const BgcQuaternionFP64 * quaternion1, const
// ================= Add Scaled ================= // // ================= Add Scaled ================= //
inline void bgc_quaternion_add_scaled_fp32(const BgcQuaternionFP32 * basic_quaternion, const BgcQuaternionFP32 * scalable_quaternion, const float scale, BgcQuaternionFP32 * sum) inline void bgc_fp32_quaternion_add_scaled(const BGC_FP32_Quaternion * basic_quaternion, const BGC_FP32_Quaternion * scalable_quaternion, const float scale, BGC_FP32_Quaternion * sum)
{ {
sum->s0 = basic_quaternion->s0 + scalable_quaternion->s0 * scale; sum->s0 = basic_quaternion->s0 + scalable_quaternion->s0 * scale;
sum->x1 = basic_quaternion->x1 + scalable_quaternion->x1 * scale; sum->x1 = basic_quaternion->x1 + scalable_quaternion->x1 * scale;
@ -219,7 +219,7 @@ inline void bgc_quaternion_add_scaled_fp32(const BgcQuaternionFP32 * basic_quate
sum->x3 = basic_quaternion->x3 + scalable_quaternion->x3 * scale; sum->x3 = basic_quaternion->x3 + scalable_quaternion->x3 * scale;
} }
inline void bgc_quaternion_add_scaled_fp64(const BgcQuaternionFP64 * basic_quaternion, const BgcQuaternionFP64 * scalable_quaternion, const double scale, BgcQuaternionFP64 * sum) inline void bgc_fp64_quaternion_add_scaled(const BGC_FP64_Quaternion * basic_quaternion, const BGC_FP64_Quaternion * scalable_quaternion, const double scale, BGC_FP64_Quaternion * sum)
{ {
sum->s0 = basic_quaternion->s0 + scalable_quaternion->s0 * scale; sum->s0 = basic_quaternion->s0 + scalable_quaternion->s0 * scale;
sum->x1 = basic_quaternion->x1 + scalable_quaternion->x1 * scale; sum->x1 = basic_quaternion->x1 + scalable_quaternion->x1 * scale;
@ -229,7 +229,7 @@ inline void bgc_quaternion_add_scaled_fp64(const BgcQuaternionFP64 * basic_quate
// ================== Subtract ================== // // ================== Subtract ================== //
inline void bgc_quaternion_subtract_fp32(const BgcQuaternionFP32 * minuend, const BgcQuaternionFP32 * subtrahend, BgcQuaternionFP32 * difference) inline void bgc_fp32_quaternion_subtract(const BGC_FP32_Quaternion * minuend, const BGC_FP32_Quaternion * subtrahend, BGC_FP32_Quaternion * difference)
{ {
difference->s0 = minuend->s0 - subtrahend->s0; difference->s0 = minuend->s0 - subtrahend->s0;
difference->x1 = minuend->x1 - subtrahend->x1; difference->x1 = minuend->x1 - subtrahend->x1;
@ -237,7 +237,7 @@ inline void bgc_quaternion_subtract_fp32(const BgcQuaternionFP32 * minuend, cons
difference->x3 = minuend->x3 - subtrahend->x3; difference->x3 = minuend->x3 - subtrahend->x3;
} }
inline void bgc_quaternion_subtract_fp64(const BgcQuaternionFP64 * minuend, const BgcQuaternionFP64 * subtrahend, BgcQuaternionFP64 * difference) inline void bgc_fp64_quaternion_subtract(const BGC_FP64_Quaternion * minuend, const BGC_FP64_Quaternion * subtrahend, BGC_FP64_Quaternion * difference)
{ {
difference->s0 = minuend->s0 - subtrahend->s0; difference->s0 = minuend->s0 - subtrahend->s0;
difference->x1 = minuend->x1 - subtrahend->x1; difference->x1 = minuend->x1 - subtrahend->x1;
@ -247,7 +247,7 @@ inline void bgc_quaternion_subtract_fp64(const BgcQuaternionFP64 * minuend, cons
// ================== Multiply ================== // // ================== Multiply ================== //
inline void bgc_quaternion_multiply_fp32(const BgcQuaternionFP32* left, const BgcQuaternionFP32* right, BgcQuaternionFP32* product) inline void bgc_fp32_quaternion_get_product(const BGC_FP32_Quaternion* left, const BGC_FP32_Quaternion* right, BGC_FP32_Quaternion* product)
{ {
const float s0 = (left->s0 * right->s0 - left->x1 * right->x1) - (left->x2 * right->x2 + left->x3 * right->x3); const float s0 = (left->s0 * right->s0 - left->x1 * right->x1) - (left->x2 * right->x2 + left->x3 * right->x3);
const float x1 = (left->x1 * right->s0 + left->s0 * right->x1) - (left->x3 * right->x2 - left->x2 * right->x3); const float x1 = (left->x1 * right->s0 + left->s0 * right->x1) - (left->x3 * right->x2 - left->x2 * right->x3);
@ -260,7 +260,7 @@ inline void bgc_quaternion_multiply_fp32(const BgcQuaternionFP32* left, const Bg
product->x3 = x3; product->x3 = x3;
} }
inline void bgc_quaternion_multiply_fp64(const BgcQuaternionFP64* left, const BgcQuaternionFP64* right, BgcQuaternionFP64* product) inline void bgc_fp64_quaternion_get_product(const BGC_FP64_Quaternion* left, const BGC_FP64_Quaternion* right, BGC_FP64_Quaternion* product)
{ {
const double s0 = (left->s0 * right->s0 - left->x1 * right->x1) - (left->x2 * right->x2 + left->x3 * right->x3); const double s0 = (left->s0 * right->s0 - left->x1 * right->x1) - (left->x2 * right->x2 + left->x3 * right->x3);
const double x1 = (left->x1 * right->s0 + left->s0 * right->x1) - (left->x3 * right->x2 - left->x2 * right->x3); const double x1 = (left->x1 * right->s0 + left->s0 * right->x1) - (left->x3 * right->x2 - left->x2 * right->x3);
@ -273,7 +273,7 @@ inline void bgc_quaternion_multiply_fp64(const BgcQuaternionFP64* left, const Bg
product->x3 = x3; product->x3 = x3;
} }
inline void bgc_quaternion_multiply_by_number_fp32(const BgcQuaternionFP32* multiplicand, const float multipier, BgcQuaternionFP32* product) inline void bgc_fp32_quaternion_multiply(const BGC_FP32_Quaternion* multiplicand, const float multipier, BGC_FP32_Quaternion* product)
{ {
product->s0 = multiplicand->s0 * multipier; product->s0 = multiplicand->s0 * multipier;
product->x1 = multiplicand->x1 * multipier; product->x1 = multiplicand->x1 * multipier;
@ -281,7 +281,7 @@ inline void bgc_quaternion_multiply_by_number_fp32(const BgcQuaternionFP32* mult
product->x3 = multiplicand->x3 * multipier; product->x3 = multiplicand->x3 * multipier;
} }
inline void bgc_quaternion_multiply_by_number_fp64(const BgcQuaternionFP64* multiplicand, const double multipier, BgcQuaternionFP64* product) inline void bgc_fp64_quaternion_multiply(const BGC_FP64_Quaternion* multiplicand, const double multipier, BGC_FP64_Quaternion* product)
{ {
product->s0 = multiplicand->s0 * multipier; product->s0 = multiplicand->s0 * multipier;
product->x1 = multiplicand->x1 * multipier; product->x1 = multiplicand->x1 * multipier;
@ -291,11 +291,11 @@ inline void bgc_quaternion_multiply_by_number_fp64(const BgcQuaternionFP64* mult
// =================== Divide =================== // // =================== Divide =================== //
inline int bgc_quaternion_divide_fp32(const BgcQuaternionFP32* divident, const BgcQuaternionFP32* divisor, BgcQuaternionFP32* quotient) inline int bgc_fp32_quaternion_get_ratio(const BGC_FP32_Quaternion* divident, const BGC_FP32_Quaternion* divisor, BGC_FP32_Quaternion* quotient)
{ {
const float square_modulus = bgc_quaternion_get_square_modulus_fp32(divisor); const float square_modulus = bgc_fp32_quaternion_get_square_modulus(divisor);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
return 0; return 0;
} }
@ -314,11 +314,11 @@ inline int bgc_quaternion_divide_fp32(const BgcQuaternionFP32* divident, const B
return 1; return 1;
} }
inline int bgc_quaternion_divide_fp64(const BgcQuaternionFP64* divident, const BgcQuaternionFP64* divisor, BgcQuaternionFP64* quotient) inline int bgc_fp64_quaternion_get_ratio(const BGC_FP64_Quaternion* divident, const BGC_FP64_Quaternion* divisor, BGC_FP64_Quaternion* quotient)
{ {
const double square_modulus = bgc_quaternion_get_square_modulus_fp64(divisor); const double square_modulus = bgc_fp64_quaternion_get_square_modulus(divisor);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
return 0; return 0;
} }
@ -337,19 +337,19 @@ inline int bgc_quaternion_divide_fp64(const BgcQuaternionFP64* divident, const B
return 1; return 1;
} }
inline void bgc_quaternion_divide_by_number_fp32(const BgcQuaternionFP32* dividend, const float divisor, BgcQuaternionFP32* quotient) inline void bgc_fp32_quaternion_divide(const BGC_FP32_Quaternion* dividend, const float divisor, BGC_FP32_Quaternion* quotient)
{ {
bgc_quaternion_multiply_by_number_fp32(dividend, 1.0f / divisor, quotient); bgc_fp32_quaternion_multiply(dividend, 1.0f / divisor, quotient);
} }
inline void bgc_quaternion_divide_by_number_fp64(const BgcQuaternionFP64* dividend, const double divisor, BgcQuaternionFP64* quotient) inline void bgc_fp64_quaternion_divide(const BGC_FP64_Quaternion* dividend, const double divisor, BGC_FP64_Quaternion* quotient)
{ {
bgc_quaternion_multiply_by_number_fp64(dividend, 1.0 / divisor, quotient); bgc_fp64_quaternion_multiply(dividend, 1.0 / divisor, quotient);
} }
// ================ Mean of Two ================= // // ================ Mean of Two ================= //
inline void bgc_quaternion_get_mean_of_two_fp32(const BgcQuaternionFP32* vector1, const BgcQuaternionFP32* vector2, BgcQuaternionFP32* mean) inline void bgc_fp32_quaternion_get_mean2(const BGC_FP32_Quaternion* vector1, const BGC_FP32_Quaternion* vector2, BGC_FP32_Quaternion* mean)
{ {
mean->s0 = (vector1->s0 + vector2->s0) * 0.5f; mean->s0 = (vector1->s0 + vector2->s0) * 0.5f;
mean->x1 = (vector1->x1 + vector2->x1) * 0.5f; mean->x1 = (vector1->x1 + vector2->x1) * 0.5f;
@ -357,7 +357,7 @@ inline void bgc_quaternion_get_mean_of_two_fp32(const BgcQuaternionFP32* vector1
mean->x3 = (vector1->x3 + vector2->x3) * 0.5f; mean->x3 = (vector1->x3 + vector2->x3) * 0.5f;
} }
inline void bgc_quaternion_get_mean_of_two_fp64(const BgcQuaternionFP64* vector1, const BgcQuaternionFP64* vector2, BgcQuaternionFP64* mean) inline void bgc_fp64_quaternion_get_mean2(const BGC_FP64_Quaternion* vector1, const BGC_FP64_Quaternion* vector2, BGC_FP64_Quaternion* mean)
{ {
mean->s0 = (vector1->s0 + vector2->s0) * 0.5f; mean->s0 = (vector1->s0 + vector2->s0) * 0.5f;
mean->x1 = (vector1->x1 + vector2->x1) * 0.5f; mean->x1 = (vector1->x1 + vector2->x1) * 0.5f;
@ -367,61 +367,61 @@ inline void bgc_quaternion_get_mean_of_two_fp64(const BgcQuaternionFP64* vector1
// =============== Mean of Three ================ // // =============== Mean of Three ================ //
inline void bgc_quaternion_get_mean_of_three_fp32(const BgcQuaternionFP32* vector1, const BgcQuaternionFP32* vector2, const BgcQuaternionFP32* vector3, BgcQuaternionFP32* mean) inline void bgc_fp32_quaternion_get_mean3(const BGC_FP32_Quaternion* vector1, const BGC_FP32_Quaternion* vector2, const BGC_FP32_Quaternion* vector3, BGC_FP32_Quaternion* mean)
{ {
mean->s0 = (vector1->s0 + vector2->s0 + vector3->s0) * BGC_ONE_THIRD_FP32; mean->s0 = (vector1->s0 + vector2->s0 + vector3->s0) * BGC_FP32_ONE_THIRD;
mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_ONE_THIRD_FP32; mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP32_ONE_THIRD;
mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_ONE_THIRD_FP32; mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP32_ONE_THIRD;
mean->x3 = (vector1->x3 + vector2->x3 + vector3->x3) * BGC_ONE_THIRD_FP32; mean->x3 = (vector1->x3 + vector2->x3 + vector3->x3) * BGC_FP32_ONE_THIRD;
} }
inline void bgc_quaternion_get_mean_of_three_fp64(const BgcQuaternionFP64* vector1, const BgcQuaternionFP64* vector2, const BgcQuaternionFP64* vector3, BgcQuaternionFP64* mean) inline void bgc_fp64_quaternion_get_mean3(const BGC_FP64_Quaternion* vector1, const BGC_FP64_Quaternion* vector2, const BGC_FP64_Quaternion* vector3, BGC_FP64_Quaternion* mean)
{ {
mean->s0 = (vector1->s0 + vector2->s0 + vector3->s0) * BGC_ONE_THIRD_FP64; mean->s0 = (vector1->s0 + vector2->s0 + vector3->s0) * BGC_FP64_ONE_THIRD;
mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_ONE_THIRD_FP64; mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP64_ONE_THIRD;
mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_ONE_THIRD_FP64; mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP64_ONE_THIRD;
mean->x3 = (vector1->x3 + vector2->x3 + vector3->x3) * BGC_ONE_THIRD_FP64; mean->x3 = (vector1->x3 + vector2->x3 + vector3->x3) * BGC_FP64_ONE_THIRD;
} }
// ============ Linear Interpolation ============ // // ============ Linear Interpolation ============ //
inline void bgc_quaternion_interpolate_fp32(const BgcQuaternionFP32* quaternion1, const BgcQuaternionFP32* quaternion2, const float phase, BgcQuaternionFP32* interpolation) inline void bgc_fp32_quaternion_interpolate(const BGC_FP32_Quaternion* quaternion1, const BGC_FP32_Quaternion* quaternion2, const float phase, BGC_FP32_Quaternion* interpolation)
{ {
const float counterphase = 1.0f - phase; const float counter_phase = 1.0f - phase;
interpolation->s0 = quaternion1->s0 * counterphase + quaternion2->s0 * phase; interpolation->s0 = quaternion1->s0 * counter_phase + quaternion2->s0 * phase;
interpolation->x1 = quaternion1->x1 * counterphase + quaternion2->x1 * phase; interpolation->x1 = quaternion1->x1 * counter_phase + quaternion2->x1 * phase;
interpolation->x2 = quaternion1->x2 * counterphase + quaternion2->x2 * phase; interpolation->x2 = quaternion1->x2 * counter_phase + quaternion2->x2 * phase;
interpolation->x3 = quaternion1->x3 * counterphase + quaternion2->x3 * phase; interpolation->x3 = quaternion1->x3 * counter_phase + quaternion2->x3 * phase;
} }
inline void bgc_quaternion_interpolate_fp64(const BgcQuaternionFP64* quaternion1, const BgcQuaternionFP64* quaternion2, const double phase, BgcQuaternionFP64* interpolation) inline void bgc_fp64_quaternion_interpolate(const BGC_FP64_Quaternion* quaternion1, const BGC_FP64_Quaternion* quaternion2, const double phase, BGC_FP64_Quaternion* interpolation)
{ {
const double counterphase = 1.0 - phase; const double counter_phase = 1.0 - phase;
interpolation->s0 = quaternion1->s0 * counterphase + quaternion2->s0 * phase; interpolation->s0 = quaternion1->s0 * counter_phase + quaternion2->s0 * phase;
interpolation->x1 = quaternion1->x1 * counterphase + quaternion2->x1 * phase; interpolation->x1 = quaternion1->x1 * counter_phase + quaternion2->x1 * phase;
interpolation->x2 = quaternion1->x2 * counterphase + quaternion2->x2 * phase; interpolation->x2 = quaternion1->x2 * counter_phase + quaternion2->x2 * phase;
interpolation->x3 = quaternion1->x3 * counterphase + quaternion2->x3 * phase; interpolation->x3 = quaternion1->x3 * counter_phase + quaternion2->x3 * phase;
} }
// ================= Conjugate ================== // // ================= Conjugate ================== //
inline void bgc_quaternion_conjugate_fp32(BgcQuaternionFP32* quaternion) inline void bgc_fp32_quaternion_conjugate(BGC_FP32_Quaternion* quaternion)
{ {
quaternion->x1 = -quaternion->x1; quaternion->x1 = -quaternion->x1;
quaternion->x2 = -quaternion->x2; quaternion->x2 = -quaternion->x2;
quaternion->x3 = -quaternion->x3; quaternion->x3 = -quaternion->x3;
} }
inline void bgc_quaternion_conjugate_fp64(BgcQuaternionFP64* quaternion) inline void bgc_fp64_quaternion_conjugate(BGC_FP64_Quaternion* quaternion)
{ {
quaternion->x1 = -quaternion->x1; quaternion->x1 = -quaternion->x1;
quaternion->x2 = -quaternion->x2; quaternion->x2 = -quaternion->x2;
quaternion->x3 = -quaternion->x3; quaternion->x3 = -quaternion->x3;
} }
inline void bgc_quaternion_get_conjugate_fp32(const BgcQuaternionFP32* quaternion, BgcQuaternionFP32* conjugate) inline void bgc_fp32_quaternion_get_conjugate(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Quaternion* conjugate)
{ {
conjugate->s0 = quaternion->s0; conjugate->s0 = quaternion->s0;
conjugate->x1 = -quaternion->x1; conjugate->x1 = -quaternion->x1;
@ -429,7 +429,7 @@ inline void bgc_quaternion_get_conjugate_fp32(const BgcQuaternionFP32* quaternio
conjugate->x3 = -quaternion->x3; conjugate->x3 = -quaternion->x3;
} }
inline void bgc_quaternion_get_conjugate_fp64(const BgcQuaternionFP64* quaternion, BgcQuaternionFP64* conjugate) inline void bgc_fp64_quaternion_get_conjugate(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Quaternion* conjugate)
{ {
conjugate->s0 = quaternion->s0; conjugate->s0 = quaternion->s0;
conjugate->x1 = -quaternion->x1; conjugate->x1 = -quaternion->x1;
@ -439,7 +439,7 @@ inline void bgc_quaternion_get_conjugate_fp64(const BgcQuaternionFP64* quaternio
// ================== Negative ================== // // ================== Negative ================== //
inline void bgc_quaternion_make_opposite_fp32(BgcQuaternionFP32* quaternion) inline void bgc_fp32_quaternion_revert(BGC_FP32_Quaternion* quaternion)
{ {
quaternion->s0 = -quaternion->s0; quaternion->s0 = -quaternion->s0;
quaternion->x1 = -quaternion->x1; quaternion->x1 = -quaternion->x1;
@ -447,7 +447,7 @@ inline void bgc_quaternion_make_opposite_fp32(BgcQuaternionFP32* quaternion)
quaternion->x3 = -quaternion->x3; quaternion->x3 = -quaternion->x3;
} }
inline void bgc_quaternion_make_opposite_fp64(BgcQuaternionFP64* quaternion) inline void bgc_fp64_quaternion_revert(BGC_FP64_Quaternion* quaternion)
{ {
quaternion->s0 = -quaternion->s0; quaternion->s0 = -quaternion->s0;
quaternion->x1 = -quaternion->x1; quaternion->x1 = -quaternion->x1;
@ -455,7 +455,7 @@ inline void bgc_quaternion_make_opposite_fp64(BgcQuaternionFP64* quaternion)
quaternion->x3 = -quaternion->x3; quaternion->x3 = -quaternion->x3;
} }
inline void bgc_quaternion_get_opposite_fp32(const BgcQuaternionFP32* quaternion, BgcQuaternionFP32* opposite) inline void bgc_fp32_quaternion_get_reverse(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Quaternion* opposite)
{ {
opposite->s0 = -quaternion->s0; opposite->s0 = -quaternion->s0;
opposite->x1 = -quaternion->x1; opposite->x1 = -quaternion->x1;
@ -463,7 +463,7 @@ inline void bgc_quaternion_get_opposite_fp32(const BgcQuaternionFP32* quaternion
opposite->x3 = -quaternion->x3; opposite->x3 = -quaternion->x3;
} }
inline void bgc_quaternion_get_opposite_fp64(const BgcQuaternionFP64* quaternion, BgcQuaternionFP64* opposite) inline void bgc_fp64_quaternion_get_reverse(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Quaternion* opposite)
{ {
opposite->s0 = -quaternion->s0; opposite->s0 = -quaternion->s0;
opposite->x1 = -quaternion->x1; opposite->x1 = -quaternion->x1;
@ -473,11 +473,11 @@ inline void bgc_quaternion_get_opposite_fp64(const BgcQuaternionFP64* quaternion
// =================== Invert =================== // // =================== Invert =================== //
inline int bgc_quaternion_get_inverse_fp32(const BgcQuaternionFP32* quaternion, BgcQuaternionFP32* inverse) inline int bgc_fp32_quaternion_get_inverse(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Quaternion* inverse)
{ {
const float square_modulus = bgc_quaternion_get_square_modulus_fp32(quaternion); const float square_modulus = bgc_fp32_quaternion_get_square_modulus(quaternion);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
return 0; return 0;
} }
@ -491,11 +491,11 @@ inline int bgc_quaternion_get_inverse_fp32(const BgcQuaternionFP32* quaternion,
return 1; return 1;
} }
inline int bgc_quaternion_get_inverse_fp64(const BgcQuaternionFP64* quaternion, BgcQuaternionFP64* inverse) inline int bgc_fp64_quaternion_get_inverse(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Quaternion* inverse)
{ {
const double square_modulus = bgc_quaternion_get_square_modulus_fp64(quaternion); const double square_modulus = bgc_fp64_quaternion_get_square_modulus(quaternion);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
return 0; return 0;
} }
@ -509,27 +509,27 @@ inline int bgc_quaternion_get_inverse_fp64(const BgcQuaternionFP64* quaternion,
return 1; return 1;
} }
inline int bgc_quaternion_invert_fp32(BgcQuaternionFP32* quaternion) inline int bgc_fp32_quaternion_invert(BGC_FP32_Quaternion* quaternion)
{ {
return bgc_quaternion_get_inverse_fp32(quaternion, quaternion); return bgc_fp32_quaternion_get_inverse(quaternion, quaternion);
} }
inline int bgc_quaternion_invert_fp64(BgcQuaternionFP64* quaternion) inline int bgc_fp64_quaternion_invert(BGC_FP64_Quaternion* quaternion)
{ {
return bgc_quaternion_get_inverse_fp64(quaternion, quaternion); return bgc_fp64_quaternion_get_inverse(quaternion, quaternion);
} }
// ================= Normalize ================== // // ================= Normalize ================== //
inline int bgc_quaternion_normalize_fp32(BgcQuaternionFP32* quaternion) inline int bgc_fp32_quaternion_normalize(BGC_FP32_Quaternion* quaternion)
{ {
const float square_modulus = bgc_quaternion_get_square_modulus_fp32(quaternion); const float square_modulus = bgc_fp32_quaternion_get_square_modulus(quaternion);
if (bgc_is_sqare_unit_fp32(square_modulus)) { if (bgc_fp32_is_square_unit(square_modulus)) {
return 1; return 1;
} }
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
return 0; return 0;
} }
@ -543,15 +543,15 @@ inline int bgc_quaternion_normalize_fp32(BgcQuaternionFP32* quaternion)
return 1; return 1;
} }
inline int bgc_quaternion_normalize_fp64(BgcQuaternionFP64* quaternion) inline int bgc_fp64_quaternion_normalize(BGC_FP64_Quaternion* quaternion)
{ {
const double square_modulus = bgc_quaternion_get_square_modulus_fp64(quaternion); const double square_modulus = bgc_fp64_quaternion_get_square_modulus(quaternion);
if (bgc_is_sqare_unit_fp64(square_modulus)) { if (bgc_fp64_is_square_unit(square_modulus)) {
return 1; return 1;
} }
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
return 0; return 0;
} }
@ -565,51 +565,51 @@ inline int bgc_quaternion_normalize_fp64(BgcQuaternionFP64* quaternion)
return 1; return 1;
} }
inline int bgc_quaternion_get_normalized_fp32(const BgcQuaternionFP32* quaternion, BgcQuaternionFP32* normalized) inline int bgc_fp32_quaternion_get_normalized(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Quaternion* normalized)
{ {
const float square_modulus = bgc_quaternion_get_square_modulus_fp32(quaternion); const float square_modulus = bgc_fp32_quaternion_get_square_modulus(quaternion);
if (bgc_is_sqare_unit_fp32(square_modulus)) { if (bgc_fp32_is_square_unit(square_modulus)) {
bgc_quaternion_copy_fp32(quaternion, normalized); bgc_fp32_quaternion_copy(quaternion, normalized);
return 1; return 1;
} }
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
bgc_quaternion_reset_fp32(normalized); bgc_fp32_quaternion_reset(normalized);
return 0; return 0;
} }
bgc_quaternion_multiply_by_number_fp32(quaternion, sqrtf(1.0f / square_modulus), normalized); bgc_fp32_quaternion_multiply(quaternion, sqrtf(1.0f / square_modulus), normalized);
return 1; return 1;
} }
inline int bgc_quaternion_get_normalized_fp64(const BgcQuaternionFP64* quaternion, BgcQuaternionFP64* normalized) inline int bgc_fp64_quaternion_get_normalized(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Quaternion* normalized)
{ {
const double square_modulus = bgc_quaternion_get_square_modulus_fp64(quaternion); const double square_modulus = bgc_fp64_quaternion_get_square_modulus(quaternion);
if (bgc_is_sqare_unit_fp64(square_modulus)) { if (bgc_fp64_is_square_unit(square_modulus)) {
bgc_quaternion_copy_fp64(quaternion, normalized); bgc_fp64_quaternion_copy(quaternion, normalized);
return 1; return 1;
} }
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
bgc_quaternion_reset_fp64(normalized); bgc_fp64_quaternion_reset(normalized);
return 0; return 0;
} }
bgc_quaternion_multiply_by_number_fp64(quaternion, sqrt(1.0 / square_modulus), normalized); bgc_fp64_quaternion_multiply(quaternion, sqrt(1.0 / square_modulus), normalized);
return 1; return 1;
} }
// =============== Get Exponation =============== // // =============== Get Exponation =============== //
int bgc_quaternion_get_exponation_fp32(const BgcQuaternionFP32* base, const float exponent, BgcQuaternionFP32* power); int bgc_fp32_quaternion_get_exponation(const BGC_FP32_Quaternion* base, const float exponent, BGC_FP32_Quaternion* power);
int bgc_quaternion_get_exponation_fp64(const BgcQuaternionFP64* base, const double exponent, BgcQuaternionFP64* power); int bgc_fp64_quaternion_get_exponation(const BGC_FP64_Quaternion* base, const double exponent, BGC_FP64_Quaternion* power);
// ============ Get Rotation Matrix ============= // // ============ Get Rotation Matrix ============= //
inline int bgc_quaternion_get_rotation_matrix_fp32(const BgcQuaternionFP32* quaternion, BgcMatrix3x3FP32* rotation) inline int bgc_fp32_quaternion_get_rotation_matrix(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Matrix3x3* rotation)
{ {
const float s0s0 = quaternion->s0 * quaternion->s0; const float s0s0 = quaternion->s0 * quaternion->s0;
const float x1x1 = quaternion->x1 * quaternion->x1; const float x1x1 = quaternion->x1 * quaternion->x1;
@ -618,9 +618,9 @@ inline int bgc_quaternion_get_rotation_matrix_fp32(const BgcQuaternionFP32* quat
const float square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3); const float square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus))
{ {
bgc_matrix3x3_set_to_identity_fp32(rotation); bgc_fp32_matrix3x3_make_identity(rotation);
return 0; return 0;
} }
@ -650,7 +650,7 @@ inline int bgc_quaternion_get_rotation_matrix_fp32(const BgcQuaternionFP32* quat
return 1; return 1;
} }
inline int bgc_quaternion_get_rotation_matrix_fp64(const BgcQuaternionFP64* quaternion, BgcMatrix3x3FP64* rotation) inline int bgc_fp64_quaternion_get_rotation_matrix(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Matrix3x3* rotation)
{ {
const double s0s0 = quaternion->s0 * quaternion->s0; const double s0s0 = quaternion->s0 * quaternion->s0;
const double x1x1 = quaternion->x1 * quaternion->x1; const double x1x1 = quaternion->x1 * quaternion->x1;
@ -659,9 +659,9 @@ inline int bgc_quaternion_get_rotation_matrix_fp64(const BgcQuaternionFP64* quat
const double square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3); const double square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus))
{ {
bgc_matrix3x3_set_to_identity_fp64(rotation); bgc_fp64_matrix3x3_make_identity(rotation);
return 0; return 0;
} }
@ -693,7 +693,7 @@ inline int bgc_quaternion_get_rotation_matrix_fp64(const BgcQuaternionFP64* quat
// ============= Get Reverse Matrix ============= // // ============= Get Reverse Matrix ============= //
inline int bgc_quaternion_get_reverse_matrix_fp32(const BgcQuaternionFP32* quaternion, BgcMatrix3x3FP32* reverse) inline int bgc_fp32_quaternion_get_reverse_matrix(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Matrix3x3* reverse)
{ {
const float s0s0 = quaternion->s0 * quaternion->s0; const float s0s0 = quaternion->s0 * quaternion->s0;
const float x1x1 = quaternion->x1 * quaternion->x1; const float x1x1 = quaternion->x1 * quaternion->x1;
@ -702,9 +702,9 @@ inline int bgc_quaternion_get_reverse_matrix_fp32(const BgcQuaternionFP32* quate
const float square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3); const float square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus))
{ {
bgc_matrix3x3_set_to_identity_fp32(reverse); bgc_fp32_matrix3x3_make_identity(reverse);
return 0; return 0;
} }
@ -734,7 +734,7 @@ inline int bgc_quaternion_get_reverse_matrix_fp32(const BgcQuaternionFP32* quate
return 1; return 1;
} }
inline int bgc_quaternion_get_reverse_matrix_fp64(const BgcQuaternionFP64* quaternion, BgcMatrix3x3FP64* reverse) inline int bgc_fp64_quaternion_get_reverse_matrix(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Matrix3x3* reverse)
{ {
const double s0s0 = quaternion->s0 * quaternion->s0; const double s0s0 = quaternion->s0 * quaternion->s0;
const double x1x1 = quaternion->x1 * quaternion->x1; const double x1x1 = quaternion->x1 * quaternion->x1;
@ -743,9 +743,9 @@ inline int bgc_quaternion_get_reverse_matrix_fp64(const BgcQuaternionFP64* quate
const double square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3); const double square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus))
{ {
bgc_matrix3x3_set_to_identity_fp64(reverse); bgc_fp64_matrix3x3_make_identity(reverse);
return 0; return 0;
} }
@ -777,20 +777,20 @@ inline int bgc_quaternion_get_reverse_matrix_fp64(const BgcQuaternionFP64* quate
// ============= Get Both Matrixes ============== // // ============= Get Both Matrixes ============== //
inline int bgc_quaternion_get_both_matrices_fp32(const BgcQuaternionFP32* quaternion, BgcMatrix3x3FP32* rotation, BgcMatrix3x3FP32* reverse) inline int bgc_fp32_quaternion_get_both_matrices(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Matrix3x3* rotation, BGC_FP32_Matrix3x3* reverse)
{ {
if (bgc_quaternion_get_reverse_matrix_fp32(quaternion, reverse)) { if (bgc_fp32_quaternion_get_reverse_matrix(quaternion, reverse)) {
bgc_matrix3x3_transpose_fp32(reverse, rotation); bgc_fp32_matrix3x3_get_transposed(reverse, rotation);
return 1; return 1;
} }
return 0; return 0;
} }
inline int bgc_quaternion_get_both_matrices_fp64(const BgcQuaternionFP64* quaternion, BgcMatrix3x3FP64* rotation, BgcMatrix3x3FP64* reverse) inline int bgc_fp64_quaternion_get_both_matrices(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Matrix3x3* rotation, BGC_FP64_Matrix3x3* reverse)
{ {
if (bgc_quaternion_get_reverse_matrix_fp64(quaternion, reverse)) { if (bgc_fp64_quaternion_get_reverse_matrix(quaternion, reverse)) {
bgc_matrix3x3_transpose_fp64(reverse, rotation); bgc_fp64_matrix3x3_get_transposed(reverse, rotation);
return 1; return 1;
} }
@ -799,40 +799,40 @@ inline int bgc_quaternion_get_both_matrices_fp64(const BgcQuaternionFP64* quater
// ================== Are Close ================= // // ================== Are Close ================= //
inline int bgc_quaternion_are_close_fp32(const BgcQuaternionFP32* quaternion1, const BgcQuaternionFP32* quaternion2) inline int bgc_fp32_quaternion_are_close(const BGC_FP32_Quaternion* quaternion1, const BGC_FP32_Quaternion* quaternion2)
{ {
const float ds0 = quaternion1->s0 - quaternion2->s0; const float ds0 = quaternion1->s0 - quaternion2->s0;
const float dx1 = quaternion1->x1 - quaternion2->x1; const float dx1 = quaternion1->x1 - quaternion2->x1;
const float dx2 = quaternion1->x2 - quaternion2->x2; const float dx2 = quaternion1->x2 - quaternion2->x2;
const float dx3 = quaternion1->x3 - quaternion2->x3; const float dx3 = quaternion1->x3 - quaternion2->x3;
const float square_modulus1 = bgc_quaternion_get_square_modulus_fp32(quaternion1); const float square_modulus1 = bgc_fp32_quaternion_get_square_modulus(quaternion1);
const float square_modulus2 = bgc_quaternion_get_square_modulus_fp32(quaternion2); const float square_modulus2 = bgc_fp32_quaternion_get_square_modulus(quaternion2);
const float square_distance = (ds0 * ds0 + dx1 * dx1) + (dx2 * dx2 + dx3 * dx3); const float square_distance = (ds0 * ds0 + dx1 * dx1) + (dx2 * dx2 + dx3 * dx3);
if (square_modulus1 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32 || square_modulus2 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32) { if (square_modulus1 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT) {
return square_distance <= BGC_SQUARE_EPSYLON_FP32; return square_distance <= BGC_FP32_SQUARE_EPSYLON;
} }
return square_distance <= BGC_SQUARE_EPSYLON_FP32 * square_modulus1 && square_distance <= BGC_SQUARE_EPSYLON_FP32 * square_modulus2; return square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus2;
} }
inline int bgc_quaternion_are_close_fp64(const BgcQuaternionFP64* quaternion1, const BgcQuaternionFP64* quaternion2) inline int bgc_fp64_quaternion_are_close(const BGC_FP64_Quaternion* quaternion1, const BGC_FP64_Quaternion* quaternion2)
{ {
const double ds0 = quaternion1->s0 - quaternion2->s0; const double ds0 = quaternion1->s0 - quaternion2->s0;
const double dx1 = quaternion1->x1 - quaternion2->x1; const double dx1 = quaternion1->x1 - quaternion2->x1;
const double dx2 = quaternion1->x2 - quaternion2->x2; const double dx2 = quaternion1->x2 - quaternion2->x2;
const double dx3 = quaternion1->x3 - quaternion2->x3; const double dx3 = quaternion1->x3 - quaternion2->x3;
const double square_modulus1 = bgc_quaternion_get_square_modulus_fp64(quaternion1); const double square_modulus1 = bgc_fp64_quaternion_get_square_modulus(quaternion1);
const double square_modulus2 = bgc_quaternion_get_square_modulus_fp64(quaternion2); const double square_modulus2 = bgc_fp64_quaternion_get_square_modulus(quaternion2);
const double square_distance = (ds0 * ds0 + dx1 * dx1) + (dx2 * dx2 + dx3 * dx3); const double square_distance = (ds0 * ds0 + dx1 * dx1) + (dx2 * dx2 + dx3 * dx3);
if (square_modulus1 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP64 || square_modulus2 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP64) { if (square_modulus1 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT) {
return square_distance <= BGC_SQUARE_EPSYLON_FP64; return square_distance <= BGC_FP64_SQUARE_EPSYLON;
} }
return square_distance <= BGC_SQUARE_EPSYLON_FP64 * square_modulus1 && square_distance <= BGC_SQUARE_EPSYLON_FP64 * square_modulus2; return square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus2;
} }
#endif #endif

View file

@ -1,14 +1,14 @@
#include "rotation3.h" #include "rotation3.h"
const BgcRotation3FP32 BGC_IDLE_ROTATION3_FP32 = { {0.0f, 0.0f, 0.0f}, 0.0f}; const BGC_FP32_Rotation3 BGC_FP32_IDLE_ROTATION3 = { {0.0f, 0.0f, 0.0f}, 0.0f};
const BgcRotation3FP64 BGC_IDLE_ROTATION3_FP64 = { {0.0, 0.0, 0.0}, 0.0}; const BGC_FP64_Rotation3 BGC_FP64_IDLE_ROTATION3 = { {0.0, 0.0, 0.0}, 0.0};
extern inline void bgc_rotation3_reset_fp32(BgcRotation3FP32* rotation); extern inline void bgc_fp32_rotation3_reset(BGC_FP32_Rotation3* rotation);
extern inline void bgc_rotation3_reset_fp64(BgcRotation3FP64* rotation); extern inline void bgc_fp64_rotation3_reset(BGC_FP64_Rotation3* rotation);
extern inline void bgc_rotation3_set_values_fp32(const float x1, const float x2, const float x3, const float angle, const BgcAngleUnitEnum unit, BgcRotation3FP32* rotation); extern inline void bgc_fp32_rotation3_make(const float x1, const float x2, const float x3, const float angle, const int unit, BGC_FP32_Rotation3* rotation);
extern inline void bgc_rotation3_set_values_fp64(const double x1, const double x2, const double x3, const double angle, const BgcAngleUnitEnum unit, BgcRotation3FP64* rotation); extern inline void bgc_fp64_rotation3_make(const double x1, const double x2, const double x3, const double angle, const int unit, BGC_FP64_Rotation3* rotation);
extern inline void bgc_rotation3_set_with_axis_fp32(const BgcVector3FP32* axis, const float angle, const BgcAngleUnitEnum unit, BgcRotation3FP32* rotation); extern inline void bgc_fp32_rotation3_make_for_axis(const BGC_FP32_Vector3* axis, const float angle, const int unit, BGC_FP32_Rotation3* rotation);
extern inline void bgc_rotation3_set_with_axis_fp64(const BgcVector3FP64* axis, const double angle, const BgcAngleUnitEnum unit, BgcRotation3FP64* rotation); extern inline void bgc_fp64_rotation3_make_for_axis(const BGC_FP64_Vector3* axis, const double angle, const int unit, BGC_FP64_Rotation3* rotation);

View file

@ -6,22 +6,22 @@
#include "vector3.h" #include "vector3.h"
typedef struct { typedef struct {
BgcVector3FP32 axis; BGC_FP32_Vector3 axis;
float radians; float radians;
} BgcRotation3FP32; } BGC_FP32_Rotation3;
typedef struct { typedef struct {
BgcVector3FP64 axis; BGC_FP64_Vector3 axis;
double radians; double radians;
} BgcRotation3FP64; } BGC_FP64_Rotation3;
extern const BgcRotation3FP32 BGC_IDLE_ROTATION3_FP32; extern const BGC_FP32_Rotation3 BGC_FP32_IDLE_ROTATION3;
extern const BgcRotation3FP64 BGC_IDLE_ROTATION3_FP64; extern const BGC_FP64_Rotation3 BGC_FP64_IDLE_ROTATION3;
// =================== Reset ==================== // // =================== Reset ==================== //
inline void bgc_rotation3_reset_fp32(BgcRotation3FP32* rotation) inline void bgc_fp32_rotation3_reset(BGC_FP32_Rotation3* rotation)
{ {
rotation->axis.x1 = 0.0f; rotation->axis.x1 = 0.0f;
rotation->axis.x2 = 0.0f; rotation->axis.x2 = 0.0f;
@ -30,7 +30,7 @@ inline void bgc_rotation3_reset_fp32(BgcRotation3FP32* rotation)
rotation->radians = 0.0f; rotation->radians = 0.0f;
} }
inline void bgc_rotation3_reset_fp64(BgcRotation3FP64* rotation) inline void bgc_fp64_rotation3_reset(BGC_FP64_Rotation3* rotation)
{ {
rotation->axis.x1 = 0.0; rotation->axis.x1 = 0.0;
rotation->axis.x2 = 0.0; rotation->axis.x2 = 0.0;
@ -41,14 +41,14 @@ inline void bgc_rotation3_reset_fp64(BgcRotation3FP64* rotation)
// ================= Set Values ================= // // ================= Set Values ================= //
inline void bgc_rotation3_set_values_fp32(const float x1, const float x2, const float x3, const float angle, const BgcAngleUnitEnum unit, BgcRotation3FP32* rotation) inline void bgc_fp32_rotation3_make(const float x1, const float x2, const float x3, const float angle, const int unit, BGC_FP32_Rotation3* rotation)
{ {
rotation->axis.x1 = x1; rotation->axis.x1 = x1;
rotation->axis.x2 = x2; rotation->axis.x2 = x2;
rotation->axis.x3 = x3; rotation->axis.x3 = x3;
if (bgc_vector3_normalize_fp32(&rotation->axis)) { if (bgc_fp32_vector3_normalize(&rotation->axis)) {
rotation->radians = bgc_angle_to_radians_fp32(angle, unit); rotation->radians = bgc_fp32_angle_to_radians(angle, unit);
} }
else { else {
rotation->radians = 0.0f; rotation->radians = 0.0f;
@ -56,34 +56,34 @@ inline void bgc_rotation3_set_values_fp32(const float x1, const float x2, const
} }
inline void bgc_rotation3_set_values_fp64(const double x1, const double x2, const double x3, const double angle, const BgcAngleUnitEnum unit, BgcRotation3FP64* rotation) inline void bgc_fp64_rotation3_make(const double x1, const double x2, const double x3, const double angle, const int unit, BGC_FP64_Rotation3* rotation)
{ {
rotation->axis.x1 = x1; rotation->axis.x1 = x1;
rotation->axis.x2 = x2; rotation->axis.x2 = x2;
rotation->axis.x3 = x3; rotation->axis.x3 = x3;
if (bgc_vector3_normalize_fp64(&rotation->axis)) { if (bgc_fp64_vector3_normalize(&rotation->axis)) {
rotation->radians = bgc_angle_to_radians_fp64(angle, unit); rotation->radians = bgc_fp64_angle_to_radians(angle, unit);
} }
else { else {
rotation->radians = 0.0; rotation->radians = 0.0;
} }
} }
inline void bgc_rotation3_set_with_axis_fp32(const BgcVector3FP32* axis, const float angle, const BgcAngleUnitEnum unit, BgcRotation3FP32* rotation) inline void bgc_fp32_rotation3_make_for_axis(const BGC_FP32_Vector3* axis, const float angle, const int unit, BGC_FP32_Rotation3* rotation)
{ {
if (bgc_vector3_get_normalized_fp32(axis, &rotation->axis)) { if (bgc_fp32_vector3_get_normalized(axis, &rotation->axis)) {
rotation->radians = bgc_angle_to_radians_fp32(angle, unit); rotation->radians = bgc_fp32_angle_to_radians(angle, unit);
} }
else { else {
rotation->radians = 0.0f; rotation->radians = 0.0f;
} }
} }
inline void bgc_rotation3_set_with_axis_fp64(const BgcVector3FP64* axis, const double angle, const BgcAngleUnitEnum unit, BgcRotation3FP64* rotation) inline void bgc_fp64_rotation3_make_for_axis(const BGC_FP64_Vector3* axis, const double angle, const int unit, BGC_FP64_Rotation3* rotation)
{ {
if (bgc_vector3_get_normalized_fp64(axis, &rotation->axis)) { if (bgc_fp64_vector3_get_normalized(axis, &rotation->axis)) {
rotation->radians = bgc_angle_to_radians_fp64(angle, unit); rotation->radians = bgc_fp64_angle_to_radians(angle, unit);
} }
else { else {
rotation->radians = 0.0; rotation->radians = 0.0;

View file

@ -1,27 +1,27 @@
#include "./slerp.h" #include "./slerp.h"
extern inline void bgc_slerp_reset_fp32(BgcSlerpFP32* slerp); extern inline void bgc_fp32_slerp_reset(BGC_FP32_Slerp* slerp);
extern inline void bgc_slerp_reset_fp64(BgcSlerpFP64* slerp); extern inline void bgc_fp64_slerp_reset(BGC_FP64_Slerp* slerp);
extern inline void bgc_slerp_make_full_fp32(const BgcVersorFP32* start, const BgcVersorFP32* end, BgcSlerpFP32* slerp); extern inline void bgc_fp32_slerp_make_full(const BGC_FP32_Versor* start, const BGC_FP32_Versor* end, BGC_FP32_Slerp* slerp);
extern inline void bgc_slerp_make_full_fp64(const BgcVersorFP64* start, const BgcVersorFP64* end, BgcSlerpFP64* slerp); extern inline void bgc_fp64_slerp_make_full(const BGC_FP64_Versor* start, const BGC_FP64_Versor* end, BGC_FP64_Slerp* slerp);
extern inline void bgc_slerp_make_shortened_fp32(const BgcVersorFP32* start, const BgcVersorFP32* end, BgcSlerpFP32* slerp); extern inline void bgc_fp32_slerp_make_shortened(const BGC_FP32_Versor* start, const BGC_FP32_Versor* end, BGC_FP32_Slerp* slerp);
extern inline void bgc_slerp_make_shortened_fp64(const BgcVersorFP64* start, const BgcVersorFP64* end, BgcSlerpFP64* slerp); extern inline void bgc_fp64_slerp_make_shortened(const BGC_FP64_Versor* start, const BGC_FP64_Versor* end, BGC_FP64_Slerp* slerp);
extern inline void bgc_slerp_get_turn_for_phase_fp32(const BgcSlerpFP32* slerp, const float phase, BgcVersorFP32* result); extern inline void bgc_fp32_slerp_get_phase_versor(const BGC_FP32_Slerp* slerp, const float phase, BGC_FP32_Versor* result);
extern inline void bgc_slerp_get_turn_for_phase_fp64(const BgcSlerpFP64* slerp, const double phase, BgcVersorFP64* result); extern inline void bgc_fp64_slerp_get_phase_versor(const BGC_FP64_Slerp* slerp, const double phase, BGC_FP64_Versor* result);
void bgc_slerp_make_fp32(const BgcVersorFP32* start, const BgcVersorFP32* augment, BgcSlerpFP32* slerp) void bgc_fp32_slerp_make(const BGC_FP32_Versor* start, const BGC_FP32_Versor* augment, BGC_FP32_Slerp* slerp)
{ {
const float square_vector = augment->_x1 * augment->_x1 + augment->_x2 * augment->_x2 + augment->_x3 * augment->_x3; const float square_vector = augment->_x1 * augment->_x1 + augment->_x2 * augment->_x2 + augment->_x3 * augment->_x3;
if (square_vector != square_vector) { if (square_vector != square_vector) {
bgc_slerp_reset_fp32(slerp); bgc_fp32_slerp_reset(slerp);
return; return;
} }
if (square_vector <= BGC_SQUARE_EPSYLON_FP32) { if (square_vector <= BGC_FP32_SQUARE_EPSYLON) {
slerp->s0_cos_weight = start->_s0; slerp->s0_cos_weight = start->_s0;
slerp->x1_cos_weight = start->_x1; slerp->x1_cos_weight = start->_x1;
slerp->x2_cos_weight = start->_x2; slerp->x2_cos_weight = start->_x2;
@ -53,16 +53,16 @@ void bgc_slerp_make_fp32(const BgcVersorFP32* start, const BgcVersorFP32* augmen
slerp->x3_sin_weight = multiplier * (augment->_x3 * start->_s0 - augment->_x2 * start->_x1 + augment->_x1 * start->_x2); slerp->x3_sin_weight = multiplier * (augment->_x3 * start->_s0 - augment->_x2 * start->_x1 + augment->_x1 * start->_x2);
} }
void bgc_slerp_make_fp64(const BgcVersorFP64* start, const BgcVersorFP64* augment, BgcSlerpFP64* slerp) void bgc_fp64_slerp_make(const BGC_FP64_Versor* start, const BGC_FP64_Versor* augment, BGC_FP64_Slerp* slerp)
{ {
const double square_vector = augment->_x1 * augment->_x1 + augment->_x2 * augment->_x2 + augment->_x3 * augment->_x3; const double square_vector = augment->_x1 * augment->_x1 + augment->_x2 * augment->_x2 + augment->_x3 * augment->_x3;
if (square_vector != square_vector) { if (square_vector != square_vector) {
bgc_slerp_reset_fp64(slerp); bgc_fp64_slerp_reset(slerp);
return; return;
} }
if (square_vector <= BGC_SQUARE_EPSYLON_FP64) { if (square_vector <= BGC_FP64_SQUARE_EPSYLON) {
slerp->s0_cos_weight = start->_s0; slerp->s0_cos_weight = start->_s0;
slerp->x1_cos_weight = start->_x1; slerp->x1_cos_weight = start->_x1;
slerp->x2_cos_weight = start->_x2; slerp->x2_cos_weight = start->_x2;

View file

@ -9,7 +9,7 @@ typedef struct {
float x2_cos_weight, x2_sin_weight; float x2_cos_weight, x2_sin_weight;
float x3_cos_weight, x3_sin_weight; float x3_cos_weight, x3_sin_weight;
float radians; float radians;
} BgcSlerpFP32; } BGC_FP32_Slerp;
typedef struct { typedef struct {
double s0_cos_weight, s0_sin_weight; double s0_cos_weight, s0_sin_weight;
@ -17,9 +17,9 @@ typedef struct {
double x2_cos_weight, x2_sin_weight; double x2_cos_weight, x2_sin_weight;
double x3_cos_weight, x3_sin_weight; double x3_cos_weight, x3_sin_weight;
double radians; double radians;
} BgcSlerpFP64; } BGC_FP64_Slerp;
inline void bgc_slerp_reset_fp32(BgcSlerpFP32* slerp) inline void bgc_fp32_slerp_reset(BGC_FP32_Slerp* slerp)
{ {
slerp->s0_cos_weight = 1.0f; slerp->s0_cos_weight = 1.0f;
slerp->s0_sin_weight = 0.0f; slerp->s0_sin_weight = 0.0f;
@ -36,7 +36,7 @@ inline void bgc_slerp_reset_fp32(BgcSlerpFP32* slerp)
slerp->radians = 0.0f; slerp->radians = 0.0f;
} }
inline void bgc_slerp_reset_fp64(BgcSlerpFP64* slerp) inline void bgc_fp64_slerp_reset(BGC_FP64_Slerp* slerp)
{ {
slerp->s0_cos_weight = 1.0; slerp->s0_cos_weight = 1.0;
slerp->s0_sin_weight = 0.0; slerp->s0_sin_weight = 0.0;
@ -53,55 +53,55 @@ inline void bgc_slerp_reset_fp64(BgcSlerpFP64* slerp)
slerp->radians = 0.0; slerp->radians = 0.0;
} }
void bgc_slerp_make_fp32(const BgcVersorFP32* start, const BgcVersorFP32* augment, BgcSlerpFP32* slerp); void bgc_fp32_slerp_make(const BGC_FP32_Versor* start, const BGC_FP32_Versor* augment, BGC_FP32_Slerp* slerp);
void bgc_slerp_make_fp64(const BgcVersorFP64* start, const BgcVersorFP64* augment, BgcSlerpFP64* slerp); void bgc_fp64_slerp_make(const BGC_FP64_Versor* start, const BGC_FP64_Versor* augment, BGC_FP64_Slerp* slerp);
inline void bgc_slerp_make_full_fp32(const BgcVersorFP32* start, const BgcVersorFP32* end, BgcSlerpFP32* slerp) inline void bgc_fp32_slerp_make_full(const BGC_FP32_Versor* start, const BGC_FP32_Versor* end, BGC_FP32_Slerp* slerp)
{ {
BgcVersorFP32 augment; BGC_FP32_Versor augment;
bgc_versor_exclude_fp32(end, start, &augment); bgc_fp32_versor_exclude(end, start, &augment);
bgc_slerp_make_fp32(start, &augment, slerp); bgc_fp32_slerp_make(start, &augment, slerp);
} }
inline void bgc_slerp_make_full_fp64(const BgcVersorFP64* start, const BgcVersorFP64* end, BgcSlerpFP64* slerp) inline void bgc_fp64_slerp_make_full(const BGC_FP64_Versor* start, const BGC_FP64_Versor* end, BGC_FP64_Slerp* slerp)
{ {
BgcVersorFP64 augment; BGC_FP64_Versor augment;
bgc_versor_exclude_fp64(end, start, &augment); bgc_fp64_versor_exclude(end, start, &augment);
bgc_slerp_make_fp64(start, &augment, slerp); bgc_fp64_slerp_make(start, &augment, slerp);
} }
inline void bgc_slerp_make_shortened_fp32(const BgcVersorFP32* start, const BgcVersorFP32* end, BgcSlerpFP32* slerp) inline void bgc_fp32_slerp_make_shortened(const BGC_FP32_Versor* start, const BGC_FP32_Versor* end, BGC_FP32_Slerp* slerp)
{ {
BgcVersorFP32 augment; BGC_FP32_Versor augment;
bgc_versor_exclude_fp32(end, start, &augment); bgc_fp32_versor_exclude(end, start, &augment);
bgc_versor_shorten_fp32(&augment); bgc_fp32_versor_shorten(&augment);
bgc_slerp_make_fp32(start, &augment, slerp); bgc_fp32_slerp_make(start, &augment, slerp);
} }
inline void bgc_slerp_make_shortened_fp64(const BgcVersorFP64* start, const BgcVersorFP64* end, BgcSlerpFP64* slerp) inline void bgc_fp64_slerp_make_shortened(const BGC_FP64_Versor* start, const BGC_FP64_Versor* end, BGC_FP64_Slerp* slerp)
{ {
BgcVersorFP64 augment; BGC_FP64_Versor augment;
bgc_versor_exclude_fp64(end, start, &augment); bgc_fp64_versor_exclude(end, start, &augment);
bgc_versor_shorten_fp64(&augment); bgc_fp64_versor_shorten(&augment);
bgc_slerp_make_fp64(start, &augment, slerp); bgc_fp64_slerp_make(start, &augment, slerp);
} }
inline void bgc_slerp_get_turn_for_phase_fp32(const BgcSlerpFP32* slerp, const float phase, BgcVersorFP32* result) inline void bgc_fp32_slerp_get_phase_versor(const BGC_FP32_Slerp* slerp, const float phase, BGC_FP32_Versor* result)
{ {
const float angle = slerp->radians * phase; const float angle = slerp->radians * phase;
const float cosine = cosf(angle); const float cosine = cosf(angle);
const float sine = sinf(angle); const float sine = sinf(angle);
bgc_versor_set_values_fp32( bgc_fp32_versor_make(
slerp->s0_cos_weight * cosine + slerp->s0_sin_weight * sine, slerp->s0_cos_weight * cosine + slerp->s0_sin_weight * sine,
slerp->x1_cos_weight * cosine + slerp->x1_sin_weight * sine, slerp->x1_cos_weight * cosine + slerp->x1_sin_weight * sine,
slerp->x2_cos_weight * cosine + slerp->x2_sin_weight * sine, slerp->x2_cos_weight * cosine + slerp->x2_sin_weight * sine,
@ -110,13 +110,13 @@ inline void bgc_slerp_get_turn_for_phase_fp32(const BgcSlerpFP32* slerp, const f
); );
} }
inline void bgc_slerp_get_turn_for_phase_fp64(const BgcSlerpFP64* slerp, const double phase, BgcVersorFP64* result) inline void bgc_fp64_slerp_get_phase_versor(const BGC_FP64_Slerp* slerp, const double phase, BGC_FP64_Versor* result)
{ {
const double angle = slerp->radians * phase; const double angle = slerp->radians * phase;
const double cosine = cos(angle); const double cosine = cos(angle);
const double sine = sin(angle); const double sine = sin(angle);
bgc_versor_set_values_fp64( bgc_fp64_versor_make(
slerp->s0_cos_weight * cosine + slerp->s0_sin_weight * sine, slerp->s0_cos_weight * cosine + slerp->s0_sin_weight * sine,
slerp->x1_cos_weight * cosine + slerp->x1_sin_weight * sine, slerp->x1_cos_weight * cosine + slerp->x1_sin_weight * sine,
slerp->x2_cos_weight * cosine + slerp->x2_sin_weight * sine, slerp->x2_cos_weight * cosine + slerp->x2_sin_weight * sine,

View file

@ -2,14 +2,14 @@
extern inline int bgc_is_correct_axis(const int axis); extern inline int bgc_is_correct_axis(const int axis);
extern inline int bgc_is_zero_fp32(const float square_value); extern inline int bgc_fp32_is_zero(const float square_value);
extern inline int bgc_is_zero_fp64(const double square_value); extern inline int bgc_fp64_is_zero(const double square_value);
extern inline int bgc_is_unit_fp32(const float square_value); extern inline int bgc_fp32_is_unit(const float square_value);
extern inline int bgc_is_unit_fp64(const double square_value); extern inline int bgc_fp64_is_unit(const double square_value);
extern inline int bgc_is_sqare_unit_fp32(const float square_value); extern inline int bgc_fp32_is_square_unit(const float square_value);
extern inline int bgc_is_sqare_unit_fp64(const double square_value); extern inline int bgc_fp64_is_square_unit(const double square_value);
extern inline int bgc_are_close_fp32(const float value1, const float value2); extern inline int bgc_fp32_are_close(const float value1, const float value2);
extern inline int bgc_are_close_fp64(const double value1, const double value2); extern inline int bgc_fp64_are_close(const double value1, const double value2);

View file

@ -1,33 +1,31 @@
#ifndef _BGC_UTILITIES_H_ #ifndef _BGC_UTILITIES_H_
#define _BGC_UTILITIES_H_ #define _BGC_UTILITIES_H_
#define BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32 1.0f #define BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT 1.0f
#define BGC_EPSYLON_FP32 4.76837E-7f #define BGC_FP32_EPSYLON 4.76837E-7f
#define BGC_SQUARE_EPSYLON_FP32 (BGC_EPSYLON_FP32 * BGC_EPSYLON_FP32) #define BGC_FP32_SQUARE_EPSYLON (BGC_FP32_EPSYLON * BGC_FP32_EPSYLON)
#define BGC_ONE_THIRD_FP32 0.3333333333f #define BGC_FP32_ONE_THIRD 0.3333333333f
#define BGC_ONE_SIXTH_FP32 0.1666666667f #define BGC_FP32_ONE_SIXTH 0.1666666667f
#define BGC_ONE_SEVENTH_FP32 0.142857142857f #define BGC_FP32_ONE_SEVENTH 0.142857142857f
#define BGC_ONE_NINETH_FP32 0.1111111111f #define BGC_FP32_ONE_NINETH 0.1111111111f
#define BGC_ARCCOSINE_PRECISION_LIMIT_FP32 0.70711f #define BGC_FP32_GOLDEN_RATIO_HIGH 1.618034f
#define BGC_FP32_GOLDEN_RATIO_LOW 0.618034f
#define BGC_GOLDEN_RATIO_HIGH_FP32 1.618034f #define BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT 1.0
#define BGC_GOLDEN_RATIO_LOW_FP32 0.618034f
#define BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP64 1.0 #define BGC_FP64_EPSYLON 4.996003611E-14
#define BGC_FP64_SQUARE_EPSYLON (BGC_FP64_EPSYLON * BGC_FP64_EPSYLON)
#define BGC_EPSYLON_FP64 4.996003611E-14 #define BGC_FP64_ONE_THIRD 0.3333333333333333333
#define BGC_SQUARE_EPSYLON_FP64 (BGC_EPSYLON_FP64 * BGC_EPSYLON_FP64) #define BGC_FP64_ONE_SIXTH 0.1666666666666666667
#define BGC_FP64_ONE_SEVENTH 0.142857142857142857
#define BGC_FP64_ONE_NINETH 0.1111111111111111111
#define BGC_ONE_THIRD_FP64 0.3333333333333333333 #define BGC_FP64_GOLDEN_RATIO_HIGH 1.61803398874989485
#define BGC_ONE_SIXTH_FP64 0.1666666666666666667 #define BGC_FP64_GOLDEN_RATIO_LOW 0.61803398874989485
#define BGC_ONE_SEVENTH_FP64 0.142857142857142857
#define BGC_ONE_NINETH_FP64 0.1111111111111111111
#define BGC_GOLDEN_RATIO_HIGH_FP64 1.61803398874989485
#define BGC_GOLDEN_RATIO_LOW_FP64 0.61803398874989485
#define BGC_SUCCESS 0 #define BGC_SUCCESS 0
#define BGC_FAILED -1 #define BGC_FAILED -1
@ -53,66 +51,66 @@ inline int bgc_is_correct_axis(const int axis)
|| axis == BGC_AXIS_X3 || axis == BGC_AXIS_REVERSE_X3; || axis == BGC_AXIS_X3 || axis == BGC_AXIS_REVERSE_X3;
} }
inline int bgc_is_zero_fp32(const float value) inline int bgc_fp32_is_zero(const float value)
{ {
return (-BGC_EPSYLON_FP32 <= value) && (value <= BGC_EPSYLON_FP32); return (-BGC_FP32_EPSYLON <= value) && (value <= BGC_FP32_EPSYLON);
} }
inline int bgc_is_zero_fp64(const double value) inline int bgc_fp64_is_zero(const double value)
{ {
return (-BGC_EPSYLON_FP64 <= value) && (value <= BGC_EPSYLON_FP64); return (-BGC_FP64_EPSYLON <= value) && (value <= BGC_FP64_EPSYLON);
} }
inline int bgc_is_unit_fp32(const float value) inline int bgc_fp32_is_unit(const float value)
{ {
return (1.0f - BGC_EPSYLON_FP32 <= value) && (value <= 1.0f + BGC_EPSYLON_FP32); return (1.0f - BGC_FP32_EPSYLON <= value) && (value <= 1.0f + BGC_FP32_EPSYLON);
} }
inline int bgc_is_unit_fp64(const double value) inline int bgc_fp64_is_unit(const double value)
{ {
return (1.0 - BGC_EPSYLON_FP64 <= value) && (value <= 1.0 + BGC_EPSYLON_FP64); return (1.0 - BGC_FP64_EPSYLON <= value) && (value <= 1.0 + BGC_FP64_EPSYLON);
} }
inline int bgc_is_sqare_unit_fp32(const float square_value) inline int bgc_fp32_is_square_unit(const float square_value)
{ {
return (1.0f - 2.0f * BGC_EPSYLON_FP32 <= square_value) && (square_value <= 1.0f + 2.0f * BGC_EPSYLON_FP32); return (1.0f - 2.0f * BGC_FP32_EPSYLON <= square_value) && (square_value <= 1.0f + 2.0f * BGC_FP32_EPSYLON);
} }
inline int bgc_is_sqare_unit_fp64(const double square_value) inline int bgc_fp64_is_square_unit(const double square_value)
{ {
return (1.0 - 2.0 * BGC_EPSYLON_FP64 <= square_value) && (square_value <= 1.0 + 2.0 * BGC_EPSYLON_FP64); return (1.0 - 2.0 * BGC_FP64_EPSYLON <= square_value) && (square_value <= 1.0 + 2.0 * BGC_FP64_EPSYLON);
} }
// ================== Are Close ================= // // ================== Are Close ================= //
inline int bgc_are_close_fp32(const float value1, const float value2) inline int bgc_fp32_are_close(const float value1, const float value2)
{ {
const float difference = value1 - value2; const float difference = value1 - value2;
const float square_value1 = value1 * value1; const float square_value1 = value1 * value1;
const float square_value2 = value2 * value2; const float square_value2 = value2 * value2;
const float square_difference = difference * difference; const float square_difference = difference * difference;
if (square_value1 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32 || square_value2 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32) { if (square_value1 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT || square_value2 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT) {
return square_difference <= BGC_SQUARE_EPSYLON_FP32; return square_difference <= BGC_FP32_SQUARE_EPSYLON;
} }
return square_difference <= BGC_SQUARE_EPSYLON_FP32 * square_value1 && square_difference <= BGC_SQUARE_EPSYLON_FP32 * square_value2; return square_difference <= BGC_FP32_SQUARE_EPSYLON * square_value1 && square_difference <= BGC_FP32_SQUARE_EPSYLON * square_value2;
} }
inline int bgc_are_close_fp64(const double value1, const double value2) inline int bgc_fp64_are_close(const double value1, const double value2)
{ {
const double difference = value1 - value2; const double difference = value1 - value2;
const double square_value1 = value1 * value1; const double square_value1 = value1 * value1;
const double square_value2 = value2 * value2; const double square_value2 = value2 * value2;
const double square_difference = difference * difference; const double square_difference = difference * difference;
if (square_value1 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP64 || square_value2 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP64) { if (square_value1 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT || square_value2 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT) {
return square_difference <= BGC_SQUARE_EPSYLON_FP64; return square_difference <= BGC_FP64_SQUARE_EPSYLON;
} }
return square_difference <= BGC_SQUARE_EPSYLON_FP64 * square_value1 && square_difference <= BGC_SQUARE_EPSYLON_FP64 * square_value2; return square_difference <= BGC_FP64_SQUARE_EPSYLON * square_value1 && square_difference <= BGC_FP64_SQUARE_EPSYLON * square_value2;
} }
#endif #endif

View file

@ -1,143 +1,143 @@
#include "vector2.h" #include "vector2.h"
extern inline void bgc_vector2_reset_fp32(BgcVector2FP32* vector); extern inline void bgc_fp32_vector2_reset(BGC_FP32_Vector2* vector);
extern inline void bgc_vector2_reset_fp64(BgcVector2FP64* vector); extern inline void bgc_fp64_vector2_reset(BGC_FP64_Vector2* vector);
extern inline void bgc_vector2_set_values_fp32(const float x1, const float x2, BgcVector2FP32* destination); extern inline void bgc_fp32_vector2_make(const float x1, const float x2, BGC_FP32_Vector2* destination);
extern inline void bgc_vector2_set_values_fp64(const double x1, const double x2, BgcVector2FP64* destination); extern inline void bgc_fp64_vector2_make(const double x1, const double x2, BGC_FP64_Vector2* destination);
extern inline float bgc_vector2_get_square_modulus_fp32(const BgcVector2FP32* vector); extern inline float bgc_fp32_vector2_get_square_modulus(const BGC_FP32_Vector2* vector);
extern inline double bgc_vector2_get_square_modulus_fp64(const BgcVector2FP64* vector); extern inline double bgc_fp64_vector2_get_square_modulus(const BGC_FP64_Vector2* vector);
extern inline float bgc_vector2_get_modulus_fp32(const BgcVector2FP32* vector); extern inline float bgc_fp32_vector2_get_modulus(const BGC_FP32_Vector2* vector);
extern inline double bgc_vector2_get_modulus_fp64(const BgcVector2FP64* vector); extern inline double bgc_fp64_vector2_get_modulus(const BGC_FP64_Vector2* vector);
extern inline int bgc_vector2_is_zero_fp32(const BgcVector2FP32* vector); extern inline int bgc_fp32_vector2_is_zero(const BGC_FP32_Vector2* vector);
extern inline int bgc_vector2_is_zero_fp64(const BgcVector2FP64* vector); extern inline int bgc_fp64_vector2_is_zero(const BGC_FP64_Vector2* vector);
extern inline int bgc_vector2_is_unit_fp32(const BgcVector2FP32* vector); extern inline int bgc_fp32_vector2_is_unit(const BGC_FP32_Vector2* vector);
extern inline int bgc_vector2_is_unit_fp64(const BgcVector2FP64* vector); extern inline int bgc_fp64_vector2_is_unit(const BGC_FP64_Vector2* vector);
extern inline void bgc_vector2_copy_fp32(const BgcVector2FP32* source, BgcVector2FP32* destination); extern inline void bgc_fp32_vector2_copy(const BGC_FP32_Vector2* source, BGC_FP32_Vector2* destination);
extern inline void bgc_vector2_copy_fp64(const BgcVector2FP64* source, BgcVector2FP64* destination); extern inline void bgc_fp64_vector2_copy(const BGC_FP64_Vector2* source, BGC_FP64_Vector2* destination);
extern inline void bgc_vector2_swap_fp32(BgcVector2FP32* vector1, BgcVector2FP32* vector2); extern inline void bgc_fp32_vector2_swap(BGC_FP32_Vector2* vector1, BGC_FP32_Vector2* vector2);
extern inline void bgc_vector2_swap_fp64(BgcVector2FP64* vector1, BgcVector2FP64* vector2); extern inline void bgc_fp64_vector2_swap(BGC_FP64_Vector2* vector1, BGC_FP64_Vector2* vector2);
extern inline void bgc_vector2_convert_fp64_to_fp32(const BgcVector2FP64* source, BgcVector2FP32* destination); extern inline void bgc_fp64_vector2_convert_to_fp32(const BGC_FP64_Vector2* source, BGC_FP32_Vector2* destination);
extern inline void bgc_vector2_convert_fp32_to_fp64(const BgcVector2FP32* source, BgcVector2FP64* destination); extern inline void bgc_fp32_vector2_convert_to_fp64(const BGC_FP32_Vector2* source, BGC_FP64_Vector2* destination);
extern inline void bgc_vector2_add_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2, BgcVector2FP32* sum); extern inline void bgc_fp32_vector2_add(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2, BGC_FP32_Vector2* sum);
extern inline void bgc_vector2_add_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2, BgcVector2FP64* sum); extern inline void bgc_fp64_vector2_add(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2, BGC_FP64_Vector2* sum);
extern inline void bgc_vector2_add_scaled_fp32(const BgcVector2FP32* basic_vector, const BgcVector2FP32* scalable_vector, const float scale, BgcVector2FP32* sum); extern inline void bgc_fp32_vector2_add_scaled(const BGC_FP32_Vector2* basic_vector, const BGC_FP32_Vector2* scalable_vector, const float scale, BGC_FP32_Vector2* sum);
extern inline void bgc_vector2_add_scaled_fp64(const BgcVector2FP64* basic_vector, const BgcVector2FP64* scalable_vector, const double scale, BgcVector2FP64* sum); extern inline void bgc_fp64_vector2_add_scaled(const BGC_FP64_Vector2* basic_vector, const BGC_FP64_Vector2* scalable_vector, const double scale, BGC_FP64_Vector2* sum);
extern inline void bgc_vector2_subtract_fp32(const BgcVector2FP32* minuend, const BgcVector2FP32* subtrahend, BgcVector2FP32* difference); extern inline void bgc_fp32_vector2_subtract(const BGC_FP32_Vector2* minuend, const BGC_FP32_Vector2* subtrahend, BGC_FP32_Vector2* difference);
extern inline void bgc_vector2_subtract_fp64(const BgcVector2FP64* minuend, const BgcVector2FP64* subtrahend, BgcVector2FP64* difference); extern inline void bgc_fp64_vector2_subtract(const BGC_FP64_Vector2* minuend, const BGC_FP64_Vector2* subtrahend, BGC_FP64_Vector2* difference);
extern inline void bgc_vector2_multiply_fp32(const BgcVector2FP32* multiplicand, const float multiplier, BgcVector2FP32* product); extern inline void bgc_fp32_vector2_multiply(const BGC_FP32_Vector2* multiplicand, const float multiplier, BGC_FP32_Vector2* product);
extern inline void bgc_vector2_multiply_fp64(const BgcVector2FP64* multiplicand, const double multiplier, BgcVector2FP64* product); extern inline void bgc_fp64_vector2_multiply(const BGC_FP64_Vector2* multiplicand, const double multiplier, BGC_FP64_Vector2* product);
extern inline void bgc_vector2_divide_fp32(const BgcVector2FP32* dividend, const float divisor, BgcVector2FP32* quotient); extern inline void bgc_fp32_vector2_divide(const BGC_FP32_Vector2* dividend, const float divisor, BGC_FP32_Vector2* quotient);
extern inline void bgc_vector2_divide_fp64(const BgcVector2FP64* dividend, const double divisor, BgcVector2FP64* quotient); extern inline void bgc_fp64_vector2_divide(const BGC_FP64_Vector2* dividend, const double divisor, BGC_FP64_Vector2* quotient);
extern inline void bgc_vector2_get_mean_of_two_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2, BgcVector2FP32* mean); extern inline void bgc_fp32_vector2_get_middle2(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2, BGC_FP32_Vector2* middle);
extern inline void bgc_vector2_get_mean_of_two_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2, BgcVector2FP64* mean); extern inline void bgc_fp64_vector2_get_middle2(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2, BGC_FP64_Vector2* middle);
extern inline void bgc_vector2_get_mean_of_three_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2, const BgcVector2FP32* vector3, BgcVector2FP32* mean); extern inline void bgc_fp32_vector2_get_middle3(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2, const BGC_FP32_Vector2* vector3, BGC_FP32_Vector2* middle);
extern inline void bgc_vector2_get_mean_of_three_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2, const BgcVector2FP64* vector3, BgcVector2FP64* mean); extern inline void bgc_fp64_vector2_get_middle3(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2, const BGC_FP64_Vector2* vector3, BGC_FP64_Vector2* middle);
extern inline void bgc_vector2_interpolate_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2, const float phase, BgcVector2FP32* interpolation); extern inline void bgc_fp32_vector2_interpolate(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2, const float phase, BGC_FP32_Vector2* interpolation);
extern inline void bgc_vector2_interpolate_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2, const double phase, BgcVector2FP64* interpolation); extern inline void bgc_fp64_vector2_interpolate(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2, const double phase, BGC_FP64_Vector2* interpolation);
extern inline void bgc_vector2_make_opposite_fp32(BgcVector2FP32* vector); extern inline void bgc_fp32_vector2_revert(BGC_FP32_Vector2* vector);
extern inline void bgc_vector2_make_opposite_fp64(BgcVector2FP64* vector); extern inline void bgc_fp64_vector2_revert(BGC_FP64_Vector2* vector);
extern inline void bgc_vector2_get_opposite_fp32(const BgcVector2FP32* vector, BgcVector2FP32* opposite); extern inline void bgc_fp32_vector2_get_reverse(const BGC_FP32_Vector2* vector, BGC_FP32_Vector2* reverse);
extern inline void bgc_vector2_get_opposite_fp64(const BgcVector2FP64* vector, BgcVector2FP64* opposite); extern inline void bgc_fp64_vector2_get_reverse(const BGC_FP64_Vector2* vector, BGC_FP64_Vector2* reverse);
extern inline int bgc_vector2_normalize_fp32(BgcVector2FP32* vector); extern inline int bgc_fp32_vector2_normalize(BGC_FP32_Vector2* vector);
extern inline int bgc_vector2_normalize_fp64(BgcVector2FP64* vector); extern inline int bgc_fp64_vector2_normalize(BGC_FP64_Vector2* vector);
extern inline int bgc_vector2_get_normalized_fp32(const BgcVector2FP32* vector, BgcVector2FP32* normalized); extern inline int bgc_fp32_vector2_get_normalized(const BGC_FP32_Vector2* vector, BGC_FP32_Vector2* normalized);
extern inline int bgc_vector2_get_normalized_fp64(const BgcVector2FP64* vector, BgcVector2FP64* normalized); extern inline int bgc_fp64_vector2_get_normalized(const BGC_FP64_Vector2* vector, BGC_FP64_Vector2* normalized);
extern inline float bgc_vector2_get_scalar_product_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2); extern inline float bgc_fp32_vector2_get_dot_product(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2);
extern inline double bgc_vector2_get_scalar_product_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2); extern inline double bgc_fp64_vector2_get_dot_product(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2);
extern inline float bgc_vector2_get_cross_product_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2); extern inline float bgc_fp32_vector2_get_cross_product(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2);
extern inline double bgc_vector2_get_cross_product_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2); extern inline double bgc_fp64_vector2_get_cross_product(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2);
extern inline float bgc_vector2_get_square_distance_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2); extern inline float bgc_fp32_vector2_get_square_distance(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2);
extern inline double bgc_vector2_get_square_distance_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2); extern inline double bgc_fp64_vector2_get_square_distance(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2);
extern inline float bgc_vector2_get_distance_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2); extern inline float bgc_fp32_vector2_get_distance(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2);
extern inline double bgc_vector2_get_distance_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2); extern inline double bgc_fp64_vector2_get_distance(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2);
extern inline int bgc_vector2_are_close_enough_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2, const float distance); extern inline int bgc_fp32_vector2_are_close_enough(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2, const float distance);
extern inline int bgc_vector2_are_close_enough_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2, const double distance); extern inline int bgc_fp64_vector2_are_close_enough(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2, const double distance);
extern inline int bgc_vector2_are_close_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2); extern inline int bgc_fp32_vector2_are_close(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2);
extern inline int bgc_vector2_are_close_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2); extern inline int bgc_fp64_vector2_are_close(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2);
extern inline int bgc_vector2_are_parallel_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2); extern inline int bgc_fp32_vector2_are_parallel(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2);
extern inline int bgc_vector2_are_parallel_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2); extern inline int bgc_fp64_vector2_are_parallel(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2);
extern inline int bgc_vector2_are_orthogonal_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2); extern inline int bgc_fp32_vector2_are_orthogonal(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2);
extern inline int bgc_vector2_are_orthogonal_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2); extern inline int bgc_fp64_vector2_are_orthogonal(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2);
extern inline int bgc_vector2_get_attitude_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2); extern inline int bgc_fp32_vector2_get_attitude(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2);
extern inline int bgc_vector2_get_attitude_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2); extern inline int bgc_fp64_vector2_get_attitude(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2);
// =================== Angle ==================== // // =================== Angle ==================== //
float bgc_vector2_get_angle_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2, const BgcAngleUnitEnum unit) float bgc_fp32_vector2_get_angle(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2, const int angle_unit)
{ {
const float square_modulus1 = bgc_vector2_get_square_modulus_fp32(vector1); const float square_modulus1 = bgc_fp32_vector2_get_square_modulus(vector1);
// square_modulus1 != square_modulus1 is check for NaN value at square_modulus1 // square_modulus1 != square_modulus1 is check for NaN value at square_modulus1
if (square_modulus1 <= BGC_SQUARE_EPSYLON_FP32 || square_modulus1 != square_modulus1) { if (square_modulus1 <= BGC_FP32_SQUARE_EPSYLON || square_modulus1 != square_modulus1) {
return 0.0f; return 0.0f;
} }
const float square_modulus2 = bgc_vector2_get_square_modulus_fp32(vector2); const float square_modulus2 = bgc_fp32_vector2_get_square_modulus(vector2);
// square_modulus2 != square_modulus2 is check for NaN value at square_modulus2 // square_modulus2 != square_modulus2 is check for NaN value at square_modulus2
if (square_modulus2 <= BGC_SQUARE_EPSYLON_FP32 || square_modulus2 != square_modulus2) { if (square_modulus2 <= BGC_FP32_SQUARE_EPSYLON || square_modulus2 != square_modulus2) {
return 0.0f; return 0.0f;
} }
const float multiplier = sqrtf(1.0f / (square_modulus1 * square_modulus2)); const float multiplier = sqrtf(1.0f / (square_modulus1 * square_modulus2));
const float x = bgc_vector2_get_scalar_product_fp32(vector1, vector2); const float x = bgc_fp32_vector2_get_dot_product(vector1, vector2);
const float y = fabsf(bgc_vector2_get_cross_product_fp32(vector1, vector2)); const float y = fabsf(bgc_fp32_vector2_get_cross_product(vector1, vector2));
return bgc_radians_to_units_fp32(atan2f(y * multiplier, x * multiplier), unit); return bgc_fp32_radians_to_units(atan2f(y * multiplier, x * multiplier), angle_unit);
} }
double bgc_vector2_get_angle_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2, const BgcAngleUnitEnum unit) double bgc_fp64_vector2_get_angle(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2, const int angle_unit)
{ {
const double square_modulus1 = bgc_vector2_get_square_modulus_fp64(vector1); const double square_modulus1 = bgc_fp64_vector2_get_square_modulus(vector1);
// square_modulus1 != square_modulus1 is check for NaN value at square_modulus1 // square_modulus1 != square_modulus1 is check for NaN value at square_modulus1
if (square_modulus1 <= BGC_SQUARE_EPSYLON_FP64 || square_modulus1 != square_modulus1) { if (square_modulus1 <= BGC_FP64_SQUARE_EPSYLON || square_modulus1 != square_modulus1) {
return 0.0; return 0.0;
} }
const double square_modulus2 = bgc_vector2_get_square_modulus_fp64(vector2); const double square_modulus2 = bgc_fp64_vector2_get_square_modulus(vector2);
// square_modulus2 != square_modulus2 is check for NaN value at square_modulus2 // square_modulus2 != square_modulus2 is check for NaN value at square_modulus2
if (square_modulus2 <= BGC_SQUARE_EPSYLON_FP64 || square_modulus2 != square_modulus2) { if (square_modulus2 <= BGC_FP64_SQUARE_EPSYLON || square_modulus2 != square_modulus2) {
return 0.0; return 0.0;
} }
const double multiplier = sqrt(1.0 / (square_modulus1 * square_modulus2)); const double multiplier = sqrt(1.0 / (square_modulus1 * square_modulus2));
const double x = bgc_vector2_get_scalar_product_fp64(vector1, vector2); const double x = bgc_fp64_vector2_get_dot_product(vector1, vector2);
const double y = bgc_vector2_get_cross_product_fp64(vector1, vector2); const double y = bgc_fp64_vector2_get_cross_product(vector1, vector2);
return bgc_radians_to_units_fp64(atan2(y * multiplier, x * multiplier), unit); return bgc_fp64_radians_to_units(atan2(y * multiplier, x * multiplier), angle_unit);
} }

View file

@ -9,22 +9,22 @@
typedef struct typedef struct
{ {
float x1, x2; float x1, x2;
} BgcVector2FP32; } BGC_FP32_Vector2;
typedef struct typedef struct
{ {
double x1, x2; double x1, x2;
} BgcVector2FP64; } BGC_FP64_Vector2;
// =================== Reset ==================== // // =================== Reset ==================== //
inline void bgc_vector2_reset_fp32(BgcVector2FP32* vector) inline void bgc_fp32_vector2_reset(BGC_FP32_Vector2* vector)
{ {
vector->x1 = 0.0f; vector->x1 = 0.0f;
vector->x2 = 0.0f; vector->x2 = 0.0f;
} }
inline void bgc_vector2_reset_fp64(BgcVector2FP64* vector) inline void bgc_fp64_vector2_reset(BGC_FP64_Vector2* vector)
{ {
vector->x1 = 0.0; vector->x1 = 0.0;
vector->x2 = 0.0; vector->x2 = 0.0;
@ -32,13 +32,13 @@ inline void bgc_vector2_reset_fp64(BgcVector2FP64* vector)
// ==================== Set ===================== // // ==================== Set ===================== //
inline void bgc_vector2_set_values_fp32(const float x1, const float x2, BgcVector2FP32* destination) inline void bgc_fp32_vector2_make(const float x1, const float x2, BGC_FP32_Vector2* destination)
{ {
destination->x1 = x1; destination->x1 = x1;
destination->x2 = x2; destination->x2 = x2;
} }
inline void bgc_vector2_set_values_fp64(const double x1, const double x2, BgcVector2FP64* destination) inline void bgc_fp64_vector2_make(const double x1, const double x2, BGC_FP64_Vector2* destination)
{ {
destination->x1 = x1; destination->x1 = x1;
destination->x2 = x2; destination->x2 = x2;
@ -46,57 +46,57 @@ inline void bgc_vector2_set_values_fp64(const double x1, const double x2, BgcVec
// ================== Modulus =================== // // ================== Modulus =================== //
inline float bgc_vector2_get_square_modulus_fp32(const BgcVector2FP32* vector) inline float bgc_fp32_vector2_get_square_modulus(const BGC_FP32_Vector2* vector)
{ {
return vector->x1 * vector->x1 + vector->x2 * vector->x2; return vector->x1 * vector->x1 + vector->x2 * vector->x2;
} }
inline double bgc_vector2_get_square_modulus_fp64(const BgcVector2FP64* vector) inline double bgc_fp64_vector2_get_square_modulus(const BGC_FP64_Vector2* vector)
{ {
return vector->x1 * vector->x1 + vector->x2 * vector->x2; return vector->x1 * vector->x1 + vector->x2 * vector->x2;
} }
inline float bgc_vector2_get_modulus_fp32(const BgcVector2FP32* vector) inline float bgc_fp32_vector2_get_modulus(const BGC_FP32_Vector2* vector)
{ {
return sqrtf(bgc_vector2_get_square_modulus_fp32(vector)); return sqrtf(bgc_fp32_vector2_get_square_modulus(vector));
} }
inline double bgc_vector2_get_modulus_fp64(const BgcVector2FP64* vector) inline double bgc_fp64_vector2_get_modulus(const BGC_FP64_Vector2* vector)
{ {
return sqrt(bgc_vector2_get_square_modulus_fp64(vector)); return sqrt(bgc_fp64_vector2_get_square_modulus(vector));
} }
// ================= Comparison ================= // // ================= Comparison ================= //
inline int bgc_vector2_is_zero_fp32(const BgcVector2FP32* vector) inline int bgc_fp32_vector2_is_zero(const BGC_FP32_Vector2* vector)
{ {
return bgc_vector2_get_square_modulus_fp32(vector) <= BGC_SQUARE_EPSYLON_FP32; return bgc_fp32_vector2_get_square_modulus(vector) <= BGC_FP32_SQUARE_EPSYLON;
} }
inline int bgc_vector2_is_zero_fp64(const BgcVector2FP64* vector) inline int bgc_fp64_vector2_is_zero(const BGC_FP64_Vector2* vector)
{ {
return bgc_vector2_get_square_modulus_fp64(vector) <= BGC_SQUARE_EPSYLON_FP64; return bgc_fp64_vector2_get_square_modulus(vector) <= BGC_FP64_SQUARE_EPSYLON;
} }
inline int bgc_vector2_is_unit_fp32(const BgcVector2FP32* vector) inline int bgc_fp32_vector2_is_unit(const BGC_FP32_Vector2* vector)
{ {
return bgc_is_sqare_unit_fp32(bgc_vector2_get_square_modulus_fp32(vector)); return bgc_fp32_is_square_unit(bgc_fp32_vector2_get_square_modulus(vector));
} }
inline int bgc_vector2_is_unit_fp64(const BgcVector2FP64* vector) inline int bgc_fp64_vector2_is_unit(const BGC_FP64_Vector2* vector)
{ {
return bgc_is_sqare_unit_fp64(bgc_vector2_get_square_modulus_fp64(vector)); return bgc_fp64_is_square_unit(bgc_fp64_vector2_get_square_modulus(vector));
} }
// ==================== Copy ==================== // // ==================== Copy ==================== //
inline void bgc_vector2_copy_fp32(const BgcVector2FP32* source, BgcVector2FP32* destination) inline void bgc_fp32_vector2_copy(const BGC_FP32_Vector2* source, BGC_FP32_Vector2* destination)
{ {
destination->x1 = source->x1; destination->x1 = source->x1;
destination->x2 = source->x2; destination->x2 = source->x2;
} }
inline void bgc_vector2_copy_fp64(const BgcVector2FP64* source, BgcVector2FP64* destination) inline void bgc_fp64_vector2_copy(const BGC_FP64_Vector2* source, BGC_FP64_Vector2* destination)
{ {
destination->x1 = source->x1; destination->x1 = source->x1;
destination->x2 = source->x2; destination->x2 = source->x2;
@ -104,7 +104,7 @@ inline void bgc_vector2_copy_fp64(const BgcVector2FP64* source, BgcVector2FP64*
// ==================== Swap ==================== // // ==================== Swap ==================== //
inline void bgc_vector2_swap_fp32(BgcVector2FP32* vector1, BgcVector2FP32* vector2) inline void bgc_fp32_vector2_swap(BGC_FP32_Vector2* vector1, BGC_FP32_Vector2* vector2)
{ {
const float x1 = vector2->x1; const float x1 = vector2->x1;
const float x2 = vector2->x2; const float x2 = vector2->x2;
@ -116,7 +116,7 @@ inline void bgc_vector2_swap_fp32(BgcVector2FP32* vector1, BgcVector2FP32* vecto
vector1->x2 = x2; vector1->x2 = x2;
} }
inline void bgc_vector2_swap_fp64(BgcVector2FP64* vector1, BgcVector2FP64* vector2) inline void bgc_fp64_vector2_swap(BGC_FP64_Vector2* vector1, BGC_FP64_Vector2* vector2)
{ {
const double x1 = vector2->x1; const double x1 = vector2->x1;
const double x2 = vector2->x2; const double x2 = vector2->x2;
@ -130,13 +130,13 @@ inline void bgc_vector2_swap_fp64(BgcVector2FP64* vector1, BgcVector2FP64* vecto
// ================== Convert =================== // // ================== Convert =================== //
inline void bgc_vector2_convert_fp64_to_fp32(const BgcVector2FP64* source, BgcVector2FP32* destination) inline void bgc_fp64_vector2_convert_to_fp32(const BGC_FP64_Vector2* source, BGC_FP32_Vector2* destination)
{ {
destination->x1 = (float)source->x1; destination->x1 = (float)source->x1;
destination->x2 = (float)source->x2; destination->x2 = (float)source->x2;
} }
inline void bgc_vector2_convert_fp32_to_fp64(const BgcVector2FP32* source, BgcVector2FP64* destination) inline void bgc_fp32_vector2_convert_to_fp64(const BGC_FP32_Vector2* source, BGC_FP64_Vector2* destination)
{ {
destination->x1 = source->x1; destination->x1 = source->x1;
destination->x2 = source->x2; destination->x2 = source->x2;
@ -144,13 +144,13 @@ inline void bgc_vector2_convert_fp32_to_fp64(const BgcVector2FP32* source, BgcVe
// ==================== Add ===================== // // ==================== Add ===================== //
inline void bgc_vector2_add_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2, BgcVector2FP32* sum) inline void bgc_fp32_vector2_add(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2, BGC_FP32_Vector2* sum)
{ {
sum->x1 = vector1->x1 + vector2->x1; sum->x1 = vector1->x1 + vector2->x1;
sum->x2 = vector1->x2 + vector2->x2; sum->x2 = vector1->x2 + vector2->x2;
} }
inline void bgc_vector2_add_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2, BgcVector2FP64* sum) inline void bgc_fp64_vector2_add(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2, BGC_FP64_Vector2* sum)
{ {
sum->x1 = vector1->x1 + vector2->x1; sum->x1 = vector1->x1 + vector2->x1;
sum->x2 = vector1->x2 + vector2->x2; sum->x2 = vector1->x2 + vector2->x2;
@ -158,13 +158,13 @@ inline void bgc_vector2_add_fp64(const BgcVector2FP64* vector1, const BgcVector2
// ================= Add scaled ================= // // ================= Add scaled ================= //
inline void bgc_vector2_add_scaled_fp32(const BgcVector2FP32* basic_vector, const BgcVector2FP32* scalable_vector, const float scale, BgcVector2FP32* sum) inline void bgc_fp32_vector2_add_scaled(const BGC_FP32_Vector2* basic_vector, const BGC_FP32_Vector2* scalable_vector, const float scale, BGC_FP32_Vector2* sum)
{ {
sum->x1 = basic_vector->x1 + scalable_vector->x1 * scale; sum->x1 = basic_vector->x1 + scalable_vector->x1 * scale;
sum->x2 = basic_vector->x2 + scalable_vector->x2 * scale; sum->x2 = basic_vector->x2 + scalable_vector->x2 * scale;
} }
inline void bgc_vector2_add_scaled_fp64(const BgcVector2FP64* basic_vector, const BgcVector2FP64* scalable_vector, const double scale, BgcVector2FP64* sum) inline void bgc_fp64_vector2_add_scaled(const BGC_FP64_Vector2* basic_vector, const BGC_FP64_Vector2* scalable_vector, const double scale, BGC_FP64_Vector2* sum)
{ {
sum->x1 = basic_vector->x1 + scalable_vector->x1 * scale; sum->x1 = basic_vector->x1 + scalable_vector->x1 * scale;
sum->x2 = basic_vector->x2 + scalable_vector->x2 * scale; sum->x2 = basic_vector->x2 + scalable_vector->x2 * scale;
@ -172,13 +172,13 @@ inline void bgc_vector2_add_scaled_fp64(const BgcVector2FP64* basic_vector, cons
// ================== Subtract ================== // // ================== Subtract ================== //
inline void bgc_vector2_subtract_fp32(const BgcVector2FP32* minuend, const BgcVector2FP32* subtrahend, BgcVector2FP32* difference) inline void bgc_fp32_vector2_subtract(const BGC_FP32_Vector2* minuend, const BGC_FP32_Vector2* subtrahend, BGC_FP32_Vector2* difference)
{ {
difference->x1 = minuend->x1 - subtrahend->x1; difference->x1 = minuend->x1 - subtrahend->x1;
difference->x2 = minuend->x2 - subtrahend->x2; difference->x2 = minuend->x2 - subtrahend->x2;
} }
inline void bgc_vector2_subtract_fp64(const BgcVector2FP64* minuend, const BgcVector2FP64* subtrahend, BgcVector2FP64* difference) inline void bgc_fp64_vector2_subtract(const BGC_FP64_Vector2* minuend, const BGC_FP64_Vector2* subtrahend, BGC_FP64_Vector2* difference)
{ {
difference->x1 = minuend->x1 - subtrahend->x1; difference->x1 = minuend->x1 - subtrahend->x1;
difference->x2 = minuend->x2 - subtrahend->x2; difference->x2 = minuend->x2 - subtrahend->x2;
@ -186,13 +186,13 @@ inline void bgc_vector2_subtract_fp64(const BgcVector2FP64* minuend, const BgcVe
// ================== Multiply ================== // // ================== Multiply ================== //
inline void bgc_vector2_multiply_fp32(const BgcVector2FP32* multiplicand, const float multiplier, BgcVector2FP32* product) inline void bgc_fp32_vector2_multiply(const BGC_FP32_Vector2* multiplicand, const float multiplier, BGC_FP32_Vector2* product)
{ {
product->x1 = multiplicand->x1 * multiplier; product->x1 = multiplicand->x1 * multiplier;
product->x2 = multiplicand->x2 * multiplier; product->x2 = multiplicand->x2 * multiplier;
} }
inline void bgc_vector2_multiply_fp64(const BgcVector2FP64* multiplicand, const double multiplier, BgcVector2FP64* product) inline void bgc_fp64_vector2_multiply(const BGC_FP64_Vector2* multiplicand, const double multiplier, BGC_FP64_Vector2* product)
{ {
product->x1 = multiplicand->x1 * multiplier; product->x1 = multiplicand->x1 * multiplier;
product->x2 = multiplicand->x2 * multiplier; product->x2 = multiplicand->x2 * multiplier;
@ -200,99 +200,99 @@ inline void bgc_vector2_multiply_fp64(const BgcVector2FP64* multiplicand, const
// =================== Divide =================== // // =================== Divide =================== //
inline void bgc_vector2_divide_fp32(const BgcVector2FP32* dividend, const float divisor, BgcVector2FP32* quotient) inline void bgc_fp32_vector2_divide(const BGC_FP32_Vector2* dividend, const float divisor, BGC_FP32_Vector2* quotient)
{ {
bgc_vector2_multiply_fp32(dividend, 1.0f / divisor, quotient); bgc_fp32_vector2_multiply(dividend, 1.0f / divisor, quotient);
} }
inline void bgc_vector2_divide_fp64(const BgcVector2FP64* dividend, const double divisor, BgcVector2FP64* quotient) inline void bgc_fp64_vector2_divide(const BGC_FP64_Vector2* dividend, const double divisor, BGC_FP64_Vector2* quotient)
{ {
bgc_vector2_multiply_fp64(dividend, 1.0 / divisor, quotient); bgc_fp64_vector2_multiply(dividend, 1.0 / divisor, quotient);
} }
// ================ Mean of Two ================= // // ================ Mean of Two ================= //
inline void bgc_vector2_get_mean_of_two_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2, BgcVector2FP32* mean) inline void bgc_fp32_vector2_get_middle2(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2, BGC_FP32_Vector2* middle)
{ {
mean->x1 = (vector1->x1 + vector2->x1) * 0.5f; middle->x1 = (vector1->x1 + vector2->x1) * 0.5f;
mean->x2 = (vector1->x2 + vector2->x2) * 0.5f; middle->x2 = (vector1->x2 + vector2->x2) * 0.5f;
} }
inline void bgc_vector2_get_mean_of_two_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2, BgcVector2FP64* mean) inline void bgc_fp64_vector2_get_middle2(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2, BGC_FP64_Vector2* middle)
{ {
mean->x1 = (vector1->x1 + vector2->x1) * 0.5; middle->x1 = (vector1->x1 + vector2->x1) * 0.5;
mean->x2 = (vector1->x2 + vector2->x2) * 0.5; middle->x2 = (vector1->x2 + vector2->x2) * 0.5;
} }
// =============== Mean of Three ================ // // =============== Mean of Three ================ //
inline void bgc_vector2_get_mean_of_three_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2, const BgcVector2FP32* vector3, BgcVector2FP32* mean) inline void bgc_fp32_vector2_get_middle3(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2, const BGC_FP32_Vector2* vector3, BGC_FP32_Vector2* middle)
{ {
mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_ONE_THIRD_FP32; middle->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP32_ONE_THIRD;
mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_ONE_THIRD_FP32; middle->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP32_ONE_THIRD;
} }
inline void bgc_vector2_get_mean_of_three_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2, const BgcVector2FP64* vector3, BgcVector2FP64* mean) inline void bgc_fp64_vector2_get_middle3(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2, const BGC_FP64_Vector2* vector3, BGC_FP64_Vector2* middle)
{ {
mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_ONE_THIRD_FP64; middle->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP64_ONE_THIRD;
mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_ONE_THIRD_FP64; middle->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP64_ONE_THIRD;
} }
// =================== Linear =================== // // =================== Linear =================== //
inline void bgc_vector2_interpolate_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2, const float phase, BgcVector2FP32* interpolation) inline void bgc_fp32_vector2_interpolate(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2, const float phase, BGC_FP32_Vector2* interpolation)
{ {
const float counterphase = 1.0f - phase; const float counter_phase = 1.0f - phase;
interpolation->x1 = vector1->x1 * counterphase + vector2->x1 * phase; interpolation->x1 = vector1->x1 * counter_phase + vector2->x1 * phase;
interpolation->x2 = vector1->x2 * counterphase + vector2->x2 * phase; interpolation->x2 = vector1->x2 * counter_phase + vector2->x2 * phase;
} }
inline void bgc_vector2_interpolate_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2, const double phase, BgcVector2FP64* interpolation) inline void bgc_fp64_vector2_interpolate(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2, const double phase, BGC_FP64_Vector2* interpolation)
{ {
const double counterphase = 1.0 - phase; const double counter_phase = 1.0 - phase;
interpolation->x1 = vector1->x1 * counterphase + vector2->x1 * phase; interpolation->x1 = vector1->x1 * counter_phase + vector2->x1 * phase;
interpolation->x2 = vector1->x2 * counterphase + vector2->x2 * phase; interpolation->x2 = vector1->x2 * counter_phase + vector2->x2 * phase;
} }
// ================== Negative ================== // // ================== Negative ================== //
inline void bgc_vector2_make_opposite_fp32(BgcVector2FP32* vector) inline void bgc_fp32_vector2_revert(BGC_FP32_Vector2* vector)
{ {
vector->x1 = -vector->x1; vector->x1 = -vector->x1;
vector->x2 = -vector->x2; vector->x2 = -vector->x2;
} }
inline void bgc_vector2_make_opposite_fp64(BgcVector2FP64* vector) inline void bgc_fp64_vector2_revert(BGC_FP64_Vector2* vector)
{ {
vector->x1 = -vector->x1; vector->x1 = -vector->x1;
vector->x2 = -vector->x2; vector->x2 = -vector->x2;
} }
inline void bgc_vector2_get_opposite_fp32(const BgcVector2FP32* vector, BgcVector2FP32* opposite) inline void bgc_fp32_vector2_get_reverse(const BGC_FP32_Vector2* vector, BGC_FP32_Vector2* reverse)
{ {
opposite->x1 = -vector->x1; reverse->x1 = -vector->x1;
opposite->x2 = -vector->x2; reverse->x2 = -vector->x2;
} }
inline void bgc_vector2_get_opposite_fp64(const BgcVector2FP64* vector, BgcVector2FP64* opposite) inline void bgc_fp64_vector2_get_reverse(const BGC_FP64_Vector2* vector, BGC_FP64_Vector2* reverse)
{ {
opposite->x1 = -vector->x1; reverse->x1 = -vector->x1;
opposite->x2 = -vector->x2; reverse->x2 = -vector->x2;
} }
// ================= Normalize ================== // // ================= Normalize ================== //
inline int bgc_vector2_normalize_fp32(BgcVector2FP32* vector) inline int bgc_fp32_vector2_normalize(BGC_FP32_Vector2* vector)
{ {
const float square_modulus = bgc_vector2_get_square_modulus_fp32(vector); const float square_modulus = bgc_fp32_vector2_get_square_modulus(vector);
if (bgc_is_sqare_unit_fp32(square_modulus)) { if (bgc_fp32_is_square_unit(square_modulus)) {
return 1; return 1;
} }
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
return 0; return 0;
} }
@ -304,15 +304,15 @@ inline int bgc_vector2_normalize_fp32(BgcVector2FP32* vector)
return 1; return 1;
} }
inline int bgc_vector2_normalize_fp64(BgcVector2FP64* vector) inline int bgc_fp64_vector2_normalize(BGC_FP64_Vector2* vector)
{ {
const double square_modulus = bgc_vector2_get_square_modulus_fp64(vector); const double square_modulus = bgc_fp64_vector2_get_square_modulus(vector);
if (bgc_is_sqare_unit_fp64(square_modulus)) { if (bgc_fp64_is_square_unit(square_modulus)) {
return 1; return 1;
} }
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
return 0; return 0;
} }
@ -324,75 +324,75 @@ inline int bgc_vector2_normalize_fp64(BgcVector2FP64* vector)
return 1; return 1;
} }
inline int bgc_vector2_get_normalized_fp32(const BgcVector2FP32* vector, BgcVector2FP32* normalized) inline int bgc_fp32_vector2_get_normalized(const BGC_FP32_Vector2* vector, BGC_FP32_Vector2* normalized)
{ {
const float square_modulus = bgc_vector2_get_square_modulus_fp32(vector); const float square_modulus = bgc_fp32_vector2_get_square_modulus(vector);
if (bgc_is_sqare_unit_fp32(square_modulus)) { if (bgc_fp32_is_square_unit(square_modulus)) {
bgc_vector2_copy_fp32(vector, normalized); bgc_fp32_vector2_copy(vector, normalized);
return 1; return 1;
} }
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
bgc_vector2_reset_fp32(normalized); bgc_fp32_vector2_reset(normalized);
return 0; return 0;
} }
bgc_vector2_multiply_fp32(vector, sqrtf(1.0f / square_modulus), normalized); bgc_fp32_vector2_multiply(vector, sqrtf(1.0f / square_modulus), normalized);
return 1; return 1;
} }
inline int bgc_vector2_get_normalized_fp64(const BgcVector2FP64* vector, BgcVector2FP64* normalized) inline int bgc_fp64_vector2_get_normalized(const BGC_FP64_Vector2* vector, BGC_FP64_Vector2* normalized)
{ {
const double square_modulus = bgc_vector2_get_square_modulus_fp64(vector); const double square_modulus = bgc_fp64_vector2_get_square_modulus(vector);
if (bgc_is_sqare_unit_fp64(square_modulus)) { if (bgc_fp64_is_square_unit(square_modulus)) {
bgc_vector2_copy_fp64(vector, normalized); bgc_fp64_vector2_copy(vector, normalized);
return 1; return 1;
} }
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
bgc_vector2_reset_fp64(normalized); bgc_fp64_vector2_reset(normalized);
return 0; return 0;
} }
bgc_vector2_multiply_fp64(vector, sqrt(1.0 / square_modulus), normalized); bgc_fp64_vector2_multiply(vector, sqrt(1.0 / square_modulus), normalized);
return 1; return 1;
} }
// ============= Get Scalar Product ============= // // ============= Get Scalar Product ============= //
inline float bgc_vector2_get_scalar_product_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2) inline float bgc_fp32_vector2_get_dot_product(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2)
{ {
return vector1->x1 * vector2->x1 + vector1->x2 * vector2->x2; return vector1->x1 * vector2->x1 + vector1->x2 * vector2->x2;
} }
inline double bgc_vector2_get_scalar_product_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2) inline double bgc_fp64_vector2_get_dot_product(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2)
{ {
return vector1->x1 * vector2->x1 + vector1->x2 * vector2->x2; return vector1->x1 * vector2->x1 + vector1->x2 * vector2->x2;
} }
// ============= Get Cross Product ============== // // ============= Get Cross Product ============== //
inline float bgc_vector2_get_cross_product_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2) inline float bgc_fp32_vector2_get_cross_product(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2)
{ {
return vector1->x1 * vector2->x2 - vector1->x2 * vector2->x1; return vector1->x1 * vector2->x2 - vector1->x2 * vector2->x1;
} }
inline double bgc_vector2_get_cross_product_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2) inline double bgc_fp64_vector2_get_cross_product(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2)
{ {
return vector1->x1 * vector2->x2 - vector1->x2 * vector2->x1; return vector1->x1 * vector2->x2 - vector1->x2 * vector2->x1;
} }
// ================= Get Angle ================== // // ================= Get Angle ================== //
float bgc_vector2_get_angle_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2, const BgcAngleUnitEnum unit); float bgc_fp32_vector2_get_angle(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2, const int angle_unit);
double bgc_vector2_get_angle_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2, const BgcAngleUnitEnum unit); double bgc_fp64_vector2_get_angle(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2, const int angle_unit);
// ============= Get Square Distance ============ // // ============= Get Square Distance ============ //
inline float bgc_vector2_get_square_distance_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2) inline float bgc_fp32_vector2_get_square_distance(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2)
{ {
const float dx1 = vector1->x1 - vector2->x1; const float dx1 = vector1->x1 - vector2->x1;
const float dx2 = vector1->x2 - vector2->x2; const float dx2 = vector1->x2 - vector2->x2;
@ -400,7 +400,7 @@ inline float bgc_vector2_get_square_distance_fp32(const BgcVector2FP32* vector1,
return dx1 * dx1 + dx2 * dx2; return dx1 * dx1 + dx2 * dx2;
} }
inline double bgc_vector2_get_square_distance_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2) inline double bgc_fp64_vector2_get_square_distance(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2)
{ {
const double dx1 = vector1->x1 - vector2->x1; const double dx1 = vector1->x1 - vector2->x1;
const double dx2 = vector1->x2 - vector2->x2; const double dx2 = vector1->x2 - vector2->x2;
@ -410,158 +410,158 @@ inline double bgc_vector2_get_square_distance_fp64(const BgcVector2FP64* vector1
// ================== Distance ================== // // ================== Distance ================== //
inline float bgc_vector2_get_distance_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2) inline float bgc_fp32_vector2_get_distance(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2)
{ {
return sqrtf(bgc_vector2_get_square_distance_fp32(vector1, vector2)); return sqrtf(bgc_fp32_vector2_get_square_distance(vector1, vector2));
} }
inline double bgc_vector2_get_distance_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2) inline double bgc_fp64_vector2_get_distance(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2)
{ {
return sqrt(bgc_vector2_get_square_distance_fp64(vector1, vector2)); return sqrt(bgc_fp64_vector2_get_square_distance(vector1, vector2));
} }
// ============== Are Close Enough ============== // // ============== Are Close Enough ============== //
inline int bgc_vector2_are_close_enough_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2, const float distance_limit) inline int bgc_fp32_vector2_are_close_enough(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2, const float distance_limit)
{ {
return bgc_vector2_get_square_distance_fp32(vector1, vector2) <= distance_limit * distance_limit; return bgc_fp32_vector2_get_square_distance(vector1, vector2) <= distance_limit * distance_limit;
} }
inline int bgc_vector2_are_close_enough_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2, const double distance_limit) inline int bgc_fp64_vector2_are_close_enough(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2, const double distance_limit)
{ {
return bgc_vector2_get_square_distance_fp64(vector1, vector2) <= distance_limit * distance_limit; return bgc_fp64_vector2_get_square_distance(vector1, vector2) <= distance_limit * distance_limit;
} }
// ================== Are Close ================= // // ================== Are Close ================= //
inline int bgc_vector2_are_close_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2) inline int bgc_fp32_vector2_are_close(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2)
{ {
const float square_modulus1 = bgc_vector2_get_square_modulus_fp32(vector1); const float square_modulus1 = bgc_fp32_vector2_get_square_modulus(vector1);
const float square_modulus2 = bgc_vector2_get_square_modulus_fp32(vector2); const float square_modulus2 = bgc_fp32_vector2_get_square_modulus(vector2);
const float square_distance = bgc_vector2_get_square_distance_fp32(vector1, vector2); const float square_distance = bgc_fp32_vector2_get_square_distance(vector1, vector2);
if (square_modulus1 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32 || square_modulus2 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32) { if (square_modulus1 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT) {
return square_distance <= BGC_SQUARE_EPSYLON_FP32; return square_distance <= BGC_FP32_SQUARE_EPSYLON;
} }
return square_distance <= BGC_SQUARE_EPSYLON_FP32 * square_modulus1 && square_distance <= BGC_SQUARE_EPSYLON_FP32 * square_modulus2; return square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus2;
} }
inline int bgc_vector2_are_close_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2) inline int bgc_fp64_vector2_are_close(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2)
{ {
const double square_modulus1 = bgc_vector2_get_square_modulus_fp64(vector1); const double square_modulus1 = bgc_fp64_vector2_get_square_modulus(vector1);
const double square_modulus2 = bgc_vector2_get_square_modulus_fp64(vector2); const double square_modulus2 = bgc_fp64_vector2_get_square_modulus(vector2);
const double square_distance = bgc_vector2_get_square_distance_fp64(vector1, vector2); const double square_distance = bgc_fp64_vector2_get_square_distance(vector1, vector2);
if (square_modulus1 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP64 || square_modulus2 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP64) { if (square_modulus1 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT) {
return square_distance <= BGC_SQUARE_EPSYLON_FP64; return square_distance <= BGC_FP64_SQUARE_EPSYLON;
} }
return square_distance <= BGC_SQUARE_EPSYLON_FP64 * square_modulus1 && square_distance <= BGC_SQUARE_EPSYLON_FP64 * square_modulus2; return square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus2;
} }
// ================== Parallel ================== // // ================== Parallel ================== //
inline int bgc_vector2_are_parallel_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2) inline int bgc_fp32_vector2_are_parallel(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2)
{ {
const float square_modulus1 = bgc_vector2_get_square_modulus_fp32(vector1); const float square_modulus1 = bgc_fp32_vector2_get_square_modulus(vector1);
if (square_modulus1 <= BGC_SQUARE_EPSYLON_FP32) { if (square_modulus1 <= BGC_FP32_SQUARE_EPSYLON) {
return 1; return 1;
} }
const float square_modulus2 = bgc_vector2_get_square_modulus_fp32(vector2); const float square_modulus2 = bgc_fp32_vector2_get_square_modulus(vector2);
if (square_modulus2 <= BGC_SQUARE_EPSYLON_FP32) { if (square_modulus2 <= BGC_FP32_SQUARE_EPSYLON) {
return 1; return 1;
} }
const float cross_product = bgc_vector2_get_cross_product_fp32(vector1, vector2); const float cross_product = bgc_fp32_vector2_get_cross_product(vector1, vector2);
return cross_product * cross_product <= BGC_SQUARE_EPSYLON_FP32 * square_modulus1 * square_modulus2; return cross_product * cross_product <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
} }
inline int bgc_vector2_are_parallel_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2) inline int bgc_fp64_vector2_are_parallel(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2)
{ {
const double square_modulus1 = bgc_vector2_get_square_modulus_fp64(vector1); const double square_modulus1 = bgc_fp64_vector2_get_square_modulus(vector1);
if (square_modulus1 <= BGC_SQUARE_EPSYLON_FP64) { if (square_modulus1 <= BGC_FP64_SQUARE_EPSYLON) {
return 1; return 1;
} }
const double square_modulus2 = bgc_vector2_get_square_modulus_fp64(vector2); const double square_modulus2 = bgc_fp64_vector2_get_square_modulus(vector2);
if (square_modulus2 <= BGC_SQUARE_EPSYLON_FP64) { if (square_modulus2 <= BGC_FP64_SQUARE_EPSYLON) {
return 1; return 1;
} }
const double cross_product = bgc_vector2_get_cross_product_fp64(vector1, vector2); const double cross_product = bgc_fp64_vector2_get_cross_product(vector1, vector2);
return cross_product * cross_product <= BGC_SQUARE_EPSYLON_FP64 * square_modulus1 * square_modulus2; return cross_product * cross_product <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
} }
// ================= Orthogonal ================= // // ================= Orthogonal ================= //
inline int bgc_vector2_are_orthogonal_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2) inline int bgc_fp32_vector2_are_orthogonal(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2)
{ {
const float square_modulus1 = bgc_vector2_get_square_modulus_fp32(vector1); const float square_modulus1 = bgc_fp32_vector2_get_square_modulus(vector1);
if (square_modulus1 <= BGC_SQUARE_EPSYLON_FP32) { if (square_modulus1 <= BGC_FP32_SQUARE_EPSYLON) {
return 1; return 1;
} }
const float square_modulus2 = bgc_vector2_get_square_modulus_fp32(vector2); const float square_modulus2 = bgc_fp32_vector2_get_square_modulus(vector2);
if (square_modulus2 <= BGC_SQUARE_EPSYLON_FP32) { if (square_modulus2 <= BGC_FP32_SQUARE_EPSYLON) {
return 1; return 1;
} }
const float scalar_product = bgc_vector2_get_scalar_product_fp32(vector1, vector2); const float scalar_product = bgc_fp32_vector2_get_dot_product(vector1, vector2);
return scalar_product * scalar_product <= BGC_SQUARE_EPSYLON_FP32 * square_modulus1 * square_modulus2; return scalar_product * scalar_product <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
} }
inline int bgc_vector2_are_orthogonal_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2) inline int bgc_fp64_vector2_are_orthogonal(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2)
{ {
const double square_modulus1 = bgc_vector2_get_square_modulus_fp64(vector1); const double square_modulus1 = bgc_fp64_vector2_get_square_modulus(vector1);
if (square_modulus1 <= BGC_SQUARE_EPSYLON_FP64) { if (square_modulus1 <= BGC_FP64_SQUARE_EPSYLON) {
return 1; return 1;
} }
const double square_modulus2 = bgc_vector2_get_square_modulus_fp64(vector2); const double square_modulus2 = bgc_fp64_vector2_get_square_modulus(vector2);
if (square_modulus2 <= BGC_SQUARE_EPSYLON_FP64) { if (square_modulus2 <= BGC_FP64_SQUARE_EPSYLON) {
return 1; return 1;
} }
const double scalar_product = bgc_vector2_get_scalar_product_fp64(vector1, vector2); const double scalar_product = bgc_fp64_vector2_get_dot_product(vector1, vector2);
return scalar_product * scalar_product <= BGC_SQUARE_EPSYLON_FP64 * square_modulus1 * square_modulus2; return scalar_product * scalar_product <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
} }
// ================== Attitude ================== // // ================== Attitude ================== //
inline int bgc_vector2_get_attitude_fp32(const BgcVector2FP32* vector1, const BgcVector2FP32* vector2) inline int bgc_fp32_vector2_get_attitude(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2)
{ {
const float square_modulus1 = bgc_vector2_get_square_modulus_fp32(vector1); const float square_modulus1 = bgc_fp32_vector2_get_square_modulus(vector1);
const float square_modulus2 = bgc_vector2_get_square_modulus_fp32(vector2); const float square_modulus2 = bgc_fp32_vector2_get_square_modulus(vector2);
if (square_modulus1 <= BGC_SQUARE_EPSYLON_FP32 || square_modulus2 <= BGC_SQUARE_EPSYLON_FP32) { if (square_modulus1 <= BGC_FP32_SQUARE_EPSYLON || square_modulus2 <= BGC_FP32_SQUARE_EPSYLON) {
return BGC_ATTITUDE_ZERO; return BGC_ATTITUDE_ZERO;
} }
const float square_limit = BGC_SQUARE_EPSYLON_FP32 * square_modulus1 * square_modulus2; const float square_limit = BGC_FP32_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
const float scalar_product = bgc_vector2_get_scalar_product_fp32(vector1, vector2); const float scalar_product = bgc_fp32_vector2_get_dot_product(vector1, vector2);
if (scalar_product * scalar_product <= square_limit) { if (scalar_product * scalar_product <= square_limit) {
return BGC_ATTITUDE_ORTHOGONAL; return BGC_ATTITUDE_ORTHOGONAL;
} }
const float cross_product = bgc_vector2_get_cross_product_fp32(vector1, vector2); const float cross_product = bgc_fp32_vector2_get_cross_product(vector1, vector2);
if (cross_product * cross_product > square_limit) { if (cross_product * cross_product > square_limit) {
return BGC_ATTITUDE_ANY; return BGC_ATTITUDE_ANY;
@ -570,24 +570,24 @@ inline int bgc_vector2_get_attitude_fp32(const BgcVector2FP32* vector1, const Bg
return scalar_product > 0.0f ? BGC_ATTITUDE_CO_DIRECTIONAL : BGC_ATTITUDE_COUNTER_DIRECTIONAL; return scalar_product > 0.0f ? BGC_ATTITUDE_CO_DIRECTIONAL : BGC_ATTITUDE_COUNTER_DIRECTIONAL;
} }
inline int bgc_vector2_get_attitude_fp64(const BgcVector2FP64* vector1, const BgcVector2FP64* vector2) inline int bgc_fp64_vector2_get_attitude(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2)
{ {
const double square_modulus1 = bgc_vector2_get_square_modulus_fp64(vector1); const double square_modulus1 = bgc_fp64_vector2_get_square_modulus(vector1);
const double square_modulus2 = bgc_vector2_get_square_modulus_fp64(vector2); const double square_modulus2 = bgc_fp64_vector2_get_square_modulus(vector2);
if (square_modulus1 <= BGC_SQUARE_EPSYLON_FP64 || square_modulus2 <= BGC_SQUARE_EPSYLON_FP64) { if (square_modulus1 <= BGC_FP64_SQUARE_EPSYLON || square_modulus2 <= BGC_FP64_SQUARE_EPSYLON) {
return BGC_ATTITUDE_ZERO; return BGC_ATTITUDE_ZERO;
} }
const double square_limit = BGC_SQUARE_EPSYLON_FP64 * square_modulus1 * square_modulus2; const double square_limit = BGC_FP64_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
const double scalar_product = bgc_vector2_get_scalar_product_fp64(vector1, vector2); const double scalar_product = bgc_fp64_vector2_get_dot_product(vector1, vector2);
if (scalar_product * scalar_product <= square_limit) { if (scalar_product * scalar_product <= square_limit) {
return BGC_ATTITUDE_ORTHOGONAL; return BGC_ATTITUDE_ORTHOGONAL;
} }
const double cross_product = bgc_vector2_get_cross_product_fp64(vector1, vector2); const double cross_product = bgc_fp64_vector2_get_cross_product(vector1, vector2);
if (cross_product * cross_product > square_limit) { if (cross_product * cross_product > square_limit) {
return BGC_ATTITUDE_ANY; return BGC_ATTITUDE_ANY;

View file

@ -1,153 +1,153 @@
#include "vector3.h" #include "vector3.h"
extern inline void bgc_vector3_reset_fp32(BgcVector3FP32* vector); extern inline void bgc_fp32_vector3_reset(BGC_FP32_Vector3* vector);
extern inline void bgc_vector3_reset_fp64(BgcVector3FP64* vector); extern inline void bgc_fp64_vector3_reset(BGC_FP64_Vector3* vector);
extern inline void bgc_vector3_set_values_fp32(const float x1, const float x2, const float x3, BgcVector3FP32* destination); extern inline void bgc_fp32_vector3_make(const float x1, const float x2, const float x3, BGC_FP32_Vector3* destination);
extern inline void bgc_vector3_set_values_fp64(const double x1, const double x2, const double x3, BgcVector3FP64* destination); extern inline void bgc_fp64_vector3_make(const double x1, const double x2, const double x3, BGC_FP64_Vector3* destination);
extern inline float bgc_vector3_get_square_modulus_fp32(const BgcVector3FP32* vector); extern inline float bgc_fp32_vector3_get_square_modulus(const BGC_FP32_Vector3* vector);
extern inline double bgc_vector3_get_square_modulus_fp64(const BgcVector3FP64* vector); extern inline double bgc_fp64_vector3_get_square_modulus(const BGC_FP64_Vector3* vector);
extern inline float bgc_vector3_get_modulus_fp32(const BgcVector3FP32* vector); extern inline float bgc_fp32_vector3_get_modulus(const BGC_FP32_Vector3* vector);
extern inline double bgc_vector3_get_modulus_fp64(const BgcVector3FP64* vector); extern inline double bgc_fp64_vector3_get_modulus(const BGC_FP64_Vector3* vector);
extern inline int bgc_vector3_is_zero_fp32(const BgcVector3FP32* vector); extern inline int bgc_fp32_vector3_is_zero(const BGC_FP32_Vector3* vector);
extern inline int bgc_vector3_is_zero_fp64(const BgcVector3FP64* vector); extern inline int bgc_fp64_vector3_is_zero(const BGC_FP64_Vector3* vector);
extern inline int bgc_vector3_is_unit_fp32(const BgcVector3FP32* vector); extern inline int bgc_fp32_vector3_is_unit(const BGC_FP32_Vector3* vector);
extern inline int bgc_vector3_is_unit_fp64(const BgcVector3FP64* vector); extern inline int bgc_fp64_vector3_is_unit(const BGC_FP64_Vector3* vector);
extern inline void bgc_vector3_copy_fp32(const BgcVector3FP32* source, BgcVector3FP32* destination); extern inline void bgc_fp32_vector3_copy(const BGC_FP32_Vector3* source, BGC_FP32_Vector3* destination);
extern inline void bgc_vector3_copy_fp64(const BgcVector3FP64* source, BgcVector3FP64* destination); extern inline void bgc_fp64_vector3_copy(const BGC_FP64_Vector3* source, BGC_FP64_Vector3* destination);
extern inline void bgc_vector3_convert_fp64_to_fp32(const BgcVector3FP64* source, BgcVector3FP32* destination); extern inline void bgc_fp32_vector3_convert_to_fp64(const BGC_FP32_Vector3* source, BGC_FP64_Vector3* destination);
extern inline void bgc_vector3_convert_fp32_to_fp64(const BgcVector3FP32* source, BgcVector3FP64* destination); extern inline void bgc_fp64_vector3_convert_to_fp32(const BGC_FP64_Vector3* source, BGC_FP32_Vector3* destination);
extern inline void bgc_vector3_swap_fp32(BgcVector3FP32* vector1, BgcVector3FP32* vector2); extern inline void bgc_fp32_vector3_swap(BGC_FP32_Vector3* vector1, BGC_FP32_Vector3* vector2);
extern inline void bgc_vector3_swap_fp64(BgcVector3FP64* vector1, BgcVector3FP64* vector2); extern inline void bgc_fp64_vector3_swap(BGC_FP64_Vector3* vector1, BGC_FP64_Vector3* vector2);
extern inline void bgc_vector3_add_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, BgcVector3FP32* sum); extern inline void bgc_fp32_vector3_add(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, BGC_FP32_Vector3* sum);
extern inline void bgc_vector3_add_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, BgcVector3FP64* sum); extern inline void bgc_fp64_vector3_add(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, BGC_FP64_Vector3* sum);
extern inline void bgc_vector3_add_scaled_fp32(const BgcVector3FP32* basic_vector, const BgcVector3FP32* scalable_vector, const float scale, BgcVector3FP32* sum); extern inline void bgc_fp32_vector3_add_scaled(const BGC_FP32_Vector3* basic_vector, const BGC_FP32_Vector3* scalable_vector, const float scale, BGC_FP32_Vector3* sum);
extern inline void bgc_vector3_add_scaled_fp64(const BgcVector3FP64* basic_vector, const BgcVector3FP64* scalable_vector, const double scale, BgcVector3FP64* sum); extern inline void bgc_fp64_vector3_add_scaled(const BGC_FP64_Vector3* basic_vector, const BGC_FP64_Vector3* scalable_vector, const double scale, BGC_FP64_Vector3* sum);
extern inline void bgc_vector3_subtract_fp32(const BgcVector3FP32* minuend, const BgcVector3FP32* subtrahend, BgcVector3FP32* difference); extern inline void bgc_fp32_vector3_subtract(const BGC_FP32_Vector3* minuend, const BGC_FP32_Vector3* subtrahend, BGC_FP32_Vector3* difference);
extern inline void bgc_vector3_subtract_fp64(const BgcVector3FP64* minuend, const BgcVector3FP64* subtrahend, BgcVector3FP64* difference); extern inline void bgc_fp64_vector3_subtract(const BGC_FP64_Vector3* minuend, const BGC_FP64_Vector3* subtrahend, BGC_FP64_Vector3* difference);
extern inline void bgc_vector3_multiply_fp32(const BgcVector3FP32* multiplicand, const float multiplier, BgcVector3FP32* product); extern inline void bgc_fp32_vector3_multiply(const BGC_FP32_Vector3* multiplicand, const float multiplier, BGC_FP32_Vector3* product);
extern inline void bgc_vector3_multiply_fp64(const BgcVector3FP64* multiplicand, const double multiplier, BgcVector3FP64* product); extern inline void bgc_fp64_vector3_multiply(const BGC_FP64_Vector3* multiplicand, const double multiplier, BGC_FP64_Vector3* product);
extern inline void bgc_vector3_divide_fp32(const BgcVector3FP32* dividend, const float divisor, BgcVector3FP32* quotient); extern inline void bgc_fp32_vector3_divide(const BGC_FP32_Vector3* dividend, const float divisor, BGC_FP32_Vector3* quotient);
extern inline void bgc_vector3_divide_fp64(const BgcVector3FP64* dividend, const double divisor, BgcVector3FP64* quotient); extern inline void bgc_fp64_vector3_divide(const BGC_FP64_Vector3* dividend, const double divisor, BGC_FP64_Vector3* quotient);
extern inline void bgc_vector3_get_mean_of_two_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, BgcVector3FP32* result); extern inline void bgc_fp32_vector3_get_middle2(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, BGC_FP32_Vector3* middle);
extern inline void bgc_vector3_get_mean_of_two_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, BgcVector3FP64* result); extern inline void bgc_fp64_vector3_get_middle2(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, BGC_FP64_Vector3* middle);
extern inline void bgc_vector3_get_mean_of_three_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, const BgcVector3FP32* vector3, BgcVector3FP32* result); extern inline void bgc_fp32_vector3_get_middle3(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const BGC_FP32_Vector3* vector3, BGC_FP32_Vector3* middle);
extern inline void bgc_vector3_get_mean_of_three_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, const BgcVector3FP64* vector3, BgcVector3FP64* result); extern inline void bgc_fp64_vector3_get_middle3(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const BGC_FP64_Vector3* vector3, BGC_FP64_Vector3* middle);
extern inline void bgc_vector3_interpolate_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, const float phase, BgcVector3FP32* interpolation); extern inline void bgc_fp32_vector3_interpolate(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const float phase, BGC_FP32_Vector3* interpolation);
extern inline void bgc_vector3_interpolate_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, const double phase, BgcVector3FP64* interpolation); extern inline void bgc_fp64_vector3_interpolate(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const double phase, BGC_FP64_Vector3* interpolation);
extern inline void bgc_vector3_make_opposite_fp32(BgcVector3FP32* vector); extern inline void bgc_fp32_vector3_revert(BGC_FP32_Vector3* vector);
extern inline void bgc_vector3_make_opposite_fp64(BgcVector3FP64* vector); extern inline void bgc_fp64_vector3_revert(BGC_FP64_Vector3* vector);
extern inline void bgc_vector3_get_opposite_fp32(const BgcVector3FP32* vector, BgcVector3FP32* opposite); extern inline void bgc_fp32_vector3_get_reverse(const BGC_FP32_Vector3* vector, BGC_FP32_Vector3* reverse);
extern inline void bgc_vector3_get_opposite_fp64(const BgcVector3FP64* vector, BgcVector3FP64* opposite); extern inline void bgc_fp64_vector3_get_reverse(const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* reverse);
extern inline int bgc_vector3_normalize_fp32(BgcVector3FP32* vector); extern inline int bgc_fp32_vector3_normalize(BGC_FP32_Vector3* vector);
extern inline int bgc_vector3_normalize_fp64(BgcVector3FP64* vector); extern inline int bgc_fp64_vector3_normalize(BGC_FP64_Vector3* vector);
extern inline int bgc_vector3_get_normalized_fp32(const BgcVector3FP32* vector, BgcVector3FP32* normalized); extern inline int bgc_fp32_vector3_get_normalized(const BGC_FP32_Vector3* vector, BGC_FP32_Vector3* normalized);
extern inline int bgc_vector3_get_normalized_fp64(const BgcVector3FP64* vector, BgcVector3FP64* normalized); extern inline int bgc_fp64_vector3_get_normalized(const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* normalized);
extern inline float bgc_vector3_get_scalar_product_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2); extern inline float bgc_fp32_vector3_get_dot_product(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2);
extern inline double bgc_vector3_get_scalar_product_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2); extern inline double bgc_fp64_vector3_get_dot_product(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2);
extern inline float bgc_vector3_get_triple_product_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, const BgcVector3FP32* vector3); extern inline float bgc_fp32_vector3_get_triple_product(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const BGC_FP32_Vector3* vector3);
extern inline double bgc_vector3_get_triple_product_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, const BgcVector3FP64* vector3); extern inline double bgc_fp64_vector3_get_triple_product(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const BGC_FP64_Vector3* vector3);
extern inline void bgc_vector3_get_cross_product_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, BgcVector3FP32* result); extern inline void bgc_fp32_vector3_get_cross_product(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, BGC_FP32_Vector3* result);
extern inline void bgc_vector3_get_cross_product_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, BgcVector3FP64* result); extern inline void bgc_fp64_vector3_get_cross_product(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, BGC_FP64_Vector3* result);
extern inline void bgc_vector3_get_double_cross_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, const BgcVector3FP32* vector3, BgcVector3FP32* result); extern inline void bgc_fp32_vector3_get_double_cross(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const BGC_FP32_Vector3* vector3, BGC_FP32_Vector3* result);
extern inline void bgc_vector3_get_double_cross_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, const BgcVector3FP64* vector3, BgcVector3FP64* result); extern inline void bgc_fp64_vector3_get_double_cross(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const BGC_FP64_Vector3* vector3, BGC_FP64_Vector3* result);
extern inline float bgc_vector3_get_square_distance_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2); extern inline float bgc_fp32_vector3_get_square_distance(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2);
extern inline double bgc_vector3_get_square_distance_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2); extern inline double bgc_fp64_vector3_get_square_distance(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2);
extern inline float bgc_vector3_get_distance_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2); extern inline float bgc_fp32_vector3_get_distance(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2);
extern inline double bgc_vector3_get_distance_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2); extern inline double bgc_fp64_vector3_get_distance(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2);
extern inline int bgc_vector3_are_close_enough_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, const float distance); extern inline int bgc_fp32_vector3_are_close_enough(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const float distance);
extern inline int bgc_vector3_are_close_enough_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, const double distance); extern inline int bgc_fp64_vector3_are_close_enough(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const double distance);
extern inline int bgc_vector3_are_close_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2); extern inline int bgc_fp32_vector3_are_close(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2);
extern inline int bgc_vector3_are_close_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2); extern inline int bgc_fp64_vector3_are_close(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2);
extern inline int bgc_vector3_are_parallel_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2); extern inline int bgc_fp32_vector3_are_parallel(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2);
extern inline int bgc_vector3_are_parallel_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2); extern inline int bgc_fp64_vector3_are_parallel(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2);
extern inline int bgc_vector3_are_orthogonal_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2); extern inline int bgc_fp32_vector3_are_orthogonal(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2);
extern inline int bgc_vector3_are_orthogonal_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2); extern inline int bgc_fp64_vector3_are_orthogonal(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2);
extern inline int bgc_vector3_get_attitude_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2); extern inline int bgc_fp32_vector3_get_attitude(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2);
extern inline int bgc_vector3_get_attitude_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2); extern inline int bgc_fp64_vector3_get_attitude(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2);
// =================== Angle ==================== // // =================== Angle ==================== //
float bgc_vector3_get_angle_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, const BgcAngleUnitEnum angle_unit) float bgc_fp32_vector3_get_angle(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const int angle_unit)
{ {
const float square_modulus1 = bgc_vector3_get_square_modulus_fp32(vector1); const float square_modulus1 = bgc_fp32_vector3_get_square_modulus(vector1);
// square_modulus1 != square_modulus1 is check for NaN value at square_modulus1 // square_modulus1 != square_modulus1 is check for NaN value at square_modulus1
if (square_modulus1 <= BGC_SQUARE_EPSYLON_FP32 || square_modulus1 != square_modulus1) { if (square_modulus1 <= BGC_FP32_SQUARE_EPSYLON || square_modulus1 != square_modulus1) {
return 0.0f; return 0.0f;
} }
const float square_modulus2 = bgc_vector3_get_square_modulus_fp32(vector2); const float square_modulus2 = bgc_fp32_vector3_get_square_modulus(vector2);
// square_modulus2 != square_modulus2 is check for NaN value at square_modulus2 // square_modulus2 != square_modulus2 is check for NaN value at square_modulus2
if (square_modulus2 <= BGC_SQUARE_EPSYLON_FP32 || square_modulus2 != square_modulus2) { if (square_modulus2 <= BGC_FP32_SQUARE_EPSYLON || square_modulus2 != square_modulus2) {
return 0.0f; return 0.0f;
} }
BgcVector3FP32 cross_product; BGC_FP32_Vector3 cross_product;
bgc_vector3_get_cross_product_fp32(vector1, vector2, &cross_product); bgc_fp32_vector3_get_cross_product(vector1, vector2, &cross_product);
const float scalar = bgc_vector3_get_scalar_product_fp32(vector1, vector2); const float scalar = bgc_fp32_vector3_get_dot_product(vector1, vector2);
const float cross = bgc_vector3_get_modulus_fp32(&cross_product); const float cross = bgc_fp32_vector3_get_modulus(&cross_product);
return bgc_radians_to_units_fp32(atan2f(cross, scalar), angle_unit); return bgc_fp32_radians_to_units(atan2f(cross, scalar), angle_unit);
} }
double bgc_vector3_get_angle_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, const BgcAngleUnitEnum angle_unit) double bgc_fp64_vector3_get_angle(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const int angle_unit)
{ {
const double square_modulus1 = bgc_vector3_get_square_modulus_fp64(vector1); const double square_modulus1 = bgc_fp64_vector3_get_square_modulus(vector1);
// square_modulus1 != square_modulus1 is check for NaN value at square_modulus1 // square_modulus1 != square_modulus1 is check for NaN value at square_modulus1
if (square_modulus1 <= BGC_SQUARE_EPSYLON_FP64 || square_modulus1 != square_modulus1) { if (square_modulus1 <= BGC_FP64_SQUARE_EPSYLON || square_modulus1 != square_modulus1) {
return 0.0; return 0.0;
} }
const double square_modulus2 = bgc_vector3_get_square_modulus_fp64(vector2); const double square_modulus2 = bgc_fp64_vector3_get_square_modulus(vector2);
// square_modulus2 != square_modulus2 is check for NaN value at square_modulus2 // square_modulus2 != square_modulus2 is check for NaN value at square_modulus2
if (square_modulus2 <= BGC_SQUARE_EPSYLON_FP64 || square_modulus2 != square_modulus2) { if (square_modulus2 <= BGC_FP64_SQUARE_EPSYLON || square_modulus2 != square_modulus2) {
return 0.0; return 0.0;
} }
BgcVector3FP64 cross_product; BGC_FP64_Vector3 cross_product;
bgc_vector3_get_cross_product_fp64(vector1, vector2, &cross_product); bgc_fp64_vector3_get_cross_product(vector1, vector2, &cross_product);
const double scalar = bgc_vector3_get_scalar_product_fp64(vector1, vector2); const double scalar = bgc_fp64_vector3_get_dot_product(vector1, vector2);
const double cross = bgc_vector3_get_modulus_fp64(&cross_product); const double cross = bgc_fp64_vector3_get_modulus(&cross_product);
return bgc_radians_to_units_fp64(atan2(cross, scalar), angle_unit); return bgc_fp64_radians_to_units(atan2(cross, scalar), angle_unit);
} }

View file

@ -11,23 +11,23 @@
typedef struct typedef struct
{ {
float x1, x2, x3; float x1, x2, x3;
} BgcVector3FP32; } BGC_FP32_Vector3;
typedef struct typedef struct
{ {
double x1, x2, x3; double x1, x2, x3;
} BgcVector3FP64; } BGC_FP64_Vector3;
// =================== Reset ==================== // // =================== Reset ==================== //
inline void bgc_vector3_reset_fp32(BgcVector3FP32* vector) inline void bgc_fp32_vector3_reset(BGC_FP32_Vector3* vector)
{ {
vector->x1 = 0.0f; vector->x1 = 0.0f;
vector->x2 = 0.0f; vector->x2 = 0.0f;
vector->x3 = 0.0f; vector->x3 = 0.0f;
} }
inline void bgc_vector3_reset_fp64(BgcVector3FP64* vector) inline void bgc_fp64_vector3_reset(BGC_FP64_Vector3* vector)
{ {
vector->x1 = 0.0; vector->x1 = 0.0;
vector->x2 = 0.0; vector->x2 = 0.0;
@ -36,14 +36,14 @@ inline void bgc_vector3_reset_fp64(BgcVector3FP64* vector)
// ==================== Set ===================== // // ==================== Set ===================== //
inline void bgc_vector3_set_values_fp32(const float x1, const float x2, const float x3, BgcVector3FP32* destination) inline void bgc_fp32_vector3_make(const float x1, const float x2, const float x3, BGC_FP32_Vector3* destination)
{ {
destination->x1 = x1; destination->x1 = x1;
destination->x2 = x2; destination->x2 = x2;
destination->x3 = x3; destination->x3 = x3;
} }
inline void bgc_vector3_set_values_fp64(const double x1, const double x2, const double x3, BgcVector3FP64* destination) inline void bgc_fp64_vector3_make(const double x1, const double x2, const double x3, BGC_FP64_Vector3* destination)
{ {
destination->x1 = x1; destination->x1 = x1;
destination->x2 = x2; destination->x2 = x2;
@ -52,58 +52,58 @@ inline void bgc_vector3_set_values_fp64(const double x1, const double x2, const
// ================== Modulus =================== // // ================== Modulus =================== //
inline float bgc_vector3_get_square_modulus_fp32(const BgcVector3FP32* vector) inline float bgc_fp32_vector3_get_square_modulus(const BGC_FP32_Vector3* vector)
{ {
return vector->x1 * vector->x1 + vector->x2 * vector->x2 + vector->x3 * vector->x3; return vector->x1 * vector->x1 + vector->x2 * vector->x2 + vector->x3 * vector->x3;
} }
inline double bgc_vector3_get_square_modulus_fp64(const BgcVector3FP64* vector) inline double bgc_fp64_vector3_get_square_modulus(const BGC_FP64_Vector3* vector)
{ {
return vector->x1 * vector->x1 + vector->x2 * vector->x2 + vector->x3 * vector->x3; return vector->x1 * vector->x1 + vector->x2 * vector->x2 + vector->x3 * vector->x3;
} }
inline float bgc_vector3_get_modulus_fp32(const BgcVector3FP32* vector) inline float bgc_fp32_vector3_get_modulus(const BGC_FP32_Vector3* vector)
{ {
return sqrtf(bgc_vector3_get_square_modulus_fp32(vector)); return sqrtf(bgc_fp32_vector3_get_square_modulus(vector));
} }
inline double bgc_vector3_get_modulus_fp64(const BgcVector3FP64* vector) inline double bgc_fp64_vector3_get_modulus(const BGC_FP64_Vector3* vector)
{ {
return sqrt(bgc_vector3_get_square_modulus_fp64(vector)); return sqrt(bgc_fp64_vector3_get_square_modulus(vector));
} }
// ================= Comparison ================= // // ================= Comparison ================= //
inline int bgc_vector3_is_zero_fp32(const BgcVector3FP32* vector) inline int bgc_fp32_vector3_is_zero(const BGC_FP32_Vector3* vector)
{ {
return bgc_vector3_get_square_modulus_fp32(vector) <= BGC_SQUARE_EPSYLON_FP32; return bgc_fp32_vector3_get_square_modulus(vector) <= BGC_FP32_SQUARE_EPSYLON;
} }
inline int bgc_vector3_is_zero_fp64(const BgcVector3FP64* vector) inline int bgc_fp64_vector3_is_zero(const BGC_FP64_Vector3* vector)
{ {
return bgc_vector3_get_square_modulus_fp64(vector) <= BGC_SQUARE_EPSYLON_FP64; return bgc_fp64_vector3_get_square_modulus(vector) <= BGC_FP64_SQUARE_EPSYLON;
} }
inline int bgc_vector3_is_unit_fp32(const BgcVector3FP32* vector) inline int bgc_fp32_vector3_is_unit(const BGC_FP32_Vector3* vector)
{ {
return bgc_is_sqare_unit_fp32(bgc_vector3_get_square_modulus_fp32(vector)); return bgc_fp32_is_square_unit(bgc_fp32_vector3_get_square_modulus(vector));
} }
inline int bgc_vector3_is_unit_fp64(const BgcVector3FP64* vector) inline int bgc_fp64_vector3_is_unit(const BGC_FP64_Vector3* vector)
{ {
return bgc_is_sqare_unit_fp64(bgc_vector3_get_square_modulus_fp64(vector)); return bgc_fp64_is_square_unit(bgc_fp64_vector3_get_square_modulus(vector));
} }
// ==================== Copy ==================== // // ==================== Copy ==================== //
inline void bgc_vector3_copy_fp32(const BgcVector3FP32* source, BgcVector3FP32* destination) inline void bgc_fp32_vector3_copy(const BGC_FP32_Vector3* source, BGC_FP32_Vector3* destination)
{ {
destination->x1 = source->x1; destination->x1 = source->x1;
destination->x2 = source->x2; destination->x2 = source->x2;
destination->x3 = source->x3; destination->x3 = source->x3;
} }
inline void bgc_vector3_copy_fp64(const BgcVector3FP64* source, BgcVector3FP64* destination) inline void bgc_fp64_vector3_copy(const BGC_FP64_Vector3* source, BGC_FP64_Vector3* destination)
{ {
destination->x1 = source->x1; destination->x1 = source->x1;
destination->x2 = source->x2; destination->x2 = source->x2;
@ -112,7 +112,7 @@ inline void bgc_vector3_copy_fp64(const BgcVector3FP64* source, BgcVector3FP64*
// ==================== Swap ==================== // // ==================== Swap ==================== //
inline void bgc_vector3_swap_fp32(BgcVector3FP32* vector1, BgcVector3FP32* vector2) inline void bgc_fp32_vector3_swap(BGC_FP32_Vector3* vector1, BGC_FP32_Vector3* vector2)
{ {
const float x1 = vector2->x1; const float x1 = vector2->x1;
const float x2 = vector2->x2; const float x2 = vector2->x2;
@ -127,7 +127,7 @@ inline void bgc_vector3_swap_fp32(BgcVector3FP32* vector1, BgcVector3FP32* vecto
vector1->x3 = x3; vector1->x3 = x3;
} }
inline void bgc_vector3_swap_fp64(BgcVector3FP64* vector1, BgcVector3FP64* vector2) inline void bgc_fp64_vector3_swap(BGC_FP64_Vector3* vector1, BGC_FP64_Vector3* vector2)
{ {
const double x1 = vector2->x1; const double x1 = vector2->x1;
const double x2 = vector2->x2; const double x2 = vector2->x2;
@ -144,14 +144,14 @@ inline void bgc_vector3_swap_fp64(BgcVector3FP64* vector1, BgcVector3FP64* vecto
// ================== Convert =================== // // ================== Convert =================== //
inline void bgc_vector3_convert_fp64_to_fp32(const BgcVector3FP64* source, BgcVector3FP32* destination) inline void bgc_fp64_vector3_convert_to_fp32(const BGC_FP64_Vector3* source, BGC_FP32_Vector3* destination)
{ {
destination->x1 = (float)source->x1; destination->x1 = (float)source->x1;
destination->x2 = (float)source->x2; destination->x2 = (float)source->x2;
destination->x3 = (float)source->x3; destination->x3 = (float)source->x3;
} }
inline void bgc_vector3_convert_fp32_to_fp64(const BgcVector3FP32* source, BgcVector3FP64* destination) inline void bgc_fp32_vector3_convert_to_fp64(const BGC_FP32_Vector3* source, BGC_FP64_Vector3* destination)
{ {
destination->x1 = source->x1; destination->x1 = source->x1;
destination->x2 = source->x2; destination->x2 = source->x2;
@ -160,14 +160,14 @@ inline void bgc_vector3_convert_fp32_to_fp64(const BgcVector3FP32* source, BgcVe
// ==================== Add ===================== // // ==================== Add ===================== //
inline void bgc_vector3_add_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, BgcVector3FP32* sum) inline void bgc_fp32_vector3_add(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, BGC_FP32_Vector3* sum)
{ {
sum->x1 = vector1->x1 + vector2->x1; sum->x1 = vector1->x1 + vector2->x1;
sum->x2 = vector1->x2 + vector2->x2; sum->x2 = vector1->x2 + vector2->x2;
sum->x3 = vector1->x3 + vector2->x3; sum->x3 = vector1->x3 + vector2->x3;
} }
inline void bgc_vector3_add_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, BgcVector3FP64* sum) inline void bgc_fp64_vector3_add(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, BGC_FP64_Vector3* sum)
{ {
sum->x1 = vector1->x1 + vector2->x1; sum->x1 = vector1->x1 + vector2->x1;
sum->x2 = vector1->x2 + vector2->x2; sum->x2 = vector1->x2 + vector2->x2;
@ -176,14 +176,14 @@ inline void bgc_vector3_add_fp64(const BgcVector3FP64* vector1, const BgcVector3
// ================= Add scaled ================= // // ================= Add scaled ================= //
inline void bgc_vector3_add_scaled_fp32(const BgcVector3FP32* basic_vector, const BgcVector3FP32* scalable_vector, const float scale, BgcVector3FP32* sum) inline void bgc_fp32_vector3_add_scaled(const BGC_FP32_Vector3* basic_vector, const BGC_FP32_Vector3* scalable_vector, const float scale, BGC_FP32_Vector3* sum)
{ {
sum->x1 = basic_vector->x1 + scalable_vector->x1 * scale; sum->x1 = basic_vector->x1 + scalable_vector->x1 * scale;
sum->x2 = basic_vector->x2 + scalable_vector->x2 * scale; sum->x2 = basic_vector->x2 + scalable_vector->x2 * scale;
sum->x3 = basic_vector->x3 + scalable_vector->x3 * scale; sum->x3 = basic_vector->x3 + scalable_vector->x3 * scale;
} }
inline void bgc_vector3_add_scaled_fp64(const BgcVector3FP64* basic_vector, const BgcVector3FP64* scalable_vector, const double scale, BgcVector3FP64* sum) inline void bgc_fp64_vector3_add_scaled(const BGC_FP64_Vector3* basic_vector, const BGC_FP64_Vector3* scalable_vector, const double scale, BGC_FP64_Vector3* sum)
{ {
sum->x1 = basic_vector->x1 + scalable_vector->x1 * scale; sum->x1 = basic_vector->x1 + scalable_vector->x1 * scale;
sum->x2 = basic_vector->x2 + scalable_vector->x2 * scale; sum->x2 = basic_vector->x2 + scalable_vector->x2 * scale;
@ -192,14 +192,14 @@ inline void bgc_vector3_add_scaled_fp64(const BgcVector3FP64* basic_vector, cons
// ================== Subtract ================== // // ================== Subtract ================== //
inline void bgc_vector3_subtract_fp32(const BgcVector3FP32* minuend, const BgcVector3FP32* subtrahend, BgcVector3FP32* difference) inline void bgc_fp32_vector3_subtract(const BGC_FP32_Vector3* minuend, const BGC_FP32_Vector3* subtrahend, BGC_FP32_Vector3* difference)
{ {
difference->x1 = minuend->x1 - subtrahend->x1; difference->x1 = minuend->x1 - subtrahend->x1;
difference->x2 = minuend->x2 - subtrahend->x2; difference->x2 = minuend->x2 - subtrahend->x2;
difference->x3 = minuend->x3 - subtrahend->x3; difference->x3 = minuend->x3 - subtrahend->x3;
} }
inline void bgc_vector3_subtract_fp64(const BgcVector3FP64* minuend, const BgcVector3FP64* subtrahend, BgcVector3FP64* difference) inline void bgc_fp64_vector3_subtract(const BGC_FP64_Vector3* minuend, const BGC_FP64_Vector3* subtrahend, BGC_FP64_Vector3* difference)
{ {
difference->x1 = minuend->x1 - subtrahend->x1; difference->x1 = minuend->x1 - subtrahend->x1;
difference->x2 = minuend->x2 - subtrahend->x2; difference->x2 = minuend->x2 - subtrahend->x2;
@ -208,14 +208,14 @@ inline void bgc_vector3_subtract_fp64(const BgcVector3FP64* minuend, const BgcVe
// ================== Multiply ================== // // ================== Multiply ================== //
inline void bgc_vector3_multiply_fp32(const BgcVector3FP32* multiplicand, const float multiplier, BgcVector3FP32* product) inline void bgc_fp32_vector3_multiply(const BGC_FP32_Vector3* multiplicand, const float multiplier, BGC_FP32_Vector3* product)
{ {
product->x1 = multiplicand->x1 * multiplier; product->x1 = multiplicand->x1 * multiplier;
product->x2 = multiplicand->x2 * multiplier; product->x2 = multiplicand->x2 * multiplier;
product->x3 = multiplicand->x3 * multiplier; product->x3 = multiplicand->x3 * multiplier;
} }
inline void bgc_vector3_multiply_fp64(const BgcVector3FP64* multiplicand, const double multiplier, BgcVector3FP64* product) inline void bgc_fp64_vector3_multiply(const BGC_FP64_Vector3* multiplicand, const double multiplier, BGC_FP64_Vector3* product)
{ {
product->x1 = multiplicand->x1 * multiplier; product->x1 = multiplicand->x1 * multiplier;
product->x2 = multiplicand->x2 * multiplier; product->x2 = multiplicand->x2 * multiplier;
@ -224,109 +224,109 @@ inline void bgc_vector3_multiply_fp64(const BgcVector3FP64* multiplicand, const
// =================== Divide =================== // // =================== Divide =================== //
inline void bgc_vector3_divide_fp32(const BgcVector3FP32* dividend, const float divisor, BgcVector3FP32* quotient) inline void bgc_fp32_vector3_divide(const BGC_FP32_Vector3* dividend, const float divisor, BGC_FP32_Vector3* quotient)
{ {
bgc_vector3_multiply_fp32(dividend, 1.0f / divisor, quotient); bgc_fp32_vector3_multiply(dividend, 1.0f / divisor, quotient);
} }
inline void bgc_vector3_divide_fp64(const BgcVector3FP64* dividend, const double divisor, BgcVector3FP64* quotient) inline void bgc_fp64_vector3_divide(const BGC_FP64_Vector3* dividend, const double divisor, BGC_FP64_Vector3* quotient)
{ {
bgc_vector3_multiply_fp64(dividend, 1.0 / divisor, quotient); bgc_fp64_vector3_multiply(dividend, 1.0 / divisor, quotient);
} }
// ================== Average2 ================== // // ================== Average2 ================== //
inline void bgc_vector3_get_mean_of_two_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, BgcVector3FP32* mean) inline void bgc_fp32_vector3_get_middle2(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, BGC_FP32_Vector3* middle)
{ {
mean->x1 = (vector1->x1 + vector2->x1) * 0.5f; middle->x1 = (vector1->x1 + vector2->x1) * 0.5f;
mean->x2 = (vector1->x2 + vector2->x2) * 0.5f; middle->x2 = (vector1->x2 + vector2->x2) * 0.5f;
mean->x3 = (vector1->x3 + vector2->x3) * 0.5f; middle->x3 = (vector1->x3 + vector2->x3) * 0.5f;
} }
inline void bgc_vector3_get_mean_of_two_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, BgcVector3FP64* mean) inline void bgc_fp64_vector3_get_middle2(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, BGC_FP64_Vector3* middle)
{ {
mean->x1 = (vector1->x1 + vector2->x1) * 0.5; middle->x1 = (vector1->x1 + vector2->x1) * 0.5;
mean->x2 = (vector1->x2 + vector2->x2) * 0.5; middle->x2 = (vector1->x2 + vector2->x2) * 0.5;
mean->x3 = (vector1->x3 + vector2->x3) * 0.5; middle->x3 = (vector1->x3 + vector2->x3) * 0.5;
} }
// ================== Average3 ================== // // ================== Average3 ================== //
inline void bgc_vector3_get_mean_of_three_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, const BgcVector3FP32* vector3, BgcVector3FP32* mean) inline void bgc_fp32_vector3_get_middle3(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const BGC_FP32_Vector3* vector3, BGC_FP32_Vector3* middle)
{ {
mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_ONE_THIRD_FP32; middle->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP32_ONE_THIRD;
mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_ONE_THIRD_FP32; middle->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP32_ONE_THIRD;
mean->x3 = (vector1->x3 + vector2->x3 + vector3->x3) * BGC_ONE_THIRD_FP32; middle->x3 = (vector1->x3 + vector2->x3 + vector3->x3) * BGC_FP32_ONE_THIRD;
} }
inline void bgc_vector3_get_mean_of_three_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, const BgcVector3FP64* vector3, BgcVector3FP64* mean) inline void bgc_fp64_vector3_get_middle3(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const BGC_FP64_Vector3* vector3, BGC_FP64_Vector3* middle)
{ {
mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_ONE_THIRD_FP64; middle->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP64_ONE_THIRD;
mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_ONE_THIRD_FP64; middle->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP64_ONE_THIRD;
mean->x3 = (vector1->x3 + vector2->x3 + vector3->x3) * BGC_ONE_THIRD_FP64; middle->x3 = (vector1->x3 + vector2->x3 + vector3->x3) * BGC_FP64_ONE_THIRD;
} }
// =================== Linear =================== // // =================== Linear =================== //
inline void bgc_vector3_interpolate_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, const float phase, BgcVector3FP32* interpolation) inline void bgc_fp32_vector3_interpolate(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const float phase, BGC_FP32_Vector3* interpolation)
{ {
const float counterphase = 1.0f - phase; const float counter_phase = 1.0f - phase;
interpolation->x1 = vector1->x1 * counterphase + vector2->x1 * phase; interpolation->x1 = vector1->x1 * counter_phase + vector2->x1 * phase;
interpolation->x2 = vector1->x2 * counterphase + vector2->x2 * phase; interpolation->x2 = vector1->x2 * counter_phase + vector2->x2 * phase;
interpolation->x3 = vector1->x3 * counterphase + vector2->x3 * phase; interpolation->x3 = vector1->x3 * counter_phase + vector2->x3 * phase;
} }
inline void bgc_vector3_interpolate_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, const double phase, BgcVector3FP64* interpolation) inline void bgc_fp64_vector3_interpolate(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const double phase, BGC_FP64_Vector3* interpolation)
{ {
const double counterphase = 1.0 - phase; const double counter_phase = 1.0 - phase;
interpolation->x1 = vector1->x1 * counterphase + vector2->x1 * phase; interpolation->x1 = vector1->x1 * counter_phase + vector2->x1 * phase;
interpolation->x2 = vector1->x2 * counterphase + vector2->x2 * phase; interpolation->x2 = vector1->x2 * counter_phase + vector2->x2 * phase;
interpolation->x3 = vector1->x3 * counterphase + vector2->x3 * phase; interpolation->x3 = vector1->x3 * counter_phase + vector2->x3 * phase;
} }
// ================== Negative ================== // // ================== Negative ================== //
inline void bgc_vector3_make_opposite_fp32(BgcVector3FP32* vector) inline void bgc_fp32_vector3_revert(BGC_FP32_Vector3* vector)
{ {
vector->x1 = -vector->x1; vector->x1 = -vector->x1;
vector->x2 = -vector->x2; vector->x2 = -vector->x2;
vector->x3 = -vector->x3; vector->x3 = -vector->x3;
} }
inline void bgc_vector3_make_opposite_fp64(BgcVector3FP64* vector) inline void bgc_fp64_vector3_revert(BGC_FP64_Vector3* vector)
{ {
vector->x1 = -vector->x1; vector->x1 = -vector->x1;
vector->x2 = -vector->x2; vector->x2 = -vector->x2;
vector->x3 = -vector->x3; vector->x3 = -vector->x3;
} }
inline void bgc_vector3_get_opposite_fp32(const BgcVector3FP32* vector, BgcVector3FP32* opposite) inline void bgc_fp32_vector3_get_reverse(const BGC_FP32_Vector3* vector, BGC_FP32_Vector3* reverse)
{ {
opposite->x1 = -vector->x1; reverse->x1 = -vector->x1;
opposite->x2 = -vector->x2; reverse->x2 = -vector->x2;
opposite->x3 = -vector->x3; reverse->x3 = -vector->x3;
} }
inline void bgc_vector3_get_opposite_fp64(const BgcVector3FP64* vector, BgcVector3FP64* opposite) inline void bgc_fp64_vector3_get_reverse(const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* reverse)
{ {
opposite->x1 = -vector->x1; reverse->x1 = -vector->x1;
opposite->x2 = -vector->x2; reverse->x2 = -vector->x2;
opposite->x3 = -vector->x3; reverse->x3 = -vector->x3;
} }
// ================= Normalize ================== // // ================= Normalize ================== //
inline int bgc_vector3_normalize_fp32(BgcVector3FP32* vector) inline int bgc_fp32_vector3_normalize(BGC_FP32_Vector3* vector)
{ {
const float square_modulus = bgc_vector3_get_square_modulus_fp32(vector); const float square_modulus = bgc_fp32_vector3_get_square_modulus(vector);
if (bgc_is_sqare_unit_fp32(square_modulus)) { if (bgc_fp32_is_square_unit(square_modulus)) {
return 1; return 1;
} }
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
return 0; return 0;
} }
@ -339,15 +339,15 @@ inline int bgc_vector3_normalize_fp32(BgcVector3FP32* vector)
return 1; return 1;
} }
inline int bgc_vector3_normalize_fp64(BgcVector3FP64* vector) inline int bgc_fp64_vector3_normalize(BGC_FP64_Vector3* vector)
{ {
const double square_modulus = bgc_vector3_get_square_modulus_fp64(vector); const double square_modulus = bgc_fp64_vector3_get_square_modulus(vector);
if (bgc_is_sqare_unit_fp64(square_modulus)) { if (bgc_fp64_is_square_unit(square_modulus)) {
return 1; return 1;
} }
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
return 0; return 0;
} }
@ -360,64 +360,64 @@ inline int bgc_vector3_normalize_fp64(BgcVector3FP64* vector)
return 1; return 1;
} }
inline int bgc_vector3_get_normalized_fp32(const BgcVector3FP32* vector, BgcVector3FP32* normalized) inline int bgc_fp32_vector3_get_normalized(const BGC_FP32_Vector3* vector, BGC_FP32_Vector3* normalized)
{ {
const float square_modulus = bgc_vector3_get_square_modulus_fp32(vector); const float square_modulus = bgc_fp32_vector3_get_square_modulus(vector);
if (bgc_is_sqare_unit_fp32(square_modulus)) { if (bgc_fp32_is_square_unit(square_modulus)) {
bgc_vector3_copy_fp32(vector, normalized); bgc_fp32_vector3_copy(vector, normalized);
return 1; return 1;
} }
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
bgc_vector3_reset_fp32(normalized); bgc_fp32_vector3_reset(normalized);
return 0; return 0;
} }
bgc_vector3_multiply_fp32(vector, sqrtf(1.0f / square_modulus), normalized); bgc_fp32_vector3_multiply(vector, sqrtf(1.0f / square_modulus), normalized);
return 1; return 1;
} }
inline int bgc_vector3_get_normalized_fp64(const BgcVector3FP64* vector, BgcVector3FP64* normalized) inline int bgc_fp64_vector3_get_normalized(const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* normalized)
{ {
const double square_modulus = bgc_vector3_get_square_modulus_fp64(vector); const double square_modulus = bgc_fp64_vector3_get_square_modulus(vector);
if (bgc_is_sqare_unit_fp64(square_modulus)) { if (bgc_fp64_is_square_unit(square_modulus)) {
bgc_vector3_copy_fp64(vector, normalized); bgc_fp64_vector3_copy(vector, normalized);
return 1; return 1;
} }
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
bgc_vector3_reset_fp64(normalized); bgc_fp64_vector3_reset(normalized);
return 0; return 0;
} }
bgc_vector3_multiply_fp64(vector, sqrt(1.0 / square_modulus), normalized); bgc_fp64_vector3_multiply(vector, sqrt(1.0 / square_modulus), normalized);
return 1; return 1;
} }
// =============== Scalar Product =============== // // =============== Scalar Product =============== //
inline float bgc_vector3_get_scalar_product_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2) inline float bgc_fp32_vector3_get_dot_product(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2)
{ {
return vector1->x1 * vector2->x1 + vector1->x2 * vector2->x2 + vector1->x3 * vector2->x3; return vector1->x1 * vector2->x1 + vector1->x2 * vector2->x2 + vector1->x3 * vector2->x3;
} }
inline double bgc_vector3_get_scalar_product_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2) inline double bgc_fp64_vector3_get_dot_product(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2)
{ {
return vector1->x1 * vector2->x1 + vector1->x2 * vector2->x2 + vector1->x3 * vector2->x3; return vector1->x1 * vector2->x1 + vector1->x2 * vector2->x2 + vector1->x3 * vector2->x3;
} }
// =============== Triple Product =============== // // =============== Triple Product =============== //
inline float bgc_vector3_get_triple_product_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, const BgcVector3FP32* vector3) inline float bgc_fp32_vector3_get_triple_product(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const BGC_FP32_Vector3* vector3)
{ {
return vector1->x1 * (vector2->x2 * vector3->x3 - vector2->x3 * vector3->x2) return vector1->x1 * (vector2->x2 * vector3->x3 - vector2->x3 * vector3->x2)
+ vector1->x2 * (vector2->x3 * vector3->x1 - vector2->x1 * vector3->x3) + vector1->x2 * (vector2->x3 * vector3->x1 - vector2->x1 * vector3->x3)
+ vector1->x3 * (vector2->x1 * vector3->x2 - vector2->x2 * vector3->x1); + vector1->x3 * (vector2->x1 * vector3->x2 - vector2->x2 * vector3->x1);
} }
inline double bgc_vector3_get_triple_product_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, const BgcVector3FP64* vector3) inline double bgc_fp64_vector3_get_triple_product(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const BGC_FP64_Vector3* vector3)
{ {
return vector1->x1 * (vector2->x2 * vector3->x3 - vector2->x3 * vector3->x2) return vector1->x1 * (vector2->x2 * vector3->x3 - vector2->x3 * vector3->x2)
+ vector1->x2 * (vector2->x3 * vector3->x1 - vector2->x1 * vector3->x3) + vector1->x2 * (vector2->x3 * vector3->x1 - vector2->x1 * vector3->x3)
@ -426,7 +426,7 @@ inline double bgc_vector3_get_triple_product_fp64(const BgcVector3FP64* vector1,
// =============== Cross Product ================ // // =============== Cross Product ================ //
inline void bgc_vector3_get_cross_product_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, BgcVector3FP32* product) inline void bgc_fp32_vector3_get_cross_product(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, BGC_FP32_Vector3* product)
{ {
const float x1 = vector1->x2 * vector2->x3 - vector1->x3 * vector2->x2; const float x1 = vector1->x2 * vector2->x3 - vector1->x3 * vector2->x2;
const float x2 = vector1->x3 * vector2->x1 - vector1->x1 * vector2->x3; const float x2 = vector1->x3 * vector2->x1 - vector1->x1 * vector2->x3;
@ -437,7 +437,7 @@ inline void bgc_vector3_get_cross_product_fp32(const BgcVector3FP32* vector1, co
product->x3 = x3; product->x3 = x3;
} }
inline void bgc_vector3_get_cross_product_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, BgcVector3FP64* product) inline void bgc_fp64_vector3_get_cross_product(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, BGC_FP64_Vector3* product)
{ {
const double x1 = vector1->x2 * vector2->x3 - vector1->x3 * vector2->x2; const double x1 = vector1->x2 * vector2->x3 - vector1->x3 * vector2->x2;
const double x2 = vector1->x3 * vector2->x1 - vector1->x1 * vector2->x3; const double x2 = vector1->x3 * vector2->x1 - vector1->x1 * vector2->x3;
@ -450,20 +450,20 @@ inline void bgc_vector3_get_cross_product_fp64(const BgcVector3FP64* vector1, co
// ============ Double Cross Product ============ // // ============ Double Cross Product ============ //
inline void bgc_vector3_get_double_cross_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, const BgcVector3FP32* vector3, BgcVector3FP32* product) inline void bgc_fp32_vector3_get_double_cross(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const BGC_FP32_Vector3* vector3, BGC_FP32_Vector3* product)
{ {
const float ac = bgc_vector3_get_scalar_product_fp32(vector1, vector3); const float ac = bgc_fp32_vector3_get_dot_product(vector1, vector3);
const float ab = bgc_vector3_get_scalar_product_fp32(vector1, vector2); const float ab = bgc_fp32_vector3_get_dot_product(vector1, vector2);
product->x1 = vector2->x1 * ac - vector3->x1 * ab; product->x1 = vector2->x1 * ac - vector3->x1 * ab;
product->x2 = vector2->x2 * ac - vector3->x2 * ab; product->x2 = vector2->x2 * ac - vector3->x2 * ab;
product->x3 = vector2->x3 * ac - vector3->x3 * ab; product->x3 = vector2->x3 * ac - vector3->x3 * ab;
} }
inline void bgc_vector3_get_double_cross_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, const BgcVector3FP64* vector3, BgcVector3FP64* product) inline void bgc_fp64_vector3_get_double_cross(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const BGC_FP64_Vector3* vector3, BGC_FP64_Vector3* product)
{ {
const double ac = bgc_vector3_get_scalar_product_fp64(vector1, vector3); const double ac = bgc_fp64_vector3_get_dot_product(vector1, vector3);
const double ab = bgc_vector3_get_scalar_product_fp64(vector1, vector2); const double ab = bgc_fp64_vector3_get_dot_product(vector1, vector2);
product->x1 = vector2->x1 * ac - vector3->x1 * ab; product->x1 = vector2->x1 * ac - vector3->x1 * ab;
product->x2 = vector2->x2 * ac - vector3->x2 * ab; product->x2 = vector2->x2 * ac - vector3->x2 * ab;
@ -472,13 +472,13 @@ inline void bgc_vector3_get_double_cross_fp64(const BgcVector3FP64* vector1, con
// =================== Angle ==================== // // =================== Angle ==================== //
float bgc_vector3_get_angle_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, const BgcAngleUnitEnum angle_unit); float bgc_fp32_vector3_get_angle(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const int angle_unit);
double bgc_vector3_get_angle_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, const BgcAngleUnitEnum angle_unit); double bgc_fp64_vector3_get_angle(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const int angle_unit);
// =============== Square Distance ============== // // =============== Square Distance ============== //
inline float bgc_vector3_get_square_distance_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2) inline float bgc_fp32_vector3_get_square_distance(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2)
{ {
const float dx1 = (vector1->x1 - vector2->x1); const float dx1 = (vector1->x1 - vector2->x1);
const float dx2 = (vector1->x2 - vector2->x2); const float dx2 = (vector1->x2 - vector2->x2);
@ -487,7 +487,7 @@ inline float bgc_vector3_get_square_distance_fp32(const BgcVector3FP32* vector1,
return dx1 * dx1 + dx2 * dx2 + dx3 * dx3; return dx1 * dx1 + dx2 * dx2 + dx3 * dx3;
} }
inline double bgc_vector3_get_square_distance_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2) inline double bgc_fp64_vector3_get_square_distance(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2)
{ {
const double dx1 = (vector1->x1 - vector2->x1); const double dx1 = (vector1->x1 - vector2->x1);
const double dx2 = (vector1->x2 - vector2->x2); const double dx2 = (vector1->x2 - vector2->x2);
@ -498,172 +498,172 @@ inline double bgc_vector3_get_square_distance_fp64(const BgcVector3FP64* vector1
// ================== Distance ================== // // ================== Distance ================== //
inline float bgc_vector3_get_distance_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2) inline float bgc_fp32_vector3_get_distance(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2)
{ {
return sqrtf(bgc_vector3_get_square_distance_fp32(vector1, vector2)); return sqrtf(bgc_fp32_vector3_get_square_distance(vector1, vector2));
} }
inline double bgc_vector3_get_distance_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2) inline double bgc_fp64_vector3_get_distance(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2)
{ {
return sqrt(bgc_vector3_get_square_distance_fp64(vector1, vector2)); return sqrt(bgc_fp64_vector3_get_square_distance(vector1, vector2));
} }
// ============== Are Close Enough ============== // // ============== Are Close Enough ============== //
inline int bgc_vector3_are_close_enough_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2, const float distance_limit) inline int bgc_fp32_vector3_are_close_enough(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const float distance_limit)
{ {
return bgc_vector3_get_square_distance_fp32(vector1, vector2) <= distance_limit * distance_limit; return bgc_fp32_vector3_get_square_distance(vector1, vector2) <= distance_limit * distance_limit;
} }
inline int bgc_vector3_are_close_enough_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2, const double distance_limit) inline int bgc_fp64_vector3_are_close_enough(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const double distance_limit)
{ {
return bgc_vector3_get_square_distance_fp64(vector1, vector2) <= distance_limit * distance_limit; return bgc_fp64_vector3_get_square_distance(vector1, vector2) <= distance_limit * distance_limit;
} }
// ================== Are Close ================= // // ================== Are Close ================= //
inline int bgc_vector3_are_close_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2) inline int bgc_fp32_vector3_are_close(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2)
{ {
const float square_modulus1 = bgc_vector3_get_square_modulus_fp32(vector1); const float square_modulus1 = bgc_fp32_vector3_get_square_modulus(vector1);
const float square_modulus2 = bgc_vector3_get_square_modulus_fp32(vector2); const float square_modulus2 = bgc_fp32_vector3_get_square_modulus(vector2);
const float square_distance = bgc_vector3_get_square_distance_fp32(vector1, vector2); const float square_distance = bgc_fp32_vector3_get_square_distance(vector1, vector2);
if (square_modulus1 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32 || square_modulus2 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32) { if (square_modulus1 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT) {
return square_distance <= BGC_SQUARE_EPSYLON_FP32; return square_distance <= BGC_FP32_SQUARE_EPSYLON;
} }
return square_distance <= BGC_SQUARE_EPSYLON_FP32 * square_modulus1 && square_distance <= BGC_SQUARE_EPSYLON_FP32 * square_modulus2; return square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus2;
} }
inline int bgc_vector3_are_close_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2) inline int bgc_fp64_vector3_are_close(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2)
{ {
const double square_modulus1 = bgc_vector3_get_square_modulus_fp64(vector1); const double square_modulus1 = bgc_fp64_vector3_get_square_modulus(vector1);
const double square_modulus2 = bgc_vector3_get_square_modulus_fp64(vector2); const double square_modulus2 = bgc_fp64_vector3_get_square_modulus(vector2);
const double square_distance = bgc_vector3_get_square_distance_fp64(vector1, vector2); const double square_distance = bgc_fp64_vector3_get_square_distance(vector1, vector2);
if (square_modulus1 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP64 || square_modulus2 <= BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP64) { if (square_modulus1 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT) {
return square_distance <= BGC_SQUARE_EPSYLON_FP64; return square_distance <= BGC_FP64_SQUARE_EPSYLON;
} }
return square_distance <= BGC_SQUARE_EPSYLON_FP64 * square_modulus1 && square_distance <= BGC_SQUARE_EPSYLON_FP64 * square_modulus2; return square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus2;
} }
// ================== Parallel ================== // // ================== Parallel ================== //
inline int bgc_vector3_are_parallel_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2) inline int bgc_fp32_vector3_are_parallel(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2)
{ {
const float square_modulus1 = bgc_vector3_get_square_modulus_fp32(vector1); const float square_modulus1 = bgc_fp32_vector3_get_square_modulus(vector1);
const float square_modulus2 = bgc_vector3_get_square_modulus_fp32(vector2); const float square_modulus2 = bgc_fp32_vector3_get_square_modulus(vector2);
if (square_modulus1 <= BGC_SQUARE_EPSYLON_FP32 || square_modulus2 <= BGC_SQUARE_EPSYLON_FP32) { if (square_modulus1 <= BGC_FP32_SQUARE_EPSYLON || square_modulus2 <= BGC_FP32_SQUARE_EPSYLON) {
return 1; return 1;
} }
BgcVector3FP32 product; BGC_FP32_Vector3 product;
bgc_vector3_get_cross_product_fp32(vector1, vector2, &product); bgc_fp32_vector3_get_cross_product(vector1, vector2, &product);
return bgc_vector3_get_square_modulus_fp32(&product) <= BGC_SQUARE_EPSYLON_FP32 * square_modulus1 * square_modulus2; return bgc_fp32_vector3_get_square_modulus(&product) <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
} }
inline int bgc_vector3_are_parallel_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2) inline int bgc_fp64_vector3_are_parallel(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2)
{ {
const double square_modulus1 = bgc_vector3_get_square_modulus_fp64(vector1); const double square_modulus1 = bgc_fp64_vector3_get_square_modulus(vector1);
const double square_modulus2 = bgc_vector3_get_square_modulus_fp64(vector2); const double square_modulus2 = bgc_fp64_vector3_get_square_modulus(vector2);
if (square_modulus1 <= BGC_SQUARE_EPSYLON_FP64 || square_modulus2 <= BGC_SQUARE_EPSYLON_FP64) { if (square_modulus1 <= BGC_FP64_SQUARE_EPSYLON || square_modulus2 <= BGC_FP64_SQUARE_EPSYLON) {
return 1; return 1;
} }
BgcVector3FP64 product; BGC_FP64_Vector3 product;
bgc_vector3_get_cross_product_fp64(vector1, vector2, &product); bgc_fp64_vector3_get_cross_product(vector1, vector2, &product);
return bgc_vector3_get_square_modulus_fp64(&product) <= BGC_SQUARE_EPSYLON_FP64 * square_modulus1 * square_modulus2; return bgc_fp64_vector3_get_square_modulus(&product) <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
} }
// ================= Orthogonal ================= // // ================= Orthogonal ================= //
inline int bgc_vector3_are_orthogonal_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2) inline int bgc_fp32_vector3_are_orthogonal(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2)
{ {
const float square_modulus1 = bgc_vector3_get_square_modulus_fp32(vector1); const float square_modulus1 = bgc_fp32_vector3_get_square_modulus(vector1);
const float square_modulus2 = bgc_vector3_get_square_modulus_fp32(vector2); const float square_modulus2 = bgc_fp32_vector3_get_square_modulus(vector2);
if (square_modulus1 <= BGC_SQUARE_EPSYLON_FP32 || square_modulus2 <= BGC_SQUARE_EPSYLON_FP32) { if (square_modulus1 <= BGC_FP32_SQUARE_EPSYLON || square_modulus2 <= BGC_FP32_SQUARE_EPSYLON) {
return 1; return 1;
} }
const float scalar_product = bgc_vector3_get_scalar_product_fp32(vector1, vector2); const float scalar_product = bgc_fp32_vector3_get_dot_product(vector1, vector2);
return scalar_product * scalar_product <= BGC_SQUARE_EPSYLON_FP32 * square_modulus1 * square_modulus2; return scalar_product * scalar_product <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
} }
inline int bgc_vector3_are_orthogonal_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2) inline int bgc_fp64_vector3_are_orthogonal(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2)
{ {
const double square_modulus1 = bgc_vector3_get_square_modulus_fp64(vector1); const double square_modulus1 = bgc_fp64_vector3_get_square_modulus(vector1);
const double square_modulus2 = bgc_vector3_get_square_modulus_fp64(vector2); const double square_modulus2 = bgc_fp64_vector3_get_square_modulus(vector2);
if (square_modulus1 <= BGC_SQUARE_EPSYLON_FP64 || square_modulus2 <= BGC_SQUARE_EPSYLON_FP64) { if (square_modulus1 <= BGC_FP64_SQUARE_EPSYLON || square_modulus2 <= BGC_FP64_SQUARE_EPSYLON) {
return 1; return 1;
} }
const double scalar_product = bgc_vector3_get_scalar_product_fp64(vector1, vector2); const double scalar_product = bgc_fp64_vector3_get_dot_product(vector1, vector2);
return scalar_product * scalar_product <= BGC_SQUARE_EPSYLON_FP64 * square_modulus1 * square_modulus2; return scalar_product * scalar_product <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
} }
// ================== Attitude ================== // // ================== Attitude ================== //
inline int bgc_vector3_get_attitude_fp32(const BgcVector3FP32* vector1, const BgcVector3FP32* vector2) inline int bgc_fp32_vector3_get_attitude(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2)
{ {
const float square_modulus1 = bgc_vector3_get_square_modulus_fp32(vector1); const float square_modulus1 = bgc_fp32_vector3_get_square_modulus(vector1);
const float square_modulus2 = bgc_vector3_get_square_modulus_fp32(vector2); const float square_modulus2 = bgc_fp32_vector3_get_square_modulus(vector2);
if (square_modulus1 <= BGC_SQUARE_EPSYLON_FP32 || square_modulus2 <= BGC_SQUARE_EPSYLON_FP32) { if (square_modulus1 <= BGC_FP32_SQUARE_EPSYLON || square_modulus2 <= BGC_FP32_SQUARE_EPSYLON) {
return BGC_ATTITUDE_ZERO; return BGC_ATTITUDE_ZERO;
} }
const float square_limit = BGC_SQUARE_EPSYLON_FP32 * square_modulus1 * square_modulus2; const float square_limit = BGC_FP32_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
const float scalar_product = bgc_vector3_get_scalar_product_fp32(vector1, vector2); const float scalar_product = bgc_fp32_vector3_get_dot_product(vector1, vector2);
if (scalar_product * scalar_product <= square_limit) { if (scalar_product * scalar_product <= square_limit) {
return BGC_ATTITUDE_ORTHOGONAL; return BGC_ATTITUDE_ORTHOGONAL;
} }
BgcVector3FP32 product; BGC_FP32_Vector3 product;
bgc_vector3_get_cross_product_fp32(vector1, vector2, &product); bgc_fp32_vector3_get_cross_product(vector1, vector2, &product);
if (bgc_vector3_get_square_modulus_fp32(&product) > square_limit) { if (bgc_fp32_vector3_get_square_modulus(&product) > square_limit) {
return BGC_ATTITUDE_ANY; return BGC_ATTITUDE_ANY;
} }
return scalar_product > 0.0f ? BGC_ATTITUDE_CO_DIRECTIONAL : BGC_ATTITUDE_COUNTER_DIRECTIONAL; return scalar_product > 0.0f ? BGC_ATTITUDE_CO_DIRECTIONAL : BGC_ATTITUDE_COUNTER_DIRECTIONAL;
} }
inline int bgc_vector3_get_attitude_fp64(const BgcVector3FP64* vector1, const BgcVector3FP64* vector2) inline int bgc_fp64_vector3_get_attitude(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2)
{ {
const double square_modulus1 = bgc_vector3_get_square_modulus_fp64(vector1); const double square_modulus1 = bgc_fp64_vector3_get_square_modulus(vector1);
const double square_modulus2 = bgc_vector3_get_square_modulus_fp64(vector2); const double square_modulus2 = bgc_fp64_vector3_get_square_modulus(vector2);
if (square_modulus1 <= BGC_SQUARE_EPSYLON_FP64 || square_modulus2 <= BGC_SQUARE_EPSYLON_FP64) { if (square_modulus1 <= BGC_FP64_SQUARE_EPSYLON || square_modulus2 <= BGC_FP64_SQUARE_EPSYLON) {
return BGC_ATTITUDE_ZERO; return BGC_ATTITUDE_ZERO;
} }
const double square_limit = BGC_SQUARE_EPSYLON_FP64 * square_modulus1 * square_modulus2; const double square_limit = BGC_FP64_SQUARE_EPSYLON * square_modulus1 * square_modulus2;
const double scalar_product = bgc_vector3_get_scalar_product_fp64(vector1, vector2); const double scalar_product = bgc_fp64_vector3_get_dot_product(vector1, vector2);
if (scalar_product * scalar_product <= square_limit) { if (scalar_product * scalar_product <= square_limit) {
return BGC_ATTITUDE_ORTHOGONAL; return BGC_ATTITUDE_ORTHOGONAL;
} }
BgcVector3FP64 product; BGC_FP64_Vector3 product;
bgc_vector3_get_cross_product_fp64(vector1, vector2, &product); bgc_fp64_vector3_get_cross_product(vector1, vector2, &product);
if (bgc_vector3_get_square_modulus_fp64(&product) > square_limit) { if (bgc_fp64_vector3_get_square_modulus(&product) > square_limit) {
return BGC_ATTITUDE_ANY; return BGC_ATTITUDE_ANY;
} }

View file

@ -3,83 +3,83 @@
#include "angle.h" #include "angle.h"
#include "versor.h" #include "versor.h"
const BgcVersorFP32 BGC_IDLE_VERSOR_FP32 = { 1.0f, 0.0f, 0.0f, 0.0f }; const BGC_FP32_Versor BGC_FP32_IDLE_VERSOR = { 1.0f, 0.0f, 0.0f, 0.0f };
const BgcVersorFP64 BGC_IDLE_VERSOR_FP64 = { 1.0, 0.0, 0.0, 0.0 }; const BGC_FP64_Versor BGC_FP64_IDLE_VERSOR = { 1.0, 0.0, 0.0, 0.0 };
extern inline void bgc_versor_reset_fp32(BgcVersorFP32* versor); extern inline void bgc_fp32_versor_reset(BGC_FP32_Versor* versor);
extern inline void bgc_versor_reset_fp64(BgcVersorFP64* versor); extern inline void bgc_fp64_versor_reset(BGC_FP64_Versor* versor);
extern inline void bgc_versor_set_values_fp32(const float s0, const float x1, const float x2, const float x3, BgcVersorFP32* versor); extern inline void bgc_fp32_versor_make(const float s0, const float x1, const float x2, const float x3, BGC_FP32_Versor* versor);
extern inline void bgc_versor_set_values_fp64(const double s0, const double x1, const double x2, const double x3, BgcVersorFP64* versor); extern inline void bgc_fp64_versor_make(const double s0, const double x1, const double x2, const double x3, BGC_FP64_Versor* versor);
extern inline void bgc_versor_set_rotation_fp32(const BgcRotation3FP32* rotation, BgcVersorFP32* result); extern inline void bgc_fp32_versor_make_for_rotation(const BGC_FP32_Rotation3* rotation, BGC_FP32_Versor* result);
extern inline void bgc_versor_set_rotation_fp64(const BgcRotation3FP64* rotation, BgcVersorFP64* result); extern inline void bgc_fp64_versor_make_for_rotation(const BGC_FP64_Rotation3* rotation, BGC_FP64_Versor* result);
extern inline void bgc_versor_copy_fp32(const BgcVersorFP32* source, BgcVersorFP32* destination); extern inline void bgc_fp32_versor_copy(const BGC_FP32_Versor* source, BGC_FP32_Versor* destination);
extern inline void bgc_versor_copy_fp64(const BgcVersorFP64* source, BgcVersorFP64* destination); extern inline void bgc_fp64_versor_copy(const BGC_FP64_Versor* source, BGC_FP64_Versor* destination);
extern inline void bgc_versor_swap_fp32(BgcVersorFP32* versor1, BgcVersorFP32* versor2); extern inline void bgc_fp32_versor_swap(BGC_FP32_Versor* versor1, BGC_FP32_Versor* versor2);
extern inline void bgc_versor_swap_fp64(BgcVersorFP64* versor1, BgcVersorFP64* versor2); extern inline void bgc_fp64_versor_swap(BGC_FP64_Versor* versor1, BGC_FP64_Versor* versor2);
extern inline int bgc_versor_is_identity_fp32(const BgcVersorFP32* versor); extern inline int bgc_fp32_versor_is_idle(const BGC_FP32_Versor* versor);
extern inline int bgc_versor_is_identity_fp64(const BgcVersorFP64* versor); extern inline int bgc_fp64_versor_is_idle(const BGC_FP64_Versor* versor);
extern inline void bgc_versor_convert_fp64_to_fp32(const BgcVersorFP64* source, BgcVersorFP32* destination); extern inline void bgc_fp64_versor_convert_to_fp32(const BGC_FP64_Versor* source, BGC_FP32_Versor* destination);
extern inline void bgc_versor_convert_fp32_to_fp64(const BgcVersorFP32* source, BgcVersorFP64* destination); extern inline void bgc_fp32_versor_convert_to_fp64(const BGC_FP32_Versor* source, BGC_FP64_Versor* destination);
extern inline void bgc_versor_shorten_fp32(BgcVersorFP32* versor); extern inline void bgc_fp32_versor_shorten(BGC_FP32_Versor* versor);
extern inline void bgc_versor_shorten_fp64(BgcVersorFP64* versor); extern inline void bgc_fp64_versor_shorten(BGC_FP64_Versor* versor);
extern inline void bgc_versor_get_shortened_fp32(const BgcVersorFP32* versor, BgcVersorFP32* shortened); extern inline void bgc_fp32_versor_get_shortened(const BGC_FP32_Versor* versor, BGC_FP32_Versor* shortened);
extern inline void bgc_versor_get_shortened_fp64(const BgcVersorFP64* versor, BgcVersorFP64* shortened); extern inline void bgc_fp64_versor_get_shortened(const BGC_FP64_Versor* versor, BGC_FP64_Versor* shortened);
extern inline void bgc_versor_make_opposite_fp32(BgcVersorFP32* versor); extern inline void bgc_fp32_versor_alternate(BGC_FP32_Versor* versor);
extern inline void bgc_versor_make_opposite_fp64(BgcVersorFP64* versor); extern inline void bgc_fp64_versor_alternate(BGC_FP64_Versor* versor);
extern inline void bgc_versor_get_opposite_fp32(const BgcVersorFP32* versor, BgcVersorFP32* opposite); extern inline void bgc_fp32_versor_get_alternative(const BGC_FP32_Versor* versor, BGC_FP32_Versor* opposite);
extern inline void bgc_versor_get_opposite_fp64(const BgcVersorFP64* versor, BgcVersorFP64* opposite); extern inline void bgc_fp64_versor_get_alternative(const BGC_FP64_Versor* versor, BGC_FP64_Versor* opposite);
extern inline void bgc_versor_invert_fp32(BgcVersorFP32* versor); extern inline void bgc_fp32_versor_revert(BGC_FP32_Versor* versor);
extern inline void bgc_versor_invert_fp64(BgcVersorFP64* versor); extern inline void bgc_fp64_versor_revert(BGC_FP64_Versor* versor);
extern inline void bgc_versor_get_inverse_fp32(const BgcVersorFP32* versor, BgcVersorFP32* inverse); extern inline void bgc_fp32_versor_get_reverse(const BGC_FP32_Versor* versor, BGC_FP32_Versor* inverse);
extern inline void bgc_versor_get_inverse_fp64(const BgcVersorFP64* versor, BgcVersorFP64* inverse); extern inline void bgc_fp64_versor_get_reverse(const BGC_FP64_Versor* versor, BGC_FP64_Versor* inverse);
extern inline void bgc_versor_combine_fp32(const BgcVersorFP32* first, const BgcVersorFP32* second, BgcVersorFP32* result); extern inline void bgc_fp32_versor_combine(const BGC_FP32_Versor* first, const BGC_FP32_Versor* second, BGC_FP32_Versor* result);
extern inline void bgc_versor_combine_fp64(const BgcVersorFP64* first, const BgcVersorFP64* second, BgcVersorFP64* result); extern inline void bgc_fp64_versor_combine(const BGC_FP64_Versor* first, const BGC_FP64_Versor* second, BGC_FP64_Versor* result);
extern inline void bgc_versor_combine3_fp32(const BgcVersorFP32* first, const BgcVersorFP32* second, const BgcVersorFP32* third, BgcVersorFP32* result); extern inline void bgc_fp32_versor_combine3(const BGC_FP32_Versor* first, const BGC_FP32_Versor* second, const BGC_FP32_Versor* third, BGC_FP32_Versor* result);
extern inline void bgc_versor_combine3_fp64(const BgcVersorFP64* first, const BgcVersorFP64* second, const BgcVersorFP64* third, BgcVersorFP64* result); extern inline void bgc_fp64_versor_combine3(const BGC_FP64_Versor* first, const BGC_FP64_Versor* second, const BGC_FP64_Versor* third, BGC_FP64_Versor* result);
extern inline void bgc_versor_exclude_fp32(const BgcVersorFP32* base, const BgcVersorFP32* excludant, BgcVersorFP32* difference); extern inline void bgc_fp32_versor_exclude(const BGC_FP32_Versor* base, const BGC_FP32_Versor* excludant, BGC_FP32_Versor* difference);
extern inline void bgc_versor_exclude_fp64(const BgcVersorFP64* base, const BgcVersorFP64* excludant, BgcVersorFP64* difference); extern inline void bgc_fp64_versor_exclude(const BGC_FP64_Versor* base, const BGC_FP64_Versor* excludant, BGC_FP64_Versor* difference);
extern inline void bgc_versor_get_rotation_matrix_fp32(const BgcVersorFP32* versor, BgcMatrix3x3FP32* matrix); extern inline void bgc_fp32_versor_get_rotation_matrix(const BGC_FP32_Versor* versor, BGC_FP32_Matrix3x3* matrix);
extern inline void bgc_versor_get_rotation_matrix_fp64(const BgcVersorFP64* versor, BgcMatrix3x3FP64* matrix); extern inline void bgc_fp64_versor_get_rotation_matrix(const BGC_FP64_Versor* versor, BGC_FP64_Matrix3x3* matrix);
extern inline void bgc_versor_get_reverse_matrix_fp32(const BgcVersorFP32* versor, BgcMatrix3x3FP32* matrix); extern inline void bgc_fp32_versor_get_reverse_matrix(const BGC_FP32_Versor* versor, BGC_FP32_Matrix3x3* matrix);
extern inline void bgc_versor_get_reverse_matrix_fp64(const BgcVersorFP64* versor, BgcMatrix3x3FP64* matrix); extern inline void bgc_fp64_versor_get_reverse_matrix(const BGC_FP64_Versor* versor, BGC_FP64_Matrix3x3* matrix);
extern inline void bgc_versor_get_both_matrices_fp32(const BgcVersorFP32* versor, BgcMatrix3x3FP32* rotation, BgcMatrix3x3FP32* reverse); extern inline void bgc_fp32_versor_get_both_matrices(const BGC_FP32_Versor* versor, BGC_FP32_Matrix3x3* rotation, BGC_FP32_Matrix3x3* reverse);
extern inline void bgc_versor_get_both_matrices_fp64(const BgcVersorFP64* versor, BgcMatrix3x3FP64* rotation, BgcMatrix3x3FP64* reverse); extern inline void bgc_fp64_versor_get_both_matrices(const BGC_FP64_Versor* versor, BGC_FP64_Matrix3x3* rotation, BGC_FP64_Matrix3x3* reverse);
extern inline void bgc_versor_turn_vector_fp32(const BgcVersorFP32* versor, const BgcVector3FP32* vector, BgcVector3FP32* result); extern inline void bgc_fp32_versor_turn_vector(const BGC_FP32_Versor* versor, const BGC_FP32_Vector3* vector, BGC_FP32_Vector3* result);
extern inline void bgc_versor_turn_vector_fp64(const BgcVersorFP64* versor, const BgcVector3FP64* vector, BgcVector3FP64* result); extern inline void bgc_fp64_versor_turn_vector(const BGC_FP64_Versor* versor, const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* result);
extern inline void bgc_versor_turn_vector_back_fp32(const BgcVersorFP32* versor, const BgcVector3FP32* vector, BgcVector3FP32* result); extern inline void bgc_fp32_versor_turn_vector_back(const BGC_FP32_Versor* versor, const BGC_FP32_Vector3* vector, BGC_FP32_Vector3* result);
extern inline void bgc_versor_turn_vector_back_fp64(const BgcVersorFP64* versor, const BgcVector3FP64* vector, BgcVector3FP64* result); extern inline void bgc_fp64_versor_turn_vector_back(const BGC_FP64_Versor* versor, const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* result);
extern inline int bgc_versor_are_close_fp32(const BgcVersorFP32* versor1, const BgcVersorFP32* versor2); extern inline int bgc_fp32_versor_are_close(const BGC_FP32_Versor* versor1, const BGC_FP32_Versor* versor2);
extern inline int bgc_versor_are_close_fp64(const BgcVersorFP64* versor1, const BgcVersorFP64* versor2); extern inline int bgc_fp64_versor_are_close(const BGC_FP64_Versor* versor1, const BGC_FP64_Versor* versor2);
// ================= Normalize ================== // // ================= Normalize ================== //
void _bgc_versor_normalize_fp32(const float square_modulus, BgcVersorFP32* versor) void _bgc_fp32_versor_normalize(BGC_FP32_Versor* versor)
{ {
// (square_modulus != square_modulus) is true when square_modulus is NaN const float square_modulus = (versor->_s0 * versor->_s0 + versor->_x1 * versor->_x1) + (versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) {
versor->_s0 = 1.0f; versor->_s0 = 1.0f;
versor->_x1 = 0.0f; versor->_x1 = 0.0f;
versor->_x2 = 0.0f; versor->_x2 = 0.0f;
@ -95,11 +95,11 @@ void _bgc_versor_normalize_fp32(const float square_modulus, BgcVersorFP32* verso
versor->_x3 *= multiplier; versor->_x3 *= multiplier;
} }
void _bgc_versor_normalize_fp64(const double square_modulus, BgcVersorFP64* versor) void _bgc_fp64_versor_normalize(BGC_FP64_Versor* versor)
{ {
// (square_modulus != square_modulus) is true when square_modulus is NaN const double square_modulus = (versor->_s0 * versor->_s0 + versor->_x1 * versor->_x1) + (versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3);
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64 || square_modulus != square_modulus) { if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) {
versor->_s0 = 1.0; versor->_s0 = 1.0;
versor->_x1 = 0.0; versor->_x1 = 0.0;
versor->_x2 = 0.0; versor->_x2 = 0.0;
@ -117,71 +117,71 @@ void _bgc_versor_normalize_fp64(const double square_modulus, BgcVersorFP64* vers
// ================== Set Turn ================== // // ================== Set Turn ================== //
void bgc_versor_set_turn_fp32(const float x1, const float x2, const float x3, const float angle, const BgcAngleUnitEnum unit, BgcVersorFP32* result) void bgc_fp32_versor_make_for_turn(const float x1, const float x2, const float x3, const float angle, const int unit, BGC_FP32_Versor* result)
{ {
const float square_vector = x1 * x1 + x2 * x2 + x3 * x3; const float square_vector = x1 * x1 + x2 * x2 + x3 * x3;
if (square_vector <= BGC_SQUARE_EPSYLON_FP32) { if (square_vector <= BGC_FP32_SQUARE_EPSYLON) {
bgc_versor_reset_fp32(result); bgc_fp32_versor_reset(result);
return; return;
} }
const float half_angle = bgc_angle_to_radians_fp32(0.5f * angle, unit); const float half_angle = bgc_fp32_angle_to_radians(0.5f * angle, unit);
const float sine = sinf(half_angle); const float sine = sinf(half_angle);
if (bgc_is_zero_fp32(sine)) { if (bgc_fp32_is_zero(sine)) {
bgc_versor_reset_fp32(result); bgc_fp32_versor_reset(result);
return; return;
} }
const float multiplier = sine / sqrtf(square_vector); const float multiplier = sine / sqrtf(square_vector);
bgc_versor_set_values_fp32(cosf(half_angle), x1 * multiplier, x2 * multiplier, x3 * multiplier, result); bgc_fp32_versor_make(cosf(half_angle), x1 * multiplier, x2 * multiplier, x3 * multiplier, result);
} }
void bgc_versor_set_turn_fp64(const double x1, const double x2, const double x3, const double angle, const BgcAngleUnitEnum unit, BgcVersorFP64* result) void bgc_fp64_versor_make_for_turn(const double x1, const double x2, const double x3, const double angle, const int unit, BGC_FP64_Versor* result)
{ {
const double square_vector = x1 * x1 + x2 * x2 + x3 * x3; const double square_vector = x1 * x1 + x2 * x2 + x3 * x3;
if (square_vector <= BGC_SQUARE_EPSYLON_FP64) { if (square_vector <= BGC_FP64_SQUARE_EPSYLON) {
bgc_versor_reset_fp64(result); bgc_fp64_versor_reset(result);
return; return;
} }
const double half_angle = bgc_angle_to_radians_fp64(0.5 * angle, unit); const double half_angle = bgc_fp64_angle_to_radians(0.5 * angle, unit);
const double sine = sin(half_angle); const double sine = sin(half_angle);
if (bgc_is_zero_fp64(sine)) { if (bgc_fp64_is_zero(sine)) {
bgc_versor_reset_fp64(result); bgc_fp64_versor_reset(result);
return; return;
} }
const double multiplier = sine / sqrt(square_vector); const double multiplier = sine / sqrt(square_vector);
bgc_versor_set_values_fp64(cos(half_angle), x1 * multiplier, x2 * multiplier, x3 * multiplier, result); bgc_fp64_versor_make(cos(half_angle), x1 * multiplier, x2 * multiplier, x3 * multiplier, result);
} }
// ========= Make Direction Difference ========== // // ========= Make Direction Difference ========== //
static int _bgc_versor_make_direction_turn_fp32(const BgcVector3FP32* start, const BgcVector3FP32* end, const float square_modulus_product, BgcVersorFP32* result) static int _bgc_fp32_versor_make_direction_turn(const BGC_FP32_Vector3* start, const BGC_FP32_Vector3* end, const float square_modulus_product, BGC_FP32_Versor* result)
{ {
BgcVector3FP32 orthogonal_axis; BGC_FP32_Vector3 orthogonal_axis;
bgc_vector3_get_cross_product_fp32(start, end, &orthogonal_axis); bgc_fp32_vector3_get_cross_product(start, end, &orthogonal_axis);
const float scalar_product = bgc_vector3_get_scalar_product_fp32(start, end); const float scalar_product = bgc_fp32_vector3_get_dot_product(start, end);
const float square_modulus = bgc_vector3_get_square_modulus_fp32(&orthogonal_axis); const float square_modulus = bgc_fp32_vector3_get_square_modulus(&orthogonal_axis);
const float square_sine = square_modulus / square_modulus_product; const float square_sine = square_modulus / square_modulus_product;
if (square_sine > BGC_SQUARE_EPSYLON_FP32) { if (square_sine > BGC_FP32_SQUARE_EPSYLON) {
const float cosine = scalar_product / sqrtf(square_modulus_product); const float cosine = scalar_product / sqrtf(square_modulus_product);
const float angle = 0.5f * atan2f(sqrtf(square_sine), cosine); const float angle = 0.5f * atan2f(sqrtf(square_sine), cosine);
const float multiplier = sinf(angle) * sqrtf(1.0f / square_modulus); const float multiplier = sinf(angle) * sqrtf(1.0f / square_modulus);
bgc_versor_set_values_fp32(cosf(angle), orthogonal_axis.x1 * multiplier, orthogonal_axis.x2 * multiplier, orthogonal_axis.x3 * multiplier, result); bgc_fp32_versor_make(cosf(angle), orthogonal_axis.x1 * multiplier, orthogonal_axis.x2 * multiplier, orthogonal_axis.x3 * multiplier, result);
return BGC_SOME_TURN; return BGC_SOME_TURN;
} }
@ -189,27 +189,27 @@ static int _bgc_versor_make_direction_turn_fp32(const BgcVector3FP32* start, con
return BGC_OPPOSITE; return BGC_OPPOSITE;
} }
bgc_versor_reset_fp32(result); bgc_fp32_versor_reset(result);
return BGC_ZERO_TURN; return BGC_ZERO_TURN;
} }
static int _bgc_versor_make_direction_turn_fp64(const BgcVector3FP64* start, const BgcVector3FP64* end, const double square_modulus_product, BgcVersorFP64* result) static int _bgc_fp64_versor_make_direction_turn(const BGC_FP64_Vector3* start, const BGC_FP64_Vector3* end, const double square_modulus_product, BGC_FP64_Versor* result)
{ {
BgcVector3FP64 orthogonal_axis; BGC_FP64_Vector3 orthogonal_axis;
bgc_vector3_get_cross_product_fp64(start, end, &orthogonal_axis); bgc_fp64_vector3_get_cross_product(start, end, &orthogonal_axis);
const double scalar_product = bgc_vector3_get_scalar_product_fp64(start, end); const double scalar_product = bgc_fp64_vector3_get_dot_product(start, end);
const double square_modulus = bgc_vector3_get_square_modulus_fp64(&orthogonal_axis); const double square_modulus = bgc_fp64_vector3_get_square_modulus(&orthogonal_axis);
const double square_sine = square_modulus / square_modulus_product; const double square_sine = square_modulus / square_modulus_product;
if (square_sine > BGC_SQUARE_EPSYLON_FP64) { if (square_sine > BGC_FP64_SQUARE_EPSYLON) {
const double cosine = scalar_product / sqrt(square_modulus_product); const double cosine = scalar_product / sqrt(square_modulus_product);
const double angle = 0.5 * atan2(sqrt(square_sine), cosine); const double angle = 0.5 * atan2(sqrt(square_sine), cosine);
const double multiplier = sin(angle) * sqrt(1.0f / square_modulus); const double multiplier = sin(angle) * sqrt(1.0f / square_modulus);
bgc_versor_set_values_fp64(cos(angle), orthogonal_axis.x1 * multiplier, orthogonal_axis.x2 * multiplier, orthogonal_axis.x3 * multiplier, result); bgc_fp64_versor_make(cos(angle), orthogonal_axis.x1 * multiplier, orthogonal_axis.x2 * multiplier, orthogonal_axis.x3 * multiplier, result);
return BGC_SOME_TURN; return BGC_SOME_TURN;
} }
@ -217,51 +217,51 @@ static int _bgc_versor_make_direction_turn_fp64(const BgcVector3FP64* start, con
return BGC_OPPOSITE; return BGC_OPPOSITE;
} }
bgc_versor_reset_fp64(result); bgc_fp64_versor_reset(result);
return BGC_ZERO_TURN; return BGC_ZERO_TURN;
} }
int bgc_versor_make_direction_difference_fp32(const BgcVector3FP32* start, const BgcVector3FP32* end, BgcVersorFP32* result) int bgc_fp32_versor_make_direction_difference(const BGC_FP32_Vector3* start, const BGC_FP32_Vector3* end, BGC_FP32_Versor* result)
{ {
const float start_square_modulus = bgc_vector3_get_square_modulus_fp32(start); const float start_square_modulus = bgc_fp32_vector3_get_square_modulus(start);
const float end_square_modulus = bgc_vector3_get_square_modulus_fp32(end); const float end_square_modulus = bgc_fp32_vector3_get_square_modulus(end);
if (start_square_modulus <= BGC_SQUARE_EPSYLON_FP32 || end_square_modulus <= BGC_SQUARE_EPSYLON_FP32) { if (start_square_modulus <= BGC_FP32_SQUARE_EPSYLON || end_square_modulus <= BGC_FP32_SQUARE_EPSYLON) {
bgc_versor_reset_fp32(result); bgc_fp32_versor_reset(result);
return BGC_ZERO_TURN; return BGC_ZERO_TURN;
} }
return _bgc_versor_make_direction_turn_fp32(start, end, start_square_modulus * end_square_modulus, result); return _bgc_fp32_versor_make_direction_turn(start, end, start_square_modulus * end_square_modulus, result);
} }
int bgc_versor_make_direction_difference_fp64(const BgcVector3FP64* start, const BgcVector3FP64* end, BgcVersorFP64* result) int bgc_fp64_versor_make_direction_difference(const BGC_FP64_Vector3* start, const BGC_FP64_Vector3* end, BGC_FP64_Versor* result)
{ {
const double start_square_modulus = bgc_vector3_get_square_modulus_fp64(start); const double start_square_modulus = bgc_fp64_vector3_get_square_modulus(start);
const double end_square_modulus = bgc_vector3_get_square_modulus_fp64(end); const double end_square_modulus = bgc_fp64_vector3_get_square_modulus(end);
if (start_square_modulus <= BGC_SQUARE_EPSYLON_FP64 || end_square_modulus <= BGC_SQUARE_EPSYLON_FP64) { if (start_square_modulus <= BGC_FP64_SQUARE_EPSYLON || end_square_modulus <= BGC_FP64_SQUARE_EPSYLON) {
bgc_versor_reset_fp64(result); bgc_fp64_versor_reset(result);
return BGC_ZERO_TURN; return BGC_ZERO_TURN;
} }
return _bgc_versor_make_direction_turn_fp64(start, end, start_square_modulus * end_square_modulus, result); return _bgc_fp64_versor_make_direction_turn(start, end, start_square_modulus * end_square_modulus, result);
} }
// =============== Set Directions =============== // // =============== Set Directions =============== //
static int _bgc_versor_validate_basis_fp32(const float primary_square_modulus, const float auxiliary_square_modulus, const float orthogonal_square_modulus) static int _bgc_fp32_versor_validate_basis(const float primary_square_modulus, const float auxiliary_square_modulus, const float orthogonal_square_modulus)
{ {
if (primary_square_modulus <= BGC_SQUARE_EPSYLON_FP32) { if (primary_square_modulus <= BGC_FP32_SQUARE_EPSYLON) {
//TODO: add error code for: primary_vector is zero //TODO: add error code for: primary_vector is zero
return BGC_FAILED; return BGC_FAILED;
} }
if (auxiliary_square_modulus <= BGC_SQUARE_EPSYLON_FP32) { if (auxiliary_square_modulus <= BGC_FP32_SQUARE_EPSYLON) {
//TODO: add error code for: auxiliary_vector is zero //TODO: add error code for: auxiliary_vector is zero
return BGC_FAILED; return BGC_FAILED;
} }
if (orthogonal_square_modulus <= BGC_SQUARE_EPSYLON_FP32 * primary_square_modulus * auxiliary_square_modulus) { if (orthogonal_square_modulus <= BGC_FP32_SQUARE_EPSYLON * primary_square_modulus * auxiliary_square_modulus) {
//TODO: add error code for: primary_vector and auxiliary_vector are parallel //TODO: add error code for: primary_vector and auxiliary_vector are parallel
return BGC_FAILED; return BGC_FAILED;
} }
@ -269,19 +269,19 @@ static int _bgc_versor_validate_basis_fp32(const float primary_square_modulus, c
return BGC_SUCCESS; return BGC_SUCCESS;
} }
static int _bgc_versor_validate_basis_fp64(const double primary_square_modulus, const double auxiliary_square_modulus, const double orthogonal_square_modulus) static int _bgc_fp64_versor_validate_basis(const double primary_square_modulus, const double auxiliary_square_modulus, const double orthogonal_square_modulus)
{ {
if (primary_square_modulus <= BGC_SQUARE_EPSYLON_FP64) { if (primary_square_modulus <= BGC_FP64_SQUARE_EPSYLON) {
//TODO: add error code for: primary_vector is zero //TODO: add error code for: primary_vector is zero
return BGC_FAILED; return BGC_FAILED;
} }
if (auxiliary_square_modulus <= BGC_SQUARE_EPSYLON_FP64) { if (auxiliary_square_modulus <= BGC_FP64_SQUARE_EPSYLON) {
//TODO: add error code for: auxiliary_vector is zero //TODO: add error code for: auxiliary_vector is zero
return BGC_FAILED; return BGC_FAILED;
} }
if (orthogonal_square_modulus <= BGC_SQUARE_EPSYLON_FP64 * primary_square_modulus * auxiliary_square_modulus) { if (orthogonal_square_modulus <= BGC_FP64_SQUARE_EPSYLON * primary_square_modulus * auxiliary_square_modulus) {
//TODO: add error code for: primary_vector and auxiliary_vector are parallel //TODO: add error code for: primary_vector and auxiliary_vector are parallel
return BGC_FAILED; return BGC_FAILED;
} }
@ -289,64 +289,64 @@ static int _bgc_versor_validate_basis_fp64(const double primary_square_modulus,
return BGC_SUCCESS; return BGC_SUCCESS;
} }
int bgc_versor_make_basis_difference_fp32( int bgc_fp32_versor_make_basis_difference(
const BgcVector3FP32* initial_primary_direction, const BGC_FP32_Vector3* initial_primary_direction,
const BgcVector3FP32* initial_auxiliary_direction, const BGC_FP32_Vector3* initial_auxiliary_direction,
const BgcVector3FP32* final_primary_direction, const BGC_FP32_Vector3* final_primary_direction,
const BgcVector3FP32* final_auxiliary_direction, const BGC_FP32_Vector3* final_auxiliary_direction,
BgcVersorFP32* result BGC_FP32_Versor* result
) )
{ {
BgcVector3FP32 initial_orthogonal_direction, turned_orthogonal_direction, final_orthogonal_direction; BGC_FP32_Vector3 initial_orthogonal_direction, turned_orthogonal_direction, final_orthogonal_direction;
// Step 1: Validate initial basis: // Step 1: Validate initial basis:
bgc_vector3_get_cross_product_fp32(initial_primary_direction, initial_auxiliary_direction, &initial_orthogonal_direction); bgc_fp32_vector3_get_cross_product(initial_primary_direction, initial_auxiliary_direction, &initial_orthogonal_direction);
const float initial_primary_square_modulus = bgc_vector3_get_square_modulus_fp32(initial_primary_direction); const float initial_primary_square_modulus = bgc_fp32_vector3_get_square_modulus(initial_primary_direction);
const float initial_auxiliary_square_modulus = bgc_vector3_get_square_modulus_fp32(initial_auxiliary_direction); const float initial_auxiliary_square_modulus = bgc_fp32_vector3_get_square_modulus(initial_auxiliary_direction);
const float initial_orthogonal_square_modulus = bgc_vector3_get_square_modulus_fp32(&initial_orthogonal_direction); const float initial_orthogonal_square_modulus = bgc_fp32_vector3_get_square_modulus(&initial_orthogonal_direction);
const int initial_basis_valudation = _bgc_versor_validate_basis_fp32(initial_primary_square_modulus, initial_auxiliary_square_modulus, initial_orthogonal_square_modulus); const int initial_basis_valudation = _bgc_fp32_versor_validate_basis(initial_primary_square_modulus, initial_auxiliary_square_modulus, initial_orthogonal_square_modulus);
if (initial_basis_valudation != BGC_SUCCESS) { if (initial_basis_valudation != BGC_SUCCESS) {
return initial_basis_valudation; return initial_basis_valudation;
} }
// Step 1: Validate final basis: // Step 1: Validate final basis:
bgc_vector3_get_cross_product_fp32(final_primary_direction, final_auxiliary_direction, &final_orthogonal_direction); bgc_fp32_vector3_get_cross_product(final_primary_direction, final_auxiliary_direction, &final_orthogonal_direction);
const float final_primary_square_modulus = bgc_vector3_get_square_modulus_fp32(final_primary_direction); const float final_primary_square_modulus = bgc_fp32_vector3_get_square_modulus(final_primary_direction);
const float final_auxiliary_square_modulus = bgc_vector3_get_square_modulus_fp32(final_auxiliary_direction); const float final_auxiliary_square_modulus = bgc_fp32_vector3_get_square_modulus(final_auxiliary_direction);
const float final_orthogonal_square_modulus = bgc_vector3_get_square_modulus_fp32(&final_orthogonal_direction); const float final_orthogonal_square_modulus = bgc_fp32_vector3_get_square_modulus(&final_orthogonal_direction);
const int final_basis_valudation = _bgc_versor_validate_basis_fp32(final_primary_square_modulus, final_auxiliary_square_modulus, final_orthogonal_square_modulus); const int final_basis_valudation = _bgc_fp32_versor_validate_basis(final_primary_square_modulus, final_auxiliary_square_modulus, final_orthogonal_square_modulus);
if (final_basis_valudation != BGC_SUCCESS) { if (final_basis_valudation != BGC_SUCCESS) {
return final_basis_valudation; return final_basis_valudation;
} }
// Step 3: Validate normalize orthogonal vectors: // Step 3: Validate normalize orthogonal vectors:
bgc_vector3_divide_fp32(&initial_orthogonal_direction, sqrtf(initial_orthogonal_square_modulus), &initial_orthogonal_direction); bgc_fp32_vector3_divide(&initial_orthogonal_direction, sqrtf(initial_orthogonal_square_modulus), &initial_orthogonal_direction);
bgc_vector3_divide_fp32(&final_orthogonal_direction, sqrtf(final_orthogonal_square_modulus), &final_orthogonal_direction); bgc_fp32_vector3_divide(&final_orthogonal_direction, sqrtf(final_orthogonal_square_modulus), &final_orthogonal_direction);
BgcVersorFP32 turn1, turn2; BGC_FP32_Versor turn1, turn2;
// Step 4: Find turn1 // Step 4: Find turn1
int turn1_code = _bgc_versor_make_direction_turn_fp32(initial_primary_direction, final_primary_direction, initial_primary_square_modulus * final_primary_square_modulus, &turn1); int turn1_code = _bgc_fp32_versor_make_direction_turn(initial_primary_direction, final_primary_direction, initial_primary_square_modulus * final_primary_square_modulus, &turn1);
if (turn1_code == BGC_OPPOSITE) { if (turn1_code == BGC_OPPOSITE) {
bgc_versor_set_values_fp32(0.0f, initial_orthogonal_direction.x1, initial_orthogonal_direction.x2, initial_orthogonal_direction.x3, &turn1); bgc_fp32_versor_make(0.0f, initial_orthogonal_direction.x1, initial_orthogonal_direction.x2, initial_orthogonal_direction.x3, &turn1);
} }
bgc_versor_turn_vector_fp32(&turn1, &initial_orthogonal_direction, &turned_orthogonal_direction); bgc_fp32_versor_turn_vector(&turn1, &initial_orthogonal_direction, &turned_orthogonal_direction);
// Step 5: Find turn2: // Step 5: Find turn2:
int turn2_code = _bgc_versor_make_direction_turn_fp32(&turned_orthogonal_direction, &final_orthogonal_direction, 1.0f, &turn2); int turn2_code = _bgc_fp32_versor_make_direction_turn(&turned_orthogonal_direction, &final_orthogonal_direction, 1.0f, &turn2);
if (turn2_code == BGC_OPPOSITE) { if (turn2_code == BGC_OPPOSITE) {
const float turn2_multiplier = sqrtf(1.0f / final_primary_square_modulus); const float turn2_multiplier = sqrtf(1.0f / final_primary_square_modulus);
bgc_versor_set_values_fp32(0.0f, bgc_fp32_versor_make(0.0f,
final_primary_direction->x1 * turn2_multiplier, final_primary_direction->x1 * turn2_multiplier,
final_primary_direction->x2 * turn2_multiplier, final_primary_direction->x2 * turn2_multiplier,
final_primary_direction->x3 * turn2_multiplier, final_primary_direction->x3 * turn2_multiplier,
@ -355,69 +355,69 @@ int bgc_versor_make_basis_difference_fp32(
} }
// Step 6: Combine turn1 and turn2: // Step 6: Combine turn1 and turn2:
bgc_versor_combine_fp32(&turn1, &turn2, result); bgc_fp32_versor_combine(&turn1, &turn2, result);
return BGC_SUCCESS; return BGC_SUCCESS;
} }
int bgc_versor_make_basis_difference_fp64( int bgc_fp64_versor_make_basis_difference(
const BgcVector3FP64* initial_primary_direction, const BGC_FP64_Vector3* initial_primary_direction,
const BgcVector3FP64* initial_auxiliary_direction, const BGC_FP64_Vector3* initial_auxiliary_direction,
const BgcVector3FP64* final_primary_direction, const BGC_FP64_Vector3* final_primary_direction,
const BgcVector3FP64* final_auxiliary_direction, const BGC_FP64_Vector3* final_auxiliary_direction,
BgcVersorFP64* result BGC_FP64_Versor* result
) )
{ {
BgcVector3FP64 initial_orthogonal_direction, turned_orthogonal_direction, final_orthogonal_direction; BGC_FP64_Vector3 initial_orthogonal_direction, turned_orthogonal_direction, final_orthogonal_direction;
// Step 1: Validate initial basis: // Step 1: Validate initial basis:
bgc_vector3_get_cross_product_fp64(initial_primary_direction, initial_auxiliary_direction, &initial_orthogonal_direction); bgc_fp64_vector3_get_cross_product(initial_primary_direction, initial_auxiliary_direction, &initial_orthogonal_direction);
const double initial_primary_square_modulus = bgc_vector3_get_square_modulus_fp64(initial_primary_direction); const double initial_primary_square_modulus = bgc_fp64_vector3_get_square_modulus(initial_primary_direction);
const double initial_auxiliary_square_modulus = bgc_vector3_get_square_modulus_fp64(initial_auxiliary_direction); const double initial_auxiliary_square_modulus = bgc_fp64_vector3_get_square_modulus(initial_auxiliary_direction);
const double initial_orthogonal_square_modulus = bgc_vector3_get_square_modulus_fp64(&initial_orthogonal_direction); const double initial_orthogonal_square_modulus = bgc_fp64_vector3_get_square_modulus(&initial_orthogonal_direction);
const int initial_basis_valudation = _bgc_versor_validate_basis_fp64(initial_primary_square_modulus, initial_auxiliary_square_modulus, initial_orthogonal_square_modulus); const int initial_basis_valudation = _bgc_fp64_versor_validate_basis(initial_primary_square_modulus, initial_auxiliary_square_modulus, initial_orthogonal_square_modulus);
if (initial_basis_valudation != BGC_SUCCESS) { if (initial_basis_valudation != BGC_SUCCESS) {
return initial_basis_valudation; return initial_basis_valudation;
} }
// Step 1: Validate final basis: // Step 1: Validate final basis:
bgc_vector3_get_cross_product_fp64(final_primary_direction, final_auxiliary_direction, &final_orthogonal_direction); bgc_fp64_vector3_get_cross_product(final_primary_direction, final_auxiliary_direction, &final_orthogonal_direction);
const double final_primary_square_modulus = bgc_vector3_get_square_modulus_fp64(final_primary_direction); const double final_primary_square_modulus = bgc_fp64_vector3_get_square_modulus(final_primary_direction);
const double final_auxiliary_square_modulus = bgc_vector3_get_square_modulus_fp64(final_auxiliary_direction); const double final_auxiliary_square_modulus = bgc_fp64_vector3_get_square_modulus(final_auxiliary_direction);
const double final_orthogonal_square_modulus = bgc_vector3_get_square_modulus_fp64(&final_orthogonal_direction); const double final_orthogonal_square_modulus = bgc_fp64_vector3_get_square_modulus(&final_orthogonal_direction);
const int final_basis_valudation = _bgc_versor_validate_basis_fp64(final_primary_square_modulus, final_auxiliary_square_modulus, final_orthogonal_square_modulus); const int final_basis_valudation = _bgc_fp64_versor_validate_basis(final_primary_square_modulus, final_auxiliary_square_modulus, final_orthogonal_square_modulus);
if (final_basis_valudation != BGC_SUCCESS) { if (final_basis_valudation != BGC_SUCCESS) {
return final_basis_valudation; return final_basis_valudation;
} }
// Step 3: Validate normalize orthogonal vectors: // Step 3: Validate normalize orthogonal vectors:
bgc_vector3_divide_fp64(&initial_orthogonal_direction, sqrt(initial_orthogonal_square_modulus), &initial_orthogonal_direction); bgc_fp64_vector3_divide(&initial_orthogonal_direction, sqrt(initial_orthogonal_square_modulus), &initial_orthogonal_direction);
bgc_vector3_divide_fp64(&final_orthogonal_direction, sqrt(final_orthogonal_square_modulus), &final_orthogonal_direction); bgc_fp64_vector3_divide(&final_orthogonal_direction, sqrt(final_orthogonal_square_modulus), &final_orthogonal_direction);
BgcVersorFP64 turn1, turn2; BGC_FP64_Versor turn1, turn2;
// Step 4: Find turn1 // Step 4: Find turn1
int turn1_code = _bgc_versor_make_direction_turn_fp64(initial_primary_direction, final_primary_direction, initial_primary_square_modulus * final_primary_square_modulus, &turn1); int turn1_code = _bgc_fp64_versor_make_direction_turn(initial_primary_direction, final_primary_direction, initial_primary_square_modulus * final_primary_square_modulus, &turn1);
if (turn1_code == BGC_OPPOSITE) { if (turn1_code == BGC_OPPOSITE) {
bgc_versor_set_values_fp64(0.0, initial_orthogonal_direction.x1, initial_orthogonal_direction.x2, initial_orthogonal_direction.x3, &turn1); bgc_fp64_versor_make(0.0, initial_orthogonal_direction.x1, initial_orthogonal_direction.x2, initial_orthogonal_direction.x3, &turn1);
} }
bgc_versor_turn_vector_fp64(&turn1, &initial_orthogonal_direction, &turned_orthogonal_direction); bgc_fp64_versor_turn_vector(&turn1, &initial_orthogonal_direction, &turned_orthogonal_direction);
// Step 5: Find turn2: // Step 5: Find turn2:
int turn2_code = _bgc_versor_make_direction_turn_fp64(&turned_orthogonal_direction, &final_orthogonal_direction, 1.0f, &turn2); int turn2_code = _bgc_fp64_versor_make_direction_turn(&turned_orthogonal_direction, &final_orthogonal_direction, 1.0f, &turn2);
if (turn2_code == BGC_OPPOSITE) { if (turn2_code == BGC_OPPOSITE) {
const double turn2_multiplier = sqrt(1.0 / final_primary_square_modulus); const double turn2_multiplier = sqrt(1.0 / final_primary_square_modulus);
bgc_versor_set_values_fp64(0.0, bgc_fp64_versor_make(0.0,
final_primary_direction->x1 * turn2_multiplier, final_primary_direction->x1 * turn2_multiplier,
final_primary_direction->x2 * turn2_multiplier, final_primary_direction->x2 * turn2_multiplier,
final_primary_direction->x3 * turn2_multiplier, final_primary_direction->x3 * turn2_multiplier,
@ -426,19 +426,19 @@ int bgc_versor_make_basis_difference_fp64(
} }
// Step 6: Combine turn1 and turn2: // Step 6: Combine turn1 and turn2:
bgc_versor_combine_fp64(&turn1, &turn2, result); bgc_fp64_versor_combine(&turn1, &turn2, result);
return BGC_SUCCESS; return BGC_SUCCESS;
} }
// =============== Get Exponation =============== // // =============== Get Exponation =============== //
void bgc_versor_get_exponation_fp32(const BgcVersorFP32* base, const float exponent, BgcVersorFP32* power) void bgc_fp32_versor_get_exponation(const BGC_FP32_Versor* base, const float exponent, BGC_FP32_Versor* power)
{ {
const float square_vector = base->_x1 * base->_x1 + base->_x2 * base->_x2 + base->_x3 * base->_x3; const float square_vector = base->_x1 * base->_x1 + base->_x2 * base->_x2 + base->_x3 * base->_x3;
if (square_vector <= BGC_SQUARE_EPSYLON_FP32 || square_vector != square_vector) { if (square_vector <= BGC_FP32_SQUARE_EPSYLON || square_vector != square_vector) {
bgc_versor_reset_fp32(power); bgc_fp32_versor_reset(power);
return; return;
} }
@ -448,15 +448,15 @@ void bgc_versor_get_exponation_fp32(const BgcVersorFP32* base, const float expon
const float multiplier = sinf(angle) / vector_modulus; const float multiplier = sinf(angle) / vector_modulus;
bgc_versor_set_values_fp32(cosf(angle), base->_x1 * multiplier, base->_x2 * multiplier, base->_x3 * multiplier, power); bgc_fp32_versor_make(cosf(angle), base->_x1 * multiplier, base->_x2 * multiplier, base->_x3 * multiplier, power);
} }
void bgc_versor_get_exponation_fp64(const BgcVersorFP64* base, const double exponent, BgcVersorFP64* power) void bgc_fp64_versor_get_exponation(const BGC_FP64_Versor* base, const double exponent, BGC_FP64_Versor* power)
{ {
const double square_vector = base->_x1 * base->_x1 + base->_x2 * base->_x2 + base->_x3 * base->_x3; const double square_vector = base->_x1 * base->_x1 + base->_x2 * base->_x2 + base->_x3 * base->_x3;
if (square_vector <= BGC_SQUARE_EPSYLON_FP64 || square_vector != square_vector) { if (square_vector <= BGC_FP64_SQUARE_EPSYLON || square_vector != square_vector) {
bgc_versor_reset_fp64(power); bgc_fp64_versor_reset(power);
return; return;
} }
@ -466,12 +466,12 @@ void bgc_versor_get_exponation_fp64(const BgcVersorFP64* base, const double expo
const double multiplier = sin(angle) / vector_modulus; const double multiplier = sin(angle) / vector_modulus;
bgc_versor_set_values_fp64(cos(angle), base->_x1 * multiplier, base->_x2 * multiplier, base->_x3 * multiplier, power); bgc_fp64_versor_make(cos(angle), base->_x1 * multiplier, base->_x2 * multiplier, base->_x3 * multiplier, power);
} }
// ============ Sphere Interpolation ============ // // ============ Sphere Interpolation ============ //
void bgc_versor_spherically_interpolate_fp32(const BgcVersorFP32* start, const BgcVersorFP32* end, const float phase, BgcVersorFP32* result) void bgc_fp32_versor_spherically_interpolate(const BGC_FP32_Versor* start, const BGC_FP32_Versor* end, const float phase, BGC_FP32_Versor* result)
{ {
const float delta_s0 = (end->_s0 * start->_s0 + end->_x1 * start->_x1) + (end->_x2 * start->_x2 + end->_x3 * start->_x3); const float delta_s0 = (end->_s0 * start->_s0 + end->_x1 * start->_x1) + (end->_x2 * start->_x2 + end->_x3 * start->_x3);
const float delta_x1 = (end->_x1 * start->_s0 + end->_x3 * start->_x2) - (end->_s0 * start->_x1 + end->_x2 * start->_x3); const float delta_x1 = (end->_x1 * start->_s0 + end->_x3 * start->_x2) - (end->_s0 * start->_x1 + end->_x2 * start->_x3);
@ -481,8 +481,8 @@ void bgc_versor_spherically_interpolate_fp32(const BgcVersorFP32* start, const B
const float square_vector = delta_x1 * delta_x1 + delta_x2 * delta_x2 + delta_x3 * delta_x3; const float square_vector = delta_x1 * delta_x1 + delta_x2 * delta_x2 + delta_x3 * delta_x3;
// square_vector != square_vector means checking for NaN value at square_vector // square_vector != square_vector means checking for NaN value at square_vector
if (square_vector <= BGC_SQUARE_EPSYLON_FP32 || square_vector != square_vector) { if (square_vector <= BGC_FP32_SQUARE_EPSYLON || square_vector != square_vector) {
bgc_versor_copy_fp32(end, result); bgc_fp32_versor_copy(end, result);
return; return;
} }
@ -497,7 +497,7 @@ void bgc_versor_spherically_interpolate_fp32(const BgcVersorFP32* start, const B
const float turn_x3 = delta_x3 * multiplier; const float turn_x3 = delta_x3 * multiplier;
// Combining of starting orientation with the turning // Combining of starting orientation with the turning
bgc_versor_set_values_fp32( bgc_fp32_versor_make(
(turn_s0 * start->_s0 - turn_x1 * start->_x1) - (turn_x2 * start->_x2 + turn_x3 * start->_x3), (turn_s0 * start->_s0 - turn_x1 * start->_x1) - (turn_x2 * start->_x2 + turn_x3 * start->_x3),
(turn_x1 * start->_s0 + turn_s0 * start->_x1) - (turn_x3 * start->_x2 - turn_x2 * start->_x3), (turn_x1 * start->_s0 + turn_s0 * start->_x1) - (turn_x3 * start->_x2 - turn_x2 * start->_x3),
(turn_x2 * start->_s0 + turn_s0 * start->_x2) - (turn_x1 * start->_x3 - turn_x3 * start->_x1), (turn_x2 * start->_s0 + turn_s0 * start->_x2) - (turn_x1 * start->_x3 - turn_x3 * start->_x1),
@ -506,7 +506,7 @@ void bgc_versor_spherically_interpolate_fp32(const BgcVersorFP32* start, const B
); );
} }
void bgc_versor_spherically_interpolate_fp64(const BgcVersorFP64* start, const BgcVersorFP64* end, const double phase, BgcVersorFP64* result) void bgc_fp64_versor_spherically_interpolate(const BGC_FP64_Versor* start, const BGC_FP64_Versor* end, const double phase, BGC_FP64_Versor* result)
{ {
const double delta_s0 = (end->_s0 * start->_s0 + end->_x1 * start->_x1) + (end->_x2 * start->_x2 + end->_x3 * start->_x3); const double delta_s0 = (end->_s0 * start->_s0 + end->_x1 * start->_x1) + (end->_x2 * start->_x2 + end->_x3 * start->_x3);
const double delta_x1 = (end->_x1 * start->_s0 + end->_x3 * start->_x2) - (end->_s0 * start->_x1 + end->_x2 * start->_x3); const double delta_x1 = (end->_x1 * start->_s0 + end->_x3 * start->_x2) - (end->_s0 * start->_x1 + end->_x2 * start->_x3);
@ -516,8 +516,8 @@ void bgc_versor_spherically_interpolate_fp64(const BgcVersorFP64* start, const B
const double square_vector = delta_x1 * delta_x1 + delta_x2 * delta_x2 + delta_x3 * delta_x3; const double square_vector = delta_x1 * delta_x1 + delta_x2 * delta_x2 + delta_x3 * delta_x3;
// square_vector != square_vector means checking for NaN value at square_vector // square_vector != square_vector means checking for NaN value at square_vector
if (square_vector <= BGC_SQUARE_EPSYLON_FP64 || square_vector != square_vector) { if (square_vector <= BGC_FP64_SQUARE_EPSYLON || square_vector != square_vector) {
bgc_versor_copy_fp64(end, result); bgc_fp64_versor_copy(end, result);
return; return;
} }
@ -532,7 +532,7 @@ void bgc_versor_spherically_interpolate_fp64(const BgcVersorFP64* start, const B
const double turn_x3 = delta_x3 * multiplier; const double turn_x3 = delta_x3 * multiplier;
// Combining of starting orientation with the turning // Combining of starting orientation with the turning
bgc_versor_set_values_fp64( bgc_fp64_versor_make(
(turn_s0 * start->_s0 - turn_x1 * start->_x1) - (turn_x2 * start->_x2 + turn_x3 * start->_x3), (turn_s0 * start->_s0 - turn_x1 * start->_x1) - (turn_x2 * start->_x2 + turn_x3 * start->_x3),
(turn_x1 * start->_s0 + turn_s0 * start->_x1) - (turn_x3 * start->_x2 - turn_x2 * start->_x3), (turn_x1 * start->_s0 + turn_s0 * start->_x1) - (turn_x3 * start->_x2 - turn_x2 * start->_x3),
(turn_x2 * start->_s0 + turn_s0 * start->_x2) - (turn_x1 * start->_x3 - turn_x3 * start->_x1), (turn_x2 * start->_s0 + turn_s0 * start->_x2) - (turn_x1 * start->_x3 - turn_x3 * start->_x1),
@ -543,12 +543,12 @@ void bgc_versor_spherically_interpolate_fp64(const BgcVersorFP64* start, const B
// ================ Get Rotation ================ // // ================ Get Rotation ================ //
void bgc_versor_get_rotation_fp32(const BgcVersorFP32* versor, BgcRotation3FP32* result) void bgc_fp32_versor_get_rotation(const BGC_FP32_Versor* versor, BGC_FP32_Rotation3* result)
{ {
const float square_modulus = versor->_x1 * versor->_x1 + versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3; const float square_modulus = versor->_x1 * versor->_x1 + versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3;
if (square_modulus <= BGC_SQUARE_EPSYLON_FP32) { if (square_modulus <= BGC_FP32_SQUARE_EPSYLON) {
bgc_rotation3_reset_fp32(result); bgc_fp32_rotation3_reset(result);
return; return;
} }
@ -563,12 +563,12 @@ void bgc_versor_get_rotation_fp32(const BgcVersorFP32* versor, BgcRotation3FP32*
result->axis.x3 = versor->_x3 * multiplier; result->axis.x3 = versor->_x3 * multiplier;
} }
void bgc_versor_get_rotation_fp64(const BgcVersorFP64* versor, BgcRotation3FP64* result) void bgc_fp64_versor_get_rotation(const BGC_FP64_Versor* versor, BGC_FP64_Rotation3* result)
{ {
const double square_modulus = versor->_x1 * versor->_x1 + versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3; const double square_modulus = versor->_x1 * versor->_x1 + versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3;
if (square_modulus <= BGC_SQUARE_EPSYLON_FP64) { if (square_modulus <= BGC_FP64_SQUARE_EPSYLON) {
bgc_rotation3_reset_fp64(result); bgc_fp64_rotation3_reset(result);
return; return;
} }

View file

@ -27,20 +27,20 @@
typedef struct { typedef struct {
float _s0, _x1, _x2, _x3; float _s0, _x1, _x2, _x3;
} BgcVersorFP32; } BGC_FP32_Versor;
typedef struct { typedef struct {
double _s0, _x1, _x2, _x3; double _s0, _x1, _x2, _x3;
} BgcVersorFP64; } BGC_FP64_Versor;
// ================= Constants ================== // // ================= Constants ================== //
extern const BgcVersorFP32 BGC_IDLE_VERSOR_FP32; extern const BGC_FP32_Versor BGC_FP32_IDLE_VERSOR;
extern const BgcVersorFP64 BGC_IDLE_VERSOR_FP64; extern const BGC_FP64_Versor BGC_FP64_IDLE_VERSOR;
// =================== Reset ==================== // // =================== Reset ==================== //
inline void bgc_versor_reset_fp32(BgcVersorFP32* versor) inline void bgc_fp32_versor_reset(BGC_FP32_Versor* versor)
{ {
versor->_s0 = 1.0f; versor->_s0 = 1.0f;
versor->_x1 = 0.0f; versor->_x1 = 0.0f;
@ -48,7 +48,7 @@ inline void bgc_versor_reset_fp32(BgcVersorFP32* versor)
versor->_x3 = 0.0f; versor->_x3 = 0.0f;
} }
inline void bgc_versor_reset_fp64(BgcVersorFP64* versor) inline void bgc_fp64_versor_reset(BGC_FP64_Versor* versor)
{ {
versor->_s0 = 1.0; versor->_s0 = 1.0;
versor->_x1 = 0.0; versor->_x1 = 0.0;
@ -58,11 +58,11 @@ inline void bgc_versor_reset_fp64(BgcVersorFP64* versor)
// ==================== Set ===================== // // ==================== Set ===================== //
void _bgc_versor_normalize_fp32(const float square_modulus, BgcVersorFP32* twin); void _bgc_fp32_versor_normalize(BGC_FP32_Versor* twin);
void _bgc_versor_normalize_fp64(const double square_modulus, BgcVersorFP64* twin); void _bgc_fp64_versor_normalize(BGC_FP64_Versor* twin);
inline void bgc_versor_set_values_fp32(const float s0, const float x1, const float x2, const float x3, BgcVersorFP32* versor) inline void bgc_fp32_versor_make(const float s0, const float x1, const float x2, const float x3, BGC_FP32_Versor* versor)
{ {
versor->_s0 = s0; versor->_s0 = s0;
versor->_x1 = x1; versor->_x1 = x1;
@ -71,12 +71,12 @@ inline void bgc_versor_set_values_fp32(const float s0, const float x1, const flo
const float square_modulus = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3); const float square_modulus = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
if (!bgc_is_sqare_unit_fp32(square_modulus)) { if (!bgc_fp32_is_square_unit(square_modulus)) {
_bgc_versor_normalize_fp32(square_modulus, versor); _bgc_fp32_versor_normalize(versor);
} }
} }
inline void bgc_versor_set_values_fp64(const double s0, const double x1, const double x2, const double x3, BgcVersorFP64* versor) inline void bgc_fp64_versor_make(const double s0, const double x1, const double x2, const double x3, BGC_FP64_Versor* versor)
{ {
versor->_s0 = s0; versor->_s0 = s0;
versor->_x1 = x1; versor->_x1 = x1;
@ -85,56 +85,56 @@ inline void bgc_versor_set_values_fp64(const double s0, const double x1, const d
const double square_modulus = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3); const double square_modulus = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3);
if (!bgc_is_sqare_unit_fp64(square_modulus)) { if (!bgc_fp64_is_square_unit(square_modulus)) {
_bgc_versor_normalize_fp64(square_modulus, versor); _bgc_fp64_versor_normalize(versor);
} }
} }
// ================== Set Turn ================== // // ================== Set Turn ================== //
void bgc_versor_set_turn_fp32(const float x1, const float x2, const float x3, const float angle, const BgcAngleUnitEnum unit, BgcVersorFP32* result); void bgc_fp32_versor_make_for_turn(const float x1, const float x2, const float x3, const float angle, const int unit, BGC_FP32_Versor* result);
void bgc_versor_set_turn_fp64(const double x1, const double x2, const double x3, const double angle, const BgcAngleUnitEnum unit, BgcVersorFP64* result); void bgc_fp64_versor_make_for_turn(const double x1, const double x2, const double x3, const double angle, const int unit, BGC_FP64_Versor* result);
// ================ Set Rotation ================ // // ================ Set Rotation ================ //
inline void bgc_versor_set_rotation_fp32(const BgcRotation3FP32* rotation, BgcVersorFP32* result) inline void bgc_fp32_versor_make_for_rotation(const BGC_FP32_Rotation3* rotation, BGC_FP32_Versor* result)
{ {
bgc_versor_set_turn_fp32(rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BGC_ANGLE_UNIT_RADIANS, result); bgc_fp32_versor_make_for_turn(rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BGC_ANGLE_UNIT_RADIANS, result);
} }
inline void bgc_versor_set_rotation_fp64(const BgcRotation3FP64* rotation, BgcVersorFP64* result) inline void bgc_fp64_versor_make_for_rotation(const BGC_FP64_Rotation3* rotation, BGC_FP64_Versor* result)
{ {
bgc_versor_set_turn_fp64(rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BGC_ANGLE_UNIT_RADIANS, result); bgc_fp64_versor_make_for_turn(rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BGC_ANGLE_UNIT_RADIANS, result);
} }
// ========= Make Direction Difference ========== // // ========= Make Direction Difference ========== //
int bgc_versor_make_direction_difference_fp32(const BgcVector3FP32* start, const BgcVector3FP32* end, BgcVersorFP32* result); int bgc_fp32_versor_make_direction_difference(const BGC_FP32_Vector3* start, const BGC_FP32_Vector3* end, BGC_FP32_Versor* result);
int bgc_versor_make_direction_difference_fp64(const BgcVector3FP64* start, const BgcVector3FP64* end, BgcVersorFP64* result); int bgc_fp64_versor_make_direction_difference(const BGC_FP64_Vector3* start, const BGC_FP64_Vector3* end, BGC_FP64_Versor* result);
// =============== Set Directions =============== // // =============== Set Directions =============== //
int bgc_versor_make_basis_difference_fp32( int bgc_fp32_versor_make_basis_difference(
const BgcVector3FP32* initial_primary_direction, const BGC_FP32_Vector3* initial_primary_direction,
const BgcVector3FP32* initial_auxiliary_direction, const BGC_FP32_Vector3* initial_auxiliary_direction,
const BgcVector3FP32* final_primary_direction, const BGC_FP32_Vector3* final_primary_direction,
const BgcVector3FP32* final_auxiliary_direction, const BGC_FP32_Vector3* final_auxiliary_direction,
BgcVersorFP32* result BGC_FP32_Versor* result
); );
int bgc_versor_make_basis_difference_fp64( int bgc_fp64_versor_make_basis_difference(
const BgcVector3FP64* initial_primary_direction, const BGC_FP64_Vector3* initial_primary_direction,
const BgcVector3FP64* initial_auxiliary_direction, const BGC_FP64_Vector3* initial_auxiliary_direction,
const BgcVector3FP64* final_primary_direction, const BGC_FP64_Vector3* final_primary_direction,
const BgcVector3FP64* final_auxiliary_direction, const BGC_FP64_Vector3* final_auxiliary_direction,
BgcVersorFP64* result BGC_FP64_Versor* result
); );
// ==================== Copy ==================== // // ==================== Copy ==================== //
inline void bgc_versor_copy_fp32(const BgcVersorFP32* source, BgcVersorFP32* destination) inline void bgc_fp32_versor_copy(const BGC_FP32_Versor* source, BGC_FP32_Versor* destination)
{ {
destination->_s0 = source->_s0; destination->_s0 = source->_s0;
destination->_x1 = source->_x1; destination->_x1 = source->_x1;
@ -142,7 +142,7 @@ inline void bgc_versor_copy_fp32(const BgcVersorFP32* source, BgcVersorFP32* des
destination->_x3 = source->_x3; destination->_x3 = source->_x3;
} }
inline void bgc_versor_copy_fp64(const BgcVersorFP64* source, BgcVersorFP64* destination) inline void bgc_fp64_versor_copy(const BGC_FP64_Versor* source, BGC_FP64_Versor* destination)
{ {
destination->_s0 = source->_s0; destination->_s0 = source->_s0;
destination->_x1 = source->_x1; destination->_x1 = source->_x1;
@ -152,7 +152,7 @@ inline void bgc_versor_copy_fp64(const BgcVersorFP64* source, BgcVersorFP64* des
// ==================== Swap ==================== // // ==================== Swap ==================== //
inline void bgc_versor_swap_fp32(BgcVersorFP32* versor1, BgcVersorFP32* versor2) inline void bgc_fp32_versor_swap(BGC_FP32_Versor* versor1, BGC_FP32_Versor* versor2)
{ {
const float s0 = versor1->_s0; const float s0 = versor1->_s0;
const float x1 = versor1->_x1; const float x1 = versor1->_x1;
@ -170,7 +170,7 @@ inline void bgc_versor_swap_fp32(BgcVersorFP32* versor1, BgcVersorFP32* versor2)
versor2->_x3 = x3; versor2->_x3 = x3;
} }
inline void bgc_versor_swap_fp64(BgcVersorFP64* versor1, BgcVersorFP64* versor2) inline void bgc_fp64_versor_swap(BGC_FP64_Versor* versor1, BGC_FP64_Versor* versor2)
{ {
const double s0 = versor1->_s0; const double s0 = versor1->_s0;
const double x1 = versor1->_x1; const double x1 = versor1->_x1;
@ -190,21 +190,21 @@ inline void bgc_versor_swap_fp64(BgcVersorFP64* versor1, BgcVersorFP64* versor2)
// ================= Comparison ================= // // ================= Comparison ================= //
inline int bgc_versor_is_identity_fp32(const BgcVersorFP32* versor) inline int bgc_fp32_versor_is_idle(const BGC_FP32_Versor* versor)
{ {
return versor->_x1 * versor->_x1 + versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3 <= BGC_SQUARE_EPSYLON_FP32; return versor->_x1 * versor->_x1 + versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3 <= BGC_FP32_SQUARE_EPSYLON;
} }
inline int bgc_versor_is_identity_fp64(const BgcVersorFP64* versor) inline int bgc_fp64_versor_is_idle(const BGC_FP64_Versor* versor)
{ {
return versor->_x1 * versor->_x1 + versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3 <= BGC_SQUARE_EPSYLON_FP64; return versor->_x1 * versor->_x1 + versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3 <= BGC_FP64_SQUARE_EPSYLON;
} }
// ================== Convert =================== // // ================== Convert =================== //
inline void bgc_versor_convert_fp64_to_fp32(const BgcVersorFP64* source, BgcVersorFP32* destination) inline void bgc_fp64_versor_convert_to_fp32(const BGC_FP64_Versor* source, BGC_FP32_Versor* destination)
{ {
bgc_versor_set_values_fp32( bgc_fp32_versor_make(
(float)source->_s0, (float)source->_s0,
(float)source->_x1, (float)source->_x1,
(float)source->_x2, (float)source->_x2,
@ -213,9 +213,9 @@ inline void bgc_versor_convert_fp64_to_fp32(const BgcVersorFP64* source, BgcVers
); );
} }
inline void bgc_versor_convert_fp32_to_fp64(const BgcVersorFP32* source, BgcVersorFP64* destination) inline void bgc_fp32_versor_convert_to_fp64(const BGC_FP32_Versor* source, BGC_FP64_Versor* destination)
{ {
bgc_versor_set_values_fp64( bgc_fp64_versor_make(
source->_s0, source->_s0,
source->_x1, source->_x1,
source->_x2, source->_x2,
@ -226,7 +226,7 @@ inline void bgc_versor_convert_fp32_to_fp64(const BgcVersorFP32* source, BgcVers
// ================== Shorten =================== // // ================== Shorten =================== //
inline void bgc_versor_shorten_fp32(BgcVersorFP32* versor) inline void bgc_fp32_versor_shorten(BGC_FP32_Versor* versor)
{ {
if (versor->_s0 < 0.0f) { if (versor->_s0 < 0.0f) {
versor->_s0 = -versor->_s0; versor->_s0 = -versor->_s0;
@ -236,7 +236,7 @@ inline void bgc_versor_shorten_fp32(BgcVersorFP32* versor)
} }
} }
inline void bgc_versor_shorten_fp64(BgcVersorFP64* versor) inline void bgc_fp64_versor_shorten(BGC_FP64_Versor* versor)
{ {
if (versor->_s0 < 0.0) { if (versor->_s0 < 0.0) {
versor->_s0 = -versor->_s0; versor->_s0 = -versor->_s0;
@ -246,7 +246,7 @@ inline void bgc_versor_shorten_fp64(BgcVersorFP64* versor)
} }
} }
inline void bgc_versor_get_shortened_fp32(const BgcVersorFP32* versor, BgcVersorFP32* shortened) inline void bgc_fp32_versor_get_shortened(const BGC_FP32_Versor* versor, BGC_FP32_Versor* shortened)
{ {
if (versor->_s0 >= 0.0f) { if (versor->_s0 >= 0.0f) {
shortened->_s0 = versor->_s0; shortened->_s0 = versor->_s0;
@ -262,7 +262,7 @@ inline void bgc_versor_get_shortened_fp32(const BgcVersorFP32* versor, BgcVersor
shortened->_x3 = -versor->_x3; shortened->_x3 = -versor->_x3;
} }
inline void bgc_versor_get_shortened_fp64(const BgcVersorFP64* versor, BgcVersorFP64* shortened) inline void bgc_fp64_versor_get_shortened(const BGC_FP64_Versor* versor, BGC_FP64_Versor* shortened)
{ {
if (versor->_s0 >= 0.0) { if (versor->_s0 >= 0.0) {
shortened->_s0 = versor->_s0; shortened->_s0 = versor->_s0;
@ -280,7 +280,7 @@ inline void bgc_versor_get_shortened_fp64(const BgcVersorFP64* versor, BgcVersor
// ================== Negative ================== // // ================== Negative ================== //
inline void bgc_versor_make_opposite_fp32(BgcVersorFP32* versor) inline void bgc_fp32_versor_alternate(BGC_FP32_Versor* versor)
{ {
versor->_s0 = -versor->_s0; versor->_s0 = -versor->_s0;
versor->_x1 = -versor->_x1; versor->_x1 = -versor->_x1;
@ -288,7 +288,7 @@ inline void bgc_versor_make_opposite_fp32(BgcVersorFP32* versor)
versor->_x3 = -versor->_x3; versor->_x3 = -versor->_x3;
} }
inline void bgc_versor_make_opposite_fp64(BgcVersorFP64* versor) inline void bgc_fp64_versor_alternate(BGC_FP64_Versor* versor)
{ {
versor->_s0 = -versor->_s0; versor->_s0 = -versor->_s0;
versor->_x1 = -versor->_x1; versor->_x1 = -versor->_x1;
@ -296,7 +296,7 @@ inline void bgc_versor_make_opposite_fp64(BgcVersorFP64* versor)
versor->_x3 = -versor->_x3; versor->_x3 = -versor->_x3;
} }
inline void bgc_versor_get_opposite_fp32(const BgcVersorFP32* versor, BgcVersorFP32* opposite) inline void bgc_fp32_versor_get_alternative(const BGC_FP32_Versor* versor, BGC_FP32_Versor* opposite)
{ {
opposite->_s0 = -versor->_s0; opposite->_s0 = -versor->_s0;
opposite->_x1 = -versor->_x1; opposite->_x1 = -versor->_x1;
@ -304,7 +304,7 @@ inline void bgc_versor_get_opposite_fp32(const BgcVersorFP32* versor, BgcVersorF
opposite->_x3 = -versor->_x3; opposite->_x3 = -versor->_x3;
} }
inline void bgc_versor_get_opposite_fp64(const BgcVersorFP64* versor, BgcVersorFP64* opposite) inline void bgc_fp64_versor_get_alternative(const BGC_FP64_Versor* versor, BGC_FP64_Versor* opposite)
{ {
opposite->_s0 = -versor->_s0; opposite->_s0 = -versor->_s0;
opposite->_x1 = -versor->_x1; opposite->_x1 = -versor->_x1;
@ -314,21 +314,21 @@ inline void bgc_versor_get_opposite_fp64(const BgcVersorFP64* versor, BgcVersorF
// =================== Invert =================== // // =================== Invert =================== //
inline void bgc_versor_invert_fp32(BgcVersorFP32* versor) inline void bgc_fp32_versor_revert(BGC_FP32_Versor* versor)
{ {
versor->_x1 = -versor->_x1; versor->_x1 = -versor->_x1;
versor->_x2 = -versor->_x2; versor->_x2 = -versor->_x2;
versor->_x3 = -versor->_x3; versor->_x3 = -versor->_x3;
} }
inline void bgc_versor_invert_fp64(BgcVersorFP64* versor) inline void bgc_fp64_versor_revert(BGC_FP64_Versor* versor)
{ {
versor->_x1 = -versor->_x1; versor->_x1 = -versor->_x1;
versor->_x2 = -versor->_x2; versor->_x2 = -versor->_x2;
versor->_x3 = -versor->_x3; versor->_x3 = -versor->_x3;
} }
inline void bgc_versor_get_inverse_fp32(const BgcVersorFP32* versor, BgcVersorFP32* inverse) inline void bgc_fp32_versor_get_reverse(const BGC_FP32_Versor* versor, BGC_FP32_Versor* inverse)
{ {
inverse->_s0 = versor->_s0; inverse->_s0 = versor->_s0;
inverse->_x1 = -versor->_x1; inverse->_x1 = -versor->_x1;
@ -336,7 +336,7 @@ inline void bgc_versor_get_inverse_fp32(const BgcVersorFP32* versor, BgcVersorFP
inverse->_x3 = -versor->_x3; inverse->_x3 = -versor->_x3;
} }
inline void bgc_versor_get_inverse_fp64(const BgcVersorFP64* versor, BgcVersorFP64* inverse) inline void bgc_fp64_versor_get_reverse(const BGC_FP64_Versor* versor, BGC_FP64_Versor* inverse)
{ {
inverse->_s0 = versor->_s0; inverse->_s0 = versor->_s0;
inverse->_x1 = -versor->_x1; inverse->_x1 = -versor->_x1;
@ -346,15 +346,15 @@ inline void bgc_versor_get_inverse_fp64(const BgcVersorFP64* versor, BgcVersorFP
// =============== Get Exponation =============== // // =============== Get Exponation =============== //
void bgc_versor_get_exponation_fp32(const BgcVersorFP32* base, const float exponent, BgcVersorFP32* power); void bgc_fp32_versor_get_exponation(const BGC_FP32_Versor* base, const float exponent, BGC_FP32_Versor* power);
void bgc_versor_get_exponation_fp64(const BgcVersorFP64* base, const double exponent, BgcVersorFP64* power); void bgc_fp64_versor_get_exponation(const BGC_FP64_Versor* base, const double exponent, BGC_FP64_Versor* power);
// ================ Combination ================= // // ================ Combination ================= //
inline void bgc_versor_combine_fp32(const BgcVersorFP32* first, const BgcVersorFP32* second, BgcVersorFP32* result) inline void bgc_fp32_versor_combine(const BGC_FP32_Versor* first, const BGC_FP32_Versor* second, BGC_FP32_Versor* result)
{ {
bgc_versor_set_values_fp32( bgc_fp32_versor_make(
(second->_s0 * first->_s0 - second->_x1 * first->_x1) - (second->_x2 * first->_x2 + second->_x3 * first->_x3), (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->_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->_x2 * first->_s0 + second->_s0 * first->_x2) - (second->_x1 * first->_x3 - second->_x3 * first->_x1),
@ -363,9 +363,9 @@ inline void bgc_versor_combine_fp32(const BgcVersorFP32* first, const BgcVersorF
); );
} }
inline void bgc_versor_combine_fp64(const BgcVersorFP64* first, const BgcVersorFP64* second, BgcVersorFP64* result) inline void bgc_fp64_versor_combine(const BGC_FP64_Versor* first, const BGC_FP64_Versor* second, BGC_FP64_Versor* result)
{ {
bgc_versor_set_values_fp64( bgc_fp64_versor_make(
(second->_s0 * first->_s0 - second->_x1 * first->_x1) - (second->_x2 * first->_x2 + second->_x3 * first->_x3), (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->_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->_x2 * first->_s0 + second->_s0 * first->_x2) - (second->_x1 * first->_x3 - second->_x3 * first->_x1),
@ -376,14 +376,14 @@ inline void bgc_versor_combine_fp64(const BgcVersorFP64* first, const BgcVersorF
// ============ Combination of three ============ // // ============ Combination of three ============ //
inline void bgc_versor_combine3_fp32(const BgcVersorFP32* first, const BgcVersorFP32* second, const BgcVersorFP32* third, BgcVersorFP32* result) inline void bgc_fp32_versor_combine3(const BGC_FP32_Versor* first, const BGC_FP32_Versor* second, const BGC_FP32_Versor* third, BGC_FP32_Versor* result)
{ {
const float s0 = (second->_s0 * first->_s0 - second->_x1 * first->_x1) - (second->_x2 * first->_x2 + second->_x3 * first->_x3); const float s0 = (second->_s0 * first->_s0 - second->_x1 * first->_x1) - (second->_x2 * first->_x2 + second->_x3 * first->_x3);
const float x1 = (second->_x1 * first->_s0 + second->_s0 * first->_x1) - (second->_x3 * first->_x2 - second->_x2 * first->_x3); const float x1 = (second->_x1 * first->_s0 + second->_s0 * first->_x1) - (second->_x3 * first->_x2 - second->_x2 * first->_x3);
const float x2 = (second->_x2 * first->_s0 + second->_s0 * first->_x2) - (second->_x1 * first->_x3 - second->_x3 * first->_x1); const float x2 = (second->_x2 * first->_s0 + second->_s0 * first->_x2) - (second->_x1 * first->_x3 - second->_x3 * first->_x1);
const float x3 = (second->_x3 * first->_s0 + second->_s0 * first->_x3) - (second->_x2 * first->_x1 - second->_x1 * first->_x2); const float x3 = (second->_x3 * first->_s0 + second->_s0 * first->_x3) - (second->_x2 * first->_x1 - second->_x1 * first->_x2);
bgc_versor_set_values_fp32( bgc_fp32_versor_make(
(third->_s0 * s0 - third->_x1 * x1) - (third->_x2 * x2 + third->_x3 * x3), (third->_s0 * s0 - third->_x1 * x1) - (third->_x2 * x2 + third->_x3 * x3),
(third->_x1 * s0 + third->_s0 * x1) - (third->_x3 * x2 - third->_x2 * x3), (third->_x1 * s0 + third->_s0 * x1) - (third->_x3 * x2 - third->_x2 * x3),
(third->_x2 * s0 + third->_s0 * x2) - (third->_x1 * x3 - third->_x3 * x1), (third->_x2 * s0 + third->_s0 * x2) - (third->_x1 * x3 - third->_x3 * x1),
@ -392,14 +392,14 @@ inline void bgc_versor_combine3_fp32(const BgcVersorFP32* first, const BgcVersor
); );
} }
inline void bgc_versor_combine3_fp64(const BgcVersorFP64* first, const BgcVersorFP64* second, const BgcVersorFP64* third, BgcVersorFP64* result) inline void bgc_fp64_versor_combine3(const BGC_FP64_Versor* first, const BGC_FP64_Versor* second, const BGC_FP64_Versor* third, BGC_FP64_Versor* result)
{ {
const double s0 = (second->_s0 * first->_s0 - second->_x1 * first->_x1) - (second->_x2 * first->_x2 + second->_x3 * first->_x3); const double s0 = (second->_s0 * first->_s0 - second->_x1 * first->_x1) - (second->_x2 * first->_x2 + second->_x3 * first->_x3);
const double x1 = (second->_x1 * first->_s0 + second->_s0 * first->_x1) - (second->_x3 * first->_x2 - second->_x2 * first->_x3); const double x1 = (second->_x1 * first->_s0 + second->_s0 * first->_x1) - (second->_x3 * first->_x2 - second->_x2 * first->_x3);
const double x2 = (second->_x2 * first->_s0 + second->_s0 * first->_x2) - (second->_x1 * first->_x3 - second->_x3 * first->_x1); const double x2 = (second->_x2 * first->_s0 + second->_s0 * first->_x2) - (second->_x1 * first->_x3 - second->_x3 * first->_x1);
const double x3 = (second->_x3 * first->_s0 + second->_s0 * first->_x3) - (second->_x2 * first->_x1 - second->_x1 * first->_x2); const double x3 = (second->_x3 * first->_s0 + second->_s0 * first->_x3) - (second->_x2 * first->_x1 - second->_x1 * first->_x2);
bgc_versor_set_values_fp64( bgc_fp64_versor_make(
(third->_s0 * s0 - third->_x1 * x1) - (third->_x2 * x2 + third->_x3 * x3), (third->_s0 * s0 - third->_x1 * x1) - (third->_x2 * x2 + third->_x3 * x3),
(third->_x1 * s0 + third->_s0 * x1) - (third->_x3 * x2 - third->_x2 * x3), (third->_x1 * s0 + third->_s0 * x1) - (third->_x3 * x2 - third->_x2 * x3),
(third->_x2 * s0 + third->_s0 * x2) - (third->_x1 * x3 - third->_x3 * x1), (third->_x2 * s0 + third->_s0 * x2) - (third->_x1 * x3 - third->_x3 * x1),
@ -410,9 +410,9 @@ inline void bgc_versor_combine3_fp64(const BgcVersorFP64* first, const BgcVersor
// ================= Exclusion ================== // // ================= Exclusion ================== //
inline void bgc_versor_exclude_fp32(const BgcVersorFP32* base, const BgcVersorFP32* excludant, BgcVersorFP32* difference) inline void bgc_fp32_versor_exclude(const BGC_FP32_Versor* base, const BGC_FP32_Versor* excludant, BGC_FP32_Versor* difference)
{ {
bgc_versor_set_values_fp32( bgc_fp32_versor_make(
(base->_s0 * excludant->_s0 + base->_x1 * excludant->_x1) + (base->_x2 * excludant->_x2 + base->_x3 * excludant->_x3), (base->_s0 * excludant->_s0 + base->_x1 * excludant->_x1) + (base->_x2 * excludant->_x2 + base->_x3 * excludant->_x3),
(base->_x1 * excludant->_s0 + base->_x3 * excludant->_x2) - (base->_s0 * excludant->_x1 + base->_x2 * excludant->_x3), (base->_x1 * excludant->_s0 + base->_x3 * excludant->_x2) - (base->_s0 * excludant->_x1 + base->_x2 * excludant->_x3),
(base->_x2 * excludant->_s0 + base->_x1 * excludant->_x3) - (base->_s0 * excludant->_x2 + base->_x3 * excludant->_x1), (base->_x2 * excludant->_s0 + base->_x1 * excludant->_x3) - (base->_s0 * excludant->_x2 + base->_x3 * excludant->_x1),
@ -421,9 +421,9 @@ inline void bgc_versor_exclude_fp32(const BgcVersorFP32* base, const BgcVersorFP
); );
} }
inline void bgc_versor_exclude_fp64(const BgcVersorFP64* base, const BgcVersorFP64* excludant, BgcVersorFP64* difference) inline void bgc_fp64_versor_exclude(const BGC_FP64_Versor* base, const BGC_FP64_Versor* excludant, BGC_FP64_Versor* difference)
{ {
bgc_versor_set_values_fp64( bgc_fp64_versor_make(
(base->_s0 * excludant->_s0 + base->_x1 * excludant->_x1) + (base->_x2 * excludant->_x2 + base->_x3 * excludant->_x3), (base->_s0 * excludant->_s0 + base->_x1 * excludant->_x1) + (base->_x2 * excludant->_x2 + base->_x3 * excludant->_x3),
(base->_x1 * excludant->_s0 + base->_x3 * excludant->_x2) - (base->_s0 * excludant->_x1 + base->_x2 * excludant->_x3), (base->_x1 * excludant->_s0 + base->_x3 * excludant->_x2) - (base->_s0 * excludant->_x1 + base->_x2 * excludant->_x3),
(base->_x2 * excludant->_s0 + base->_x1 * excludant->_x3) - (base->_s0 * excludant->_x2 + base->_x3 * excludant->_x1), (base->_x2 * excludant->_s0 + base->_x1 * excludant->_x3) - (base->_s0 * excludant->_x2 + base->_x3 * excludant->_x1),
@ -434,19 +434,19 @@ inline void bgc_versor_exclude_fp64(const BgcVersorFP64* base, const BgcVersorFP
// ============ Sphere Interpolation ============ // // ============ Sphere Interpolation ============ //
void bgc_versor_spherically_interpolate_fp32(const BgcVersorFP32* start, const BgcVersorFP32* end, const float phase, BgcVersorFP32* result); void bgc_fp32_versor_spherically_interpolate(const BGC_FP32_Versor* start, const BGC_FP32_Versor* end, const float phase, BGC_FP32_Versor* result);
void bgc_versor_spherically_interpolate_fp64(const BgcVersorFP64* start, const BgcVersorFP64* end, const double phase, BgcVersorFP64* result); void bgc_fp64_versor_spherically_interpolate(const BGC_FP64_Versor* start, const BGC_FP64_Versor* end, const double phase, BGC_FP64_Versor* result);
// ================ Get Rotation ================ // // ================ Get Rotation ================ //
void bgc_versor_get_rotation_fp32(const BgcVersorFP32* versor, BgcRotation3FP32* result); void bgc_fp32_versor_get_rotation(const BGC_FP32_Versor* versor, BGC_FP32_Rotation3* result);
void bgc_versor_get_rotation_fp64(const BgcVersorFP64* versor, BgcRotation3FP64* result); void bgc_fp64_versor_get_rotation(const BGC_FP64_Versor* versor, BGC_FP64_Rotation3* result);
// ============ Get Rotation Matrix ============= // // ============ Get Rotation Matrix ============= //
inline void bgc_versor_get_rotation_matrix_fp32(const BgcVersorFP32* versor, BgcMatrix3x3FP32* matrix) inline void bgc_fp32_versor_get_rotation_matrix(const BGC_FP32_Versor* versor, BGC_FP32_Matrix3x3* matrix)
{ {
const float s0s0 = versor->_s0 * versor->_s0; const float s0s0 = versor->_s0 * versor->_s0;
const float x1x1 = versor->_x1 * versor->_x1; const float x1x1 = versor->_x1 * versor->_x1;
@ -473,7 +473,7 @@ inline void bgc_versor_get_rotation_matrix_fp32(const BgcVersorFP32* versor, Bgc
matrix->r1c3 = 2.0f * (x1x3 + s0x2); matrix->r1c3 = 2.0f * (x1x3 + s0x2);
} }
inline void bgc_versor_get_rotation_matrix_fp64(const BgcVersorFP64* versor, BgcMatrix3x3FP64* matrix) inline void bgc_fp64_versor_get_rotation_matrix(const BGC_FP64_Versor* versor, BGC_FP64_Matrix3x3* matrix)
{ {
const double s0s0 = versor->_s0 * versor->_s0; const double s0s0 = versor->_s0 * versor->_s0;
const double x1x1 = versor->_x1 * versor->_x1; const double x1x1 = versor->_x1 * versor->_x1;
@ -502,7 +502,7 @@ inline void bgc_versor_get_rotation_matrix_fp64(const BgcVersorFP64* versor, Bgc
// ============= Get Reverse Matrix ============= // // ============= Get Reverse Matrix ============= //
inline void bgc_versor_get_reverse_matrix_fp32(const BgcVersorFP32* versor, BgcMatrix3x3FP32* matrix) inline void bgc_fp32_versor_get_reverse_matrix(const BGC_FP32_Versor* versor, BGC_FP32_Matrix3x3* matrix)
{ {
const float s0s0 = versor->_s0 * versor->_s0; const float s0s0 = versor->_s0 * versor->_s0;
const float x1x1 = versor->_x1 * versor->_x1; const float x1x1 = versor->_x1 * versor->_x1;
@ -529,7 +529,7 @@ inline void bgc_versor_get_reverse_matrix_fp32(const BgcVersorFP32* versor, BgcM
matrix->r1c3 = 2.0f * (x1x3 - s0x2); matrix->r1c3 = 2.0f * (x1x3 - s0x2);
} }
inline void bgc_versor_get_reverse_matrix_fp64(const BgcVersorFP64* versor, BgcMatrix3x3FP64* matrix) inline void bgc_fp64_versor_get_reverse_matrix(const BGC_FP64_Versor* versor, BGC_FP64_Matrix3x3* matrix)
{ {
const double s0s0 = versor->_s0 * versor->_s0; const double s0s0 = versor->_s0 * versor->_s0;
const double x1x1 = versor->_x1 * versor->_x1; const double x1x1 = versor->_x1 * versor->_x1;
@ -558,21 +558,21 @@ inline void bgc_versor_get_reverse_matrix_fp64(const BgcVersorFP64* versor, BgcM
// ============= Get Both Matrixes ============== // // ============= Get Both Matrixes ============== //
inline void bgc_versor_get_both_matrices_fp32(const BgcVersorFP32* versor, BgcMatrix3x3FP32* rotation, BgcMatrix3x3FP32* reverse) inline void bgc_fp32_versor_get_both_matrices(const BGC_FP32_Versor* versor, BGC_FP32_Matrix3x3* rotation, BGC_FP32_Matrix3x3* reverse)
{ {
bgc_versor_get_reverse_matrix_fp32(versor, reverse); bgc_fp32_versor_get_reverse_matrix(versor, reverse);
bgc_matrix3x3_transpose_fp32(reverse, rotation); bgc_fp32_matrix3x3_get_transposed(reverse, rotation);
} }
inline void bgc_versor_get_both_matrices_fp64(const BgcVersorFP64* versor, BgcMatrix3x3FP64* rotation, BgcMatrix3x3FP64* reverse) inline void bgc_fp64_versor_get_both_matrices(const BGC_FP64_Versor* versor, BGC_FP64_Matrix3x3* rotation, BGC_FP64_Matrix3x3* reverse)
{ {
bgc_versor_get_reverse_matrix_fp64(versor, reverse); bgc_fp64_versor_get_reverse_matrix(versor, reverse);
bgc_matrix3x3_transpose_fp64(reverse, rotation); bgc_fp64_matrix3x3_get_transposed(reverse, rotation);
} }
// ================ Turn Vector ================= // // ================ Turn Vector ================= //
inline void bgc_versor_turn_vector_fp32(const BgcVersorFP32* versor, const BgcVector3FP32* vector, BgcVector3FP32* result) inline void bgc_fp32_versor_turn_vector(const BGC_FP32_Versor* versor, const BGC_FP32_Vector3* vector, BGC_FP32_Vector3* result)
{ {
const float tx1 = 2.0f * (versor->_x2 * vector->x3 - versor->_x3 * vector->x2); const float tx1 = 2.0f * (versor->_x2 * vector->x3 - versor->_x3 * vector->x2);
const float tx2 = 2.0f * (versor->_x3 * vector->x1 - versor->_x1 * vector->x3); const float tx2 = 2.0f * (versor->_x3 * vector->x1 - versor->_x1 * vector->x3);
@ -587,7 +587,7 @@ inline void bgc_versor_turn_vector_fp32(const BgcVersorFP32* versor, const BgcVe
result->x3 = x3; result->x3 = x3;
} }
inline void bgc_versor_turn_vector_fp64(const BgcVersorFP64* versor, const BgcVector3FP64* vector, BgcVector3FP64* result) inline void bgc_fp64_versor_turn_vector(const BGC_FP64_Versor* versor, const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* result)
{ {
const double tx1 = 2.0 * (versor->_x2 * vector->x3 - versor->_x3 * vector->x2); const double tx1 = 2.0 * (versor->_x2 * vector->x3 - versor->_x3 * vector->x2);
const double tx2 = 2.0 * (versor->_x3 * vector->x1 - versor->_x1 * vector->x3); const double tx2 = 2.0 * (versor->_x3 * vector->x1 - versor->_x1 * vector->x3);
@ -604,7 +604,7 @@ inline void bgc_versor_turn_vector_fp64(const BgcVersorFP64* versor, const BgcVe
// ============== Turn Vector Back ============== // // ============== Turn Vector Back ============== //
inline void bgc_versor_turn_vector_back_fp32(const BgcVersorFP32* versor, const BgcVector3FP32* vector, BgcVector3FP32* result) inline void bgc_fp32_versor_turn_vector_back(const BGC_FP32_Versor* versor, const BGC_FP32_Vector3* vector, BGC_FP32_Vector3* result)
{ {
const float tx1 = 2.0f * (versor->_x2 * vector->x3 - versor->_x3 * vector->x2); const float tx1 = 2.0f * (versor->_x2 * vector->x3 - versor->_x3 * vector->x2);
const float tx2 = 2.0f * (versor->_x3 * vector->x1 - versor->_x1 * vector->x3); const float tx2 = 2.0f * (versor->_x3 * vector->x1 - versor->_x1 * vector->x3);
@ -619,7 +619,7 @@ inline void bgc_versor_turn_vector_back_fp32(const BgcVersorFP32* versor, const
result->x3 = x3; result->x3 = x3;
} }
inline void bgc_versor_turn_vector_back_fp64(const BgcVersorFP64* versor, const BgcVector3FP64* vector, BgcVector3FP64* result) inline void bgc_fp64_versor_turn_vector_back(const BGC_FP64_Versor* versor, const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* result)
{ {
const double tx1 = 2.0 * (versor->_x2 * vector->x3 - versor->_x3 * vector->x2); const double tx1 = 2.0 * (versor->_x2 * vector->x3 - versor->_x3 * vector->x2);
const double tx2 = 2.0 * (versor->_x3 * vector->x1 - versor->_x1 * vector->x3); const double tx2 = 2.0 * (versor->_x3 * vector->x1 - versor->_x1 * vector->x3);
@ -636,24 +636,24 @@ inline void bgc_versor_turn_vector_back_fp64(const BgcVersorFP64* versor, const
// ================== Are Close ================= // // ================== Are Close ================= //
inline int bgc_versor_are_close_fp32(const BgcVersorFP32* versor1, const BgcVersorFP32* versor2) inline int bgc_fp32_versor_are_close(const BGC_FP32_Versor* versor1, const BGC_FP32_Versor* versor2)
{ {
const float ds0 = versor1->_s0 - versor2->_s0; const float ds0 = versor1->_s0 - versor2->_s0;
const float dx1 = versor1->_x1 - versor2->_x1; const float dx1 = versor1->_x1 - versor2->_x1;
const float dx2 = versor1->_x2 - versor2->_x2; const float dx2 = versor1->_x2 - versor2->_x2;
const float dx3 = versor1->_x3 - versor2->_x3; const float dx3 = versor1->_x3 - versor2->_x3;
return (ds0 * ds0 + dx1 * dx1) + (dx2 * dx2 + dx3 * dx3) <= BGC_SQUARE_EPSYLON_FP32; return (ds0 * ds0 + dx1 * dx1) + (dx2 * dx2 + dx3 * dx3) <= BGC_FP32_SQUARE_EPSYLON;
} }
inline int bgc_versor_are_close_fp64(const BgcVersorFP64* versor1, const BgcVersorFP64* versor2) inline int bgc_fp64_versor_are_close(const BGC_FP64_Versor* versor1, const BGC_FP64_Versor* versor2)
{ {
const double ds0 = versor1->_s0 - versor2->_s0; const double ds0 = versor1->_s0 - versor2->_s0;
const double dx1 = versor1->_x1 - versor2->_x1; const double dx1 = versor1->_x1 - versor2->_x1;
const double dx2 = versor1->_x2 - versor2->_x2; const double dx2 = versor1->_x2 - versor2->_x2;
const double dx3 = versor1->_x3 - versor2->_x3; const double dx3 = versor1->_x3 - versor2->_x3;
return (ds0 * ds0 + dx1 * dx1) + (dx2 * dx2 + dx3 * dx3) <= BGC_SQUARE_EPSYLON_FP64; return (ds0 * ds0 + dx1 * dx1) + (dx2 * dx2 + dx3 * dx3) <= BGC_FP64_SQUARE_EPSYLON;
} }
#endif #endif