From f7e41645fe98e5fb4f9ba1cafd46cc5c79be971b Mon Sep 17 00:00:00 2001 From: Andrey Pokidov Date: Fri, 30 Jan 2026 19:37:49 +0700 Subject: [PATCH 1/9] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D1=85=D0=BE=D0=B4?= =?UTF-8?q?=20=D0=BD=D0=B0=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=8E=200.3:?= =?UTF-8?q?=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=B4=D1=85=D0=BE=D0=B4=D0=B0=20=D0=BA=20=D0=B8?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8E=20=D1=81?= =?UTF-8?q?=D1=83=D1=89=D0=BD=D0=BE=D1=81=D1=82=D0=B5=D0=B9,=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5,=20?= =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B8?= =?UTF-8?q?=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=80?= =?UTF-8?q?=D1=8F=D0=B4=D0=B0=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Geometry.workspace | 2 +- README-Eng.md | 2 +- README.md | 2 +- basic-geometry-dev/affine3.c | 34 +- basic-geometry-dev/main.c | 312 +++++----- basic-geometry-test/helpers.h | 8 +- .../tests/complex/complex_copy.c | 16 +- .../tests/complex/complex_is_unit.c | 68 +-- .../tests/complex/complex_is_zero.c | 60 +- .../tests/complex/complex_modulus.c | 20 +- .../tests/complex/complex_reset.c | 12 +- .../tests/complex/complex_set_values.c | 20 +- .../tests/complex/complex_swap.c | 28 +- .../tests/quaternion/quaternion_copy.c | 16 +- .../tests/quaternion/quaternion_is_unit.c | 108 ++-- .../tests/quaternion/quaternion_is_zero.c | 92 +-- .../tests/quaternion/quaternion_modulus.c | 20 +- .../tests/quaternion/quaternion_reset.c | 12 +- .../quaternion/quaternion_set_to_identity.c | 20 +- .../quaternion/quaternion_set_to_identity.h | 4 +- .../tests/quaternion/quaternion_set_values.c | 20 +- .../tests/quaternion/quaternion_swap.c | 28 +- .../tests/utilities/are_close.c | 116 ++-- basic-geometry-test/tests/utilities/is_unit.c | 64 +-- basic-geometry-test/tests/utilities/is_unit.h | 4 +- basic-geometry-test/tests/utilities/is_zero.c | 28 +- basic-geometry-test/tests/vector2.c | 20 +- .../tests/vector2/vector2_copy.c | 16 +- .../tests/vector2/vector2_is_unit.c | 60 +- .../tests/vector2/vector2_is_zero.c | 60 +- .../tests/vector2/vector2_modulus.c | 20 +- .../tests/vector2/vector2_reset.c | 12 +- .../tests/vector2/vector2_set_values.c | 20 +- .../tests/vector2/vector2_swap.c | 28 +- .../tests/vector3/vector3_copy.c | 16 +- .../tests/vector3/vector3_is_unit.c | 76 +-- .../tests/vector3/vector3_is_zero.c | 76 +-- .../tests/vector3/vector3_modulus.c | 20 +- .../tests/vector3/vector3_reset.c | 12 +- .../tests/vector3/vector3_set_values.c | 20 +- .../tests/vector3/vector3_swap.c | 28 +- .../tests/versor/versor_are_close.c | 76 +-- .../tests/versor/versor_combine.c | 16 +- .../tests/versor/versor_copy.c | 16 +- .../tests/versor/versor_is_identity.c | 56 +- .../tests/versor/versor_reset.c | 12 +- .../tests/versor/versor_set_values.c | 36 +- .../tests/versor/versor_swap.c | 32 +- basic-geometry/affine2.c | 39 +- basic-geometry/affine2.h | 150 ++--- basic-geometry/affine3.c | 39 +- basic-geometry/affine3.h | 150 ++--- basic-geometry/angle.c | 74 ++- basic-geometry/angle.h | 378 ++++++------- basic-geometry/basic-geometry.cbp | 4 + basic-geometry/complex.c | 124 ++-- basic-geometry/complex.h | 228 ++++---- basic-geometry/cotes-number.c | 91 ++- basic-geometry/cotes-number.h | 181 +++--- basic-geometry/matrix2x2.c | 105 ++-- basic-geometry/matrix2x2.h | 386 ++++++++----- basic-geometry/matrix2x3.c | 71 ++- basic-geometry/matrix2x3.h | 304 ++++++---- basic-geometry/matrix3x2.c | 71 ++- basic-geometry/matrix3x2.h | 328 +++++++---- basic-geometry/matrix3x3.c | 149 ++--- basic-geometry/matrix3x3.h | 534 ++++++++++++------ basic-geometry/matrixes.c | 287 +--------- basic-geometry/matrixes.h | 298 ++++++++-- basic-geometry/position2.c | 62 +- basic-geometry/position2.h | 234 ++++---- basic-geometry/position3.c | 62 +- basic-geometry/position3.h | 234 ++++---- basic-geometry/quaternion.c | 146 ++--- basic-geometry/quaternion.h | 288 +++++----- basic-geometry/rotation3.c | 16 +- basic-geometry/rotation3.h | 40 +- basic-geometry/slerp.c | 28 +- basic-geometry/slerp.h | 56 +- basic-geometry/utilities.c | 16 +- basic-geometry/utilities.h | 78 ++- basic-geometry/vector2.c | 152 ++--- basic-geometry/vector2.h | 320 +++++------ basic-geometry/vector3.c | 168 +++--- basic-geometry/vector3.h | 356 ++++++------ basic-geometry/versor.c | 352 ++++++------ basic-geometry/versor.h | 188 +++--- 87 files changed, 4580 insertions(+), 4051 deletions(-) diff --git a/Geometry.workspace b/Geometry.workspace index 23e6315..e53afab 100644 --- a/Geometry.workspace +++ b/Geometry.workspace @@ -4,9 +4,9 @@ - + diff --git a/README-Eng.md b/README-Eng.md index e5849fb..375e382 100644 --- a/README-Eng.md +++ b/README-Eng.md @@ -8,7 +8,7 @@ Programming language: C (C99) -Version: 0.2.0-dev +Version: 0.3.0-dev License: Apache-2.0 diff --git a/README.md b/README.md index 440a2d8..919caa3 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Язык программирования: Си (C99) -Версия: 0.2.0-dev +Версия: 0.3.0-dev Лицензия: Apache-2.0 diff --git a/basic-geometry-dev/affine3.c b/basic-geometry-dev/affine3.c index 15232ef..639e9d0 100644 --- a/basic-geometry-dev/affine3.c +++ b/basic-geometry-dev/affine3.c @@ -9,16 +9,16 @@ #include #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) { return 0; } for (int i = 0; i < affine_amount; i++) { - bgc_affine3_reset_fp32(&affines[i]); + bgc_fp32_affine3_reset(&affines[i]); } return affines; @@ -29,18 +29,18 @@ float get_random_value_fp32() 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) { return 0; } - BgcPosition3FP32 position; + BGC_FP32_Position3 position; 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(), @@ -52,20 +52,20 @@ BgcAffine3FP32* _create_bgc_affine3_random_list(int affine_amount) position.shift.x2 = 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; } -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) { 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) { - BgcAffine3FP32* affines; - BgcVector3FP32* source_vectors; - BgcVector3FP32* result_vectors; + BGC_FP32_Affine3* affines; + BGC_FP32_Vector3* source_vectors; + BGC_FP32_Vector3* result_vectors; int vector_index = 0; 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 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++; } } @@ -153,4 +153,4 @@ float test_bgc_affine3_performance(int affine_amount, int vector_per_affine) free(affines); return time; -} \ No newline at end of file +} diff --git a/basic-geometry-dev/main.c b/basic-geometry-dev/main.c index 04912ed..9536829 100644 --- a/basic-geometry-dev/main.c +++ b/basic-geometry-dev/main.c @@ -10,7 +10,7 @@ #endif // _WINDOWS_ typedef struct { - BgcVersorFP32 versor1, versor2, result; + BGC_FP32_Versor versor1, versor2, result; } structure_fp32_t; structure_fp32_t* allocate_structures(const unsigned int amount) @@ -29,7 +29,7 @@ structure_fp32_t* make_structures(const unsigned int amount) const float multiplier = 2.0f / RAND_MAX; for (unsigned int i = 0; i < amount; i++) { - bgc_versor_set_values_fp32( + bgc_fp32_versor_make( 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 ); - bgc_versor_set_values_fp32( + bgc_fp32_versor_make( 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 ); - bgc_versor_reset_fp32(&list[i].result); + bgc_fp32_versor_reset(&list[i].result); } 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); } -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); } -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) { for (uint_fast32_t j = 0; j < 1000; j++) { 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() { - 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); @@ -140,10 +140,10 @@ int main() { */ /* int main() { - BgcVersorFP32 start = { 1.0f, 0.0f, 0.0f, 0.0f }; - BgcVersorFP32 end = { 0.0f, 1.0f, 0.0f, 0.0f }; - BgcVersorFP32 result; - bgc_versor_spherical_interpolation_fp32(&start, &end, 0.5f, &result); + BGC_FP32_Versor start = { 1.0f, 0.0f, 0.0f, 0.0f }; + BGC_FP32_Versor end = { 0.0f, 1.0f, 0.0f, 0.0f }; + BGC_FP32_Versor result; + bgc_fp32_versor_spherical_interpolation(&start, &end, 0.5f, &result); printf("Result: %0.12f, %0.12f, %0.12f, %0.12f\n", result.s0, result.x1, result.x2, result.x3); return 0; } @@ -152,79 +152,79 @@ int main() { void test_basis_difference_fp32() { - BgcVector3FP32 initial_primary, initial_auxiliary; - BgcVector3FP32 final_primary, final_auxiliary; - BgcVersorFP32 turn; + BGC_FP32_Vector3 initial_primary, initial_auxiliary; + BGC_FP32_Vector3 final_primary, final_auxiliary; + BGC_FP32_Versor turn; // No turn - bgc_vector3_set_values_fp32(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(1.0f, 0.0f, 0.0f, &initial_primary); + 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_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_auxiliary); + bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &final_primary); + 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"); print_versor_fp32(&turn); // Turn around (1, 1, 0) axis on 180 degrees - bgc_vector3_set_values_fp32(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(1.0f, 0.0f, 0.0f, &initial_primary); + 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_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &final_auxiliary); + bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_primary); + 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"); print_versor_fp32(&turn); // 180 degree turn - bgc_vector3_set_values_fp32(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(1.0f, 0.0f, 0.0f, &initial_primary); + 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_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &final_auxiliary); + bgc_fp32_vector3_make(-1.0f, 0.0f, 0.0f, &final_primary); + 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"); print_versor_fp32(&turn); // 90 degree turn around x3 axis - bgc_vector3_set_values_fp32(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(2.0f, 0.0f, 0.0f, &initial_primary); + 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_vector3_set_values_fp32(-1.0f, 0.0f, 0.0f, &final_auxiliary); + bgc_fp32_vector3_make(0.0f, 10.0f, 0.0f, &final_primary); + 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"); print_versor_fp32(&turn); // Unorthogonal pairs turn at 90 degrees around x3 axis - bgc_vector3_set_values_fp32(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, 0.0f, 0.0f, &initial_primary); + 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_vector3_set_values_fp32(-1.0f, 5.0f, 0.0f, &final_auxiliary); + bgc_fp32_vector3_make(0.0f, 10.0f, 0.0f, &final_primary); + 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"); print_versor_fp32(&turn); // Zero vectors - bgc_vector3_set_values_fp32(0.0f, 0.0f, 0.0f, &initial_primary); - bgc_vector3_set_values_fp32(0.0f, 1.0f, 0.0f, &initial_auxiliary); - bgc_vector3_set_values_fp32(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, 0.0f, 0.0f, &initial_primary); + bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &initial_auxiliary); + bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &final_primary); + bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_auxiliary); 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) { printf("\nZero vectors: this cannot be!\n"); @@ -235,12 +235,12 @@ void test_basis_difference_fp32() } // Parallel vectors - bgc_vector3_set_values_fp32(1.0f, 0.0f, 0.0f, &initial_primary); - bgc_vector3_set_values_fp32(2.0f, 0.0f, 0.0f, &initial_auxiliary); - bgc_vector3_set_values_fp32(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(1.0f, 0.0f, 0.0f, &initial_primary); + bgc_fp32_vector3_make(2.0f, 0.0f, 0.0f, &initial_auxiliary); + bgc_fp32_vector3_make(1.0f, 0.0f, 0.0f, &final_primary); + 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) { printf("\nParallel vectors: this cannot be!\n"); @@ -251,60 +251,60 @@ void test_basis_difference_fp32() } // Small angle turn (about 1 degree): - bgc_vector3_set_values_fp32(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(1.0f, 0.0f, 0.0f, &initial_primary); + 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_vector3_set_values_fp32(-0.017452f, 0.999848f, 0.0f, &final_auxiliary); + bgc_fp32_vector3_make(0.999848f, 0.017452f, 0.0f, &final_primary); + 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"); print_versor_fp32(&turn); // About 179 degrees turn - bgc_vector3_set_values_fp32(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(1.0f, 0.0f, 0.0f, &initial_primary); + 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_vector3_set_values_fp32(0.017452f, -0.999848f, 0.0f, &final_auxiliary); + bgc_fp32_vector3_make(-0.999848f, -0.017452f, 0.0f, &final_primary); + 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"); print_versor_fp32(&turn); // 120 degrees around (-1, -1, 1) - bgc_vector3_set_values_fp32(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(1.0f, 0.0f, 0.0f, &initial_primary); + 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_vector3_set_values_fp32(0.0f, 0.0f, -1.0f, &final_auxiliary); + bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_primary); + 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"); print_versor_fp32(&turn); // 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_vector3_set_values_fp32(0.999848f, 0.017452f, 0.0f, &initial_auxiliary); - bgc_vector3_set_values_fp32(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, &initial_primary); + bgc_fp32_vector3_make(0.999848f, 0.017452f, 0.0f, &initial_auxiliary); + bgc_fp32_vector3_make(0.0f, 1.0f, 0.0f, &final_primary); + 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"); print_versor_fp32(&turn); // 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_vector3_set_values_fp32(1.0f, 0.000001f, 0.0f, &initial_auxiliary); - bgc_vector3_set_values_fp32(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, &initial_primary); + bgc_fp32_vector3_make(1.0f, 0.000001f, 0.0f, &initial_auxiliary); + bgc_fp32_vector3_make(0.0f, -1.0f, 0.0f, &final_primary); + 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"); print_versor_fp32(&turn); @@ -313,77 +313,77 @@ void test_basis_difference_fp32() void test_basis_difference_fp64() { - BgcVector3FP64 initial_primary, initial_auxiliary; - BgcVector3FP64 final_primary, final_auxiliary; - BgcVersorFP64 turn; + BGC_FP64_Vector3 initial_primary, initial_auxiliary; + BGC_FP64_Vector3 final_primary, final_auxiliary; + BGC_FP64_Versor turn; // No turn - bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary); - bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary); - bgc_vector3_set_values_fp64(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(1.0, 0.0, 0.0, &initial_primary); + bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary); + bgc_fp64_vector3_make(1.0, 0.0, 0.0, &final_primary); + 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"); print_versor_fp64(&turn); // Turn around (1, 1, 0) axis on 180 degrees - bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary); - bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary); - bgc_vector3_set_values_fp64(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, &initial_primary); + bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary); + bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_primary); + 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"); print_versor_fp64(&turn); // 180 degree turn - bgc_vector3_set_values_fp64(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(1.0, 0.0, 0.0, &initial_primary); + 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_vector3_set_values_fp64(0.0, 1.0, 0.0, &final_auxiliary); + bgc_fp64_vector3_make(-1.0, 0.0, 0.0, &final_primary); + 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"); print_versor_fp64(&turn); // 90 degree turn around x3 axis - bgc_vector3_set_values_fp64(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(2.0, 0.0, 0.0, &initial_primary); + 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_vector3_set_values_fp64(-1.0, 0.0, 0.0, &final_auxiliary); + bgc_fp64_vector3_make(0.0, 10.0, 0.0, &final_primary); + 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"); print_versor_fp64(&turn); // Unorthogonal pairs turn at 90 degrees around x3 axis - bgc_vector3_set_values_fp64(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, 0.0, 0.0, &initial_primary); + 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_vector3_set_values_fp64(-1.0, 5.0, 0.0, &final_auxiliary); + bgc_fp64_vector3_make(0.0, 10.0, 0.0, &final_primary); + 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"); print_versor_fp64(&turn); // Zero vectors - bgc_vector3_set_values_fp64(0.0, 0.0, 0.0, &initial_primary); - bgc_vector3_set_values_fp64(0.0, 1.0, 0.0, &initial_auxiliary); - bgc_vector3_set_values_fp64(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, 0.0, 0.0, &initial_primary); + bgc_fp64_vector3_make(0.0, 1.0, 0.0, &initial_auxiliary); + bgc_fp64_vector3_make(1.0, 0.0, 0.0, &final_primary); + bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_auxiliary); 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) { printf("\nZero vectors: this cannot be!\n"); @@ -394,12 +394,12 @@ void test_basis_difference_fp64() } // Parallel vectors - bgc_vector3_set_values_fp64(1.0, 0.0, 0.0, &initial_primary); - bgc_vector3_set_values_fp64(2.0, 0.0, 0.0, &initial_auxiliary); - bgc_vector3_set_values_fp64(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(1.0, 0.0, 0.0, &initial_primary); + bgc_fp64_vector3_make(2.0, 0.0, 0.0, &initial_auxiliary); + bgc_fp64_vector3_make(1.0, 0.0, 0.0, &final_primary); + 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) { printf("\nParallel vectors: this cannot be!\n"); @@ -410,60 +410,60 @@ void test_basis_difference_fp64() } // Small angle turn (about 1 degree): - bgc_vector3_set_values_fp64(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(1.0, 0.0, 0.0, &initial_primary); + 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_vector3_set_values_fp64(-0.017452, 0.999848, 0.0, &final_auxiliary); + bgc_fp64_vector3_make(0.999848, 0.017452, 0.0, &final_primary); + 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"); print_versor_fp64(&turn); // About 179 degrees turn - bgc_vector3_set_values_fp64(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(1.0, 0.0, 0.0, &initial_primary); + 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_vector3_set_values_fp64(0.017452, -0.999848, 0.0, &final_auxiliary); + bgc_fp64_vector3_make(-0.999848, -0.017452, 0.0, &final_primary); + 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"); print_versor_fp64(&turn); // 120 degrees around (-1, -1, 1) - bgc_vector3_set_values_fp64(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(1.0, 0.0, 0.0, &initial_primary); + 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_vector3_set_values_fp64(0.0, 0.0, -1.0, &final_auxiliary); + bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_primary); + 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"); print_versor_fp64(&turn); // 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_vector3_set_values_fp64(0.999848, 0.017452, 0.0, &initial_auxiliary); - bgc_vector3_set_values_fp64(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, &initial_primary); + bgc_fp64_vector3_make(0.999848, 0.017452, 0.0, &initial_auxiliary); + bgc_fp64_vector3_make(0.0, 1.0, 0.0, &final_primary); + 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"); print_versor_fp64(&turn); // 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_vector3_set_values_fp64(1.0, 0.000001, 0.0, &initial_auxiliary); - bgc_vector3_set_values_fp64(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, &initial_primary); + bgc_fp64_vector3_make(1.0, 0.000001, 0.0, &initial_auxiliary); + bgc_fp64_vector3_make(0.0, -1.0, 0.0, &final_primary); + 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"); print_versor_fp64(&turn); @@ -473,15 +473,15 @@ void test_basis_difference_fp64() int main() { - //BgcVersorFP32 start = { 1.0f, 0.0f, 0.0f, 0.0f }; - //BgcVersorFP32 end = { 0.0f, 1.0f, 0.0f, 0.0f }; + //BGC_FP32_Versor start = { 1.0f, 0.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 }; - BgcVersorFP32 end = { 0.9999f, 0.01414f, 0.0f, 0.0f }; - BgcSlerpFP32 slerp; - BgcVersorFP32 result; - bgc_slerp_make_full_fp32(&start, &end, &slerp); - bgc_slerp_get_turn_for_phase_fp32(&slerp, 0.5f, &result); + BGC_FP32_Versor start = { 1.0f, 0.0f, 0.0f, 0.0f }; + BGC_FP32_Versor end = { 0.9999f, 0.01414f, 0.0f, 0.0f }; + BGC_FP32_Slerp slerp; + BGC_FP32_Versor result; + bgc_fp32_slerp_make_full(&start, &end, &slerp); + bgc_fp32_slerp_get_phase_versor(&slerp, 0.5f, &result); print_versor_fp32(&result); */ @@ -489,9 +489,9 @@ int main() printf("Affine3 performance test: %f\n", test_bgc_affine3_performance(10000000, 10)); - printf("sizeof(BgcAffine3FP32) = %zu\n", sizeof(BgcAffine3FP32)); - //printf("offsetof(shift) = %zu\n", offsetof(BgcAffine3FP32, shift)); - printf("sizeof(BgcMatrix3x3FP32) = %zu\n", sizeof(BgcMatrix3x3FP32)); + printf("sizeof(BGC_FP32_Affine3) = %zu\n", sizeof(BGC_FP32_Affine3)); + //printf("offsetof(shift) = %zu\n", offsetof(BGC_FP32_Affine3, shift)); + printf("sizeof(BGC_FP32_Matrix3x3) = %zu\n", sizeof(BGC_FP32_Matrix3x3)); return 0; } diff --git a/basic-geometry-test/helpers.h b/basic-geometry-test/helpers.h index eeddfe0..10bd548 100644 --- a/basic-geometry-test/helpers.h +++ b/basic-geometry-test/helpers.h @@ -25,19 +25,19 @@ typedef struct { // =================== Versor =================== // typedef struct { - BgcVersorFP32 first, second; + BGC_FP32_Versor first, second; } TestVersorPairFP32; typedef struct { - BgcVersorFP64 first, second; + BGC_FP64_Versor first, second; } TestVersorPairFP64; typedef struct { - BgcVersorFP32 first, second, result; + BGC_FP32_Versor first, second, result; } TestVersorTripletFP32; typedef struct { - BgcVersorFP64 first, second, result; + BGC_FP64_Versor first, second, result; } TestVersorTripletFP64; // ================= Functions ================== // diff --git a/basic-geometry-test/tests/complex/complex_copy.c b/basic-geometry-test/tests/complex/complex_copy.c index 84ed825..631b4a8 100644 --- a/basic-geometry-test/tests/complex/complex_copy.c +++ b/basic-geometry-test/tests/complex/complex_copy.c @@ -7,7 +7,7 @@ // ==================== FP32 ==================== // 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 }, { -4.0f, -3.0f }, { -0.001f, 100.0f }, @@ -16,13 +16,13 @@ static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST[] = { 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++) { - 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 || vector.imaginary != _TEST_FP32_COMPLEX_LIST[i].imaginary) { @@ -37,7 +37,7 @@ void test_complex_copy_fp32() // ==================== FP64 ==================== // 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 }, { -4.0, -3.0 }, { -0.001, 100.0 }, @@ -46,13 +46,13 @@ static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST[] = { 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++) { - 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 || vector.imaginary != _TEST_FP64_COMPLEX_LIST[i].imaginary) { diff --git a/basic-geometry-test/tests/complex/complex_is_unit.c b/basic-geometry-test/tests/complex/complex_is_unit.c index f06ca66..a95e7c6 100644 --- a/basic-geometry-test/tests/complex/complex_is_unit.c +++ b/basic-geometry-test/tests/complex/complex_is_unit.c @@ -7,35 +7,35 @@ static const int _TEST_FP32_UNIT_COMPLEX_AMOUNT = 10; 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 }, { 0.6f, -0.8f }, - { 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f }, - { 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f }, - { 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32 }, - { 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32 }, + { 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f }, + { 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f }, + { 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON }, + { 0.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON }, { 0.7071067812f, 0.7071067812f }, - { 0.7071067812f + 0.75f * BGC_EPSYLON_FP32, 0.7071067812f }, - { 0.7071067812f, 0.7071067812f - 0.75f * BGC_EPSYLON_FP32 } + { 0.7071067812f + 0.75f * BGC_FP32_EPSYLON, 0.7071067812f }, + { 0.7071067812f, 0.7071067812f - 0.75f * BGC_FP32_EPSYLON } }; -static const BgcComplexFP32 _TEST_FP32_NONUNIT_QUATERION_LIST[] = { - { 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f }, - { 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f }, - { 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32 }, - { 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32 }, - { 0.7071067812f + 1.25f * BGC_EPSYLON_FP32, 0.7071067812f + 1.25f * BGC_EPSYLON_FP32 }, - { 0.7071067812f - 1.25f * BGC_EPSYLON_FP32, 0.7071067812f - 1.25f * BGC_EPSYLON_FP32 } +static const BGC_FP32_Complex _TEST_FP32_NONUNIT_QUATERION_LIST[] = { + { 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f }, + { 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f }, + { 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON }, + { 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON }, + { 0.7071067812f + 1.25f * BGC_FP32_EPSYLON, 0.7071067812f + 1.25f * BGC_FP32_EPSYLON }, + { 0.7071067812f - 1.25f * BGC_FP32_EPSYLON, 0.7071067812f - 1.25f * BGC_FP32_EPSYLON } }; 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: 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"); return; } @@ -43,7 +43,7 @@ void test_complex_is_unit_fp32() // Testing non-zero values: 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"); 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_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 }, { -0.6, 0.8 }, - { 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0 }, - { 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0 }, - { 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64 }, - { 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64 }, + { 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0 }, + { 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0 }, + { 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON }, + { 0.0, 1.0 - 0.75 * BGC_FP64_EPSYLON }, { 0.7071067811865475244, 0.7071067811865475244 }, - { 0.7071067811865475244 + 0.75 * BGC_EPSYLON_FP64, 0.7071067811865475244 }, - { 0.7071067811865475244, 0.7071067811865475244 - 0.75 * BGC_EPSYLON_FP64 } + { 0.7071067811865475244 + 0.75 * BGC_FP64_EPSYLON, 0.7071067811865475244 }, + { 0.7071067811865475244, 0.7071067811865475244 - 0.75 * BGC_FP64_EPSYLON } }; -static const BgcComplexFP64 _TEST_FP64_NONUNIT_QUATERION_LIST[] = { - { 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0 }, - { 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0 }, - { 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64 }, - { 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64 }, - { 0.7071067811865475244 + 1.25 * BGC_EPSYLON_FP64, 0.7071067811865475244 + 1.25 * BGC_EPSYLON_FP64 }, - { 0.7071067811865475244 - 1.25 * BGC_EPSYLON_FP64, 0.7071067811865475244 - 1.25 * BGC_EPSYLON_FP64 } +static const BGC_FP64_Complex _TEST_FP64_NONUNIT_QUATERION_LIST[] = { + { 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0 }, + { 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0 }, + { 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON }, + { 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON }, + { 0.7071067811865475244 + 1.25 * BGC_FP64_EPSYLON, 0.7071067811865475244 + 1.25 * BGC_FP64_EPSYLON }, + { 0.7071067811865475244 - 1.25 * BGC_FP64_EPSYLON, 0.7071067811865475244 - 1.25 * BGC_FP64_EPSYLON } }; 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: 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"); return; } @@ -93,7 +93,7 @@ void test_complex_is_unit_fp64() // Testing non-zero values: 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"); return; } diff --git a/basic-geometry-test/tests/complex/complex_is_zero.c b/basic-geometry-test/tests/complex/complex_is_zero.c index 1f658e3..a10816a 100644 --- a/basic-geometry-test/tests/complex/complex_is_zero.c +++ b/basic-geometry-test/tests/complex/complex_is_zero.c @@ -7,31 +7,31 @@ static const int _TEST_FP32_ZERO_COMPLEX_AMOUNT = 4; 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.75f * BGC_EPSYLON_FP32, 0.0f }, - { -0.75f * BGC_EPSYLON_FP32, 0.0f }, - { 0.0f, 0.75f * BGC_EPSYLON_FP32 }, - { 0.0f, -0.75f * BGC_EPSYLON_FP32 } + { 0.75f * BGC_FP32_EPSYLON, 0.0f }, + { -0.75f * BGC_FP32_EPSYLON, 0.0f }, + { 0.0f, 0.75f * BGC_FP32_EPSYLON }, + { 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 }, - { 1.25f * BGC_EPSYLON_FP32 }, - { -1.25f * BGC_EPSYLON_FP32 }, - { 0.0f, 1.25f * BGC_EPSYLON_FP32 }, - { 0.0f, -1.25f * BGC_EPSYLON_FP32 }, - { 1.25f * BGC_EPSYLON_FP32, 1.25f * BGC_EPSYLON_FP32 }, - { -1.25f * BGC_EPSYLON_FP32, -1.25f * BGC_EPSYLON_FP32 } + { 1.25f * BGC_FP32_EPSYLON }, + { -1.25f * BGC_FP32_EPSYLON }, + { 0.0f, 1.25f * BGC_FP32_EPSYLON }, + { 0.0f, -1.25f * BGC_FP32_EPSYLON }, + { 1.25f * BGC_FP32_EPSYLON, 1.25f * BGC_FP32_EPSYLON }, + { -1.25f * BGC_FP32_EPSYLON, -1.25f * BGC_FP32_EPSYLON } }; 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: 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"); return; } @@ -39,7 +39,7 @@ void test_complex_is_zero_fp32() // Testing non-zero values: 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"); 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_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.75 * BGC_EPSYLON_FP64, 0.0 }, - { -0.75 * BGC_EPSYLON_FP64, 0.0 }, - { 0.0, 0.75 * BGC_EPSYLON_FP64 }, - { 0.0, -0.75 * BGC_EPSYLON_FP64 } + { 0.75 * BGC_FP64_EPSYLON, 0.0 }, + { -0.75 * BGC_FP64_EPSYLON, 0.0 }, + { 0.0, 0.75 * BGC_FP64_EPSYLON }, + { 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 }, - { 1.25 * BGC_EPSYLON_FP64, 0.0 }, - { -1.25 * BGC_EPSYLON_FP64, 0.0 }, - { 0.0, 1.25 * BGC_EPSYLON_FP64 }, - { 0.0, -1.25 * BGC_EPSYLON_FP64 }, - { 1.25 * BGC_EPSYLON_FP64, 1.25 * BGC_EPSYLON_FP64 }, - { -1.25 * BGC_EPSYLON_FP64, -1.25 * BGC_EPSYLON_FP64 } + { 1.25 * BGC_FP64_EPSYLON, 0.0 }, + { -1.25 * BGC_FP64_EPSYLON, 0.0 }, + { 0.0, 1.25 * BGC_FP64_EPSYLON }, + { 0.0, -1.25 * BGC_FP64_EPSYLON }, + { 1.25 * BGC_FP64_EPSYLON, 1.25 * BGC_FP64_EPSYLON }, + { -1.25 * BGC_FP64_EPSYLON, -1.25 * BGC_FP64_EPSYLON } }; 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: 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"); return; } @@ -85,7 +85,7 @@ void test_complex_is_zero_fp64() // Testing non-zero values: 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"); return; } diff --git a/basic-geometry-test/tests/complex/complex_modulus.c b/basic-geometry-test/tests/complex/complex_modulus.c index 20c0495..7ed97d0 100644 --- a/basic-geometry-test/tests/complex/complex_modulus.c +++ b/basic-geometry-test/tests/complex/complex_modulus.c @@ -6,7 +6,7 @@ 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 }, { -1.0f, 1.0f }, { 100.0f, -100.0f }, @@ -29,10 +29,10 @@ static const float _TEST_FP32_MODULUS_LIST[] = { 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++) { - 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(); return; } @@ -43,10 +43,10 @@ void test_complex_square_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++) { - 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(); return; } @@ -59,7 +59,7 @@ void test_complex_modulus_fp32() 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 }, { -1.0, -1.0 }, { -100.0, 100.0 }, @@ -82,10 +82,10 @@ static const double _TEST_FP64_MODULUS_LIST[] = { 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++) { - 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(); return; } @@ -96,10 +96,10 @@ void test_complex_square_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++) { - 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(); return; } diff --git a/basic-geometry-test/tests/complex/complex_reset.c b/basic-geometry-test/tests/complex/complex_reset.c index 6c8b11f..66cb2d7 100644 --- a/basic-geometry-test/tests/complex/complex_reset.c +++ b/basic-geometry-test/tests/complex/complex_reset.c @@ -4,11 +4,11 @@ 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) { print_testing_failed(); @@ -20,11 +20,11 @@ void test_complex_reset_fp32() 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) { print_testing_failed(); diff --git a/basic-geometry-test/tests/complex/complex_set_values.c b/basic-geometry-test/tests/complex/complex_set_values.c index 9f20beb..57d129e 100644 --- a/basic-geometry-test/tests/complex/complex_set_values.c +++ b/basic-geometry-test/tests/complex/complex_set_values.c @@ -8,25 +8,25 @@ 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) { print_testing_error("First step failed"); 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) { print_testing_error("Second step failed"); 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) { print_testing_error("Third step failed"); @@ -40,25 +40,25 @@ void test_complex_set_values_fp32() 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) { print_testing_error("First step failed"); 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) { print_testing_error("Second step failed"); 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) { print_testing_error("Third step failed"); diff --git a/basic-geometry-test/tests/complex/complex_swap.c b/basic-geometry-test/tests/complex/complex_swap.c index bec0546..54d4732 100644 --- a/basic-geometry-test/tests/complex/complex_swap.c +++ b/basic-geometry-test/tests/complex/complex_swap.c @@ -8,14 +8,14 @@ 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 }, { -2.0f, -1.0f }, { -244.8f, 100.0f }, { 1000.32f, -100.1f } }; -static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST2[] = { +static const BGC_FP32_Complex _TEST_FP32_COMPLEX_LIST2[] = { { 5.3f, 1003.28f }, { -0.0032f, 891.3f }, { 5.322f, 0.9275f }, @@ -24,15 +24,15 @@ static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST2[] = { 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++) { - bgc_complex_copy_fp32(&_TEST_FP32_COMPLEX_LIST1[i], &compleimaginary); - bgc_complex_copy_fp32(&_TEST_FP32_COMPLEX_LIST2[i], &complex2); + bgc_fp32_complex_copy(&_TEST_FP32_COMPLEX_LIST1[i], &compleimaginary); + 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 || 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 BgcComplexFP64 _TEST_FP64_COMPLEX_LIST1[] = { +static const BGC_FP64_Complex _TEST_FP64_COMPLEX_LIST1[] = { { 1.0, 4.0 }, { -4.0, -3.0 }, { -244.8, 344.7 }, { 1000.32, -271.3 } }; -static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST2[] = { +static const BGC_FP64_Complex _TEST_FP64_COMPLEX_LIST2[] = { { -0.123, 1003.28 }, { 204.07, -781.89 }, { 5.322, 0.9275 }, @@ -66,15 +66,15 @@ static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST2[] = { 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++) { - bgc_complex_copy_fp64(&_TEST_FP64_COMPLEX_LIST1[i], &compleimaginary); - bgc_complex_copy_fp64(&_TEST_FP64_COMPLEX_LIST2[i], &complex2); + bgc_fp64_complex_copy(&_TEST_FP64_COMPLEX_LIST1[i], &compleimaginary); + 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 || compleimaginary.imaginary != _TEST_FP64_COMPLEX_LIST2[i].imaginary || diff --git a/basic-geometry-test/tests/quaternion/quaternion_copy.c b/basic-geometry-test/tests/quaternion/quaternion_copy.c index ee377f5..72ead24 100644 --- a/basic-geometry-test/tests/quaternion/quaternion_copy.c +++ b/basic-geometry-test/tests/quaternion/quaternion_copy.c @@ -7,7 +7,7 @@ // ==================== FP32 ==================== // 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 }, { -4.0f, -3.0f, -2.0f, -1.0f }, { -0.001f, 100.0f, -100.0f, 0.001f }, @@ -16,13 +16,13 @@ static const BgcQuaternionFP32 _TEST_FP32_QUATERNION_LIST[] = { 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++) { - 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 || vector.x1 != _TEST_FP32_QUATERNION_LIST[i].x1 || @@ -39,7 +39,7 @@ void test_quaternion_copy_fp32() // ==================== FP64 ==================== // 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 }, { -4.0, -3.0, -2.0, -1.0 }, { -0.001, 100.0, -100.0, 0.001 }, @@ -48,13 +48,13 @@ static const BgcQuaternionFP64 _TEST_FP64_QUATERNION_LIST[] = { 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++) { - 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 || vector.x1 != _TEST_FP64_QUATERNION_LIST[i].x1 || diff --git a/basic-geometry-test/tests/quaternion/quaternion_is_unit.c b/basic-geometry-test/tests/quaternion/quaternion_is_unit.c index 594ce1e..8b37f97 100644 --- a/basic-geometry-test/tests/quaternion/quaternion_is_unit.c +++ b/basic-geometry-test/tests/quaternion/quaternion_is_unit.c @@ -7,45 +7,45 @@ static const int _TEST_FP32_UNIT_QUATERNION_AMOUNT = 16; 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 }, { 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_EPSYLON_FP32, 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_EPSYLON_FP32, 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_EPSYLON_FP32, 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_EPSYLON_FP32 }, + { 1.0f + 0.75f * BGC_FP32_EPSYLON, 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_FP32_EPSYLON, 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_FP32_EPSYLON, 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_FP32_EPSYLON }, + { 0.0f, 0.0f, 0.0f, 1.0f - 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.5f - 0.75f * BGC_EPSYLON_FP32, 0.5f, 0.5f }, - { 0.5f, 0.5f, 0.5f + 0.75f * BGC_EPSYLON_FP32, 0.5f }, - { 0.5f, 0.5f, 0.5f, 0.5f - 0.75f * BGC_EPSYLON_FP32 } + { 0.5f + 0.75f * BGC_FP32_EPSYLON, 0.5f, 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_FP32_EPSYLON, 0.5f }, + { 0.5f, 0.5f, 0.5f, 0.5f - 0.75f * BGC_FP32_EPSYLON } }; -static const BgcQuaternionFP32 _TEST_FP32_NONUNIT_QUATERION_LIST[] = { - { 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, - { 1.0f - 1.25f * BGC_EPSYLON_FP32, 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_EPSYLON_FP32, 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_EPSYLON_FP32, 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_EPSYLON_FP32 }, - { 0.5f + 1.25f * BGC_EPSYLON_FP32, 0.5f + 1.25f * BGC_EPSYLON_FP32, 0.5f, 0.5f }, - { 0.5f - 1.25f * BGC_EPSYLON_FP32, 0.5f - 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.5f } +static const BGC_FP32_Quaternion _TEST_FP32_NONUNIT_QUATERION_LIST[] = { + { 1.0f + 1.25f * BGC_FP32_EPSYLON, 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_FP32_EPSYLON, 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_FP32_EPSYLON, 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_FP32_EPSYLON }, + { 0.0f, 0.0f, 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON }, + { 0.5f + 1.25f * BGC_FP32_EPSYLON, 0.5f + 1.25f * BGC_FP32_EPSYLON, 0.5f, 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() { - print_testing_name("bgc_quaternion_is_unit_fp32"); + print_testing_name("bgc_fp32_quaternion_is_unit"); // Testing zero values: 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"); return; } @@ -53,7 +53,7 @@ void test_quaternion_is_unit_fp32() // Testing non-zero values: 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"); 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_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 }, { 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_EPSYLON_FP64, 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_EPSYLON_FP64, 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_EPSYLON_FP64, 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_EPSYLON_FP64 }, + { 1.0 + 0.75 * BGC_FP64_EPSYLON, 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_FP64_EPSYLON, 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_FP64_EPSYLON, 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_FP64_EPSYLON }, + { 0.0, 0.0, 0.0, 1.0 - 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.5 - 0.75 * BGC_EPSYLON_FP64, 0.5, 0.5 }, - { 0.5, 0.5, 0.5 + 0.75 * BGC_EPSYLON_FP64, 0.5 }, - { 0.5, 0.5, 0.5, 0.5 - 0.75 * BGC_EPSYLON_FP64 } + { 0.5 + 0.75 * BGC_FP64_EPSYLON, 0.5, 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_FP64_EPSYLON, 0.5 }, + { 0.5, 0.5, 0.5, 0.5 - 0.75 * BGC_FP64_EPSYLON } }; -static const BgcQuaternionFP64 _TEST_FP64_NONUNIT_QUATERION_LIST[] = { - { 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, - { 1.0 - 1.25 * BGC_EPSYLON_FP64, 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_EPSYLON_FP64, 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_EPSYLON_FP64, 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_EPSYLON_FP64 }, - { 0.5 + 1.25 * BGC_EPSYLON_FP64, 0.5 + 1.25 * BGC_EPSYLON_FP64, 0.5, 0.5 }, - { 0.5 - 1.25 * BGC_EPSYLON_FP64, 0.5 - 1.25 * BGC_EPSYLON_FP64, 0.0, 0.5 } +static const BGC_FP64_Quaternion _TEST_FP64_NONUNIT_QUATERION_LIST[] = { + { 1.0 + 1.25 * BGC_FP64_EPSYLON, 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_FP64_EPSYLON, 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_FP64_EPSYLON, 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_FP64_EPSYLON }, + { 0.0, 0.0, 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON }, + { 0.5 + 1.25 * BGC_FP64_EPSYLON, 0.5 + 1.25 * BGC_FP64_EPSYLON, 0.5, 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() { - print_testing_name("bgc_quaternion_is_unit_fp64"); + print_testing_name("bgc_fp64_quaternion_is_unit"); // Testing zero values: 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"); return; } @@ -113,7 +113,7 @@ void test_quaternion_is_unit_fp64() // Testing non-zero values: 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"); return; } diff --git a/basic-geometry-test/tests/quaternion/quaternion_is_zero.c b/basic-geometry-test/tests/quaternion/quaternion_is_zero.c index 416802a..ca02131 100644 --- a/basic-geometry-test/tests/quaternion/quaternion_is_zero.c +++ b/basic-geometry-test/tests/quaternion/quaternion_is_zero.c @@ -7,39 +7,39 @@ static const int _TEST_FP32_ZERO_QUATERNION_AMOUNT = 9; 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.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, - { -0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, - { 0.0f, 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, - { 0.0f, -0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, - { 0.0f, 0.0f, 0.75f * BGC_EPSYLON_FP32, 0.0f }, - { 0.0f, 0.0f, -0.75f * BGC_EPSYLON_FP32, 0.0f }, - { 0.0f, 0.0f, 0.0f, 0.75f * BGC_EPSYLON_FP32 }, - { 0.0f, 0.0f, 0.0f, -0.75f * BGC_EPSYLON_FP32 } + { 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f }, + { -0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f }, + { 0.0f, 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f }, + { 0.0f, -0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f }, + { 0.0f, 0.0f, 0.75f * BGC_FP32_EPSYLON, 0.0f }, + { 0.0f, 0.0f, -0.75f * BGC_FP32_EPSYLON, 0.0f }, + { 0.0f, 0.0f, 0.0f, 0.75f * BGC_FP32_EPSYLON }, + { 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 }, - { 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, - { -1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, - { 0.0f, 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, - { 0.0f, -1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, - { 0.0f, 0.0f, 1.25f * BGC_EPSYLON_FP32, 0.0f }, - { 0.0f, 0.0f, -1.25f * BGC_EPSYLON_FP32, 0.0f }, - { 0.0f, 0.0f, 0.0f, 1.25f * BGC_EPSYLON_FP32 }, - { 0.0f, 0.0f, 0.0f, -1.25f * BGC_EPSYLON_FP32 }, - { 1.25f * BGC_EPSYLON_FP32, 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, - { -1.25f * BGC_EPSYLON_FP32, -1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f } + { 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f }, + { -1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f }, + { 0.0f, 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f }, + { 0.0f, -1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f }, + { 0.0f, 0.0f, 1.25f * BGC_FP32_EPSYLON, 0.0f }, + { 0.0f, 0.0f, -1.25f * BGC_FP32_EPSYLON, 0.0f }, + { 0.0f, 0.0f, 0.0f, 1.25f * BGC_FP32_EPSYLON }, + { 0.0f, 0.0f, 0.0f, -1.25f * BGC_FP32_EPSYLON }, + { 1.25f * BGC_FP32_EPSYLON, 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f }, + { -1.25f * BGC_FP32_EPSYLON, -1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f } }; 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: 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"); return; } @@ -47,7 +47,7 @@ void test_quaternion_is_zero_fp32() // Testing non-zero values: 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"); 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_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.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, - { -0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, - { 0.0, 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }, - { 0.0, -0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }, - { 0.0, 0.0, 0.75 * BGC_EPSYLON_FP64, 0.0 }, - { 0.0, 0.0, -0.75 * BGC_EPSYLON_FP64, 0.0 }, - { 0.0, 0.0, 0.0, 0.75 * BGC_EPSYLON_FP64 }, - { 0.0, 0.0, 0.0, -0.75 * BGC_EPSYLON_FP64 } + { 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 }, + { -0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 }, + { 0.0, 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 }, + { 0.0, -0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 }, + { 0.0, 0.0, 0.75 * BGC_FP64_EPSYLON, 0.0 }, + { 0.0, 0.0, -0.75 * BGC_FP64_EPSYLON, 0.0 }, + { 0.0, 0.0, 0.0, 0.75 * BGC_FP64_EPSYLON }, + { 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 }, - { 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, - { -1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, - { 0.0, 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }, - { 0.0, -1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }, - { 0.0, 0.0, 1.25 * BGC_EPSYLON_FP64, 0.0 }, - { 0.0, 0.0, -1.25 * BGC_EPSYLON_FP64, 0.0 }, - { 0.0, 0.0, 0.0, 1.25 * BGC_EPSYLON_FP64 }, - { 0.0, 0.0, 0.0, -1.25 * BGC_EPSYLON_FP64 }, - { 1.25 * BGC_EPSYLON_FP64, 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }, - { -1.25 * BGC_EPSYLON_FP64, -1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 } + { 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 }, + { -1.25 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 }, + { 0.0, 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 }, + { 0.0, -1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 }, + { 0.0, 0.0, 1.25 * BGC_FP64_EPSYLON, 0.0 }, + { 0.0, 0.0, -1.25 * BGC_FP64_EPSYLON, 0.0 }, + { 0.0, 0.0, 0.0, 1.25 * BGC_FP64_EPSYLON }, + { 0.0, 0.0, 0.0, -1.25 * BGC_FP64_EPSYLON }, + { 1.25 * BGC_FP64_EPSYLON, 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 }, + { -1.25 * BGC_FP64_EPSYLON, -1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 } }; 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: 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"); return; } @@ -101,7 +101,7 @@ void test_quaternion_is_zero_fp64() // Testing non-zero values: 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"); return; } diff --git a/basic-geometry-test/tests/quaternion/quaternion_modulus.c b/basic-geometry-test/tests/quaternion/quaternion_modulus.c index 5d6b4e6..042bd7c 100644 --- a/basic-geometry-test/tests/quaternion/quaternion_modulus.c +++ b/basic-geometry-test/tests/quaternion/quaternion_modulus.c @@ -6,7 +6,7 @@ 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 }, { -1.0f, 1.0f, -1.0f, 1.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() { - 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++) { - 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(); return; } @@ -43,10 +43,10 @@ void test_quaternion_square_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++) { - 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(); return; } @@ -59,7 +59,7 @@ void test_quaternion_modulus_fp32() 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 }, { -1.0, 1.0, -1.0, 1.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() { - 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++) { - 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(); return; } @@ -96,10 +96,10 @@ void test_quaternion_square_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++) { - 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(); return; } diff --git a/basic-geometry-test/tests/quaternion/quaternion_reset.c b/basic-geometry-test/tests/quaternion/quaternion_reset.c index 62db061..91b9908 100644 --- a/basic-geometry-test/tests/quaternion/quaternion_reset.c +++ b/basic-geometry-test/tests/quaternion/quaternion_reset.c @@ -4,11 +4,11 @@ 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) { print_testing_failed(); @@ -20,11 +20,11 @@ void test_quaternion_reset_fp32() 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) { print_testing_failed(); diff --git a/basic-geometry-test/tests/quaternion/quaternion_set_to_identity.c b/basic-geometry-test/tests/quaternion/quaternion_set_to_identity.c index 36d6766..8ce85a7 100644 --- a/basic-geometry-test/tests/quaternion/quaternion_set_to_identity.c +++ b/basic-geometry-test/tests/quaternion/quaternion_set_to_identity.c @@ -2,13 +2,13 @@ #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) { print_testing_failed(); @@ -18,13 +18,13 @@ void test_quaternion_set_to_identity_fp32() 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) { print_testing_failed(); @@ -36,6 +36,6 @@ void test_quaternion_set_to_identity_fp64() void test_quaternion_set_to_identity() { - test_quaternion_set_to_identity_fp32(); - test_quaternion_set_to_identity_fp64(); + test_quaternion_make_unit_fp32(); + test_quaternion_make_unit_fp64(); } diff --git a/basic-geometry-test/tests/quaternion/quaternion_set_to_identity.h b/basic-geometry-test/tests/quaternion/quaternion_set_to_identity.h index 53bc58f..53bb12e 100644 --- a/basic-geometry-test/tests/quaternion/quaternion_set_to_identity.h +++ b/basic-geometry-test/tests/quaternion/quaternion_set_to_identity.h @@ -1,9 +1,9 @@ #ifndef _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(); diff --git a/basic-geometry-test/tests/quaternion/quaternion_set_values.c b/basic-geometry-test/tests/quaternion/quaternion_set_values.c index 0164ad5..45cf3c1 100644 --- a/basic-geometry-test/tests/quaternion/quaternion_set_values.c +++ b/basic-geometry-test/tests/quaternion/quaternion_set_values.c @@ -8,25 +8,25 @@ 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) { print_testing_error("First step failed"); 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) { print_testing_error("Second step failed"); 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) { print_testing_error("Third step failed"); @@ -40,25 +40,25 @@ void test_quaternion_set_values_fp32() 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) { print_testing_error("First step failed"); 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) { print_testing_error("Second step failed"); 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) { print_testing_error("Third step failed"); diff --git a/basic-geometry-test/tests/quaternion/quaternion_swap.c b/basic-geometry-test/tests/quaternion/quaternion_swap.c index dad3269..1648404 100644 --- a/basic-geometry-test/tests/quaternion/quaternion_swap.c +++ b/basic-geometry-test/tests/quaternion/quaternion_swap.c @@ -8,14 +8,14 @@ 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 }, { -4.0f, -3.0f, -2.0f, -1.0f }, { -244.8f, 100.0f, -100.0f, 344.7f }, { 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 }, { 204.07f, -781.89f, -0.0032f, 891.3f }, { -20.02f, -1.0003f, 5.322f, 0.9275f }, @@ -24,15 +24,15 @@ static const BgcQuaternionFP32 _TEST_FP32_QUATERNION_LIST2[] = { 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++) { - bgc_quaternion_copy_fp32(&_TEST_FP32_QUATERNION_LIST1[i], &quaternion1); - bgc_quaternion_copy_fp32(&_TEST_FP32_QUATERNION_LIST2[i], &quaternion2); + bgc_fp32_quaternion_copy(&_TEST_FP32_QUATERNION_LIST1[i], &quaternion1); + 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 || 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 BgcQuaternionFP64 _TEST_FP64_QUATERNION_LIST1[] = { +static const BGC_FP64_Quaternion _TEST_FP64_QUATERNION_LIST1[] = { { 1.0, 2.0, 3.0, 4.0 }, { -4.0, -3.0, -2.0, -1.0 }, { -244.8, 100.0, -100.0, 344.7 }, { 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 }, { 204.07, -781.89, -0.0032, 891.3 }, { -20.02, -1.0003, 5.322, 0.9275 }, @@ -70,15 +70,15 @@ static const BgcQuaternionFP64 _TEST_FP64_QUATERNION_LIST2[] = { 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++) { - bgc_quaternion_copy_fp64(&_TEST_FP64_QUATERNION_LIST1[i], &quaternion1); - bgc_quaternion_copy_fp64(&_TEST_FP64_QUATERNION_LIST2[i], &quaternion2); + bgc_fp64_quaternion_copy(&_TEST_FP64_QUATERNION_LIST1[i], &quaternion1); + 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 || quaternion1.x1 != _TEST_FP64_QUATERNION_LIST2[i].x1 || diff --git a/basic-geometry-test/tests/utilities/are_close.c b/basic-geometry-test/tests/utilities/are_close.c index d35dcbe..f94b5c2 100644 --- a/basic-geometry-test/tests/utilities/are_close.c +++ b/basic-geometry-test/tests/utilities/are_close.c @@ -12,22 +12,22 @@ static const TestNumberPairFP32 _TEST_FP32_DATA_CLOSE[] = { {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_EPSYLON_FP32}, - {1.0f + 0.75f * BGC_EPSYLON_FP32, 1.0f}, - {1.0f - 0.75f * BGC_EPSYLON_FP32, 1.0f}, + {1.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON}, + {1.0f, 1.0f - 0.75f * BGC_FP32_EPSYLON}, + {1.0f + 0.75f * BGC_FP32_EPSYLON, 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_EPSYLON_FP32}, - {-1.0f + 0.75f * BGC_EPSYLON_FP32, -1.0f}, - {-1.0f - 0.75f * BGC_EPSYLON_FP32, -1.0f}, + {-1.0f, -1.0f + 0.75f * BGC_FP32_EPSYLON}, + {-1.0f, -1.0f - 0.75f * BGC_FP32_EPSYLON}, + {-1.0f + 0.75f * BGC_FP32_EPSYLON, -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_EPSYLON_FP32)}, - {-100.0f, -100.0f * (1.0f + 0.75f * BGC_EPSYLON_FP32)}, - {-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_FP32_EPSYLON)}, + {-100.0f, -100.0f * (1.0f + 0.75f * BGC_FP32_EPSYLON)}, + {-100.0f, -100.0f * (1.0f - 0.75f * BGC_FP32_EPSYLON)} }; 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}, - {-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_EPSYLON_FP32}, - {1.0f + 1.25f * BGC_EPSYLON_FP32, 1.0f}, - {1.0f - 1.25f * BGC_EPSYLON_FP32, 1.0f}, + {1.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON}, + {1.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON}, + {1.0f + 1.25f * BGC_FP32_EPSYLON, 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_EPSYLON_FP32}, - {-1.0f + 1.25f * BGC_EPSYLON_FP32, -1.0f}, - {-1.0f - 1.25f * BGC_EPSYLON_FP32, -1.0f}, + {-1.0f, -1.0f + 1.25f * BGC_FP32_EPSYLON}, + {-1.0f, -1.0f - 1.25f * BGC_FP32_EPSYLON}, + {-1.0f + 1.25f * BGC_FP32_EPSYLON, -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_EPSYLON_FP32)}, - {-100.0f, -100.0f * (1.0f + 1.25f * BGC_EPSYLON_FP32)}, - {-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_FP32_EPSYLON)}, + {-100.0f, -100.0f * (1.0f + 1.25f * BGC_FP32_EPSYLON)}, + {-100.0f, -100.0f * (1.0f - 1.25f * BGC_FP32_EPSYLON)} }; void test_are_close_fp32() { - print_testing_name("bgc_are_close_fp32"); + print_testing_name("bgc_fp32_are_close"); // Testing close pairs of values: 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"); return; } @@ -67,7 +67,7 @@ void test_are_close_fp32() // Testing different pairs of values: 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"); return; } @@ -86,22 +86,22 @@ static const TestNumberPairFP64 _TEST_FP64_DATA_CLOSE[] = { {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_EPSYLON_FP64}, - {1.0 + 0.75 * BGC_EPSYLON_FP64, 1.0}, - {1.0 - 0.75 * BGC_EPSYLON_FP64, 1.0}, + {1.0, 1.0 + 0.75 * BGC_FP64_EPSYLON}, + {1.0, 1.0 - 0.75 * BGC_FP64_EPSYLON}, + {1.0 + 0.75 * BGC_FP64_EPSYLON, 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_EPSYLON_FP64}, - {-1.0 + 0.75 * BGC_EPSYLON_FP64, -1.0}, - {-1.0 - 0.75 * BGC_EPSYLON_FP64, -1.0}, + {-1.0, -1.0 + 0.75 * BGC_FP64_EPSYLON}, + {-1.0, -1.0 - 0.75 * BGC_FP64_EPSYLON}, + {-1.0 + 0.75 * BGC_FP64_EPSYLON, -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_EPSYLON_FP64)}, - {-100.0, -100.0 * (1.0 + 0.75 * BGC_EPSYLON_FP64)}, - {-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_FP64_EPSYLON)}, + {-100.0, -100.0 * (1.0 + 0.75 * BGC_FP64_EPSYLON)}, + {-100.0, -100.0 * (1.0 - 0.75 * BGC_FP64_EPSYLON)} }; 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}, - {-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_EPSYLON_FP64}, - {1.0 + 1.25 * BGC_EPSYLON_FP64, 1.0}, - {1.0 - 1.25 * BGC_EPSYLON_FP64, 1.0}, + {1.0, 1.0 + 1.25 * BGC_FP64_EPSYLON}, + {1.0, 1.0 - 1.25 * BGC_FP64_EPSYLON}, + {1.0 + 1.25 * BGC_FP64_EPSYLON, 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_EPSYLON_FP64}, - {-1.0 + 1.25 * BGC_EPSYLON_FP64, -1.0}, - {-1.0 - 1.25 * BGC_EPSYLON_FP64, -1.0}, + {-1.0, -1.0 + 1.25 * BGC_FP64_EPSYLON}, + {-1.0, -1.0 - 1.25 * BGC_FP64_EPSYLON}, + {-1.0 + 1.25 * BGC_FP64_EPSYLON, -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_EPSYLON_FP64)}, - {-100.0, -100.0 * (1.0 + 1.25 * BGC_EPSYLON_FP64)}, - {-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_FP64_EPSYLON)}, + {-100.0, -100.0 * (1.0 + 1.25 * BGC_FP64_EPSYLON)}, + {-100.0, -100.0 * (1.0 - 1.25 * BGC_FP64_EPSYLON)} }; void test_are_close_fp64() { - print_testing_name("bgc_are_close_fp64"); + print_testing_name("bgc_fp64_are_close"); // Testing close pairs of values: 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"); return; } @@ -141,7 +141,7 @@ void test_are_close_fp64() // Testing different pairs of values: 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"); return; } diff --git a/basic-geometry-test/tests/utilities/is_unit.c b/basic-geometry-test/tests/utilities/is_unit.c index 49e30d4..763b727 100644 --- a/basic-geometry-test/tests/utilities/is_unit.c +++ b/basic-geometry-test/tests/utilities/is_unit.c @@ -9,24 +9,24 @@ static const int _TEST_FP32_NONUNIT_NUMBERS_AMOUNT = 4; static const float _TEST_FP32_UNIT_NUMBERS[] = { 1.0f, - 1.0f + 0.75f * BGC_EPSYLON_FP32, - 1.0f - 0.75f * BGC_EPSYLON_FP32 + 1.0f + 0.75f * BGC_FP32_EPSYLON, + 1.0f - 0.75f * BGC_FP32_EPSYLON }; static const float _TEST_FP32_NONUNIT_NUMBERS[] = { 0.0f, -1.0f, - 1.0f + 1.25f * BGC_EPSYLON_FP32, - 1.0f - 1.25f * BGC_EPSYLON_FP32 + 1.0f + 1.25f * BGC_FP32_EPSYLON, + 1.0f - 1.25f * BGC_FP32_EPSYLON }; void test_is_unit_fp32() { - print_testing_name("bgc_is_unit_fp32"); + print_testing_name("bgc_fp32_is_unit"); // Testing unit values: 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"); return; } @@ -34,7 +34,7 @@ void test_is_unit_fp32() // Testing non-unit values: 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"); return; } @@ -50,24 +50,24 @@ static const int _TEST_FP64_NONUNIT_NUMBERS_AMOUNT = 4; static const double _TEST_FP64_UNIT_NUMBERS[] = { 1.0, - 1.0 + 0.75 * BGC_EPSYLON_FP64, - 1.0 - 0.75 * BGC_EPSYLON_FP64 + 1.0 + 0.75 * BGC_FP64_EPSYLON, + 1.0 - 0.75 * BGC_FP64_EPSYLON }; static const double _TEST_FP64_NONUNIT_NUMBERS[] = { 0.0, -1.0, - 1.0 + 1.25 * BGC_EPSYLON_FP64, - 1.0 - 1.25 * BGC_EPSYLON_FP64 + 1.0 + 1.25 * BGC_FP64_EPSYLON, + 1.0 - 1.25 * BGC_FP64_EPSYLON }; void test_is_unit_fp64() { - print_testing_name("bgc_is_unit_fp64"); + print_testing_name("bgc_fp64_is_unit"); // Testing unit values: 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"); return; } @@ -75,7 +75,7 @@ void test_is_unit_fp64() // Testing non-unit values: 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"); return; } @@ -91,24 +91,24 @@ static const int _TEST_FP32_DATA_SQUARE_NONUNIT_AMOUNT = 4; static const float _TEST_FP32_DATA_SQUARE_UNIT[] = { 1.0f, - 1.0f + 1.75f * BGC_EPSYLON_FP32, - 1.0f - 1.75f * BGC_EPSYLON_FP32 + 1.0f + 1.75f * BGC_FP32_EPSYLON, + 1.0f - 1.75f * BGC_FP32_EPSYLON }; static const float _TEST_FP32_DATA_SQUARE_NONUNIT[] = { 0.0f, -1.0f, - 1.0f + 2.25f * BGC_EPSYLON_FP32, - 1.0f - 2.25f * BGC_EPSYLON_FP32 + 1.0f + 2.25f * BGC_FP32_EPSYLON, + 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: 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"); return; } @@ -116,7 +116,7 @@ void test_is_sqare_unit_fp32() // Testing non-unit values: 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"); return; } @@ -132,24 +132,24 @@ static const int _TEST_FP64_DATA_SQUARE_NONUNIT_AMOUNT = 4; static const double _TEST_FP64_DATA_SQUARE_UNIT[] = { 1.0, - 1.0 + 1.75 * BGC_EPSYLON_FP64, - 1.0 - 1.75 * BGC_EPSYLON_FP64 + 1.0 + 1.75 * BGC_FP64_EPSYLON, + 1.0 - 1.75 * BGC_FP64_EPSYLON }; static const double _TEST_FP64_DATA_SQUARE_NONUNIT[] = { 0.0, -1.0, - 1.0 + 2.25 * BGC_EPSYLON_FP64, - 1.0 - 2.25 * BGC_EPSYLON_FP64 + 1.0 + 2.25 * BGC_FP64_EPSYLON, + 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: 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"); return; } @@ -157,7 +157,7 @@ void test_is_sqare_unit_fp64() // Testing non-unit values: 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"); return; } @@ -171,6 +171,6 @@ void test_is_unit() test_is_unit_fp32(); test_is_unit_fp64(); - test_is_sqare_unit_fp32(); - test_is_sqare_unit_fp64(); + test_is_square_unit_fp32(); + test_is_square_unit_fp64(); } diff --git a/basic-geometry-test/tests/utilities/is_unit.h b/basic-geometry-test/tests/utilities/is_unit.h index 83e404d..945e5f5 100644 --- a/basic-geometry-test/tests/utilities/is_unit.h +++ b/basic-geometry-test/tests/utilities/is_unit.h @@ -5,9 +5,9 @@ void test_is_unit_fp32(); 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(); diff --git a/basic-geometry-test/tests/utilities/is_zero.c b/basic-geometry-test/tests/utilities/is_zero.c index 06c8473..b85b2d4 100644 --- a/basic-geometry-test/tests/utilities/is_zero.c +++ b/basic-geometry-test/tests/utilities/is_zero.c @@ -9,24 +9,24 @@ static const int _TEST_FP32_NONZERO_NUMBERS_AMOUNT = 4; static const float _TEST_FP32_ZERO_NUMBERS[] = { 0.0f, - 0.75f * BGC_EPSYLON_FP32, - -0.75f * BGC_EPSYLON_FP32 + 0.75f * BGC_FP32_EPSYLON, + -0.75f * BGC_FP32_EPSYLON }; static const float _TEST_FP32_NONZERO_NUMBERS[] = { 1.0f, -1.0f, - 1.25f * BGC_EPSYLON_FP32, - -1.25f * BGC_EPSYLON_FP32 + 1.25f * BGC_FP32_EPSYLON, + -1.25f * BGC_FP32_EPSYLON }; void test_is_zero_fp32() { - print_testing_name("bgc_is_zero_fp32"); + print_testing_name("bgc_fp32_is_zero"); // Testing zero values: 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"); return; } @@ -34,7 +34,7 @@ void test_is_zero_fp32() // Testing non-zero values: 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"); return; } @@ -50,24 +50,24 @@ static const int _TEST_FP64_NONZERO_NUMBERS_AMOUNT = 4; static const double _TEST_FP64_ZERO_NUMBERS[] = { 0.0, - 0.75 * BGC_EPSYLON_FP64, - -0.75 * BGC_EPSYLON_FP64 + 0.75 * BGC_FP64_EPSYLON, + -0.75 * BGC_FP64_EPSYLON }; static const double _TEST_FP64_NONZERO_NUMBERS[] = { 1.0, -1.0, - 1.25 * BGC_EPSYLON_FP64, - -1.25 * BGC_EPSYLON_FP64 + 1.25 * BGC_FP64_EPSYLON, + -1.25 * BGC_FP64_EPSYLON }; void test_is_zero_fp64() { - print_testing_name("bgc_is_zero_fp64"); + print_testing_name("bgc_fp64_is_zero"); // Testing zero values: 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"); return; } @@ -75,7 +75,7 @@ void test_is_zero_fp64() // Testing non-zero values: 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"); return; } diff --git a/basic-geometry-test/tests/vector2.c b/basic-geometry-test/tests/vector2.c index 66915b7..f699ba8 100644 --- a/basic-geometry-test/tests/vector2.c +++ b/basic-geometry-test/tests/vector2.c @@ -22,7 +22,7 @@ void test_vector2() 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 }, { 10000.0f, -20000.0f }, @@ -30,7 +30,7 @@ const BgcVector2FP32 TEST_FP32_VECTOR2_COMMON_1[] = { { -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 }, { 0.002f, -0.05f }, @@ -49,7 +49,7 @@ int test_vector2_fp32_square_modulus() float square_modulus; 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])) { print_testing_failed(); @@ -72,7 +72,7 @@ int test_vector2_fp32_modulus() float square_modulus; 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])) { print_testing_failed(); @@ -86,7 +86,7 @@ int test_vector2_fp32_modulus() // ===================== 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 }, { -6.0f, -8.0f }, { 10000.002f, -20000.05f }, @@ -98,10 +98,10 @@ int test_vector2_add_fp32() { print_testing_name("vector2_fp32_t add"); - BgcVector2FP32 vector; + BGC_FP32_Vector2 vector; 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) || !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 ================== // -const BgcVector2FP32 TEST_FP32_VECTOR2_COMMON_1_2_DIFF[] = { +const BGC_FP32_Vector2 TEST_FP32_VECTOR2_COMMON_1_2_DIFF[] = { { 6.0f, 8.0f }, { 0.0f, 0.0f }, { 9999.998f, -19999.95f }, @@ -128,10 +128,10 @@ int test_vector2_subtract_fp32() { print_testing_name("vector2_fp32_t subtract"); - BgcVector2FP32 vector; + BGC_FP32_Vector2 vector; 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) || !test_are_equal_fp32(vector.x2, TEST_FP32_VECTOR2_COMMON_1_2_DIFF[i].x2)) { diff --git a/basic-geometry-test/tests/vector2/vector2_copy.c b/basic-geometry-test/tests/vector2/vector2_copy.c index d6f463f..0639aea 100644 --- a/basic-geometry-test/tests/vector2/vector2_copy.c +++ b/basic-geometry-test/tests/vector2/vector2_copy.c @@ -7,7 +7,7 @@ // ==================== FP32 ==================== // 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 }, { -2.0f, -1.0f }, { 100.0f, -100.0f }, @@ -16,13 +16,13 @@ static const BgcVector2FP32 _TEST_FP32_VECTOR2_LIST[] = { 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++) { - 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) { print_testing_failed(); @@ -36,7 +36,7 @@ void test_vector2_copy_fp32() // ==================== FP64 ==================== // 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 }, { -2.0, -1.0 }, { 100.0, -100.0 }, @@ -45,13 +45,13 @@ static const BgcVector2FP64 _TEST_FP64_VECTOR2_LIST[] = { 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++) { - 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) { print_testing_failed(); diff --git a/basic-geometry-test/tests/vector2/vector2_is_unit.c b/basic-geometry-test/tests/vector2/vector2_is_unit.c index 4876bbf..d8f91bb 100644 --- a/basic-geometry-test/tests/vector2/vector2_is_unit.c +++ b/basic-geometry-test/tests/vector2/vector2_is_unit.c @@ -7,32 +7,32 @@ static const int _TEST_FP32_UNIT_VECTOR2_AMOUNT = 6; 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 }, { 0.0f, -1.0f }, - { 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f }, - { 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f }, - { 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32 }, - { 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32 } + { 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f }, + { 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f }, + { 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON }, + { 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 }, - { 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f }, - { 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f }, - { 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32 }, - { 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32 }, - { 0.8f + 1.25f * BGC_EPSYLON_FP32, 0.6f + 1.25f * BGC_EPSYLON_FP32 }, - { 0.6f - 1.25f * BGC_EPSYLON_FP32, 0.8f - 1.25f * BGC_EPSYLON_FP32 } + { 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f }, + { 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f }, + { 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON }, + { 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON }, + { 0.8f + 1.25f * BGC_FP32_EPSYLON, 0.6f + 1.25f * BGC_FP32_EPSYLON }, + { 0.6f - 1.25f * BGC_FP32_EPSYLON, 0.8f - 1.25f * BGC_FP32_EPSYLON } }; 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: 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"); return; } @@ -40,7 +40,7 @@ void test_vector2_is_unit_fp32() // Testing non-zero values: 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"); 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_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 }, { 0.0, 1.0 }, - { 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0 }, - { 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0 }, - { 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64 }, - { 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64 } + { 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0 }, + { 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0 }, + { 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON }, + { 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 }, - { 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0 }, - { 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0 }, - { 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64 }, - { 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64 }, - { 0.6 + 1.25 * BGC_EPSYLON_FP64, 0.8 + 1.25 * BGC_EPSYLON_FP64 }, - { 0.8 - 1.25 * BGC_EPSYLON_FP64, 0.6 - 1.25 * BGC_EPSYLON_FP64 } + { 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0 }, + { 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0 }, + { 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON }, + { 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON }, + { 0.6 + 1.25 * BGC_FP64_EPSYLON, 0.8 + 1.25 * BGC_FP64_EPSYLON }, + { 0.8 - 1.25 * BGC_FP64_EPSYLON, 0.6 - 1.25 * BGC_FP64_EPSYLON } }; 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: 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"); return; } @@ -87,7 +87,7 @@ void test_vector2_is_unit_fp64() // Testing non-zero values: 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"); return; } diff --git a/basic-geometry-test/tests/vector2/vector2_is_zero.c b/basic-geometry-test/tests/vector2/vector2_is_zero.c index c189b98..7545e6a 100644 --- a/basic-geometry-test/tests/vector2/vector2_is_zero.c +++ b/basic-geometry-test/tests/vector2/vector2_is_zero.c @@ -7,31 +7,31 @@ static const int _TEST_FP32_ZERO_VECTOR2_AMOUNT = 5; 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.75f * BGC_EPSYLON_FP32, 0.0f }, - { -0.75f * BGC_EPSYLON_FP32, 0.0f }, - { 0.0f, 0.75f * BGC_EPSYLON_FP32 }, - { 0.0f, -0.75f * BGC_EPSYLON_FP32 } + { 0.75f * BGC_FP32_EPSYLON, 0.0f }, + { -0.75f * BGC_FP32_EPSYLON, 0.0f }, + { 0.0f, 0.75f * BGC_FP32_EPSYLON }, + { 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 }, - { 1.25f * BGC_EPSYLON_FP32, 0.0f }, - { -1.25f * BGC_EPSYLON_FP32, 0.0f }, - { 0.0f, 1.25f * BGC_EPSYLON_FP32 }, - { 0.0f, -1.25f * BGC_EPSYLON_FP32 }, - { 1.25f * BGC_EPSYLON_FP32, 1.25f * BGC_EPSYLON_FP32 }, - { -1.25f * BGC_EPSYLON_FP32, -1.25f * BGC_EPSYLON_FP32 } + { 1.25f * BGC_FP32_EPSYLON, 0.0f }, + { -1.25f * BGC_FP32_EPSYLON, 0.0f }, + { 0.0f, 1.25f * BGC_FP32_EPSYLON }, + { 0.0f, -1.25f * BGC_FP32_EPSYLON }, + { 1.25f * BGC_FP32_EPSYLON, 1.25f * BGC_FP32_EPSYLON }, + { -1.25f * BGC_FP32_EPSYLON, -1.25f * BGC_FP32_EPSYLON } }; 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: 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"); return; } @@ -39,7 +39,7 @@ void test_vector2_is_zero_fp32() // Testing non-zero values: 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"); 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_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.75 * BGC_EPSYLON_FP64, 0.0 }, - { -0.75 * BGC_EPSYLON_FP64, 0.0 }, - { 0.0, 0.75 * BGC_EPSYLON_FP64 }, - { 0.0, -0.75 * BGC_EPSYLON_FP64 } + { 0.75 * BGC_FP64_EPSYLON, 0.0 }, + { -0.75 * BGC_FP64_EPSYLON, 0.0 }, + { 0.0, 0.75 * BGC_FP64_EPSYLON }, + { 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 }, - { 1.25 * BGC_EPSYLON_FP64, 0.0 }, - { -1.25 * BGC_EPSYLON_FP64, 0.0 }, - { 0.0, 1.25 * BGC_EPSYLON_FP64 }, - { 0.0, -1.25 * BGC_EPSYLON_FP64 }, - { 1.25 * BGC_EPSYLON_FP64, 1.25 * BGC_EPSYLON_FP64 }, - { -1.25 * BGC_EPSYLON_FP64, -1.25 * BGC_EPSYLON_FP64 } + { 1.25 * BGC_FP64_EPSYLON, 0.0 }, + { -1.25 * BGC_FP64_EPSYLON, 0.0 }, + { 0.0, 1.25 * BGC_FP64_EPSYLON }, + { 0.0, -1.25 * BGC_FP64_EPSYLON }, + { 1.25 * BGC_FP64_EPSYLON, 1.25 * BGC_FP64_EPSYLON }, + { -1.25 * BGC_FP64_EPSYLON, -1.25 * BGC_FP64_EPSYLON } }; 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: 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"); return; } @@ -85,7 +85,7 @@ void test_vector2_is_zero_fp64() // Testing non-zero values: 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"); return; } diff --git a/basic-geometry-test/tests/vector2/vector2_modulus.c b/basic-geometry-test/tests/vector2/vector2_modulus.c index 63f13d5..6e0b842 100644 --- a/basic-geometry-test/tests/vector2/vector2_modulus.c +++ b/basic-geometry-test/tests/vector2/vector2_modulus.c @@ -6,7 +6,7 @@ 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 }, { -3.0f, -4.0f }, { 100.0f, -100.0f }, @@ -29,10 +29,10 @@ static const float _TEST_FP32_MODULUS_LIST[] = { 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++) { - 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(); return; } @@ -43,10 +43,10 @@ void test_vector2_square_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++) { - 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(); return; } @@ -59,7 +59,7 @@ void test_vector2_modulus_fp32() 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 }, { -3.0, -4.0 }, { 100.0, -100.0 }, @@ -82,10 +82,10 @@ static const double _TEST_FP64_MODULUS_LIST[] = { 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++) { - 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(); return; } @@ -96,10 +96,10 @@ void test_vector2_square_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++) { - 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(); return; } diff --git a/basic-geometry-test/tests/vector2/vector2_reset.c b/basic-geometry-test/tests/vector2/vector2_reset.c index 04b1e15..f5e2bab 100644 --- a/basic-geometry-test/tests/vector2/vector2_reset.c +++ b/basic-geometry-test/tests/vector2/vector2_reset.c @@ -4,11 +4,11 @@ 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) { print_testing_failed(); @@ -20,11 +20,11 @@ void test_vector2_reset_fp32() 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) { print_testing_failed(); diff --git a/basic-geometry-test/tests/vector2/vector2_set_values.c b/basic-geometry-test/tests/vector2/vector2_set_values.c index 80ec5c3..9933d09 100644 --- a/basic-geometry-test/tests/vector2/vector2_set_values.c +++ b/basic-geometry-test/tests/vector2/vector2_set_values.c @@ -8,25 +8,25 @@ 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) { print_testing_error("First step failed"); 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) { print_testing_error("Second step failed"); 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) { print_testing_error("Third step failed"); @@ -40,26 +40,26 @@ void test_vector2_set_values_fp32() 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) { print_testing_error("First step failed"); 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) { print_testing_error("Second step failed"); 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) { print_testing_error("Third step failed"); diff --git a/basic-geometry-test/tests/vector2/vector2_swap.c b/basic-geometry-test/tests/vector2/vector2_swap.c index c40494f..9eeada2 100644 --- a/basic-geometry-test/tests/vector2/vector2_swap.c +++ b/basic-geometry-test/tests/vector2/vector2_swap.c @@ -8,14 +8,14 @@ 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 }, { -2.0f, -1.0f }, { 100.0f, -100.0f }, { -100.1f, 100.2f } }; -static const BgcVector2FP32 _TEST_FP32_VECTOR2_LIST2[] = { +static const BGC_FP32_Vector2 _TEST_FP32_VECTOR2_LIST2[] = { { 3.6f, 5.3f }, { 204.07f, -781.89f }, { -20.02f, -1.0003f }, @@ -24,15 +24,15 @@ static const BgcVector2FP32 _TEST_FP32_VECTOR2_LIST2[] = { 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++) { - bgc_vector2_copy_fp32(&_TEST_FP32_VECTOR2_LIST1[i], &vector1); - bgc_vector2_copy_fp32(&_TEST_FP32_VECTOR2_LIST2[i], &vector2); + bgc_fp32_vector2_copy(&_TEST_FP32_VECTOR2_LIST1[i], &vector1); + 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 || 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 BgcVector2FP64 _TEST_FP64_VECTOR2_LIST1[] = { +static const BGC_FP64_Vector2 _TEST_FP64_VECTOR2_LIST1[] = { { 1.0, 2.0 }, { -2.0, -1.0 }, { 100.0, -100.0 }, { -100.1, 100.2 } }; -static const BgcVector2FP64 _TEST_FP64_VECTOR2_LIST2[] = { +static const BGC_FP64_Vector2 _TEST_FP64_VECTOR2_LIST2[] = { { 3.6, 5.3 }, { 204.07, -781.89 }, { -20.02, -1.0003 }, @@ -66,15 +66,15 @@ static const BgcVector2FP64 _TEST_FP64_VECTOR2_LIST2[] = { 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++) { - bgc_vector2_copy_fp64(&_TEST_FP64_VECTOR2_LIST1[i], &vector1); - bgc_vector2_copy_fp64(&_TEST_FP64_VECTOR2_LIST2[i], &vector2); + bgc_fp64_vector2_copy(&_TEST_FP64_VECTOR2_LIST1[i], &vector1); + 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 || vector1.x2 != _TEST_FP64_VECTOR2_LIST2[i].x2 || diff --git a/basic-geometry-test/tests/vector3/vector3_copy.c b/basic-geometry-test/tests/vector3/vector3_copy.c index 38562d9..f4ea248 100644 --- a/basic-geometry-test/tests/vector3/vector3_copy.c +++ b/basic-geometry-test/tests/vector3/vector3_copy.c @@ -7,7 +7,7 @@ // ==================== FP32 ==================== // 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 }, { -3.0f, -2.0f, -1.0f }, { 100.0f, -100.0f, 0.001f }, @@ -16,13 +16,13 @@ static const BgcVector3FP32 _TEST_FP32_VECTOR3_LIST[] = { 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++) { - 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 || vector.x2 != _TEST_FP32_VECTOR3_LIST[i].x2 || @@ -38,7 +38,7 @@ void test_vector3_copy_fp32() // ==================== FP64 ==================== // 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 }, { -3.0, -2.0, -1.0 }, { 100.0, -100.0, 0.001 }, @@ -47,13 +47,13 @@ static const BgcVector3FP64 _TEST_FP64_VECTOR3_LIST[] = { 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++) { - 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 || vector.x2 != _TEST_FP64_VECTOR3_LIST[i].x2 || diff --git a/basic-geometry-test/tests/vector3/vector3_is_unit.c b/basic-geometry-test/tests/vector3/vector3_is_unit.c index 97972e5..3500d32 100644 --- a/basic-geometry-test/tests/vector3/vector3_is_unit.c +++ b/basic-geometry-test/tests/vector3/vector3_is_unit.c @@ -7,38 +7,38 @@ static const int _TEST_FP32_UNIT_VECTOR3_AMOUNT = 10; 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 }, { 0.0f, -1.0f, 0.0f }, { 0.0f, -0.8f, 0.6f }, { -0.6f, 0.0f, 0.8f }, - { 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, - { 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, - { 0.0f, -1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f }, - { 0.0f, -1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f }, - { 0.0f, 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32 }, - { 0.0f, 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32 } + { 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f }, + { 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f }, + { 0.0f, -1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f }, + { 0.0f, -1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f }, + { 0.0f, 0.0f, 1.0f + 0.75f * BGC_FP32_EPSYLON }, + { 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 }, - { 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, - { 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, - { 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f }, - { 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f }, - { 0.0f, 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32 }, - { 0.0f, 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32 }, - { 0.8f + 1.25f * BGC_EPSYLON_FP32, -0.6f - 1.25f * BGC_EPSYLON_FP32, 0.0f }, - { 0.6f - 1.25f * BGC_EPSYLON_FP32, -0.8f + 1.25f * BGC_EPSYLON_FP32, 0.0f } + { 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f }, + { 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f }, + { 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON, 0.0f }, + { 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON, 0.0f }, + { 0.0f, 0.0f, 1.0f + 1.25f * BGC_FP32_EPSYLON }, + { 0.0f, 0.0f, 1.0f - 1.25f * BGC_FP32_EPSYLON }, + { 0.8f + 1.25f * BGC_FP32_EPSYLON, -0.6f - 1.25f * BGC_FP32_EPSYLON, 0.0f }, + { 0.6f - 1.25f * BGC_FP32_EPSYLON, -0.8f + 1.25f * BGC_FP32_EPSYLON, 0.0f } }; 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: 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"); return; } @@ -46,7 +46,7 @@ void test_vector3_is_unit_fp32() // Testing non-zero values: 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"); 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_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 }, { 0.0, -1.0, 0.0 }, { 0.0, -0.8, 0.6 }, { -0.6, 0.0, 0.8 }, - { 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }, - { 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }, - { 0.0, -1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0 }, - { 0.0, -1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0 }, - { 0.0, 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64 }, - { 0.0, 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64 } + { 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 }, + { 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 }, + { 0.0, -1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0 }, + { 0.0, -1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0 }, + { 0.0, 0.0, 1.0 + 0.75 * BGC_FP64_EPSYLON }, + { 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 }, - { 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }, - { 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }, - { 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0 }, - { 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0 }, - { 0.0, 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64 }, - { 0.0, 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64 }, - { 0.8 + 1.25 * BGC_EPSYLON_FP64, -0.6 - 1.25 * BGC_EPSYLON_FP64, 0.0 }, - { 0.6 - 1.25 * BGC_EPSYLON_FP64, -0.8 + 1.25 * BGC_EPSYLON_FP64, 0.0 } + { 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 }, + { 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 }, + { 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON, 0.0 }, + { 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON, 0.0 }, + { 0.0, 0.0, 1.0 + 1.25 * BGC_FP64_EPSYLON }, + { 0.0, 0.0, 1.0 - 1.25 * BGC_FP64_EPSYLON }, + { 0.8 + 1.25 * BGC_FP64_EPSYLON, -0.6 - 1.25 * BGC_FP64_EPSYLON, 0.0 }, + { 0.6 - 1.25 * BGC_FP64_EPSYLON, -0.8 + 1.25 * BGC_FP64_EPSYLON, 0.0 } }; 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: 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"); return; } @@ -99,7 +99,7 @@ void test_vector3_is_unit_fp64() // Testing non-zero values: 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"); return; } diff --git a/basic-geometry-test/tests/vector3/vector3_is_zero.c b/basic-geometry-test/tests/vector3/vector3_is_zero.c index e7b03c4..97247aa 100644 --- a/basic-geometry-test/tests/vector3/vector3_is_zero.c +++ b/basic-geometry-test/tests/vector3/vector3_is_zero.c @@ -7,35 +7,35 @@ static const int _TEST_FP32_ZERO_VECTOR3_AMOUNT = 7; 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.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, - { -0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, - { 0.0f, 0.75f * BGC_EPSYLON_FP32, 0.0f }, - { 0.0f, -0.75f * BGC_EPSYLON_FP32, 0.0f }, - { 0.0f, 0.0f, 0.75f * BGC_EPSYLON_FP32 }, - { 0.0f, 0.0f, -0.75f * BGC_EPSYLON_FP32 } + { 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f }, + { -0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f }, + { 0.0f, 0.75f * BGC_FP32_EPSYLON, 0.0f }, + { 0.0f, -0.75f * BGC_FP32_EPSYLON, 0.0f }, + { 0.0f, 0.0f, 0.75f * BGC_FP32_EPSYLON }, + { 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 }, - { 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, - { -1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, - { 0.0f, 1.25f * BGC_EPSYLON_FP32, 0.0f }, - { 0.0f, -1.25f * BGC_EPSYLON_FP32, 0.0f }, - { 0.0f, 0.0f, 1.25f * BGC_EPSYLON_FP32 }, - { 0.0f, 0.0f, -1.25f * BGC_EPSYLON_FP32 }, - { 1.25f * BGC_EPSYLON_FP32, 1.25f * BGC_EPSYLON_FP32, 0.0f }, - { -1.25f * BGC_EPSYLON_FP32, -1.25f * BGC_EPSYLON_FP32, 0.0f } + { 1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f }, + { -1.25f * BGC_FP32_EPSYLON, 0.0f, 0.0f }, + { 0.0f, 1.25f * BGC_FP32_EPSYLON, 0.0f }, + { 0.0f, -1.25f * BGC_FP32_EPSYLON, 0.0f }, + { 0.0f, 0.0f, 1.25f * BGC_FP32_EPSYLON }, + { 0.0f, 0.0f, -1.25f * BGC_FP32_EPSYLON }, + { 1.25f * BGC_FP32_EPSYLON, 1.25f * BGC_FP32_EPSYLON, 0.0f }, + { -1.25f * BGC_FP32_EPSYLON, -1.25f * BGC_FP32_EPSYLON, 0.0f } }; 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: 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"); return; } @@ -43,7 +43,7 @@ void test_vector3_is_zero_fp32() // Testing non-zero values: 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"); 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_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.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }, - { -0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }, - { 0.0, 0.75 * BGC_EPSYLON_FP64, 0.0 }, - { 0.0, -0.75 * BGC_EPSYLON_FP64, 0.0 }, - { 0.0, 0.0, 0.75 * BGC_EPSYLON_FP64 }, - { 0.0, 0.0, -0.75 * BGC_EPSYLON_FP64 } + { 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 }, + { -0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 }, + { 0.0, 0.75 * BGC_FP64_EPSYLON, 0.0 }, + { 0.0, -0.75 * BGC_FP64_EPSYLON, 0.0 }, + { 0.0, 0.0, 0.75 * BGC_FP64_EPSYLON }, + { 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 }, - { 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }, - { -1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }, - { 0.0, 1.25 * BGC_EPSYLON_FP64, 0.0 }, - { 0.0, -1.25 * BGC_EPSYLON_FP64, 0.0 }, - { 0.0, 0.0, 1.25 * BGC_EPSYLON_FP64 }, - { 0.0, 0.0, -1.25 * BGC_EPSYLON_FP64 }, - { 1.25 * BGC_EPSYLON_FP64, 1.25 * BGC_EPSYLON_FP64, 0.0 }, - { -BGC_EPSYLON_FP64, -BGC_EPSYLON_FP64, 0.0 } + { 1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 }, + { -1.25 * BGC_FP64_EPSYLON, 0.0, 0.0 }, + { 0.0, 1.25 * BGC_FP64_EPSYLON, 0.0 }, + { 0.0, -1.25 * BGC_FP64_EPSYLON, 0.0 }, + { 0.0, 0.0, 1.25 * BGC_FP64_EPSYLON }, + { 0.0, 0.0, -1.25 * BGC_FP64_EPSYLON }, + { 1.25 * BGC_FP64_EPSYLON, 1.25 * BGC_FP64_EPSYLON, 0.0 }, + { -BGC_FP64_EPSYLON, -BGC_FP64_EPSYLON, 0.0 } }; 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: 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"); return; } @@ -93,7 +93,7 @@ void test_vector3_is_zero_fp64() // Testing non-zero values: 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"); return; } diff --git a/basic-geometry-test/tests/vector3/vector3_modulus.c b/basic-geometry-test/tests/vector3/vector3_modulus.c index c080032..55a1a4b 100644 --- a/basic-geometry-test/tests/vector3/vector3_modulus.c +++ b/basic-geometry-test/tests/vector3/vector3_modulus.c @@ -6,7 +6,7 @@ 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 }, { 0.0f, -3.0f, -4.0f }, { 100.0f, -100.0f, 100.0f }, @@ -29,10 +29,10 @@ static const float _TEST_FP32_MODULUS_LIST[] = { 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++) { - 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(); return; } @@ -43,10 +43,10 @@ void test_vector3_square_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++) { - 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(); return; } @@ -59,7 +59,7 @@ void test_vector3_modulus_fp32() 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 }, { -3.0, 0.0, -4.0 }, { 100.0, -100.0, 100.0 }, @@ -82,10 +82,10 @@ static const double _TEST_FP64_MODULUS_LIST[] = { 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++) { - 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(); return; } @@ -96,10 +96,10 @@ void test_vector3_square_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++) { - 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(); return; } diff --git a/basic-geometry-test/tests/vector3/vector3_reset.c b/basic-geometry-test/tests/vector3/vector3_reset.c index 5a1ee00..21f06d5 100644 --- a/basic-geometry-test/tests/vector3/vector3_reset.c +++ b/basic-geometry-test/tests/vector3/vector3_reset.c @@ -4,11 +4,11 @@ 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) { print_testing_failed(); @@ -20,11 +20,11 @@ void test_vector3_reset_fp32() 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) { print_testing_failed(); diff --git a/basic-geometry-test/tests/vector3/vector3_set_values.c b/basic-geometry-test/tests/vector3/vector3_set_values.c index 5d0363b..617bcdb 100644 --- a/basic-geometry-test/tests/vector3/vector3_set_values.c +++ b/basic-geometry-test/tests/vector3/vector3_set_values.c @@ -8,25 +8,25 @@ 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) { print_testing_error("First step failed"); 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) { print_testing_error("Second step failed"); 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) { print_testing_error("Third step failed"); @@ -40,26 +40,26 @@ void test_vector3_set_values_fp32() 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) { print_testing_error("First step failed"); 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) { print_testing_error("Second step failed"); 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) { print_testing_error("Third step failed"); diff --git a/basic-geometry-test/tests/vector3/vector3_swap.c b/basic-geometry-test/tests/vector3/vector3_swap.c index 9c7705d..6573bae 100644 --- a/basic-geometry-test/tests/vector3/vector3_swap.c +++ b/basic-geometry-test/tests/vector3/vector3_swap.c @@ -8,14 +8,14 @@ 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 }, { -3.0f, -2.0f, -1.0f }, { 100.0f, -100.0f, 344.7f }, { -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 }, { 204.07f, -781.89f, 891.3f }, { -20.02f, -1.0003f, 0.9275f }, @@ -24,15 +24,15 @@ static const BgcVector3FP32 _TEST_FP32_VECTOR3_LIST2[] = { 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++) { - bgc_vector3_copy_fp32(&_TEST_FP32_VECTOR3_LIST1[i], &vector1); - bgc_vector3_copy_fp32(&_TEST_FP32_VECTOR3_LIST2[i], &vector2); + bgc_fp32_vector3_copy(&_TEST_FP32_VECTOR3_LIST1[i], &vector1); + 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 || 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 BgcVector3FP64 _TEST_FP64_VECTOR3_LIST1[] = { +static const BGC_FP64_Vector3 _TEST_FP64_VECTOR3_LIST1[] = { { 1.0, 2.0, 3.0 }, { -3.0, -2.0, -1.0 }, { 100.0, -100.0, 344.7 }, { -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 }, { 204.07, -781.89, 891.3 }, { -20.02, -1.0003, 0.9275 }, @@ -68,15 +68,15 @@ static const BgcVector3FP64 _TEST_FP64_VECTOR3_LIST2[] = { 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++) { - bgc_vector3_copy_fp64(&_TEST_FP64_VECTOR3_LIST1[i], &vector1); - bgc_vector3_copy_fp64(&_TEST_FP64_VECTOR3_LIST2[i], &vector2); + bgc_fp64_vector3_copy(&_TEST_FP64_VECTOR3_LIST1[i], &vector1); + 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 || vector1.x2 != _TEST_FP64_VECTOR3_LIST2[i].x2 || diff --git a/basic-geometry-test/tests/versor/versor_are_close.c b/basic-geometry-test/tests/versor/versor_are_close.c index 312c795..acf9e14 100644 --- a/basic-geometry-test/tests/versor/versor_are_close.c +++ b/basic-geometry-test/tests/versor/versor_are_close.c @@ -9,35 +9,35 @@ static const int _TEST_FP32_CLOSE_VERSOR_PAIR_AMOUNT = 10; static const TestVersorPairFP32 _TEST_FP32_CLOSE_VERSOR_PAIR_LIST[] = { { { 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.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.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.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.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.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.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.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 }, @@ -54,35 +54,35 @@ static const int _TEST_FP32_DIFFERENT_VERSOR_PAIR_AMOUNT = 10; static const TestVersorPairFP32 _TEST_FP32_DIFFERENT_VERSOR_PAIR_LIST[] = { { { 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 - 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 + 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 - 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 + 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 - 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 + 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 - 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 }, @@ -96,11 +96,11 @@ static const TestVersorPairFP32 _TEST_FP32_DIFFERENT_VERSOR_PAIR_LIST[] = { 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: 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"); return; } @@ -108,7 +108,7 @@ void test_versor_are_close_fp32() // Testing different pairs of versors: 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"); return; } @@ -125,35 +125,35 @@ static const int _TEST_FP64_CLOSE_VERSOR_PAIR_AMOUNT = 10; static const TestVersorPairFP64 _TEST_FP64_CLOSE_VERSOR_PAIR_LIST[] = { { { 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.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.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.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.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.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.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.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 }, @@ -170,35 +170,35 @@ static const int _TEST_FP64_DIFFERENT_VERSOR_PAIR_AMOUNT = 10; static const TestVersorPairFP64 _TEST_FP64_DIFFERENT_VERSOR_PAIR_LIST[] = { { { 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 - 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 + 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 - 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 + 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 - 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 + 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 - 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 }, @@ -212,11 +212,11 @@ static const TestVersorPairFP64 _TEST_FP64_DIFFERENT_VERSOR_PAIR_LIST[] = { 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: 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"); return; } @@ -224,7 +224,7 @@ void test_versor_are_close_fp64() // Testing different pairs of versors: 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"); return; } diff --git a/basic-geometry-test/tests/versor/versor_combine.c b/basic-geometry-test/tests/versor/versor_combine.c index 443f2a2..830e880 100644 --- a/basic-geometry-test/tests/versor/versor_combine.c +++ b/basic-geometry-test/tests/versor/versor_combine.c @@ -38,14 +38,14 @@ static const TestVersorTripletFP32 _TEST_FP32_VERSOR_TRIPLET_LIST[] = { 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++) { - 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(); return; } @@ -88,14 +88,14 @@ static const TestVersorTripletFP64 _TEST_FP64_VERSOR_TRIPLET_LIST[] = { 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++) { - 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(); return; } diff --git a/basic-geometry-test/tests/versor/versor_copy.c b/basic-geometry-test/tests/versor/versor_copy.c index e424869..74a2bb2 100644 --- a/basic-geometry-test/tests/versor/versor_copy.c +++ b/basic-geometry-test/tests/versor/versor_copy.c @@ -7,7 +7,7 @@ // ==================== FP32 ==================== // 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 }, { 0.182574185835f, 0.36514837167f, 0.54772255751f, 0.73029674334f }, @@ -20,13 +20,13 @@ static const BgcVersorFP32 _TEST_FP32_VERSOR_LIST[] = { 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++) { - 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 || versor._x1 != _TEST_FP32_VERSOR_LIST[i]._x1 || @@ -43,7 +43,7 @@ void test_versor_copy_fp32() // ==================== FP64 ==================== // 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 }, { 0.1825741858350553712, 0.3651483716701107423, 0.5477225575051661135, 0.7302967433402214846 }, @@ -56,13 +56,13 @@ static const BgcVersorFP64 _TEST_FP64_VERSOR_LIST[] = { 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++) { - 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 || versor._x1 != _TEST_FP64_VERSOR_LIST[i]._x1 || diff --git a/basic-geometry-test/tests/versor/versor_is_identity.c b/basic-geometry-test/tests/versor/versor_is_identity.c index 024bcf9..738f0f3 100644 --- a/basic-geometry-test/tests/versor/versor_is_identity.c +++ b/basic-geometry-test/tests/versor/versor_is_identity.c @@ -7,33 +7,33 @@ static const int _TEST_FP32_IDENTIYTY_VERSOR_AMOUNT = 9; 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.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, - { 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, - { 1.0f, 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, - { 1.0f, -0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, - { 1.0f, 0.0f, 0.75f * BGC_EPSYLON_FP32, 0.0f }, - { 1.0f, 0.0f, -0.75f * BGC_EPSYLON_FP32, 0.0f }, - { 1.0f, 0.0f, 0.0f, 0.75f * BGC_EPSYLON_FP32 }, - { 1.0f, 0.0f, 0.0f, -0.75f * BGC_EPSYLON_FP32 } + { 1.0f + 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f }, + { 1.0f - 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f, 0.0f }, + { 1.0f, 0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f }, + { 1.0f, -0.75f * BGC_FP32_EPSYLON, 0.0f, 0.0f }, + { 1.0f, 0.0f, 0.75f * BGC_FP32_EPSYLON, 0.0f }, + { 1.0f, 0.0f, -0.75f * BGC_FP32_EPSYLON, 0.0f }, + { 1.0f, 0.0f, 0.0f, 0.75f * BGC_FP32_EPSYLON }, + { 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, 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 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() { - print_testing_name("bgc_versor_is_identity_fp32"); + print_testing_name("bgc_fp32_versor_is_idle"); // Testing zero values: 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"); return; } @@ -41,7 +41,7 @@ void test_versor_is_identity_fp32() // Testing non-zero values: 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"); 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_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.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, - { 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, - { 1.0, -0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }, - { 1.0, 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 }, - { 1.0, 0.0, 0.75 * BGC_EPSYLON_FP64, 0.0 }, - { 1.0, 0.0, -0.75 * BGC_EPSYLON_FP64, 0.0 }, - { 1.0, 0.0, 0.0, 0.75 * BGC_EPSYLON_FP64 }, - { 1.0, 0.0, 0.0, -0.75 * BGC_EPSYLON_FP64 } + { 1.0 + 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 }, + { 1.0 - 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0, 0.0 }, + { 1.0, -0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 }, + { 1.0, 0.75 * BGC_FP64_EPSYLON, 0.0, 0.0 }, + { 1.0, 0.0, 0.75 * BGC_FP64_EPSYLON, 0.0 }, + { 1.0, 0.0, -0.75 * BGC_FP64_EPSYLON, 0.0 }, + { 1.0, 0.0, 0.0, 0.75 * BGC_FP64_EPSYLON }, + { 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, 0.0, 1.0, 0.0 }, { 0.0, 0.0, 0.0, 1.0 }, { 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() { - print_testing_name("bgc_versor_is_identity_fp64"); + print_testing_name("bgc_fp64_versor_is_idle"); // Testing zero values: 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"); return; } @@ -89,7 +89,7 @@ void test_versor_is_identity_fp64() // Testing non-zero values: 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"); return; } diff --git a/basic-geometry-test/tests/versor/versor_reset.c b/basic-geometry-test/tests/versor/versor_reset.c index 016f2d9..cc7e0c3 100644 --- a/basic-geometry-test/tests/versor/versor_reset.c +++ b/basic-geometry-test/tests/versor/versor_reset.c @@ -4,11 +4,11 @@ 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) { print_testing_failed(); @@ -20,11 +20,11 @@ void test_versor_reset_fp32() 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) { print_testing_failed(); diff --git a/basic-geometry-test/tests/versor/versor_set_values.c b/basic-geometry-test/tests/versor/versor_set_values.c index 0e108b4..4b051d1 100644 --- a/basic-geometry-test/tests/versor/versor_set_values.c +++ b/basic-geometry-test/tests/versor/versor_set_values.c @@ -7,7 +7,7 @@ // ==================== FP32 ==================== // 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 }, { 4.0f, 3.0f, 2.0f, 1.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() { 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++) { - bgc_versor_set_values_fp32( + bgc_fp32_versor_make( _TEST_FP32_VERSOR_DATA_LIST[i].s0, _TEST_FP32_VERSOR_DATA_LIST[i].x1, _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); - if (!bgc_is_unit_fp32(versor_module)) { + if (!bgc_fp32_is_unit(versor_module)) { print_testing_error("Versor module is not equal to one."); 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; } 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)."); 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)."); 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)."); return; } @@ -65,7 +65,7 @@ void test_versor_set_values_fp32() // ==================== FP64 ==================== // 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 }, { 4.0, 3.0, 2.0, 1.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() { 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++) { - bgc_versor_set_values_fp64( + bgc_fp64_versor_make( _TEST_FP64_VERSOR_DATA_LIST[i].s0, _TEST_FP64_VERSOR_DATA_LIST[i].x1, _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); - if (!bgc_is_unit_fp64(versor_module)) { + if (!bgc_fp64_is_unit(versor_module)) { print_testing_error("Versor module is not equal to one."); 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; } 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)."); 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)."); 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)."); return; } diff --git a/basic-geometry-test/tests/versor/versor_swap.c b/basic-geometry-test/tests/versor/versor_swap.c index 7abb862..b106bf6 100644 --- a/basic-geometry-test/tests/versor/versor_swap.c +++ b/basic-geometry-test/tests/versor/versor_swap.c @@ -8,13 +8,13 @@ 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 }, { -4.0f, -3.0f, -2.0f, -1.0f }, { 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 }, { -1.0f, -2.0f, -3.0f, -4.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() { - 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++) { - bgc_versor_set_values_fp32( + bgc_fp32_versor_make( _TEST_FP32_VERSOR_LIST1[i].s0, _TEST_FP32_VERSOR_LIST1[i].x1, _TEST_FP32_VERSOR_LIST1[i].x2, @@ -35,7 +35,7 @@ void test_versor_swap_fp32() &versor1a ); - bgc_versor_set_values_fp32( + bgc_fp32_versor_make( _TEST_FP32_VERSOR_LIST2[i].s0, _TEST_FP32_VERSOR_LIST2[i].x1, _TEST_FP32_VERSOR_LIST2[i].x2, @@ -43,10 +43,10 @@ void test_versor_swap_fp32() &versor2a ); - bgc_versor_copy_fp32(&versor1a, &versor1b); - bgc_versor_copy_fp32(&versor2a, &versor2b); + bgc_fp32_versor_copy(&versor1a, &versor1b); + 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 || 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() { - 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++) { - bgc_versor_set_values_fp64( + bgc_fp64_versor_make( _TEST_FP32_VERSOR_LIST1[i].s0, _TEST_FP32_VERSOR_LIST1[i].x1, _TEST_FP32_VERSOR_LIST1[i].x2, @@ -75,7 +75,7 @@ void test_versor_swap_fp64() &versor1a ); - bgc_versor_set_values_fp64( + bgc_fp64_versor_make( _TEST_FP32_VERSOR_LIST2[i].s0, _TEST_FP32_VERSOR_LIST2[i].x1, _TEST_FP32_VERSOR_LIST2[i].x2, @@ -83,10 +83,10 @@ void test_versor_swap_fp64() &versor2a ); - bgc_versor_copy_fp64(&versor1a, &versor1b); - bgc_versor_copy_fp64(&versor2a, &versor2b); + bgc_fp64_versor_copy(&versor1a, &versor1b); + 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 || versor2a._s0 != versor1b._s0 || versor2a._x1 != versor1b._x1 || versor2a._x2 != versor1b._x2 || versor2a._x3 != versor1b._x3) { diff --git a/basic-geometry/affine2.c b/basic-geometry/affine2.c index a9d325f..de4c7c5 100644 --- a/basic-geometry/affine2.c +++ b/basic-geometry/affine2.c @@ -1,28 +1,31 @@ #include "affine2.h" -extern inline void bgc_affine2_reset_fp32(BgcAffine2FP32 * affine); -extern inline void bgc_affine2_reset_fp64(BgcAffine2FP64 * affine); +extern inline void bgc_fp32_affine2_reset(BGC_FP32_Affine2 * 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_affine2_make_fp64(const BgcMatrix2x2FP64 * distortion, const BgcVector2FP64 * shift, BgcAffine2FP64 * 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_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_affine2_copy_fp64(const BgcAffine2FP64 * source, BgcAffine2FP64 * destination); +extern inline void bgc_fp32_affine2_copy(const BGC_FP32_Affine2 * source, BGC_FP32_Affine2 * 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_affine2_convert_fp32_to_fp64(const BgcAffine2FP32 * source, BgcAffine2FP64 * destination); +extern inline void bgc_fp32_affine2_swap(BGC_FP32_Affine2 * first, BGC_FP32_Affine2 * second); +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 int bgc_affine2_invert_fp64(BgcAffine2FP64 * affine); +extern inline void bgc_fp64_affine2_convert_to_fp32(const BGC_FP64_Affine2 * source, BGC_FP32_Affine2 * destination); +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_affine2_get_inverse_fp64(const BgcAffine2FP64 * source, BgcAffine2FP64 * destination); +extern inline int bgc_fp32_affine2_invert(BGC_FP32_Affine2 * affine); +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 void bgc_affine2_combine_fp64(const BgcAffine2FP64 * first, const BgcAffine2FP64 * second, BgcAffine2FP64 * combination); +extern inline int bgc_fp32_affine2_get_inverse(const BGC_FP32_Affine2 * source, BGC_FP32_Affine2 * destination); +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_affine2_transform_point_fp64(const BgcAffine2FP64 * affine, const BgcVector2FP64 * initial_point, BgcVector2FP64 * 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_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_affine2_transform_vector_fp64(const BgcAffine2FP64 * affine, const BgcVector2FP64 * initial_vector, BgcVector2FP64 * 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_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); diff --git a/basic-geometry/affine2.h b/basic-geometry/affine2.h index be0aaf5..abc9172 100644 --- a/basic-geometry/affine2.h +++ b/basic-geometry/affine2.h @@ -8,168 +8,182 @@ // ==================== Types ==================== // typedef struct { - BgcMatrix2x2FP32 distortion; - BgcVector2FP32 shift; -} BgcAffine2FP32; + BGC_FP32_Matrix2x2 distortion; + BGC_FP32_Vector2 shift; +} BGC_FP32_Affine2; typedef struct { - BgcMatrix2x2FP64 distortion; - BgcVector2FP64 shift; -} BgcAffine2FP64; + BGC_FP64_Matrix2x2 distortion; + BGC_FP64_Vector2 shift; +} BGC_FP64_Affine2; // ==================== 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_vector2_reset_fp32(&affine->shift); + bgc_fp32_matrix2x2_make_identity(&affine->distortion); + 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_vector2_reset_fp64(&affine->shift); + bgc_fp64_matrix2x2_make_identity(&affine->distortion); + bgc_fp64_vector2_reset(&affine->shift); } // ==================== 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_vector2_copy_fp32(shift, &affine->shift); + bgc_fp32_matrix2x2_copy(distortion, &affine->distortion); + 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_vector2_copy_fp64(shift, &affine->shift); + bgc_fp64_matrix2x2_copy(distortion, &affine->distortion); + bgc_fp64_vector2_copy(shift, &affine->shift); } // ==================== 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_vector2_copy_fp32(&source->shift, &destination->shift); + bgc_fp32_matrix2x2_copy(&source->distortion, &destination->distortion); + 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_vector2_copy_fp64(&source->shift, &destination->shift); + bgc_fp64_matrix2x2_copy(&source->distortion, &destination->distortion); + 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 =================== // -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_vector2_convert_fp64_to_fp32(&source->shift, &destination->shift); + bgc_fp64_matrix2x2_convert_to_fp32(&source->distortion, &destination->distortion); + 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_vector2_convert_fp32_to_fp64(&source->shift, &destination->shift); + bgc_fp32_matrix2x2_convert_to_fp64(&source->distortion, &destination->distortion); + bgc_fp32_vector2_convert_to_fp64(&source->shift, &destination->shift); } // =================== 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; } - bgc_matrix2x2_get_right_product_fp32(&affine->distortion, &affine->shift, &affine->shift); - bgc_vector2_make_opposite_fp32(&affine->shift); + bgc_fp32_multiply_matrix2x2_by_vector2(&affine->distortion, &affine->shift, &affine->shift); + bgc_fp32_vector2_revert(&affine->shift); 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; } - bgc_matrix2x2_get_right_product_fp64(&affine->distortion, &affine->shift, &affine->shift); - bgc_vector2_make_opposite_fp64(&affine->shift); + bgc_fp64_multiply_matrix2x2_by_vector2(&affine->distortion, &affine->shift, &affine->shift); + bgc_fp64_vector2_revert(&affine->shift); return 1; } // ================= 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; } - bgc_matrix2x2_get_right_product_fp32(&destination->distortion, &source->shift, &destination->shift); - bgc_vector2_make_opposite_fp32(&destination->shift); + bgc_fp32_multiply_matrix2x2_by_vector2(&destination->distortion, &source->shift, &destination->shift); + bgc_fp32_vector2_revert(&destination->shift); 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; } - bgc_matrix2x2_get_right_product_fp64(&destination->distortion, &source->shift, &destination->shift); - bgc_vector2_make_opposite_fp64(&destination->shift); + bgc_fp64_multiply_matrix2x2_by_vector2(&destination->distortion, &source->shift, &destination->shift); + bgc_fp64_vector2_revert(&destination->shift); return 1; } // =================== 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_matrix2x2_get_right_product_fp32(&second->distortion, &first->shift, &first_shift); - bgc_matrix_product_2x2_at_2x2_fp32(&second->distortion, &first->distortion, &combination->distortion); - bgc_vector2_add_fp32(&first_shift, &second->shift, &combination->shift); + BGC_FP32_Vector2 first_shift; + bgc_fp32_multiply_matrix2x2_by_vector2(&second->distortion, &first->shift, &first_shift); + bgc_fp32_multiply_matrix2x2_by_matrix2x2(&second->distortion, &first->distortion, &combination->distortion); + 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_matrix2x2_get_right_product_fp64(&second->distortion, &first->shift, &first_shift); - bgc_matrix_product_2x2_at_2x2_fp64(&second->distortion, &first->distortion, &combination->distortion); - bgc_vector2_add_fp64(&first_shift, &second->shift, &combination->shift); + BGC_FP64_Vector2 first_shift; + bgc_fp64_multiply_matrix2x2_by_vector2(&second->distortion, &first->shift, &first_shift); + bgc_fp64_multiply_matrix2x2_by_matrix2x2(&second->distortion, &first->distortion, &combination->distortion); + bgc_fp64_vector2_add(&first_shift, &second->shift, &combination->shift); } // =============== 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_matrix2x2_get_right_product_fp32(&affine->distortion, initial_point, &distorted); - bgc_vector2_add_fp32(&affine->shift, &distorted, transformed_point); + BGC_FP32_Vector2 distorted; + bgc_fp32_multiply_matrix2x2_by_vector2(&affine->distortion, initial_point, &distorted); + 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_matrix2x2_get_right_product_fp64(&affine->distortion, initial_point, &distorted); - bgc_vector2_add_fp64(&affine->shift, &distorted, transformed_point); + BGC_FP64_Vector2 distorted; + bgc_fp64_multiply_matrix2x2_by_vector2(&affine->distortion, initial_point, &distorted); + bgc_fp64_vector2_add(&affine->shift, &distorted, transformed_point); } // ============== 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 diff --git a/basic-geometry/affine3.c b/basic-geometry/affine3.c index 8f4940f..e540320 100644 --- a/basic-geometry/affine3.c +++ b/basic-geometry/affine3.c @@ -1,28 +1,31 @@ #include "affine3.h" -extern inline void bgc_affine3_reset_fp32(BgcAffine3FP32 * affine); -extern inline void bgc_affine3_reset_fp64(BgcAffine3FP64 * affine); +extern inline void bgc_fp32_affine3_reset(BGC_FP32_Affine3 * 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_affine3_make_fp64(const BgcMatrix3x3FP64 * distortion, const BgcVector3FP64 * shift, BgcAffine3FP64 * 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_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_affine3_copy_fp64(const BgcAffine3FP64 * source, BgcAffine3FP64 * destination); +extern inline void bgc_fp32_affine3_copy(const BGC_FP32_Affine3 * source, BGC_FP32_Affine3 * 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_affine3_convert_fp32_to_fp64(const BgcAffine3FP32 * source, BgcAffine3FP64 * destination); +extern inline void bgc_fp32_affine3_swap(BGC_FP32_Affine3 * first, BGC_FP32_Affine3 * second); +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 int bgc_affine3_invert_fp64(BgcAffine3FP64 * affine); +extern inline void bgc_fp64_affine3_convert_to_fp32(const BGC_FP64_Affine3 * source, BGC_FP32_Affine3 * destination); +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_affine3_get_inverse_fp64(const BgcAffine3FP64 * source, BgcAffine3FP64 * destination); +extern inline int bgc_fp32_affine3_invert(BGC_FP32_Affine3 * affine); +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 void bgc_affine3_combine_fp64(const BgcAffine3FP64 * first, const BgcAffine3FP64 * second, BgcAffine3FP64 * combination); +extern inline int bgc_fp32_affine3_get_inverse(const BGC_FP32_Affine3 * source, BGC_FP32_Affine3 * destination); +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_affine3_transform_point_fp64(const BgcAffine3FP64 * affine, const BgcVector3FP64 * initial_point, BgcVector3FP64 * 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_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_affine3_transform_vector_fp64(const BgcAffine3FP64 * affine, const BgcVector3FP64 * initial_vector, BgcVector3FP64 * 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_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); diff --git a/basic-geometry/affine3.h b/basic-geometry/affine3.h index 71bbf0c..68b8b59 100644 --- a/basic-geometry/affine3.h +++ b/basic-geometry/affine3.h @@ -8,167 +8,181 @@ // ==================== Types ==================== // typedef struct { - BgcMatrix3x3FP32 distortion; - BgcVector3FP32 shift; -} BgcAffine3FP32; + BGC_FP32_Matrix3x3 distortion; + BGC_FP32_Vector3 shift; +} BGC_FP32_Affine3; typedef struct { - BgcMatrix3x3FP64 distortion; - BgcVector3FP64 shift; -} BgcAffine3FP64; + BGC_FP64_Matrix3x3 distortion; + BGC_FP64_Vector3 shift; +} BGC_FP64_Affine3; // ==================== 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_vector3_reset_fp32(&affine->shift); + bgc_fp32_matrix3x3_make_identity(&affine->distortion); + 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_vector3_reset_fp64(&affine->shift); + bgc_fp64_matrix3x3_make_identity(&affine->distortion); + bgc_fp64_vector3_reset(&affine->shift); } // ==================== 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_vector3_copy_fp32(shift, &affine->shift); + bgc_fp32_matrix3x3_copy(distortion, &affine->distortion); + 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_vector3_copy_fp64(shift, &affine->shift); + bgc_fp64_matrix3x3_copy(distortion, &affine->distortion); + bgc_fp64_vector3_copy(shift, &affine->shift); } // ==================== 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_vector3_copy_fp32(&source->shift, &destination->shift); + bgc_fp32_matrix3x3_copy(&source->distortion, &destination->distortion); + 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_vector3_copy_fp64(&source->shift, &destination->shift); + bgc_fp64_matrix3x3_copy(&source->distortion, &destination->distortion); + 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 =================== // -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_vector3_convert_fp64_to_fp32(&source->shift, &destination->shift); + bgc_fp64_matrix3x3_convert_to_fp32(&source->distortion, &destination->distortion); + 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_vector3_convert_fp32_to_fp64(&source->shift, &destination->shift); + bgc_fp32_matrix3x3_convert_to_fp64(&source->distortion, &destination->distortion); + bgc_fp32_vector3_convert_to_fp64(&source->shift, &destination->shift); } // =================== 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; } - bgc_matrix3x3_get_right_product_fp32(&affine->distortion, &affine->shift, &affine->shift); - bgc_vector3_make_opposite_fp32(&affine->shift); + bgc_fp32_multiply_matrix3x3_by_vector3(&affine->distortion, &affine->shift, &affine->shift); + bgc_fp32_vector3_revert(&affine->shift); 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; } - bgc_matrix3x3_get_right_product_fp64(&affine->distortion, &affine->shift, &affine->shift); - bgc_vector3_make_opposite_fp64(&affine->shift); + bgc_fp64_multiply_matrix3x3_by_vector3(&affine->distortion, &affine->shift, &affine->shift); + bgc_fp64_vector3_revert(&affine->shift); return 1; } // ================= 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; } - bgc_matrix3x3_get_right_product_fp32(&destination->distortion, &source->shift, &destination->shift); - bgc_vector3_make_opposite_fp32(&destination->shift); + bgc_fp32_multiply_matrix3x3_by_vector3(&destination->distortion, &source->shift, &destination->shift); + bgc_fp32_vector3_revert(&destination->shift); 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; } - bgc_matrix3x3_get_right_product_fp64(&destination->distortion, &source->shift, &destination->shift); - bgc_vector3_make_opposite_fp64(&destination->shift); + bgc_fp64_multiply_matrix3x3_by_vector3(&destination->distortion, &source->shift, &destination->shift); + bgc_fp64_vector3_revert(&destination->shift); return 1; } // =================== 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_matrix3x3_get_right_product_fp32(&second->distortion, &first->shift, &first_shift); - bgc_matrix_product_3x3_at_3x3_fp32(&second->distortion, &first->distortion, &combination->distortion); - bgc_vector3_add_fp32(&first_shift, &second->shift, &combination->shift); + BGC_FP32_Vector3 first_shift; + bgc_fp32_multiply_matrix3x3_by_vector3(&second->distortion, &first->shift, &first_shift); + bgc_fp32_multiply_matrix3x3_by_matrix3x3(&second->distortion, &first->distortion, &combination->distortion); + 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_matrix3x3_get_right_product_fp64(&second->distortion, &first->shift, &first_shift); - bgc_matrix_product_3x3_at_3x3_fp64(&second->distortion, &first->distortion, &combination->distortion); - bgc_vector3_add_fp64(&first_shift, &second->shift, &combination->shift); + BGC_FP64_Vector3 first_shift; + bgc_fp64_multiply_matrix3x3_by_vector3(&second->distortion, &first->shift, &first_shift); + bgc_fp64_multiply_matrix3x3_by_matrix3x3(&second->distortion, &first->distortion, &combination->distortion); + bgc_fp64_vector3_add(&first_shift, &second->shift, &combination->shift); } // =============== 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_matrix3x3_get_right_product_fp32(&affine->distortion, initial_point, &distorted); - bgc_vector3_add_fp32(&affine->shift, &distorted, transformed_point); + BGC_FP32_Vector3 distorted; + bgc_fp32_multiply_matrix3x3_by_vector3(&affine->distortion, initial_point, &distorted); + 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_matrix3x3_get_right_product_fp64(&affine->distortion, initial_point, &distorted); - bgc_vector3_add_fp64(&affine->shift, &distorted, transformed_point); + BGC_FP64_Vector3 distorted; + bgc_fp64_multiply_matrix3x3_by_vector3(&affine->distortion, initial_point, &distorted); + bgc_fp64_vector3_add(&affine->shift, &distorted, transformed_point); } // ============== 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 diff --git a/basic-geometry/angle.c b/basic-geometry/angle.c index ea18e61..2f9798f 100644 --- a/basic-geometry/angle.c +++ b/basic-geometry/angle.c @@ -3,65 +3,59 @@ // !================= Radians ==================! // -extern inline float bgc_radians_to_degrees_fp32(const float radians); -extern inline double bgc_radians_to_degrees_fp64(const double radians); +extern inline float bgc_fp32_radians_to_degrees(const float 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 double bgc_radians_to_turns_fp64(const double radians); +extern inline float bgc_fp32_radians_to_turns(const float 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 double bgc_radians_to_units_fp64(const double radians, const BgcAngleUnitEnum to_unit); +extern inline float bgc_fp32_radians_to_units(const float radians, const int angle_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 double bgc_radians_normalize_fp64(const double radians, const BgcAngleRangeEnum range); +extern inline float bgc_fp32_normalize_radians(const float radians, const int angle_range); +extern inline double bgc_fp64_normalize_radians(const double radians, const int angle_range); // !================= Degrees ==================! // -extern inline float bgc_degrees_to_radians_fp32(const float degrees); -extern inline double bgc_degrees_to_radians_fp64(const double degrees); +extern inline float bgc_fp32_degrees_to_radians(const float 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 double bgc_degrees_to_turns_fp64(const double radians); +extern inline float bgc_fp32_degrees_to_turns(const float 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 double bgc_degrees_to_units_fp64(const double degrees, const BgcAngleUnitEnum to_unit); +extern inline float bgc_fp32_degrees_to_units(const float degrees, const int angle_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 double bgc_degrees_normalize_fp64(const double degrees, const BgcAngleRangeEnum range); +extern inline float bgc_fp32_normalize_degrees(const float degrees, const int angle_range); +extern inline double bgc_fp64_degrees_normalize(const double degrees, const int angle_range); // !================== Turns ===================! // -extern inline float bgc_turns_to_radians_fp32(const float turns); -extern inline double bgc_turns_to_radians_fp64(const double turns); +extern inline float bgc_fp32_turns_to_radians(const float 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 double bgc_turns_to_degrees_fp64(const double turns); +extern inline float bgc_fp32_turns_to_degrees(const float 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 double bgc_turns_to_units_fp64(const double turns, const BgcAngleUnitEnum to_unit); +extern inline float bgc_fp32_turns_to_units(const float turns, const int angle_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 double bgc_turns_normalize_fp64(const double turns, const BgcAngleRangeEnum range); +extern inline float bgc_fp32_normalize_turns(const float turns, const int angle_range); +extern inline double bgc_fp64_normalize_turns(const double turns, const int angle_range); // !================== Angle ===================! // -extern inline float bgc_angle_to_radians_fp32(const float angle, const BgcAngleUnitEnum unit); -extern inline double bgc_angle_to_radians_fp64(const double angle, const BgcAngleUnitEnum unit); +extern inline float bgc_fp32_angle_to_radians(const float angle, const int angle_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 double bgc_angle_to_degrees_fp64(const double angle, const BgcAngleUnitEnum unit); +extern inline float bgc_fp32_angle_to_degrees(const float angle, const int angle_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 double bgc_angle_to_turns_fp64(const double angle, const BgcAngleUnitEnum unit); +extern inline float bgc_fp32_angle_to_turns(const float angle, const int angle_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 double bgc_angle_get_full_circle_fp64(const BgcAngleUnitEnum unit); +extern inline float bgc_fp32_full_circle(const int angle_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 double bgc_angle_get_half_circle_fp64(const BgcAngleUnitEnum unit); - -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); +extern inline float bgc_fp32_normalize_angle(const float angle, const int angle_unit, const int angle_range); +extern inline double bgc_fp64_normalize_angle(const double angle, const int angle_unit, const int angle_range); diff --git a/basic-geometry/angle.h b/basic-geometry/angle.h index 0c82af7..a50b599 100644 --- a/basic-geometry/angle.h +++ b/basic-geometry/angle.h @@ -4,99 +4,95 @@ #include #include "utilities.h" -#define BGC_PI_FP32 3.1415926536f -#define BGC_TWO_PI_FP32 6.2831853072f -#define BGC_HALF_OF_PI_FP32 1.5707963268f -#define BGC_THIRD_OF_PI_FP32 1.0471975512f -#define BGC_FOURTH_OF_PI_FP32 0.7853981634f -#define BGC_SIXTH_OF_PI_FP32 0.5235987756f +#define BGC_FP32_PI 3.1415926536f +#define BGC_FP32_TWO_PI 6.2831853072f +#define BGC_FP32_HALF_OF_PI 1.5707963268f +#define BGC_FP32_ONE_THIRD_OF_PI 1.0471975512f +#define BGC_FP32_ONE_FOURTH_OF_PI 0.7853981634f +#define BGC_FP32_ONE_SIXTH_OF_PI 0.5235987756f -#define BGC_DEGREES_IN_RADIAN_FP32 57.295779513f -#define BGC_TURNS_IN_RADIAN_FP32 0.1591549431f -#define BGC_RADIANS_IN_DEGREE_FP32 1.745329252E-2f -#define BGC_TURNS_IN_DEGREE_FP32 2.7777777778E-3f +#define BGC_FP32_DEGREES_IN_RADIAN 57.295779513f +#define BGC_FP32_TURNS_IN_RADIAN 0.1591549431f +#define BGC_FP32_RADIANS_IN_DEGREE 1.745329252E-2f +#define BGC_FP32_TURNS_IN_DEGREE 2.7777777778E-3f -#define BGC_PI_FP64 3.14159265358979324 -#define BGC_TWO_PI_FP64 6.28318530717958648 -#define BGC_HALF_OF_PI_FP64 1.57079632679489662 -#define BGC_THIRD_OF_PI_FP64 1.04719755119659775 -#define BGC_FOURTH_OF_PI_FP64 0.78539816339744831 -#define BGC_SIXTH_OF_PI_FP64 0.523598775598298873 +#define BGC_FP64_PI 3.14159265358979324 +#define BGC_FP64_TWO_PI 6.28318530717958648 +#define BGC_FP64_HALF_OF_PI 1.57079632679489662 +#define BGC_FP64_ONE_THIRD_OF_PI 1.04719755119659775 +#define BGC_FP64_ONE_FOURTH_OF_PI 0.78539816339744831 +#define BGC_FP64_ONE_SIXTH_OF_PI 0.523598775598298873 -#define BGC_DEGREES_IN_RADIAN_FP64 57.2957795130823209 -#define BGC_TURNS_IN_RADIAN_FP64 0.159154943091895336 -#define BGC_RADIANS_IN_DEGREE_FP64 1.74532925199432958E-2 -#define BGC_TURNS_IN_DEGREE_FP64 2.77777777777777778E-3 +#define BGC_FP64_DEGREES_IN_RADIAN 57.2957795130823209 +#define BGC_FP64_TURNS_IN_RADIAN 0.159154943091895336 +#define BGC_FP64_RADIANS_IN_DEGREE 1.74532925199432958E-2 +#define BGC_FP64_TURNS_IN_DEGREE 2.77777777777777778E-3 -typedef enum { - BGC_ANGLE_UNIT_RADIANS = 1, - BGC_ANGLE_UNIT_DEGREES = 2, - BGC_ANGLE_UNIT_TURNS = 3 -} BgcAngleUnitEnum; +#define BGC_ANGLE_UNIT_RADIANS 1 +#define BGC_ANGLE_UNIT_DEGREES 2 +#define BGC_ANGLE_UNIT_TURNS 3 -typedef enum { - /** - * The measure of an angle with a range of: - * [0, 360) degrees, [0, 2xPI) radians, [0, 1) turns, [0, 400) gradians - */ - BGC_ANGLE_RANGE_UNSIGNED = 1, + /** + * The measure of an angle with a range of: + * [0, 360) degrees, [0, 2xPI) radians, [0, 1) turns, [0, 400) gradians + */ +#define BGC_ANGLE_RANGE_UNSIGNED 1 - /** - * The measure of an angle with a range of: - * (-180, 180] degrees, (-PI, PI] radians, (-0.5, 0.5] turns, (-200, 200] gradians - */ - BGC_ANGLE_RANGE_SIGNED = 2 -} BgcAngleRangeEnum; +/** + * The measure of an angle with a range of: + * (-180, 180] degrees, (-PI, PI] radians, (-0.5, 0.5] turns, (-200, 200] gradians + */ +#define BGC_ANGLE_RANGE_SIGNED 2 // !================= Radians ==================! // // ========= 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 ========== // -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 ======== // -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) { - return radians * BGC_DEGREES_IN_RADIAN_FP32; + if (angle_unit == BGC_ANGLE_UNIT_DEGREES) { + return radians * BGC_FP32_DEGREES_IN_RADIAN; } - if (to_unit == BGC_ANGLE_UNIT_TURNS) { - return radians * BGC_TURNS_IN_RADIAN_FP32; + if (angle_unit == BGC_ANGLE_UNIT_TURNS) { + return radians * BGC_FP32_TURNS_IN_RADIAN; } 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) { - return radians * BGC_DEGREES_IN_RADIAN_FP64; + if (angle_unit == BGC_ANGLE_UNIT_DEGREES) { + return radians * BGC_FP64_DEGREES_IN_RADIAN; } - if (to_unit == BGC_ANGLE_UNIT_TURNS) { - return radians * BGC_TURNS_IN_RADIAN_FP64; + if (angle_unit == BGC_ANGLE_UNIT_TURNS) { + return radians * BGC_FP64_TURNS_IN_RADIAN; } return radians; @@ -104,103 +100,103 @@ inline double bgc_radians_to_units_fp64(const double radians, const BgcAngleUnit // ============ 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 (0.0f <= radians && radians < BGC_TWO_PI_FP32) { + if (angle_range == BGC_ANGLE_RANGE_UNSIGNED) { + if (0.0f <= radians && radians < BGC_FP32_TWO_PI) { return radians; } } else { - if (-BGC_PI_FP32 < radians && radians <= BGC_PI_FP32) { + if (-BGC_FP32_PI < radians && radians <= BGC_FP32_PI) { return radians; } } - float turns = radians * BGC_TURNS_IN_RADIAN_FP32; + float turns = radians * BGC_FP32_TURNS_IN_RADIAN; 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; } - 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 (0.0 <= radians && radians < BGC_TWO_PI_FP64) { + if (angle_range == BGC_ANGLE_RANGE_UNSIGNED) { + if (0.0 <= radians && radians < BGC_FP64_TWO_PI) { return radians; } } else { - if (-BGC_PI_FP64 < radians && radians <= BGC_PI_FP64) { + if (-BGC_FP64_PI < radians && radians <= BGC_FP64_PI) { return radians; } } - double turns = radians * BGC_TURNS_IN_RADIAN_FP64; + double turns = radians * BGC_FP64_TURNS_IN_RADIAN; 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; } - return turns * BGC_TWO_PI_FP64; + return turns * BGC_FP64_TWO_PI; } // !================= Degrees ==================! // // ========= 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 ========== // -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 ======== // -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) { - return degrees * BGC_RADIANS_IN_DEGREE_FP32; + if (angle_unit == BGC_ANGLE_UNIT_RADIANS) { + return degrees * BGC_FP32_RADIANS_IN_DEGREE; } - if (to_unit == BGC_ANGLE_UNIT_TURNS) { - return degrees * BGC_TURNS_IN_DEGREE_FP32; + if (angle_unit == BGC_ANGLE_UNIT_TURNS) { + return degrees * BGC_FP32_TURNS_IN_DEGREE; } 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) { - return degrees * BGC_RADIANS_IN_DEGREE_FP64; + if (angle_unit == BGC_ANGLE_UNIT_RADIANS) { + return degrees * BGC_FP64_RADIANS_IN_DEGREE; } - if (to_unit == BGC_ANGLE_UNIT_TURNS) { - return degrees * BGC_TURNS_IN_DEGREE_FP64; + if (angle_unit == BGC_ANGLE_UNIT_TURNS) { + return degrees * BGC_FP64_TURNS_IN_DEGREE; } return degrees; @@ -208,9 +204,9 @@ inline double bgc_degrees_to_units_fp64(const double degrees, const BgcAngleUnit // ============ 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) { 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); - if (range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5f) { + if (angle_range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5f) { turns -= 1.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) { 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); - if (range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5) { + if (angle_range == BGC_ANGLE_RANGE_SIGNED && turns > 0.5) { turns -= 1.0; } @@ -260,50 +256,50 @@ inline double bgc_degrees_normalize_fp64(const double degrees, const BgcAngleRan // ========== 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 ========== // -inline float bgc_turns_to_degrees_fp32(const float turns) +inline float bgc_fp32_turns_to_degrees(const float turns) { 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; } // ========= 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) { - return turns * BGC_TWO_PI_FP32; + if (angle_unit == BGC_ANGLE_UNIT_RADIANS) { + 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; } -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) { - return turns * BGC_TWO_PI_FP64; + if (angle_unit == BGC_ANGLE_UNIT_RADIANS) { + return turns * BGC_FP64_TWO_PI; } - if (to_unit == BGC_ANGLE_UNIT_DEGREES) { + if (angle_unit == BGC_ANGLE_UNIT_DEGREES) { return turns * 360.0; } @@ -312,9 +308,9 @@ inline double bgc_turns_to_units_fp64(const double turns, const BgcAngleUnitEnum // ============= 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) { return turns; } @@ -327,16 +323,16 @@ inline float bgc_turns_normalize_fp32(const float turns, const BgcAngleRangeEnum 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; } -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) { return turns; } @@ -349,7 +345,7 @@ inline double bgc_turns_normalize_fp64(const double turns, const BgcAngleRangeEn 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; } @@ -360,27 +356,27 @@ inline double bgc_turns_normalize_fp64(const double turns, const BgcAngleRangeEn // ========= 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) { - return angle * BGC_RADIANS_IN_DEGREE_FP32; + if (angle_unit == BGC_ANGLE_UNIT_DEGREES) { + return angle * BGC_FP32_RADIANS_IN_DEGREE; } - if (unit == BGC_ANGLE_UNIT_TURNS) { - return angle * BGC_TWO_PI_FP32; + if (angle_unit == BGC_ANGLE_UNIT_TURNS) { + return angle * BGC_FP32_TWO_PI; } 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) { - return angle * BGC_RADIANS_IN_DEGREE_FP64; + if (angle_unit == BGC_ANGLE_UNIT_DEGREES) { + return angle * BGC_FP64_RADIANS_IN_DEGREE; } - if (unit == BGC_ANGLE_UNIT_TURNS) { - return angle * BGC_TWO_PI_FP64; + if (angle_unit == BGC_ANGLE_UNIT_TURNS) { + return angle * BGC_FP64_TWO_PI; } return angle; @@ -388,26 +384,26 @@ inline double bgc_angle_to_radians_fp64(const double angle, const BgcAngleUnitEn // ========= 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) { - return angle * BGC_DEGREES_IN_RADIAN_FP32; + if (angle_unit == BGC_ANGLE_UNIT_RADIANS) { + 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; } -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) { - return angle * BGC_DEGREES_IN_RADIAN_FP64; + if (angle_unit == BGC_ANGLE_UNIT_RADIANS) { + return angle * BGC_FP64_DEGREES_IN_RADIAN; } - if (unit == BGC_ANGLE_UNIT_TURNS) { + if (angle_unit == BGC_ANGLE_UNIT_TURNS) { 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 ======== // -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) { - return angle * BGC_TURNS_IN_RADIAN_FP32; + if (angle_unit == BGC_ANGLE_UNIT_RADIANS) { + return angle * BGC_FP32_TURNS_IN_RADIAN; } - if (unit == BGC_ANGLE_UNIT_DEGREES) { - return angle * BGC_TURNS_IN_DEGREE_FP32; + if (angle_unit == BGC_ANGLE_UNIT_DEGREES) { + return angle * BGC_FP32_TURNS_IN_DEGREE; } 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) { - return angle * BGC_TURNS_IN_RADIAN_FP64; + if (angle_unit == BGC_ANGLE_UNIT_RADIANS) { + return angle * BGC_FP64_TURNS_IN_RADIAN; } - if (unit == BGC_ANGLE_UNIT_DEGREES) { - return angle * BGC_TURNS_IN_DEGREE_FP64; + if (angle_unit == BGC_ANGLE_UNIT_DEGREES) { + return angle * BGC_FP64_TURNS_IN_DEGREE; } return angle; @@ -444,114 +440,58 @@ inline double bgc_angle_to_turns_fp64(const double angle, const BgcAngleUnitEnum // ============= 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; } - if (unit == BGC_ANGLE_UNIT_TURNS) { + if (angle_unit == BGC_ANGLE_UNIT_TURNS) { 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; } - if (unit == BGC_ANGLE_UNIT_TURNS) { + if (angle_unit == BGC_ANGLE_UNIT_TURNS) { return 1.0; } - return BGC_TWO_PI_FP64; -} - -// ============= 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; + return BGC_FP64_TWO_PI; } // ================ 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) { - return bgc_degrees_normalize_fp32(angle, range); + if (angle_unit == BGC_ANGLE_UNIT_DEGREES) { + return bgc_fp32_normalize_degrees(angle, angle_range); } - if (unit == BGC_ANGLE_UNIT_TURNS) { - return bgc_turns_normalize_fp32(angle, range); + if (angle_unit == BGC_ANGLE_UNIT_TURNS) { + 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) { - return bgc_degrees_normalize_fp64(angle, range); + if (angle_unit == BGC_ANGLE_UNIT_DEGREES) { + return bgc_fp64_degrees_normalize(angle, angle_range); } - if (unit == BGC_ANGLE_UNIT_TURNS) { - return bgc_turns_normalize_fp64(angle, range); + if (angle_unit == BGC_ANGLE_UNIT_TURNS) { + return bgc_fp64_normalize_turns(angle, angle_range); } - return bgc_radians_normalize_fp64(angle, range); + return bgc_fp64_normalize_radians(angle, angle_range); } #endif diff --git a/basic-geometry/basic-geometry.cbp b/basic-geometry/basic-geometry.cbp index 9d41076..bed02d1 100644 --- a/basic-geometry/basic-geometry.cbp +++ b/basic-geometry/basic-geometry.cbp @@ -100,6 +100,10 @@ \ No newline at end of file diff --git a/basic-geometry/affine2.c b/basic-geometry/affine2.c index de4c7c5..9810d0a 100644 --- a/basic-geometry/affine2.c +++ b/basic-geometry/affine2.c @@ -1,31 +1,31 @@ #include "affine2.h" -extern inline void bgc_fp32_affine2_reset(BGC_FP32_Affine2 * affine); -extern inline void bgc_fp64_affine2_reset(BGC_FP64_Affine2 * affine); +extern inline void bgc_fp32_affine2_reset(BGC_FP32_Affine2* affine); +extern inline void bgc_fp64_affine2_reset(BGC_FP64_Affine2* 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_fp64_affine2_make(const BGC_FP64_Matrix2x2 * distortion, const BGC_FP64_Vector2 * shift, BGC_FP64_Affine2 * affine); +extern inline void bgc_fp32_affine2_make(BGC_FP32_Affine2* affine, const BGC_FP32_Matrix2x2* distortion, const BGC_FP32_Vector2* shift); +extern inline void bgc_fp64_affine2_make(BGC_FP64_Affine2* affine, const BGC_FP64_Matrix2x2* distortion, const BGC_FP64_Vector2* shift); -extern inline void bgc_fp32_affine2_copy(const BGC_FP32_Affine2 * source, BGC_FP32_Affine2 * destination); -extern inline void bgc_fp64_affine2_copy(const BGC_FP64_Affine2 * source, BGC_FP64_Affine2 * destination); +extern inline void bgc_fp32_affine2_copy(BGC_FP32_Affine2* destination, const BGC_FP32_Affine2* source); +extern inline void bgc_fp64_affine2_copy(BGC_FP64_Affine2* destination, const BGC_FP64_Affine2* source); -extern inline void bgc_fp32_affine2_swap(BGC_FP32_Affine2 * first, BGC_FP32_Affine2 * second); -extern inline void bgc_fp64_affine2_swap(BGC_FP64_Affine2 * first, BGC_FP64_Affine2 * second); +extern inline void bgc_fp32_affine2_swap(BGC_FP32_Affine2* first, BGC_FP32_Affine2* second); +extern inline void bgc_fp64_affine2_swap(BGC_FP64_Affine2* first, BGC_FP64_Affine2* second); -extern inline void bgc_fp64_affine2_convert_to_fp32(const BGC_FP64_Affine2 * source, BGC_FP32_Affine2 * destination); -extern inline void bgc_fp32_affine2_convert_to_fp64(const BGC_FP32_Affine2 * source, BGC_FP64_Affine2 * destination); +extern inline void bgc_fp32_affine2_convert_to_fp64(BGC_FP64_Affine2* destination, const BGC_FP32_Affine2* source); +extern inline void bgc_fp64_affine2_convert_to_fp32(BGC_FP32_Affine2* destination, const BGC_FP64_Affine2* source); -extern inline int bgc_fp32_affine2_invert(BGC_FP32_Affine2 * affine); -extern inline int bgc_fp64_affine2_invert(BGC_FP64_Affine2 * affine); +extern inline int bgc_fp32_affine2_invert(BGC_FP32_Affine2* affine); +extern inline int bgc_fp64_affine2_invert(BGC_FP64_Affine2* affine); -extern inline int bgc_fp32_affine2_get_inverse(const BGC_FP32_Affine2 * source, BGC_FP32_Affine2 * destination); -extern inline int bgc_fp64_affine2_get_inverse(const BGC_FP64_Affine2 * source, BGC_FP64_Affine2 * destination); +extern inline int bgc_fp32_affine2_get_inverse(BGC_FP32_Affine2* inverse, const BGC_FP32_Affine2* affine); +extern inline int bgc_fp64_affine2_get_inverse(BGC_FP64_Affine2* inverse, const BGC_FP64_Affine2* affine); -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_fp64_affine2_combine(const BGC_FP64_Affine2 * first, const BGC_FP64_Affine2 * second, BGC_FP64_Affine2 * combination); +extern inline void bgc_fp32_affine2_combine(BGC_FP32_Affine2* combination, const BGC_FP32_Affine2* first, const BGC_FP32_Affine2* second); +extern inline void bgc_fp64_affine2_combine(BGC_FP64_Affine2* combination, const BGC_FP64_Affine2* first, const BGC_FP64_Affine2* second); -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_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_point(BGC_FP32_Vector2* transformed_point, const BGC_FP32_Affine2* affine, const BGC_FP32_Vector2* initial_point); +extern inline void bgc_fp64_affine2_transform_point(BGC_FP64_Vector2* transformed_point, const BGC_FP64_Affine2* affine, const BGC_FP64_Vector2* initial_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); +extern inline void bgc_fp32_affine2_transform_vector(BGC_FP32_Vector2* transformed_vector, const BGC_FP32_Affine2* affine, const BGC_FP32_Vector2* initial_vector); +extern inline void bgc_fp64_affine2_transform_vector(BGC_FP64_Vector2* transformed_vector, const BGC_FP64_Affine2* affine, const BGC_FP64_Vector2* initial_vector); diff --git a/basic-geometry/affine2.h b/basic-geometry/affine2.h index abc9172..b21fb59 100644 --- a/basic-geometry/affine2.h +++ b/basic-geometry/affine2.h @@ -2,7 +2,7 @@ #define _BGC_AFFINE2_H_INCLUDED_ #include "vector2.h" -#include "matrixes.h" +#include "matrices.h" #include "matrix2x2.h" // ==================== Types ==================== // @@ -19,13 +19,13 @@ typedef struct { // ==================== Reset ==================== // -inline void bgc_fp32_affine2_reset(BGC_FP32_Affine2 * affine) +inline void bgc_fp32_affine2_reset(BGC_FP32_Affine2* affine) { bgc_fp32_matrix2x2_make_identity(&affine->distortion); bgc_fp32_vector2_reset(&affine->shift); } -inline void bgc_fp64_affine2_reset(BGC_FP64_Affine2 * affine) +inline void bgc_fp64_affine2_reset(BGC_FP64_Affine2* affine) { bgc_fp64_matrix2x2_make_identity(&affine->distortion); bgc_fp64_vector2_reset(&affine->shift); @@ -33,31 +33,31 @@ inline void bgc_fp64_affine2_reset(BGC_FP64_Affine2 * affine) // ==================== Make ===================== // -inline void bgc_fp32_affine2_make(const BGC_FP32_Matrix2x2 * distortion, const BGC_FP32_Vector2 * shift, BGC_FP32_Affine2 * affine) +inline void bgc_fp32_affine2_make(BGC_FP32_Affine2* affine, const BGC_FP32_Matrix2x2* distortion, const BGC_FP32_Vector2* shift) { - bgc_fp32_matrix2x2_copy(distortion, &affine->distortion); - bgc_fp32_vector2_copy(shift, &affine->shift); + bgc_fp32_matrix2x2_copy(&affine->distortion, distortion); + bgc_fp32_vector2_copy(&affine->shift, shift); } -inline void bgc_fp64_affine2_make(const BGC_FP64_Matrix2x2 * distortion, const BGC_FP64_Vector2 * shift, BGC_FP64_Affine2 * affine) +inline void bgc_fp64_affine2_make(BGC_FP64_Affine2* affine, const BGC_FP64_Matrix2x2* distortion, const BGC_FP64_Vector2* shift) { - bgc_fp64_matrix2x2_copy(distortion, &affine->distortion); - bgc_fp64_vector2_copy(shift, &affine->shift); + bgc_fp64_matrix2x2_copy(&affine->distortion, distortion); + bgc_fp64_vector2_copy(&affine->shift, shift); } // ==================== Copy ===================== // -inline void bgc_fp32_affine2_copy(const BGC_FP32_Affine2 * source, BGC_FP32_Affine2 * destination) +inline void bgc_fp32_affine2_copy(BGC_FP32_Affine2* destination, const BGC_FP32_Affine2* source) { - bgc_fp32_matrix2x2_copy(&source->distortion, &destination->distortion); - bgc_fp32_vector2_copy(&source->shift, &destination->shift); + bgc_fp32_matrix2x2_copy(&destination->distortion, &source->distortion); + bgc_fp32_vector2_copy(&destination->shift, &source->shift); } -inline void bgc_fp64_affine2_copy(const BGC_FP64_Affine2 * source, BGC_FP64_Affine2 * destination) +inline void bgc_fp64_affine2_copy(BGC_FP64_Affine2* destination, const BGC_FP64_Affine2* source) { - bgc_fp64_matrix2x2_copy(&source->distortion, &destination->distortion); - bgc_fp64_vector2_copy(&source->shift, &destination->shift); + bgc_fp64_matrix2x2_copy(&destination->distortion, &source->distortion); + bgc_fp64_vector2_copy(&destination->shift, &source->shift); } // ==================== Swap ===================== // @@ -76,16 +76,16 @@ inline void bgc_fp64_affine2_swap(BGC_FP64_Affine2 * first, BGC_FP64_Affine2 * s // =================== Convert =================== // -inline void bgc_fp64_affine2_convert_to_fp32(const BGC_FP64_Affine2 * source, BGC_FP32_Affine2 * destination) +inline void bgc_fp32_affine2_convert_to_fp64(BGC_FP64_Affine2* destination, const BGC_FP32_Affine2* source) { - bgc_fp64_matrix2x2_convert_to_fp32(&source->distortion, &destination->distortion); - bgc_fp64_vector2_convert_to_fp32(&source->shift, &destination->shift); + bgc_fp32_matrix2x2_convert_to_fp64(&destination->distortion, &source->distortion); + bgc_fp32_vector2_convert_to_fp64(&destination->shift, &source->shift); } -inline void bgc_fp32_affine2_convert_to_fp64(const BGC_FP32_Affine2 * source, BGC_FP64_Affine2 * destination) +inline void bgc_fp64_affine2_convert_to_fp32(BGC_FP32_Affine2* destination, const BGC_FP64_Affine2 * source) { - bgc_fp32_matrix2x2_convert_to_fp64(&source->distortion, &destination->distortion); - bgc_fp32_vector2_convert_to_fp64(&source->shift, &destination->shift); + bgc_fp64_matrix2x2_convert_to_fp32(&destination->distortion, &source->distortion); + bgc_fp64_vector2_convert_to_fp32(&destination->shift, &source->shift); } // =================== Invert ==================== // @@ -96,7 +96,7 @@ inline int bgc_fp32_affine2_invert(BGC_FP32_Affine2 * affine) return 0; } - bgc_fp32_multiply_matrix2x2_by_vector2(&affine->distortion, &affine->shift, &affine->shift); + bgc_fp32_multiply_matrix2x2_by_vector2(&affine->shift, &affine->distortion, &affine->shift); bgc_fp32_vector2_revert(&affine->shift); return 1; @@ -108,7 +108,7 @@ inline int bgc_fp64_affine2_invert(BGC_FP64_Affine2 * affine) return 0; } - bgc_fp64_multiply_matrix2x2_by_vector2(&affine->distortion, &affine->shift, &affine->shift); + bgc_fp64_multiply_matrix2x2_by_vector2(&affine->shift, &affine->distortion, &affine->shift); bgc_fp64_vector2_revert(&affine->shift); return 1; @@ -116,74 +116,74 @@ inline int bgc_fp64_affine2_invert(BGC_FP64_Affine2 * affine) // ================= Get Inverse ================= // -inline int bgc_fp32_affine2_get_inverse(const BGC_FP32_Affine2 * source, BGC_FP32_Affine2 * destination) +inline int bgc_fp32_affine2_get_inverse(BGC_FP32_Affine2* inverse, const BGC_FP32_Affine2 * affine) { - if (!bgc_fp32_matrix2x2_get_inverse(&source->distortion, &destination->distortion)) { + if (!bgc_fp32_matrix2x2_get_inverse(&inverse->distortion, &affine->distortion)) { return 0; } - bgc_fp32_multiply_matrix2x2_by_vector2(&destination->distortion, &source->shift, &destination->shift); - bgc_fp32_vector2_revert(&destination->shift); + bgc_fp32_multiply_matrix2x2_by_vector2(&inverse->shift, &inverse->distortion, &affine->shift); + bgc_fp32_vector2_revert(&inverse->shift); return 1; } -inline int bgc_fp64_affine2_get_inverse(const BGC_FP64_Affine2 * source, BGC_FP64_Affine2 * destination) +inline int bgc_fp64_affine2_get_inverse(BGC_FP64_Affine2* inverse, const BGC_FP64_Affine2 * affine) { - if (!bgc_fp64_matrix2x2_get_inverse(&source->distortion, &destination->distortion)) { + if (!bgc_fp64_matrix2x2_get_inverse(&inverse->distortion, &affine->distortion)) { return 0; } - bgc_fp64_multiply_matrix2x2_by_vector2(&destination->distortion, &source->shift, &destination->shift); - bgc_fp64_vector2_revert(&destination->shift); + bgc_fp64_multiply_matrix2x2_by_vector2(&inverse->shift, &inverse->distortion, &affine->shift); + bgc_fp64_vector2_revert(&inverse->shift); return 1; } // =================== Combine =================== // -inline void bgc_fp32_affine2_combine(const BGC_FP32_Affine2 * first, const BGC_FP32_Affine2 * second, BGC_FP32_Affine2 * combination) +inline void bgc_fp32_affine2_combine(BGC_FP32_Affine2* combination, const BGC_FP32_Affine2 * first, const BGC_FP32_Affine2 * second) { BGC_FP32_Vector2 first_shift; - bgc_fp32_multiply_matrix2x2_by_vector2(&second->distortion, &first->shift, &first_shift); - bgc_fp32_multiply_matrix2x2_by_matrix2x2(&second->distortion, &first->distortion, &combination->distortion); - bgc_fp32_vector2_add(&first_shift, &second->shift, &combination->shift); + bgc_fp32_multiply_matrix2x2_by_vector2(&first_shift, &second->distortion, &first->shift); + bgc_fp32_multiply_matrix2x2_by_matrix2x2(&combination->distortion, &second->distortion, &first->distortion); + bgc_fp32_vector2_add(&combination->shift, &second->shift, &first_shift); } -inline void bgc_fp64_affine2_combine(const BGC_FP64_Affine2 * first, const BGC_FP64_Affine2 * second, BGC_FP64_Affine2 * combination) +inline void bgc_fp64_affine2_combine(BGC_FP64_Affine2* combination, const BGC_FP64_Affine2 * first, const BGC_FP64_Affine2 * second) { BGC_FP64_Vector2 first_shift; - bgc_fp64_multiply_matrix2x2_by_vector2(&second->distortion, &first->shift, &first_shift); - bgc_fp64_multiply_matrix2x2_by_matrix2x2(&second->distortion, &first->distortion, &combination->distortion); - bgc_fp64_vector2_add(&first_shift, &second->shift, &combination->shift); + bgc_fp64_multiply_matrix2x2_by_vector2(&first_shift, &second->distortion, &first->shift); + bgc_fp64_multiply_matrix2x2_by_matrix2x2(&combination->distortion, &second->distortion, &first->distortion); + bgc_fp64_vector2_add(&combination->shift, &second->shift, &first_shift); } // =============== Transform Point =============== // -inline void bgc_fp32_affine2_transform_point(const BGC_FP32_Affine2 * affine, const BGC_FP32_Vector2 * initial_point, BGC_FP32_Vector2 * transformed_point) +inline void bgc_fp32_affine2_transform_point(BGC_FP32_Vector2* transformed_point, const BGC_FP32_Affine2 * affine, const BGC_FP32_Vector2 * initial_point) { BGC_FP32_Vector2 distorted; - bgc_fp32_multiply_matrix2x2_by_vector2(&affine->distortion, initial_point, &distorted); - bgc_fp32_vector2_add(&affine->shift, &distorted, transformed_point); + bgc_fp32_multiply_matrix2x2_by_vector2(&distorted, &affine->distortion, initial_point); + bgc_fp32_vector2_add(transformed_point, &affine->shift, &distorted); } -inline void bgc_fp64_affine2_transform_point(const BGC_FP64_Affine2 * affine, const BGC_FP64_Vector2 * initial_point, BGC_FP64_Vector2 * transformed_point) +inline void bgc_fp64_affine2_transform_point(BGC_FP64_Vector2* transformed_point, const BGC_FP64_Affine2 * affine, const BGC_FP64_Vector2 * initial_point) { BGC_FP64_Vector2 distorted; - bgc_fp64_multiply_matrix2x2_by_vector2(&affine->distortion, initial_point, &distorted); - bgc_fp64_vector2_add(&affine->shift, &distorted, transformed_point); + bgc_fp64_multiply_matrix2x2_by_vector2(&distorted, &affine->distortion, initial_point); + bgc_fp64_vector2_add(transformed_point, &affine->shift, &distorted); } // ============== Transform Vector =============== // -inline void bgc_fp32_affine2_transform_vector(const BGC_FP32_Affine2 * affine, const BGC_FP32_Vector2 * initial_vector, BGC_FP32_Vector2 * transformed_vector) +inline void bgc_fp32_affine2_transform_vector(BGC_FP32_Vector2* transformed_vector, const BGC_FP32_Affine2 * affine, const BGC_FP32_Vector2 * initial_vector) { - bgc_fp32_multiply_matrix2x2_by_vector2(&affine->distortion, initial_vector, transformed_vector); + bgc_fp32_multiply_matrix2x2_by_vector2(transformed_vector, &affine->distortion, initial_vector); } -inline void bgc_fp64_affine2_transform_vector(const BGC_FP64_Affine2 * affine, const BGC_FP64_Vector2 * initial_vector, BGC_FP64_Vector2 * transformed_vector) +inline void bgc_fp64_affine2_transform_vector(BGC_FP64_Vector2* transformed_vector, const BGC_FP64_Affine2 * affine, const BGC_FP64_Vector2 * initial_vector) { - bgc_fp64_multiply_matrix2x2_by_vector2(&affine->distortion, initial_vector, transformed_vector); + bgc_fp64_multiply_matrix2x2_by_vector2(transformed_vector, &affine->distortion, initial_vector); } #endif diff --git a/basic-geometry/affine3.c b/basic-geometry/affine3.c index e540320..70ad5b5 100644 --- a/basic-geometry/affine3.c +++ b/basic-geometry/affine3.c @@ -1,31 +1,31 @@ #include "affine3.h" -extern inline void bgc_fp32_affine3_reset(BGC_FP32_Affine3 * affine); -extern inline void bgc_fp64_affine3_reset(BGC_FP64_Affine3 * affine); +extern inline void bgc_fp32_affine3_reset(BGC_FP32_Affine3* affine); +extern inline void bgc_fp64_affine3_reset(BGC_FP64_Affine3* 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_fp64_affine3_make(const BGC_FP64_Matrix3x3 * distortion, const BGC_FP64_Vector3 * shift, BGC_FP64_Affine3 * affine); +extern inline void bgc_fp32_affine3_make(BGC_FP32_Affine3* affine, const BGC_FP32_Matrix3x3* distortion, const BGC_FP32_Vector3* shift); +extern inline void bgc_fp64_affine3_make(BGC_FP64_Affine3* affine, const BGC_FP64_Matrix3x3* distortion, const BGC_FP64_Vector3* shift); -extern inline void bgc_fp32_affine3_copy(const BGC_FP32_Affine3 * source, BGC_FP32_Affine3 * destination); -extern inline void bgc_fp64_affine3_copy(const BGC_FP64_Affine3 * source, BGC_FP64_Affine3 * destination); +extern inline void bgc_fp32_affine3_copy(BGC_FP32_Affine3* destination, const BGC_FP32_Affine3* source); +extern inline void bgc_fp64_affine3_copy(BGC_FP64_Affine3* destination, const BGC_FP64_Affine3* source); -extern inline void bgc_fp32_affine3_swap(BGC_FP32_Affine3 * first, BGC_FP32_Affine3 * second); -extern inline void bgc_fp64_affine3_swap(BGC_FP64_Affine3 * first, BGC_FP64_Affine3 * second); +extern inline void bgc_fp32_affine3_swap(BGC_FP32_Affine3* first, BGC_FP32_Affine3* second); +extern inline void bgc_fp64_affine3_swap(BGC_FP64_Affine3* first, BGC_FP64_Affine3* second); -extern inline void bgc_fp64_affine3_convert_to_fp32(const BGC_FP64_Affine3 * source, BGC_FP32_Affine3 * destination); -extern inline void bgc_fp32_affine3_convert_to_fp64(const BGC_FP32_Affine3 * source, BGC_FP64_Affine3 * destination); +extern inline void bgc_fp32_affine3_convert_to_fp64(BGC_FP64_Affine3* destination, const BGC_FP32_Affine3* source); +extern inline void bgc_fp64_affine3_convert_to_fp32(BGC_FP32_Affine3* destination, const BGC_FP64_Affine3* source); -extern inline int bgc_fp32_affine3_invert(BGC_FP32_Affine3 * affine); -extern inline int bgc_fp64_affine3_invert(BGC_FP64_Affine3 * affine); +extern inline int bgc_fp32_affine3_invert(BGC_FP32_Affine3* affine); +extern inline int bgc_fp64_affine3_invert(BGC_FP64_Affine3* affine); -extern inline int bgc_fp32_affine3_get_inverse(const BGC_FP32_Affine3 * source, BGC_FP32_Affine3 * destination); -extern inline int bgc_fp64_affine3_get_inverse(const BGC_FP64_Affine3 * source, BGC_FP64_Affine3 * destination); +extern inline int bgc_fp32_affine3_get_inverse(BGC_FP32_Affine3* inverse, const BGC_FP32_Affine3* affine); +extern inline int bgc_fp64_affine3_get_inverse(BGC_FP64_Affine3* inverse, const BGC_FP64_Affine3* affine); -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_fp64_affine3_combine(const BGC_FP64_Affine3 * first, const BGC_FP64_Affine3 * second, BGC_FP64_Affine3 * combination); +extern inline void bgc_fp32_affine3_combine(BGC_FP32_Affine3* combination, const BGC_FP32_Affine3* first, const BGC_FP32_Affine3* second); +extern inline void bgc_fp64_affine3_combine(BGC_FP64_Affine3* combination, const BGC_FP64_Affine3* first, const BGC_FP64_Affine3* second); -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_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_point(BGC_FP32_Vector3* transformed_point, const BGC_FP32_Affine3* affine, const BGC_FP32_Vector3* initial_point); +extern inline void bgc_fp64_affine3_transform_point(BGC_FP64_Vector3* transformed_point, const BGC_FP64_Affine3* affine, const BGC_FP64_Vector3* initial_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); +extern inline void bgc_fp32_affine3_transform_vector(BGC_FP32_Vector3* transformed_vector, const BGC_FP32_Affine3* affine, const BGC_FP32_Vector3* initial_vector); +extern inline void bgc_fp64_affine3_transform_vector(BGC_FP64_Vector3* transformed_vector, const BGC_FP64_Affine3* affine, const BGC_FP64_Vector3* initial_vector); diff --git a/basic-geometry/affine3.h b/basic-geometry/affine3.h index 68b8b59..eaa8d98 100644 --- a/basic-geometry/affine3.h +++ b/basic-geometry/affine3.h @@ -2,7 +2,7 @@ #define _BGC_AFFINE3_H_INCLUDED_ #include "vector3.h" -#include "matrixes.h" +#include "matrices.h" #include "matrix3x3.h" // ==================== Types ==================== // @@ -33,58 +33,58 @@ inline void bgc_fp64_affine3_reset(BGC_FP64_Affine3 * affine) // ==================== Make ===================== // -inline void bgc_fp32_affine3_make(const BGC_FP32_Matrix3x3 * distortion, const BGC_FP32_Vector3 * shift, BGC_FP32_Affine3 * affine) +inline void bgc_fp32_affine3_make(BGC_FP32_Affine3* affine, const BGC_FP32_Matrix3x3 * distortion, const BGC_FP32_Vector3 * shift) { - bgc_fp32_matrix3x3_copy(distortion, &affine->distortion); - bgc_fp32_vector3_copy(shift, &affine->shift); + bgc_fp32_matrix3x3_copy(&affine->distortion, distortion); + bgc_fp32_vector3_copy(&affine->shift, shift); } -inline void bgc_fp64_affine3_make(const BGC_FP64_Matrix3x3 * distortion, const BGC_FP64_Vector3 * shift, BGC_FP64_Affine3 * affine) +inline void bgc_fp64_affine3_make(BGC_FP64_Affine3* affine, const BGC_FP64_Matrix3x3 * distortion, const BGC_FP64_Vector3 * shift) { - bgc_fp64_matrix3x3_copy(distortion, &affine->distortion); - bgc_fp64_vector3_copy(shift, &affine->shift); + bgc_fp64_matrix3x3_copy(&affine->distortion, distortion); + bgc_fp64_vector3_copy(&affine->shift, shift); } // ==================== Copy ===================== // -inline void bgc_fp32_affine3_copy(const BGC_FP32_Affine3 * source, BGC_FP32_Affine3 * destination) +inline void bgc_fp32_affine3_copy(BGC_FP32_Affine3* destination, const BGC_FP32_Affine3 * source) { - bgc_fp32_matrix3x3_copy(&source->distortion, &destination->distortion); - bgc_fp32_vector3_copy(&source->shift, &destination->shift); + bgc_fp32_matrix3x3_copy(&destination->distortion, &source->distortion); + bgc_fp32_vector3_copy(&destination->shift, &source->shift); } -inline void bgc_fp64_affine3_copy(const BGC_FP64_Affine3 * source, BGC_FP64_Affine3 * destination) +inline void bgc_fp64_affine3_copy(BGC_FP64_Affine3* destination, const BGC_FP64_Affine3 * source) { - bgc_fp64_matrix3x3_copy(&source->distortion, &destination->distortion); - bgc_fp64_vector3_copy(&source->shift, &destination->shift); + bgc_fp64_matrix3x3_copy(&destination->distortion, &source->distortion); + bgc_fp64_vector3_copy(&destination->shift, &source->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); + bgc_fp32_matrix3x3_swap(&first->distortion, &second->distortion); + bgc_fp32_vector3_swap(&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); + bgc_fp64_matrix3x3_swap(&first->distortion, &second->distortion); + bgc_fp64_vector3_swap(&first->shift, &second->shift); } // =================== Convert =================== // -inline void bgc_fp64_affine3_convert_to_fp32(const BGC_FP64_Affine3 * source, BGC_FP32_Affine3 * destination) +inline void bgc_fp32_affine3_convert_to_fp64(BGC_FP64_Affine3* destination, const BGC_FP32_Affine3 * source) { - bgc_fp64_matrix3x3_convert_to_fp32(&source->distortion, &destination->distortion); - bgc_fp64_vector3_convert_to_fp32(&source->shift, &destination->shift); + bgc_fp32_matrix3x3_convert_to_fp64(&destination->distortion, &source->distortion); + bgc_fp32_vector3_convert_to_fp64(&destination->shift, &source->shift); } -inline void bgc_fp32_affine3_convert_to_fp64(const BGC_FP32_Affine3 * source, BGC_FP64_Affine3 * destination) +inline void bgc_fp64_affine3_convert_to_fp32(BGC_FP32_Affine3* destination, const BGC_FP64_Affine3* source) { - bgc_fp32_matrix3x3_convert_to_fp64(&source->distortion, &destination->distortion); - bgc_fp32_vector3_convert_to_fp64(&source->shift, &destination->shift); + bgc_fp64_matrix3x3_convert_to_fp32(&destination->distortion, &source->distortion); + bgc_fp64_vector3_convert_to_fp32(&destination->shift, &source->shift); } // =================== Invert ==================== // @@ -95,7 +95,7 @@ inline int bgc_fp32_affine3_invert(BGC_FP32_Affine3 * affine) return 0; } - bgc_fp32_multiply_matrix3x3_by_vector3(&affine->distortion, &affine->shift, &affine->shift); + bgc_fp32_multiply_matrix3x3_by_vector3(&affine->shift, &affine->distortion, &affine->shift); bgc_fp32_vector3_revert(&affine->shift); return 1; @@ -107,7 +107,7 @@ inline int bgc_fp64_affine3_invert(BGC_FP64_Affine3 * affine) return 0; } - bgc_fp64_multiply_matrix3x3_by_vector3(&affine->distortion, &affine->shift, &affine->shift); + bgc_fp64_multiply_matrix3x3_by_vector3(&affine->shift, &affine->distortion, &affine->shift); bgc_fp64_vector3_revert(&affine->shift); return 1; @@ -115,25 +115,25 @@ inline int bgc_fp64_affine3_invert(BGC_FP64_Affine3 * affine) // ================= Get Inverse ================= // -inline int bgc_fp32_affine3_get_inverse(const BGC_FP32_Affine3 * source, BGC_FP32_Affine3 * destination) +inline int bgc_fp32_affine3_get_inverse(BGC_FP32_Affine3* destination, const BGC_FP32_Affine3 * source) { - if (!bgc_fp32_matrix3x3_get_inverse(&source->distortion, &destination->distortion)) { + if (!bgc_fp32_matrix3x3_get_inverse(&destination->distortion, &source->distortion)) { return 0; } - bgc_fp32_multiply_matrix3x3_by_vector3(&destination->distortion, &source->shift, &destination->shift); + bgc_fp32_multiply_matrix3x3_by_vector3(&destination->shift, &destination->distortion, &source->shift); bgc_fp32_vector3_revert(&destination->shift); return 1; } -inline int bgc_fp64_affine3_get_inverse(const BGC_FP64_Affine3 * source, BGC_FP64_Affine3 * destination) +inline int bgc_fp64_affine3_get_inverse(BGC_FP64_Affine3* destination, const BGC_FP64_Affine3 * source) { - if (!bgc_fp64_matrix3x3_get_inverse(&source->distortion, &destination->distortion)) { + if (!bgc_fp64_matrix3x3_get_inverse(&destination->distortion, &source->distortion)) { return 0; } - bgc_fp64_multiply_matrix3x3_by_vector3(&destination->distortion, &source->shift, &destination->shift); + bgc_fp64_multiply_matrix3x3_by_vector3(&destination->shift, &destination->distortion, &source->shift); bgc_fp64_vector3_revert(&destination->shift); return 1; @@ -141,48 +141,48 @@ inline int bgc_fp64_affine3_get_inverse(const BGC_FP64_Affine3 * source, BGC_FP6 // =================== Combine =================== // -inline void bgc_fp32_affine3_combine(const BGC_FP32_Affine3 * first, const BGC_FP32_Affine3 * second, BGC_FP32_Affine3 * combination) +inline void bgc_fp32_affine3_combine(BGC_FP32_Affine3* combination, const BGC_FP32_Affine3 * first, const BGC_FP32_Affine3 * second) { BGC_FP32_Vector3 first_shift; - bgc_fp32_multiply_matrix3x3_by_vector3(&second->distortion, &first->shift, &first_shift); - bgc_fp32_multiply_matrix3x3_by_matrix3x3(&second->distortion, &first->distortion, &combination->distortion); - bgc_fp32_vector3_add(&first_shift, &second->shift, &combination->shift); + bgc_fp32_multiply_matrix3x3_by_vector3(&first_shift, &second->distortion, &first->shift); + bgc_fp32_multiply_matrix3x3_by_matrix3x3(&combination->distortion, &second->distortion, &first->distortion); + bgc_fp32_vector3_add(&combination->shift, &first_shift, &second->shift); } -inline void bgc_fp64_affine3_combine(const BGC_FP64_Affine3 * first, const BGC_FP64_Affine3 * second, BGC_FP64_Affine3 * combination) +inline void bgc_fp64_affine3_combine(BGC_FP64_Affine3* combination, const BGC_FP64_Affine3 * first, const BGC_FP64_Affine3 * second) { BGC_FP64_Vector3 first_shift; - bgc_fp64_multiply_matrix3x3_by_vector3(&second->distortion, &first->shift, &first_shift); - bgc_fp64_multiply_matrix3x3_by_matrix3x3(&second->distortion, &first->distortion, &combination->distortion); - bgc_fp64_vector3_add(&first_shift, &second->shift, &combination->shift); + bgc_fp64_multiply_matrix3x3_by_vector3(&first_shift, &second->distortion, &first->shift); + bgc_fp64_multiply_matrix3x3_by_matrix3x3(&combination->distortion, &second->distortion, &first->distortion); + bgc_fp64_vector3_add(&combination->shift, &first_shift, &second->shift); } // =============== Transform Point =============== // -inline void bgc_fp32_affine3_transform_point(const BGC_FP32_Affine3 * affine, const BGC_FP32_Vector3 * initial_point, BGC_FP32_Vector3 * transformed_point) +inline void bgc_fp32_affine3_transform_point(BGC_FP32_Vector3* transformed_point, const BGC_FP32_Affine3 * affine, const BGC_FP32_Vector3 * initial_point) { BGC_FP32_Vector3 distorted; - bgc_fp32_multiply_matrix3x3_by_vector3(&affine->distortion, initial_point, &distorted); - bgc_fp32_vector3_add(&affine->shift, &distorted, transformed_point); + bgc_fp32_multiply_matrix3x3_by_vector3(&distorted, &affine->distortion, initial_point); + bgc_fp32_vector3_add(transformed_point, &affine->shift, &distorted); } -inline void bgc_fp64_affine3_transform_point(const BGC_FP64_Affine3 * affine, const BGC_FP64_Vector3 * initial_point, BGC_FP64_Vector3 * transformed_point) +inline void bgc_fp64_affine3_transform_point(BGC_FP64_Vector3* transformed_point, const BGC_FP64_Affine3 * affine, const BGC_FP64_Vector3 * initial_point) { BGC_FP64_Vector3 distorted; - bgc_fp64_multiply_matrix3x3_by_vector3(&affine->distortion, initial_point, &distorted); - bgc_fp64_vector3_add(&affine->shift, &distorted, transformed_point); + bgc_fp64_multiply_matrix3x3_by_vector3(&distorted, &affine->distortion, initial_point); + bgc_fp64_vector3_add(transformed_point, &affine->shift, &distorted); } // ============== Transform Vector =============== // -inline void bgc_fp32_affine3_transform_vector(const BGC_FP32_Affine3 * affine, const BGC_FP32_Vector3 * initial_vector, BGC_FP32_Vector3 * transformed_vector) +inline void bgc_fp32_affine3_transform_vector(BGC_FP32_Vector3* transformed_vector, const BGC_FP32_Affine3 * affine, const BGC_FP32_Vector3 * initial_vector) { - bgc_fp32_multiply_matrix3x3_by_vector3(&affine->distortion, initial_vector, transformed_vector); + bgc_fp32_multiply_matrix3x3_by_vector3(transformed_vector, &affine->distortion, initial_vector); } -inline void bgc_fp64_affine3_transform_vector(const BGC_FP64_Affine3 * affine, const BGC_FP64_Vector3 * initial_vector, BGC_FP64_Vector3 * transformed_vector) +inline void bgc_fp64_affine3_transform_vector(BGC_FP64_Vector3* transformed_vector, const BGC_FP64_Affine3 * affine, const BGC_FP64_Vector3 * initial_vector) { - bgc_fp64_multiply_matrix3x3_by_vector3(&affine->distortion, initial_vector, transformed_vector); + bgc_fp64_multiply_matrix3x3_by_vector3(transformed_vector, &affine->distortion, initial_vector); } #endif diff --git a/basic-geometry/basic-geometry.h b/basic-geometry/basic-geometry.h index 402e083..eaacad7 100644 --- a/basic-geometry/basic-geometry.h +++ b/basic-geometry/basic-geometry.h @@ -8,14 +8,14 @@ #include "./vector2.h" #include "./vector3.h" -#include "./matrixes.h" +#include "./matrices.h" #include "./matrix2x2.h" #include "./matrix2x3.h" #include "./matrix3x2.h" #include "./matrix3x3.h" - -#include "./affine2.h" -#include "./affine3.h" + +#include "./affine2.h" +#include "./affine3.h" #include "./complex.h" #include "./cotes-number.h" @@ -25,8 +25,8 @@ #include "./quaternion.h" #include "./versor.h" #include "./slerp.h" - -#include "./position2.h" -#include "./position3.h" + +#include "./position2.h" +#include "./position3.h" #endif diff --git a/basic-geometry/basic-geometry.vcxproj b/basic-geometry/basic-geometry.vcxproj index fe4ec00..2b985f5 100644 --- a/basic-geometry/basic-geometry.vcxproj +++ b/basic-geometry/basic-geometry.vcxproj @@ -1,4 +1,4 @@ - + @@ -29,7 +29,7 @@ - + @@ -54,7 +54,7 @@ - + diff --git a/basic-geometry/basic-geometry.vcxproj.filters b/basic-geometry/basic-geometry.vcxproj.filters index 2f732d3..5200901 100644 --- a/basic-geometry/basic-geometry.vcxproj.filters +++ b/basic-geometry/basic-geometry.vcxproj.filters @@ -57,7 +57,7 @@ Файлы заголовков - + Файлы заголовков @@ -113,7 +113,7 @@ Исходные файлы - + Исходные файлы diff --git a/basic-geometry/complex.c b/basic-geometry/complex.c index 2f5ddd8..b5f6788 100644 --- a/basic-geometry/complex.c +++ b/basic-geometry/complex.c @@ -3,8 +3,8 @@ extern inline void bgc_fp32_complex_reset(BGC_FP32_Complex* complex); extern inline void bgc_fp64_complex_reset(BGC_FP64_Complex* complex); -extern inline void bgc_fp32_complex_make(const float real, const float imaginary, BGC_FP32_Complex* complex); -extern inline void bgc_fp64_complex_make(const double real, const double imaginary, BGC_FP64_Complex* complex); +extern inline void bgc_fp32_complex_make(BGC_FP32_Complex* complex, const float real, const float imaginary); +extern inline void bgc_fp64_complex_make(BGC_FP64_Complex* complex, const double real, const double imaginary); extern inline float bgc_fp32_complex_get_square_modulus(const BGC_FP32_Complex* number); extern inline double bgc_fp64_complex_get_square_modulus(const BGC_FP64_Complex* number); @@ -18,75 +18,75 @@ extern inline int bgc_fp64_complex_is_zero(const BGC_FP64_Complex* number); extern inline int bgc_fp32_complex_is_unit(const BGC_FP32_Complex* number); extern inline int bgc_fp64_complex_is_unit(const BGC_FP64_Complex* number); -extern inline void bgc_fp32_complex_copy(const BGC_FP32_Complex* source, BGC_FP32_Complex* destination); -extern inline void bgc_fp64_complex_copy(const BGC_FP64_Complex* source, BGC_FP64_Complex* destination); +extern inline void bgc_fp32_complex_copy(BGC_FP32_Complex* destination, const BGC_FP32_Complex* source); +extern inline void bgc_fp64_complex_copy(BGC_FP64_Complex* destination, const BGC_FP64_Complex* source); extern inline void bgc_fp32_complex_swap(BGC_FP32_Complex* number1, BGC_FP32_Complex* number2); extern inline void bgc_fp64_complex_swap(BGC_FP64_Complex* number1, BGC_FP64_Complex* number2); -extern inline void bgc_fp64_complex_convert_to_fp32(const BGC_FP64_Complex* source, BGC_FP32_Complex* destination); -extern inline void bgc_fp32_complex_convert_to_fp64(const BGC_FP32_Complex* source, BGC_FP64_Complex* destination); +extern inline void bgc_fp64_complex_convert_to_fp32(BGC_FP32_Complex* destination, const BGC_FP64_Complex* source); +extern inline void bgc_fp32_complex_convert_to_fp64(BGC_FP64_Complex* destination, const BGC_FP32_Complex* source); extern inline void bgc_fp32_complex_revert(BGC_FP32_Complex* number); extern inline void bgc_fp64_complex_revert(BGC_FP64_Complex* number); -extern inline void bgc_fp32_complex_get_reverse(const BGC_FP32_Complex* number, BGC_FP32_Complex* opposite); -extern inline void bgc_fp64_complex_get_reverse(const BGC_FP64_Complex* number, BGC_FP64_Complex* opposite); +extern inline void bgc_fp32_complex_get_reverse(BGC_FP32_Complex* reverse, const BGC_FP32_Complex* number); +extern inline void bgc_fp64_complex_get_reverse(BGC_FP64_Complex* reverse, const BGC_FP64_Complex* number); extern inline int bgc_fp32_complex_normalize(BGC_FP32_Complex* number); extern inline int bgc_fp64_complex_normalize(BGC_FP64_Complex* number); -extern inline int bgc_fp32_complex_get_normalized(const BGC_FP32_Complex* number, BGC_FP32_Complex* normalized); -extern inline int bgc_fp64_complex_get_normalized(const BGC_FP64_Complex* number, BGC_FP64_Complex* normalized); +extern inline int bgc_fp32_complex_get_normalized(BGC_FP32_Complex* normalized, const BGC_FP32_Complex* number); +extern inline int bgc_fp64_complex_get_normalized(BGC_FP64_Complex* normalized, const BGC_FP64_Complex* number); extern inline void bgc_fp32_complex_conjugate(BGC_FP32_Complex* number); extern inline void bgc_fp64_complex_conjugate(BGC_FP64_Complex* number); -extern inline void bgc_fp32_complex_get_conjugate(const BGC_FP32_Complex* number, BGC_FP32_Complex* conjugate); -extern inline void bgc_fp64_complex_get_conjugate(const BGC_FP64_Complex* number, BGC_FP64_Complex* conjugate); +extern inline void bgc_fp32_complex_get_conjugate(BGC_FP32_Complex* conjugate, const BGC_FP32_Complex* number); +extern inline void bgc_fp64_complex_get_conjugate(BGC_FP64_Complex* conjugate, const BGC_FP64_Complex* number); extern inline int bgc_fp32_complex_invert(BGC_FP32_Complex* number); extern inline int bgc_fp64_complex_invert(BGC_FP64_Complex* number); -extern inline int bgc_fp32_complex_get_inverse(const BGC_FP32_Complex* number, BGC_FP32_Complex* inverse); -extern inline int bgc_fp64_complex_get_inverse(const BGC_FP64_Complex* number, BGC_FP64_Complex* inverse); +extern inline int bgc_fp32_complex_get_inverse(BGC_FP32_Complex* inverse, const BGC_FP32_Complex* number); +extern inline int bgc_fp64_complex_get_inverse(BGC_FP64_Complex* inverse, const BGC_FP64_Complex* number); -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_fp64_complex_get_product(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* product); +extern inline void bgc_fp32_complex_get_product(BGC_FP32_Complex* product, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2); +extern inline void bgc_fp64_complex_get_product(BGC_FP64_Complex* product, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2); -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_fp64_complex_get_ratio(const BGC_FP64_Complex* divident, const BGC_FP64_Complex* divisor, BGC_FP64_Complex* quotient); +extern inline int bgc_fp32_complex_get_ratio(BGC_FP32_Complex* quotient, const BGC_FP32_Complex* divident, const BGC_FP32_Complex* divisor); +extern inline int bgc_fp64_complex_get_ratio(BGC_FP64_Complex* quotient, const BGC_FP64_Complex* divident, const BGC_FP64_Complex* divisor); -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_fp64_complex_add(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* sum); +extern inline void bgc_fp32_complex_add(BGC_FP32_Complex* sum, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2); +extern inline void bgc_fp64_complex_add(BGC_FP64_Complex* sum, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2); -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_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_fp32_complex_add_scaled(BGC_FP32_Complex* sum, const BGC_FP32_Complex* basic_number, const BGC_FP32_Complex* scalable_number, const float scale); +extern inline void bgc_fp64_complex_add_scaled(BGC_FP64_Complex* sum, const BGC_FP64_Complex* basic_number, const BGC_FP64_Complex* scalable_number, const double scale); -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_fp64_complex_subtract(const BGC_FP64_Complex* minuend, const BGC_FP64_Complex* subtrahend, BGC_FP64_Complex* difference); +extern inline void bgc_fp32_complex_subtract(BGC_FP32_Complex* difference, const BGC_FP32_Complex* minuend, const BGC_FP32_Complex* subtrahend); +extern inline void bgc_fp64_complex_subtract(BGC_FP64_Complex* difference, const BGC_FP64_Complex* minuend, const BGC_FP64_Complex* subtrahend); -extern inline void bgc_fp32_complex_multiply(const BGC_FP32_Complex* multiplicand, const float multiplier, BGC_FP32_Complex* product); -extern inline void bgc_fp64_complex_multiply(const BGC_FP64_Complex* multiplicand, const double multiplier, BGC_FP64_Complex* product); +extern inline void bgc_fp32_complex_multiply(BGC_FP32_Complex* product, const BGC_FP32_Complex* multiplicand, const float multiplier); +extern inline void bgc_fp64_complex_multiply(BGC_FP64_Complex* product, const BGC_FP64_Complex* multiplicand, const double multiplier); -extern inline void bgc_fp32_complex_divide(const BGC_FP32_Complex* dividend, const float divisor, BGC_FP32_Complex* quotient); -extern inline void bgc_fp64_complex_divide(const BGC_FP64_Complex* dividend, const double divisor, BGC_FP64_Complex* quotient); +extern inline void bgc_fp32_complex_divide(BGC_FP32_Complex* quotient, const BGC_FP32_Complex* dividend, const float divisor); +extern inline void bgc_fp64_complex_divide(BGC_FP64_Complex* quotient, const BGC_FP64_Complex* dividend, const double divisor); -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_fp64_complex_get_mean2(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* mean); +extern inline void bgc_fp32_complex_get_mean2(BGC_FP32_Complex* mean, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2); +extern inline void bgc_fp64_complex_get_mean2(BGC_FP64_Complex* mean, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2); -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_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_fp32_complex_get_mean3(BGC_FP32_Complex* mean, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, const BGC_FP32_Complex* number3); +extern inline void bgc_fp64_complex_get_mean3(BGC_FP64_Complex* mean, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, const BGC_FP64_Complex* number3); -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_fp64_complex_interpolate(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, const double phase, BGC_FP64_Complex* interpolation); +extern inline void bgc_fp32_complex_interpolate(BGC_FP32_Complex* interpolation, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, const float phase); +extern inline void bgc_fp64_complex_interpolate(BGC_FP64_Complex* interpolation, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, const double phase); extern inline int bgc_fp32_complex_are_close(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2); extern inline int bgc_fp64_complex_are_close(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2); // =============== Get Exponation =============== // -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_fp32_complex_get_exponation(BGC_FP32_Complex* power, const BGC_FP32_Complex* base, const float real_exponent, const float imaginary_exponent) { const float square_modulus = bgc_fp32_complex_get_square_modulus(base); @@ -106,7 +106,7 @@ void bgc_fp32_complex_get_exponation(const BGC_FP32_Complex* base, const float r power->imaginary = power_modulus * sinf(power_angle); } -void bgc_fp64_complex_get_exponation(const BGC_FP64_Complex* base, const double real_exponent, const double imaginary_exponent, BGC_FP64_Complex* power) +void bgc_fp64_complex_get_exponation(BGC_FP64_Complex* power, const BGC_FP64_Complex* base, const double real_exponent, const double imaginary_exponent) { const double square_modulus = bgc_fp64_complex_get_square_modulus(base); diff --git a/basic-geometry/complex.h b/basic-geometry/complex.h index 7c4825d..6bd26a2 100644 --- a/basic-geometry/complex.h +++ b/basic-geometry/complex.h @@ -32,13 +32,13 @@ inline void bgc_fp64_complex_reset(BGC_FP64_Complex* complex) // ==================== Set ===================== // -inline void bgc_fp32_complex_make(const float real, const float imaginary, BGC_FP32_Complex* complex) +inline void bgc_fp32_complex_make(BGC_FP32_Complex* complex, const float real, const float imaginary) { complex->real = real; complex->imaginary = imaginary; } -inline void bgc_fp64_complex_make(const double real, const double imaginary, BGC_FP64_Complex* complex) +inline void bgc_fp64_complex_make(BGC_FP64_Complex* complex, const double real, const double imaginary) { complex->real = real; complex->imaginary = imaginary; @@ -90,13 +90,13 @@ inline int bgc_fp64_complex_is_unit(const BGC_FP64_Complex* number) // ==================== Copy ==================== // -inline void bgc_fp32_complex_copy(const BGC_FP32_Complex* source, BGC_FP32_Complex* destination) +inline void bgc_fp32_complex_copy(BGC_FP32_Complex* destination, const BGC_FP32_Complex* source) { destination->real = source->real; destination->imaginary = source->imaginary; } -inline void bgc_fp64_complex_copy(const BGC_FP64_Complex* source, BGC_FP64_Complex* destination) +inline void bgc_fp64_complex_copy(BGC_FP64_Complex* destination, const BGC_FP64_Complex* source) { destination->real = source->real; destination->imaginary = source->imaginary; @@ -130,13 +130,13 @@ inline void bgc_fp64_complex_swap(BGC_FP64_Complex* number1, BGC_FP64_Complex* n // ================== Convert =================== // -inline void bgc_fp64_complex_convert_to_fp32(const BGC_FP64_Complex* source, BGC_FP32_Complex* destination) +inline void bgc_fp64_complex_convert_to_fp32(BGC_FP32_Complex* destination, const BGC_FP64_Complex* source) { destination->real = (float)source->real; destination->imaginary = (float)source->imaginary; } -inline void bgc_fp32_complex_convert_to_fp64(const BGC_FP32_Complex* source, BGC_FP64_Complex* destination) +inline void bgc_fp32_complex_convert_to_fp64(BGC_FP64_Complex* destination, const BGC_FP32_Complex* source) { destination->real = source->real; destination->imaginary = source->imaginary; @@ -156,16 +156,16 @@ inline void bgc_fp64_complex_revert(BGC_FP64_Complex* number) number->imaginary = -number->imaginary; } -inline void bgc_fp32_complex_get_reverse(const BGC_FP32_Complex* number, BGC_FP32_Complex* opposite) +inline void bgc_fp32_complex_get_reverse(BGC_FP32_Complex* reverse, const BGC_FP32_Complex* number) { - opposite->real = -number->real; - opposite->imaginary = -number->imaginary; + reverse->real = -number->real; + reverse->imaginary = -number->imaginary; } -inline void bgc_fp64_complex_get_reverse(const BGC_FP64_Complex* number, BGC_FP64_Complex* opposite) +inline void bgc_fp64_complex_get_reverse(BGC_FP64_Complex* reverse, const BGC_FP64_Complex* number) { - opposite->real = -number->real; - opposite->imaginary = -number->imaginary; + reverse->real = -number->real; + reverse->imaginary = -number->imaginary; } // ================= Normalize ================== // @@ -210,7 +210,7 @@ inline int bgc_fp64_complex_normalize(BGC_FP64_Complex* number) return 1; } -inline int bgc_fp32_complex_get_normalized(const BGC_FP32_Complex* number, BGC_FP32_Complex* normalized) +inline int bgc_fp32_complex_get_normalized(BGC_FP32_Complex* normalized, const BGC_FP32_Complex* number) { const float square_modulus = bgc_fp32_complex_get_square_modulus(number); @@ -234,7 +234,7 @@ inline int bgc_fp32_complex_get_normalized(const BGC_FP32_Complex* number, BGC_F return 1; } -inline int bgc_fp64_complex_get_normalized(const BGC_FP64_Complex* number, BGC_FP64_Complex* normalized) +inline int bgc_fp64_complex_get_normalized(BGC_FP64_Complex* normalized, const BGC_FP64_Complex* number) { const double square_modulus = bgc_fp64_complex_get_square_modulus(number); @@ -270,13 +270,13 @@ inline void bgc_fp64_complex_conjugate(BGC_FP64_Complex* number) number->imaginary = -number->imaginary; } -inline void bgc_fp32_complex_get_conjugate(const BGC_FP32_Complex* number, BGC_FP32_Complex* conjugate) +inline void bgc_fp32_complex_get_conjugate(BGC_FP32_Complex* conjugate, const BGC_FP32_Complex* number) { conjugate->real = number->real; conjugate->imaginary = -number->imaginary; } -inline void bgc_fp64_complex_get_conjugate(const BGC_FP64_Complex* number, BGC_FP64_Complex* conjugate) +inline void bgc_fp64_complex_get_conjugate(BGC_FP64_Complex* conjugate, const BGC_FP64_Complex* number) { conjugate->real = number->real; conjugate->imaginary = -number->imaginary; @@ -284,7 +284,7 @@ inline void bgc_fp64_complex_get_conjugate(const BGC_FP64_Complex* number, BGC_F // =================== Invert =================== // -inline int bgc_fp32_complex_get_inverse(const BGC_FP32_Complex* number, BGC_FP32_Complex* inverse) +inline int bgc_fp32_complex_get_inverse(BGC_FP32_Complex* inverse, const BGC_FP32_Complex* number) { const float square_modulus = bgc_fp32_complex_get_square_modulus(number); @@ -300,7 +300,7 @@ inline int bgc_fp32_complex_get_inverse(const BGC_FP32_Complex* number, BGC_FP32 return 1; } -inline int bgc_fp64_complex_get_inverse(const BGC_FP64_Complex* number, BGC_FP64_Complex* inverse) +inline int bgc_fp64_complex_get_inverse(BGC_FP64_Complex* inverse, const BGC_FP64_Complex* number) { const double square_modulus = bgc_fp64_complex_get_square_modulus(number); @@ -328,19 +328,19 @@ inline int bgc_fp64_complex_invert(BGC_FP64_Complex* number) // =============== Get Exponation =============== // -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_fp32_complex_get_exponation(BGC_FP32_Complex* power, const BGC_FP32_Complex* base, const float real_exponent, const float imaginary_exponent); -void bgc_fp64_complex_get_exponation(const BGC_FP64_Complex* base, const double real_exponent, const double imaginary_exponent, BGC_FP64_Complex* power); +void bgc_fp64_complex_get_exponation(BGC_FP64_Complex* power, const BGC_FP64_Complex* base, const double real_exponent, const double imaginary_exponent); // ==================== Add ===================== // -inline void bgc_fp32_complex_add(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, BGC_FP32_Complex* sum) +inline void bgc_fp32_complex_add(BGC_FP32_Complex* sum, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2) { sum->real = number1->real + number2->real; sum->imaginary = number1->imaginary + number2->imaginary; } -inline void bgc_fp64_complex_add(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* sum) +inline void bgc_fp64_complex_add(BGC_FP64_Complex* sum, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2) { sum->real = number1->real + number2->real; sum->imaginary = number1->imaginary + number2->imaginary; @@ -348,13 +348,13 @@ inline void bgc_fp64_complex_add(const BGC_FP64_Complex* number1, const BGC_FP64 // ================= Add scaled ================= // -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) +inline void bgc_fp32_complex_add_scaled(BGC_FP32_Complex* sum, const BGC_FP32_Complex* basic_number, const BGC_FP32_Complex* scalable_number, const float scale) { sum->real = basic_number->real + scalable_number->real * scale; sum->imaginary = basic_number->imaginary + scalable_number->imaginary * scale; } -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) +inline void bgc_fp64_complex_add_scaled(BGC_FP64_Complex* sum, const BGC_FP64_Complex* basic_number, const BGC_FP64_Complex* scalable_number, const double scale) { sum->real = basic_number->real + scalable_number->real * scale; sum->imaginary = basic_number->imaginary + scalable_number->imaginary * scale; @@ -362,7 +362,7 @@ inline void bgc_fp64_complex_add_scaled(const BGC_FP64_Complex* basic_number, co // ================== Subtract ================== // -inline void bgc_fp32_complex_subtract(const BGC_FP32_Complex* minuend, const BGC_FP32_Complex* subtrahend, BGC_FP32_Complex* difference) +inline void bgc_fp32_complex_subtract(BGC_FP32_Complex* difference, const BGC_FP32_Complex* minuend, const BGC_FP32_Complex* subtrahend) { difference->real = minuend->real - subtrahend->real; difference->imaginary = minuend->imaginary - subtrahend->imaginary; @@ -376,7 +376,7 @@ inline void bgc_fp64_complex_subtract(const BGC_FP64_Complex* minuend, const BGC // ================== Multiply ================== // -inline void bgc_fp32_complex_get_product(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, BGC_FP32_Complex* product) +inline void bgc_fp32_complex_get_product(BGC_FP32_Complex* product, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2) { const float real = number1->real * number2->real - number1->imaginary * number2->imaginary; const float imaginary = number1->real * number2->imaginary + number1->imaginary * number2->real; @@ -385,7 +385,7 @@ inline void bgc_fp32_complex_get_product(const BGC_FP32_Complex* number1, const product->imaginary = imaginary; } -inline void bgc_fp64_complex_get_product(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* product) +inline void bgc_fp64_complex_get_product(BGC_FP64_Complex* product, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2) { const double real = number1->real * number2->real - number1->imaginary * number2->imaginary; const double imaginary = number1->real * number2->imaginary + number1->imaginary * number2->real; @@ -396,13 +396,13 @@ inline void bgc_fp64_complex_get_product(const BGC_FP64_Complex* number1, const // ============= Multiply By Number ============= // -inline void bgc_fp32_complex_multiply(const BGC_FP32_Complex* multiplicand, const float multiplier, BGC_FP32_Complex* product) +inline void bgc_fp32_complex_multiply(BGC_FP32_Complex* product, const BGC_FP32_Complex* multiplicand, const float multiplier) { product->real = multiplicand->real * multiplier; product->imaginary = multiplicand->imaginary * multiplier; } -inline void bgc_fp64_complex_multiply(const BGC_FP64_Complex* multiplicand, const double multiplier, BGC_FP64_Complex* product) +inline void bgc_fp64_complex_multiply(BGC_FP64_Complex* product, const BGC_FP64_Complex* multiplicand, const double multiplier) { product->real = multiplicand->real * multiplier; product->imaginary = multiplicand->imaginary * multiplier; @@ -410,7 +410,7 @@ inline void bgc_fp64_complex_multiply(const BGC_FP64_Complex* multiplicand, cons // =================== Divide =================== // -inline int bgc_fp32_complex_get_ratio(const BGC_FP32_Complex* divident, const BGC_FP32_Complex* divisor, BGC_FP32_Complex* quotient) +inline int bgc_fp32_complex_get_ratio(BGC_FP32_Complex* quotient, const BGC_FP32_Complex* divident, const BGC_FP32_Complex* divisor) { const float square_modulus = bgc_fp32_complex_get_square_modulus(divisor); @@ -429,7 +429,7 @@ inline int bgc_fp32_complex_get_ratio(const BGC_FP32_Complex* divident, const BG return 1; } -inline int bgc_fp64_complex_get_ratio(const BGC_FP64_Complex* divident, const BGC_FP64_Complex* divisor, BGC_FP64_Complex* quotient) +inline int bgc_fp64_complex_get_ratio(BGC_FP64_Complex* quotient, const BGC_FP64_Complex* divident, const BGC_FP64_Complex* divisor) { const double square_modulus = bgc_fp64_complex_get_square_modulus(divisor); @@ -450,25 +450,25 @@ inline int bgc_fp64_complex_get_ratio(const BGC_FP64_Complex* divident, const BG // ============== Divide By Number ============== // -inline void bgc_fp32_complex_divide(const BGC_FP32_Complex* dividend, const float divisor, BGC_FP32_Complex* quotient) +inline void bgc_fp32_complex_divide(BGC_FP32_Complex* quotient, const BGC_FP32_Complex* dividend, const float divisor) { - bgc_fp32_complex_multiply(dividend, 1.0f / divisor, quotient); + bgc_fp32_complex_multiply(quotient, dividend, 1.0f / divisor); } -inline void bgc_fp64_complex_divide(const BGC_FP64_Complex* dividend, const double divisor, BGC_FP64_Complex* quotient) +inline void bgc_fp64_complex_divide(BGC_FP64_Complex* quotient, const BGC_FP64_Complex* dividend, const double divisor) { - bgc_fp64_complex_multiply(dividend, 1.0 / divisor, quotient); + bgc_fp64_complex_multiply(quotient, dividend, 1.0 / divisor); } // ================== Average2 ================== // -inline void bgc_fp32_complex_get_mean2(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, BGC_FP32_Complex* mean) +inline void bgc_fp32_complex_get_mean2(BGC_FP32_Complex* mean, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2) { mean->real = (number1->real + number2->real) * 0.5f; mean->imaginary = (number1->imaginary + number2->imaginary) * 0.5f; } -inline void bgc_fp64_complex_get_mean2(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, BGC_FP64_Complex* mean) +inline void bgc_fp64_complex_get_mean2(BGC_FP64_Complex* mean, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2) { mean->real = (number1->real + number2->real) * 0.5; mean->imaginary = (number1->imaginary + number2->imaginary) * 0.5; @@ -476,13 +476,13 @@ inline void bgc_fp64_complex_get_mean2(const BGC_FP64_Complex* number1, const BG // ================== Average3 ================== // -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) +inline void bgc_fp32_complex_get_mean3(BGC_FP32_Complex* mean, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, const BGC_FP32_Complex* number3) { mean->real = (number1->real + number2->real + number3->real) * BGC_FP32_ONE_THIRD; mean->imaginary = (number1->imaginary + number2->imaginary + number3->imaginary) * BGC_FP32_ONE_THIRD; } -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) +inline void bgc_fp64_complex_get_mean3(BGC_FP64_Complex* mean, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, const BGC_FP64_Complex* number3) { mean->real = (number1->real + number2->real + number3->real) * BGC_FP64_ONE_THIRD; mean->imaginary = (number1->imaginary + number2->imaginary + number3->imaginary) * BGC_FP64_ONE_THIRD; @@ -490,7 +490,7 @@ inline void bgc_fp64_complex_get_mean3(const BGC_FP64_Complex* number1, const BG // =================== Linear =================== // -inline void bgc_fp32_complex_interpolate(const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, const float phase, BGC_FP32_Complex* interpolation) +inline void bgc_fp32_complex_interpolate(BGC_FP32_Complex* interpolation, const BGC_FP32_Complex* number1, const BGC_FP32_Complex* number2, const float phase) { const float counter_phase = 1.0f - phase; @@ -498,7 +498,7 @@ inline void bgc_fp32_complex_interpolate(const BGC_FP32_Complex* number1, const interpolation->imaginary = number1->imaginary * counter_phase + number2->imaginary * phase; } -inline void bgc_fp64_complex_interpolate(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, const double phase, BGC_FP64_Complex* interpolation) +inline void bgc_fp64_complex_interpolate(BGC_FP64_Complex* interpolation, const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2, const double phase) { const double counter_phase = 1.0 - phase; diff --git a/basic-geometry/cotes-number.c b/basic-geometry/cotes-number.c index d9170ec..f7b99a7 100644 --- a/basic-geometry/cotes-number.c +++ b/basic-geometry/cotes-number.c @@ -7,11 +7,11 @@ const BGC_FP64_CotesNumber BGC_FP64_IDLE_COTES_NUMBER = { 1.0, 0.0 }; extern inline void bgc_fp32_cotes_number_reset(BGC_FP32_CotesNumber* number); extern inline void bgc_fp64_cotes_number_reset(BGC_FP64_CotesNumber* number); -extern inline void bgc_fp32_cotes_number_make(const float x1, const float x2, BGC_FP32_CotesNumber* number); -extern inline void bgc_fp64_cotes_number_make(const double x1, const double x2, BGC_FP64_CotesNumber* number); +extern inline void bgc_fp32_cotes_number_make(BGC_FP32_CotesNumber* number, const float x1, const float x2); +extern inline void bgc_fp64_cotes_number_make(BGC_FP64_CotesNumber* number, const double x1, const double x2); -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_fp64_cotes_number_make_for_angle(const double angle, const int angle_unit, BGC_FP64_CotesNumber* number); +extern inline void bgc_fp32_cotes_number_make_for_angle(BGC_FP32_CotesNumber* number, const float angle, const int angle_unit); +extern inline void bgc_fp64_cotes_number_make_for_angle(BGC_FP64_CotesNumber* number, const double angle, const int angle_unit); extern inline int bgc_fp32_cotes_number_is_idle(const BGC_FP32_CotesNumber* number); extern inline int bgc_fp64_cotes_number_is_idle(const BGC_FP64_CotesNumber* number); @@ -19,41 +19,41 @@ extern inline int bgc_fp64_cotes_number_is_idle(const BGC_FP64_CotesNumber* numb extern inline float bgc_fp32_cotes_number_get_angle(const BGC_FP32_CotesNumber* number, const int angle_unit); extern inline double bgc_fp64_cotes_number_get_angle(const BGC_FP64_CotesNumber* number, const int angle_unit); -extern inline void bgc_fp32_cotes_number_copy(const BGC_FP32_CotesNumber* source, BGC_FP32_CotesNumber* destination); -extern inline void bgc_fp64_cotes_number_copy(const BGC_FP64_CotesNumber* source, BGC_FP64_CotesNumber* destination); +extern inline void bgc_fp32_cotes_number_copy(BGC_FP32_CotesNumber* destination, const BGC_FP32_CotesNumber* source); +extern inline void bgc_fp64_cotes_number_copy(BGC_FP64_CotesNumber* destination, const BGC_FP64_CotesNumber* source); extern inline void bgc_fp32_cotes_number_swap(BGC_FP32_CotesNumber* number1, BGC_FP32_CotesNumber* number2); extern inline void bgc_fp64_cotes_number_swap(BGC_FP64_CotesNumber* number1, BGC_FP64_CotesNumber* number2); -extern inline void bgc_fp64_cotes_number_convert_to_fp32(const BGC_FP64_CotesNumber* source, BGC_FP32_CotesNumber* destination); -extern inline void bgc_fp32_cotes_number_convert_to_fp64(const BGC_FP32_CotesNumber* source, BGC_FP64_CotesNumber* destination); +extern inline void bgc_fp64_cotes_number_convert_to_fp32(BGC_FP32_CotesNumber* destination, const BGC_FP64_CotesNumber* source); +extern inline void bgc_fp32_cotes_number_convert_to_fp64(BGC_FP64_CotesNumber* destination, const BGC_FP32_CotesNumber* source); extern inline void bgc_fp32_cotes_number_revert(BGC_FP32_CotesNumber* number); extern inline void bgc_fp64_cotes_number_revert(BGC_FP64_CotesNumber* number); -extern inline void bgc_fp32_cotes_number_get_reverse(const BGC_FP32_CotesNumber* number, BGC_FP32_CotesNumber* inverse); -extern inline void bgc_fp64_cotes_number_get_inverse(const BGC_FP64_CotesNumber* number, BGC_FP64_CotesNumber* inverse); +extern inline void bgc_fp32_cotes_number_get_reverse(BGC_FP32_CotesNumber* reverse, const BGC_FP32_CotesNumber* number); +extern inline void bgc_fp64_cotes_number_get_reverse(BGC_FP64_CotesNumber* reverse, const BGC_FP64_CotesNumber* number); -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_fp64_cotes_number_get_exponation(const BGC_FP64_CotesNumber* base, const double exponent, BGC_FP64_CotesNumber* power); +extern inline void bgc_fp32_cotes_number_get_exponation(BGC_FP32_CotesNumber* power, const BGC_FP32_CotesNumber* base, const float exponent); +extern inline void bgc_fp64_cotes_number_get_exponation(BGC_FP64_CotesNumber* power, const BGC_FP64_CotesNumber* base, const double exponent); -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_fp64_cotes_number_combine(const BGC_FP64_CotesNumber* number1, const BGC_FP64_CotesNumber* number2, BGC_FP64_CotesNumber* result); +extern inline void bgc_fp32_cotes_number_combine(BGC_FP32_CotesNumber* combination, const BGC_FP32_CotesNumber* number1, const BGC_FP32_CotesNumber* number2); +extern inline void bgc_fp64_cotes_number_combine(BGC_FP64_CotesNumber* combination, const BGC_FP64_CotesNumber* number1, const BGC_FP64_CotesNumber* number2); -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_fp64_cotes_number_exclude(const BGC_FP64_CotesNumber* base, const BGC_FP64_CotesNumber* excludant, BGC_FP64_CotesNumber* difference); +extern inline void bgc_fp32_cotes_number_exclude(BGC_FP32_CotesNumber* difference, const BGC_FP32_CotesNumber* base, const BGC_FP32_CotesNumber* excludant); +extern inline void bgc_fp64_cotes_number_exclude(BGC_FP64_CotesNumber* difference, const BGC_FP64_CotesNumber* base, const BGC_FP64_CotesNumber* excludant); -extern inline void bgc_fp32_cotes_number_get_rotation_matrix(const BGC_FP32_CotesNumber* number, BGC_FP32_Matrix2x2* matrix); -extern inline void bgc_fp64_cotes_number_get_rotation_matrix(const BGC_FP64_CotesNumber* number, BGC_FP64_Matrix2x2* matrix); +extern inline void bgc_fp32_cotes_number_get_rotation_matrix(BGC_FP32_Matrix2x2* matrix, const BGC_FP32_CotesNumber* number); +extern inline void bgc_fp64_cotes_number_get_rotation_matrix(BGC_FP64_Matrix2x2* matrix, const BGC_FP64_CotesNumber* number); -extern inline void bgc_fp32_cotes_number_get_reverse_matrix(const BGC_FP32_CotesNumber* number, BGC_FP32_Matrix2x2* matrix); -extern inline void bgc_fp64_cotes_number_get_reverse_matrix(const BGC_FP64_CotesNumber* number, BGC_FP64_Matrix2x2* matrix); +extern inline void bgc_fp32_cotes_number_get_reverse_matrix(BGC_FP32_Matrix2x2* matrix, const BGC_FP32_CotesNumber* number); +extern inline void bgc_fp64_cotes_number_get_reverse_matrix(BGC_FP64_Matrix2x2* matrix, const BGC_FP64_CotesNumber* number); -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_fp64_cotes_number_turn_vector(const BGC_FP64_CotesNumber* number, const BGC_FP64_Vector2* vector, BGC_FP64_Vector2* result); +extern inline void bgc_fp32_cotes_number_turn_vector(BGC_FP32_Vector2* turned_vector, const BGC_FP32_CotesNumber* number, const BGC_FP32_Vector2* vector); +extern inline void bgc_fp64_cotes_number_turn_vector(BGC_FP64_Vector2* turned_vector, const BGC_FP64_CotesNumber* number, const BGC_FP64_Vector2* vector); -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_fp64_cotes_number_turn_vector_back(const BGC_FP64_CotesNumber* number, const BGC_FP64_Vector2* vector, BGC_FP64_Vector2* result); +extern inline void bgc_fp32_cotes_number_turn_vector_back(BGC_FP32_Vector2* turned_vector, const BGC_FP32_CotesNumber* number, const BGC_FP32_Vector2* vector); +extern inline void bgc_fp64_cotes_number_turn_vector_back(BGC_FP64_Vector2* turned_vector, const BGC_FP64_CotesNumber* number, const BGC_FP64_Vector2* vector); extern inline int bgc_fp32_cotes_number_are_close(const BGC_FP32_CotesNumber* number1, const BGC_FP32_CotesNumber* number2); extern inline int bgc_fp64_cotes_number_are_close(const BGC_FP64_CotesNumber* number1, const BGC_FP64_CotesNumber* number2); diff --git a/basic-geometry/cotes-number.h b/basic-geometry/cotes-number.h index a3bdc79..f40a3d5 100644 --- a/basic-geometry/cotes-number.h +++ b/basic-geometry/cotes-number.h @@ -41,7 +41,7 @@ inline void bgc_fp64_cotes_number_reset(BGC_FP64_CotesNumber* number) // ================== Set Turn ================== // -inline void bgc_fp32_cotes_number_make_for_angle(const float angle, const int angle_unit, BGC_FP32_CotesNumber* number) +inline void bgc_fp32_cotes_number_make_for_angle(BGC_FP32_CotesNumber* number, const float angle, const int angle_unit) { const float radians = bgc_fp32_angle_to_radians(angle, angle_unit); @@ -49,7 +49,7 @@ inline void bgc_fp32_cotes_number_make_for_angle(const float angle, const int an number->_sin = sinf(radians); } -inline void bgc_fp64_cotes_number_make_for_angle(const double angle, const int angle_unit, BGC_FP64_CotesNumber* number) +inline void bgc_fp64_cotes_number_make_for_angle(BGC_FP64_CotesNumber* number, const double angle, const int angle_unit) { const double radians = bgc_fp64_angle_to_radians(angle, angle_unit); @@ -76,7 +76,7 @@ void _bgc_fp32_cotes_number_normalize(BGC_FP32_CotesNumber* twin); void _bgc_fp64_cotes_number_normalize(BGC_FP64_CotesNumber* twin); -inline void bgc_fp32_cotes_number_make(const float x1, const float x2, BGC_FP32_CotesNumber* number) +inline void bgc_fp32_cotes_number_make(BGC_FP32_CotesNumber* number, const float x1, const float x2) { const float square_modulus = x1 * x1 + x2 * x2; @@ -88,7 +88,7 @@ inline void bgc_fp32_cotes_number_make(const float x1, const float x2, BGC_FP32_ } } -inline void bgc_fp64_cotes_number_make(const double x1, const double x2, BGC_FP64_CotesNumber* number) +inline void bgc_fp64_cotes_number_make(BGC_FP64_CotesNumber* number, const double x1, const double x2) { const double square_modulus = x1 * x1 + x2 * x2; @@ -114,13 +114,13 @@ inline double bgc_fp64_cotes_number_get_angle(const BGC_FP64_CotesNumber* number // ==================== Copy ==================== // -inline void bgc_fp32_cotes_number_copy(const BGC_FP32_CotesNumber* source, BGC_FP32_CotesNumber* destination) +inline void bgc_fp32_cotes_number_copy(BGC_FP32_CotesNumber* destination, const BGC_FP32_CotesNumber* source) { destination->_cos = source->_cos; destination->_sin = source->_sin; } -inline void bgc_fp64_cotes_number_copy(const BGC_FP64_CotesNumber* source, BGC_FP64_CotesNumber* destination) +inline void bgc_fp64_cotes_number_copy(BGC_FP64_CotesNumber* destination, const BGC_FP64_CotesNumber* source) { destination->_cos = source->_cos; destination->_sin = source->_sin; @@ -154,14 +154,14 @@ inline void bgc_fp64_cotes_number_swap(BGC_FP64_CotesNumber* number1, BGC_FP64_C // ================== Convert =================== // -inline void bgc_fp64_cotes_number_convert_to_fp32(const BGC_FP64_CotesNumber* source, BGC_FP32_CotesNumber* destination) +inline void bgc_fp64_cotes_number_convert_to_fp32(BGC_FP32_CotesNumber* destination, const BGC_FP64_CotesNumber* source) { - bgc_fp32_cotes_number_make((float)source->_cos, (float)source->_sin, destination); + bgc_fp32_cotes_number_make(destination, (float)source->_cos, (float)source->_sin); } -inline void bgc_fp32_cotes_number_convert_to_fp64(const BGC_FP32_CotesNumber* source, BGC_FP64_CotesNumber* destination) +inline void bgc_fp32_cotes_number_convert_to_fp64(BGC_FP64_CotesNumber* destination, const BGC_FP32_CotesNumber* source) { - bgc_fp64_cotes_number_make((double)source->_cos, (double)source->_sin, destination); + bgc_fp64_cotes_number_make(destination, (double)source->_cos, (double)source->_sin); } // =================== Revert =================== // @@ -176,21 +176,21 @@ inline void bgc_fp64_cotes_number_revert(BGC_FP64_CotesNumber* number) number->_sin = -number->_sin; } -inline void bgc_fp32_cotes_number_get_reverse(const BGC_FP32_CotesNumber* number, BGC_FP32_CotesNumber* inverse) +inline void bgc_fp32_cotes_number_get_reverse(BGC_FP32_CotesNumber* reverse, const BGC_FP32_CotesNumber* number) { - inverse->_cos = number->_cos; - inverse->_sin = -number->_sin; + reverse->_cos = number->_cos; + reverse->_sin = -number->_sin; } -inline void bgc_fp64_cotes_number_get_inverse(const BGC_FP64_CotesNumber* number, BGC_FP64_CotesNumber* inverse) +inline void bgc_fp64_cotes_number_get_reverse(BGC_FP64_CotesNumber* reverse, const BGC_FP64_CotesNumber* number) { - inverse->_cos = number->_cos; - inverse->_sin = -number->_sin; + reverse->_cos = number->_cos; + reverse->_sin = -number->_sin; } // ================= Exponation ================= // -inline void bgc_fp32_cotes_number_get_exponation(const BGC_FP32_CotesNumber* base, const float exponent, BGC_FP32_CotesNumber* power) +inline void bgc_fp32_cotes_number_get_exponation(BGC_FP32_CotesNumber* power, const BGC_FP32_CotesNumber* base, const float exponent) { const float power_angle = exponent * atan2f(base->_sin, base->_cos); @@ -198,7 +198,7 @@ inline void bgc_fp32_cotes_number_get_exponation(const BGC_FP32_CotesNumber* bas power->_sin = sinf(power_angle); } -inline void bgc_fp64_cotes_number_get_exponation(const BGC_FP64_CotesNumber* base, const double exponent, BGC_FP64_CotesNumber* power) +inline void bgc_fp64_cotes_number_get_exponation(BGC_FP64_CotesNumber* power, const BGC_FP64_CotesNumber* base, const double exponent) { const double power_angle = exponent * atan2(base->_sin, base->_cos); @@ -208,47 +208,47 @@ inline void bgc_fp64_cotes_number_get_exponation(const BGC_FP64_CotesNumber* bas // ================ Combination ================= // -inline void bgc_fp32_cotes_number_combine(const BGC_FP32_CotesNumber* number1, const BGC_FP32_CotesNumber* number2, BGC_FP32_CotesNumber* result) +inline void bgc_fp32_cotes_number_combine(BGC_FP32_CotesNumber* combination, const BGC_FP32_CotesNumber* number1, const BGC_FP32_CotesNumber* number2) { bgc_fp32_cotes_number_make( + combination, number1->_cos * number2->_cos - number1->_sin * number2->_sin, - number1->_cos * number2->_sin + number1->_sin * number2->_cos, - result + number1->_cos * number2->_sin + number1->_sin * number2->_cos ); } -inline void bgc_fp64_cotes_number_combine(const BGC_FP64_CotesNumber* number1, const BGC_FP64_CotesNumber* number2, BGC_FP64_CotesNumber* result) +inline void bgc_fp64_cotes_number_combine(BGC_FP64_CotesNumber* combination, const BGC_FP64_CotesNumber* number1, const BGC_FP64_CotesNumber* number2) { bgc_fp64_cotes_number_make( + combination, number1->_cos * number2->_cos - number1->_sin * number2->_sin, - number1->_cos * number2->_sin + number1->_sin * number2->_cos, - result + number1->_cos * number2->_sin + number1->_sin * number2->_cos ); } // ================= Exclusion ================== // -inline void bgc_fp32_cotes_number_exclude(const BGC_FP32_CotesNumber* base, const BGC_FP32_CotesNumber* excludant, BGC_FP32_CotesNumber* difference) +inline void bgc_fp32_cotes_number_exclude(BGC_FP32_CotesNumber* difference, const BGC_FP32_CotesNumber* base, const BGC_FP32_CotesNumber* excludant) { bgc_fp32_cotes_number_make( + difference, base->_cos * excludant->_cos + base->_sin * excludant->_sin, - base->_sin * excludant->_cos - base->_cos * excludant->_sin, - difference + base->_sin * excludant->_cos - base->_cos * excludant->_sin ); } -inline void bgc_fp64_cotes_number_exclude(const BGC_FP64_CotesNumber* base, const BGC_FP64_CotesNumber* excludant, BGC_FP64_CotesNumber* difference) +inline void bgc_fp64_cotes_number_exclude(BGC_FP64_CotesNumber* difference, const BGC_FP64_CotesNumber* base, const BGC_FP64_CotesNumber* excludant) { bgc_fp64_cotes_number_make( + difference, base->_cos * excludant->_cos + base->_sin * excludant->_sin, - base->_sin * excludant->_cos - base->_cos * excludant->_sin, - difference + base->_sin * excludant->_cos - base->_cos * excludant->_sin ); } // ============== Rotation Matrix =============== // -inline void bgc_fp32_cotes_number_get_rotation_matrix(const BGC_FP32_CotesNumber* number, BGC_FP32_Matrix2x2* matrix) +inline void bgc_fp32_cotes_number_get_rotation_matrix(BGC_FP32_Matrix2x2* matrix, const BGC_FP32_CotesNumber* number) { matrix->r1c1 = number->_cos; matrix->r1c2 = -number->_sin; @@ -256,7 +256,7 @@ inline void bgc_fp32_cotes_number_get_rotation_matrix(const BGC_FP32_CotesNumber matrix->r2c2 = number->_cos; } -inline void bgc_fp64_cotes_number_get_rotation_matrix(const BGC_FP64_CotesNumber* number, BGC_FP64_Matrix2x2* matrix) +inline void bgc_fp64_cotes_number_get_rotation_matrix(BGC_FP64_Matrix2x2* matrix, const BGC_FP64_CotesNumber* number) { matrix->r1c1 = number->_cos; matrix->r1c2 = -number->_sin; @@ -266,7 +266,7 @@ inline void bgc_fp64_cotes_number_get_rotation_matrix(const BGC_FP64_CotesNumber // ============== Reverse Matrix ================ // -inline void bgc_fp32_cotes_number_get_reverse_matrix(const BGC_FP32_CotesNumber* number, BGC_FP32_Matrix2x2* matrix) +inline void bgc_fp32_cotes_number_get_reverse_matrix(BGC_FP32_Matrix2x2* matrix, const BGC_FP32_CotesNumber* number) { matrix->r1c1 = number->_cos; matrix->r1c2 = number->_sin; @@ -274,7 +274,7 @@ inline void bgc_fp32_cotes_number_get_reverse_matrix(const BGC_FP32_CotesNumber* matrix->r2c2 = number->_cos; } -inline void bgc_fp64_cotes_number_get_reverse_matrix(const BGC_FP64_CotesNumber* number, BGC_FP64_Matrix2x2* matrix) +inline void bgc_fp64_cotes_number_get_reverse_matrix(BGC_FP64_Matrix2x2* matrix, const BGC_FP64_CotesNumber* number) { matrix->r1c1 = number->_cos; matrix->r1c2 = number->_sin; @@ -284,42 +284,42 @@ inline void bgc_fp64_cotes_number_get_reverse_matrix(const BGC_FP64_CotesNumber* // ================ Turn Vector ================= // -inline void bgc_fp32_cotes_number_turn_vector(const BGC_FP32_CotesNumber* number, const BGC_FP32_Vector2* vector, BGC_FP32_Vector2* result) +inline void bgc_fp32_cotes_number_turn_vector(BGC_FP32_Vector2* turned_vector, const BGC_FP32_CotesNumber* number, const BGC_FP32_Vector2* vector) { const float x1 = number->_cos * vector->x1 - number->_sin * vector->x2; const float x2 = number->_sin * vector->x1 + number->_cos * vector->x2; - result->x1 = x1; - result->x2 = x2; + turned_vector->x1 = x1; + turned_vector->x2 = x2; } -inline void bgc_fp64_cotes_number_turn_vector(const BGC_FP64_CotesNumber* number, const BGC_FP64_Vector2* vector, BGC_FP64_Vector2* result) +inline void bgc_fp64_cotes_number_turn_vector(BGC_FP64_Vector2* turned_vector, const BGC_FP64_CotesNumber* number, const BGC_FP64_Vector2* vector) { const double x1 = number->_cos * vector->x1 - number->_sin * vector->x2; const double x2 = number->_sin * vector->x1 + number->_cos * vector->x2; - result->x1 = x1; - result->x2 = x2; + turned_vector->x1 = x1; + turned_vector->x2 = x2; } // ============ Turn Vector Backward ============ // -inline void bgc_fp32_cotes_number_turn_vector_back(const BGC_FP32_CotesNumber* number, const BGC_FP32_Vector2* vector, BGC_FP32_Vector2* result) +inline void bgc_fp32_cotes_number_turn_vector_back(BGC_FP32_Vector2* turned_vector, const BGC_FP32_CotesNumber* number, const BGC_FP32_Vector2* vector) { const float x1 = number->_sin * vector->x2 + number->_cos * vector->x1; const float x2 = number->_cos * vector->x2 - number->_sin * vector->x1; - result->x1 = x1; - result->x2 = x2; + turned_vector->x1 = x1; + turned_vector->x2 = x2; } -inline void bgc_fp64_cotes_number_turn_vector_back(const BGC_FP64_CotesNumber* number, const BGC_FP64_Vector2* vector, BGC_FP64_Vector2* result) +inline void bgc_fp64_cotes_number_turn_vector_back(BGC_FP64_Vector2* turned_vector, const BGC_FP64_CotesNumber* number, const BGC_FP64_Vector2* vector) { const double x1 = number->_sin * vector->x2 + number->_cos * vector->x1; const double x2 = number->_cos * vector->x2 - number->_sin * vector->x1; - result->x1 = x1; - result->x2 = x2; + turned_vector->x1 = x1; + turned_vector->x2 = x2; } // ================== Are Close ================= // diff --git a/basic-geometry/matrices.c b/basic-geometry/matrices.c new file mode 100644 index 0000000..450f51a --- /dev/null +++ b/basic-geometry/matrices.c @@ -0,0 +1,25 @@ +#include "matrices.h" + +extern inline void bgc_fp32_multiply_matrix2x2_by_matrix2x2(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2); +extern inline void bgc_fp64_multiply_matrix2x2_by_matrix2x2(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2); + +extern inline void bgc_fp32_multiply_matrix2x2_by_matrix3x2(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix3x2* matrix2); +extern inline void bgc_fp64_multiply_matrix2x2_by_matrix3x2(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix3x2* matrix2); + +extern inline void bgc_fp32_multiply_matrix2x3_by_matrix2x2(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x2* matrix2); +extern inline void bgc_fp64_multiply_matrix2x3_by_matrix2x2(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x2* matrix2); + +extern inline void bgc_fp32_multiply_matrix2x3_by_matrix3x2(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix3x2* matrix2); +extern inline void bgc_fp64_multiply_matrix2x3_by_matrix3x2(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix3x2* matrix2); + +extern inline void bgc_fp32_multiply_matrix3x2_by_matrix2x3(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix2x3* matrix2); +extern inline void bgc_fp64_multiply_matrix3x2_by_matrix2x3(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix2x3* matrix2); + +extern inline void bgc_fp32_multiply_matrix3x2_by_matrix3x3(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x3* matrix2); +extern inline void bgc_fp64_multiply_matrix3x2_by_matrix3x3(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x3* matrix2); + +extern inline void bgc_fp32_multiply_matrix3x3_by_matrix2x3(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix2x3* matrix2); +extern inline void bgc_fp64_multiply_matrix3x3_by_matrix2x3(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix2x3* matrix2); + +extern inline void bgc_fp32_multiply_matrix3x3_by_matrix3x3(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2); +extern inline void bgc_fp64_multiply_matrix3x3_by_matrix3x3(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2); diff --git a/basic-geometry/matrixes.h b/basic-geometry/matrices.h similarity index 84% rename from basic-geometry/matrixes.h rename to basic-geometry/matrices.h index 09cfc0e..3f2180e 100644 --- a/basic-geometry/matrixes.h +++ b/basic-geometry/matrices.h @@ -1,5 +1,5 @@ -#ifndef _BGC_MATRIX_TYPES_H_ -#define _BGC_MATRIX_TYPES_H_ +#ifndef _BGC_MATRICES_H_ +#define _BGC_MATRICES_H_ // ================== Matrix2x2 ================= // @@ -55,7 +55,7 @@ typedef struct { // ========== Matrix Product 2x2 at 2x2 ========= // -inline void bgc_fp32_multiply_matrix2x2_by_matrix2x2(const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2, BGC_FP32_Matrix2x2* product) +inline void bgc_fp32_multiply_matrix2x2_by_matrix2x2(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2) { const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1; const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2; @@ -70,7 +70,7 @@ inline void bgc_fp32_multiply_matrix2x2_by_matrix2x2(const BGC_FP32_Matrix2x2* m product->r2c2 = r2c2; } -inline void bgc_fp64_multiply_matrix2x2_by_matrix2x2(const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2, BGC_FP64_Matrix2x2* product) +inline void bgc_fp64_multiply_matrix2x2_by_matrix2x2(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2) { const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1; const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2; @@ -87,7 +87,7 @@ inline void bgc_fp64_multiply_matrix2x2_by_matrix2x2(const BGC_FP64_Matrix2x2* m // ========== Matrix Product 2x2 at 3x2 ========= // -inline void bgc_fp32_multiply_matrix2x2_by_matrix3x2(const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix3x2* matrix2, BGC_FP32_Matrix3x2* product) +inline void bgc_fp32_multiply_matrix2x2_by_matrix3x2(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix3x2* matrix2) { const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1; const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2; @@ -106,7 +106,7 @@ inline void bgc_fp32_multiply_matrix2x2_by_matrix3x2(const BGC_FP32_Matrix2x2* m 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) +inline void bgc_fp64_multiply_matrix2x2_by_matrix3x2(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix3x2* matrix2) { const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1; const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2; @@ -127,7 +127,7 @@ inline void bgc_fp64_multiply_matrix2x2_by_matrix3x2(const BGC_FP64_Matrix2x2* m // ========== Matrix Product 2x3 at 2x2 ========= // -inline void bgc_fp32_multiply_matrix2x3_by_matrix2x2(const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x2* matrix2, BGC_FP32_Matrix2x3* product) +inline void bgc_fp32_multiply_matrix2x3_by_matrix2x2(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x2* matrix2) { const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1; const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2; @@ -148,7 +148,7 @@ inline void bgc_fp32_multiply_matrix2x3_by_matrix2x2(const BGC_FP32_Matrix2x3* m 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) +inline void bgc_fp64_multiply_matrix2x3_by_matrix2x2(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x2* matrix2) { const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1; const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2; @@ -171,7 +171,7 @@ inline void bgc_fp64_multiply_matrix2x3_by_matrix2x2(const BGC_FP64_Matrix2x3* m // ========== Matrix Product 2x3 at 3x2 ========= // -inline void bgc_fp32_multiply_matrix2x3_by_matrix3x2(const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix3x2* matrix2, BGC_FP32_Matrix3x3* product) +inline void bgc_fp32_multiply_matrix2x3_by_matrix3x2(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix3x2* matrix2) { product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1; product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2; @@ -186,7 +186,7 @@ inline void bgc_fp32_multiply_matrix2x3_by_matrix3x2(const BGC_FP32_Matrix2x3* m 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) +inline void bgc_fp64_multiply_matrix2x3_by_matrix3x2(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix3x2* matrix2) { product->r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1; product->r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2; @@ -203,7 +203,7 @@ inline void bgc_fp64_multiply_matrix2x3_by_matrix3x2(const BGC_FP64_Matrix2x3* m // ========== Matrix Product 3x2 at 2x3 ========= // -inline void bgc_fp32_multiply_matrix3x2_by_matrix2x3(const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix2x3* matrix2, BGC_FP32_Matrix2x2* product) +inline void bgc_fp32_multiply_matrix3x2_by_matrix2x3(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix2x3* matrix2) { 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; @@ -212,7 +212,7 @@ inline void bgc_fp32_multiply_matrix3x2_by_matrix2x3(const BGC_FP32_Matrix3x2* m 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) +inline void bgc_fp64_multiply_matrix3x2_by_matrix2x3(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix2x3* matrix2) { 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; @@ -223,7 +223,7 @@ inline void bgc_fp64_multiply_matrix3x2_by_matrix2x3(const BGC_FP64_Matrix3x2* m // ========== Matrix Product 3x2 at 3x3 ========= // -inline void bgc_fp32_multiply_matrix3x2_by_matrix3x3(const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x3* matrix2, BGC_FP32_Matrix3x2* product) +inline void bgc_fp32_multiply_matrix3x2_by_matrix3x3(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x3* matrix2) { 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; @@ -242,7 +242,7 @@ inline void bgc_fp32_multiply_matrix3x2_by_matrix3x3(const BGC_FP32_Matrix3x2* m 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) +inline void bgc_fp64_multiply_matrix3x2_by_matrix3x3(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x3* matrix2) { 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; @@ -263,7 +263,7 @@ inline void bgc_fp64_multiply_matrix3x2_by_matrix3x3(const BGC_FP64_Matrix3x2* m // ========== Matrix Product 3x3 at 2x3 ========= // -inline void bgc_fp32_multiply_matrix3x3_by_matrix2x3(const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix2x3* matrix2, BGC_FP32_Matrix2x3* product) +inline void bgc_fp32_multiply_matrix3x3_by_matrix2x3(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix2x3* matrix2) { 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; @@ -284,7 +284,7 @@ inline void bgc_fp32_multiply_matrix3x3_by_matrix2x3(const BGC_FP32_Matrix3x3* m 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) +inline void bgc_fp64_multiply_matrix3x3_by_matrix2x3(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix2x3* matrix2) { 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; @@ -307,7 +307,7 @@ inline void bgc_fp64_multiply_matrix3x3_by_matrix2x3(const BGC_FP64_Matrix3x3* m // ========== Matrix Product 3x3 at 3x3 ========= // -inline void bgc_fp32_multiply_matrix3x3_by_matrix3x3(const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2, BGC_FP32_Matrix3x3* product) +inline void bgc_fp32_multiply_matrix3x3_by_matrix3x3(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2) { 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; @@ -334,7 +334,7 @@ inline void bgc_fp32_multiply_matrix3x3_by_matrix3x3(const BGC_FP32_Matrix3x3* m 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) +inline void bgc_fp64_multiply_matrix3x3_by_matrix3x3(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2) { 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; diff --git a/basic-geometry/matrix2x2.c b/basic-geometry/matrix2x2.c index 8fb27af..7fd4224 100644 --- a/basic-geometry/matrix2x2.c +++ b/basic-geometry/matrix2x2.c @@ -6,11 +6,11 @@ extern inline void bgc_fp64_matrix2x2_reset(BGC_FP64_Matrix2x2* matrix); extern inline void bgc_fp32_matrix2x2_make_identity(BGC_FP32_Matrix2x2* matrix); extern inline void bgc_fp64_matrix2x2_make_identity(BGC_FP64_Matrix2x2* matrix); -extern inline void bgc_fp32_matrix2x2_make_diagonal(const float d1, const float d2, BGC_FP32_Matrix2x2* matrix); -extern inline void bgc_fp64_matrix2x2_make_diagonal(const double d1, const double d2, BGC_FP64_Matrix2x2* matrix); +extern inline void bgc_fp32_matrix2x2_make_diagonal(BGC_FP32_Matrix2x2* matrix, const float d1, const float d2); +extern inline void bgc_fp64_matrix2x2_make_diagonal(BGC_FP64_Matrix2x2* matrix, const double d1, const double d2); -extern inline void bgc_fp32_matrix2x2_make_for_turn(const float angle, const int angle_unit, BGC_FP32_Matrix2x2* matrix); -extern inline void bgc_fp64_matrix2x2_make_for_turn(const double angle, const int angle_unit, BGC_FP64_Matrix2x2* matrix); +extern inline void bgc_fp32_matrix2x2_make_for_turn(BGC_FP32_Matrix2x2* matrix, const float angle, const int angle_unit); +extern inline void bgc_fp64_matrix2x2_make_for_turn(BGC_FP64_Matrix2x2* matrix, const double angle, const int angle_unit); extern inline float bgc_fp32_matrix2x2_get_determinant(const BGC_FP32_Matrix2x2* matrix); extern inline double bgc_fp64_matrix2x2_get_determinant(const BGC_FP64_Matrix2x2* matrix); @@ -24,17 +24,17 @@ extern inline int bgc_fp64_matrix2x2_is_singular(const BGC_FP64_Matrix2x2* matri extern inline int bgc_fp32_matrix2x2_is_rotation(const BGC_FP32_Matrix2x2* matrix); extern inline int bgc_fp64_matrix2x2_is_rotation(const BGC_FP64_Matrix2x2* matrix); -extern inline void bgc_fp32_matrix2x2_copy(const BGC_FP32_Matrix2x2* source, BGC_FP32_Matrix2x2* destination); -extern inline void bgc_fp64_matrix2x2_copy(const BGC_FP64_Matrix2x2* source, BGC_FP64_Matrix2x2* destination); +extern inline void bgc_fp32_matrix2x2_copy(BGC_FP32_Matrix2x2* destination, const BGC_FP32_Matrix2x2* source); +extern inline void bgc_fp64_matrix2x2_copy(BGC_FP64_Matrix2x2* destination, const BGC_FP64_Matrix2x2* source); extern inline void bgc_fp32_matrix2x2_swap(BGC_FP32_Matrix2x2* matrix1, BGC_FP32_Matrix2x2* matrix2); extern inline void bgc_fp64_matrix2x2_swap(BGC_FP64_Matrix2x2* matrix1, BGC_FP64_Matrix2x2* matrix2); -extern inline void bgc_fp64_matrix2x2_convert_to_fp32(const BGC_FP64_Matrix2x2* source, BGC_FP32_Matrix2x2* destination); -extern inline void bgc_fp32_matrix2x2_convert_to_fp64(const BGC_FP32_Matrix2x2* source, BGC_FP64_Matrix2x2* destination); +extern inline void bgc_fp64_matrix2x2_convert_to_fp32(BGC_FP32_Matrix2x2* destination, const BGC_FP64_Matrix2x2* source); +extern inline void bgc_fp32_matrix2x2_convert_to_fp64(BGC_FP64_Matrix2x2* destination, const BGC_FP32_Matrix2x2* source); -extern inline int bgc_fp32_matrix2x2_get_inverse(const BGC_FP32_Matrix2x2* matrix, BGC_FP32_Matrix2x2* inverse); -extern inline int bgc_fp64_matrix2x2_get_inverse(const BGC_FP64_Matrix2x2* matrix, BGC_FP64_Matrix2x2* inverse); +extern inline int bgc_fp32_matrix2x2_get_inverse(BGC_FP32_Matrix2x2* inverse, const BGC_FP32_Matrix2x2* matrix); +extern inline int bgc_fp64_matrix2x2_get_inverse(BGC_FP64_Matrix2x2* inverse, const BGC_FP64_Matrix2x2* matrix); extern inline int bgc_fp32_matrix2x2_invert(BGC_FP32_Matrix2x2* matrix); extern inline int bgc_fp64_matrix2x2_invert(BGC_FP64_Matrix2x2* matrix); @@ -42,41 +42,41 @@ extern inline int bgc_fp64_matrix2x2_invert(BGC_FP64_Matrix2x2* matrix); extern inline void bgc_fp32_matrix2x2_transpose(BGC_FP32_Matrix2x2* matrix); extern inline void bgc_fp64_matrix2x2_transpose(BGC_FP64_Matrix2x2* matrix); -extern inline void bgc_fp32_matrix2x2_get_transposed(const BGC_FP32_Matrix2x2* matrix, BGC_FP32_Matrix2x2* transposed); -extern inline void bgc_fp64_matrix2x2_get_transposed(const BGC_FP64_Matrix2x2* matrix, BGC_FP64_Matrix2x2* transposed); +extern inline void bgc_fp32_matrix2x2_get_transposed(BGC_FP32_Matrix2x2* transposed, const BGC_FP32_Matrix2x2* matrix); +extern inline void bgc_fp64_matrix2x2_get_transposed(BGC_FP64_Matrix2x2* transposed, const BGC_FP64_Matrix2x2* 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_fp64_matrix2x2_get_row(const int number, const BGC_FP64_Matrix2x2* matrix, BGC_FP64_Vector2* row); +extern inline void bgc_fp32_matrix2x2_get_row(BGC_FP32_Vector2* row, const BGC_FP32_Matrix2x2* matrix, const int row_number); +extern inline void bgc_fp64_matrix2x2_get_row(BGC_FP64_Vector2* row, const BGC_FP64_Matrix2x2* matrix, const int row_number); -extern inline void bgc_fp32_matrix2x2_set_row(const int number, const BGC_FP32_Vector2* row, BGC_FP32_Matrix2x2* matrix); -extern inline void bgc_fp64_matrix2x2_set_row(const int number, const BGC_FP64_Vector2* row, BGC_FP64_Matrix2x2* matrix); +extern inline void bgc_fp32_matrix2x2_set_row(BGC_FP32_Matrix2x2* matrix, const int row_number, const BGC_FP32_Vector2* row); +extern inline void bgc_fp64_matrix2x2_set_row(BGC_FP64_Matrix2x2* matrix, const int row_number, const BGC_FP64_Vector2* row); -extern inline void bgc_fp32_matrix2x2_get_column(const int number, const BGC_FP32_Matrix2x2* matrix, BGC_FP32_Vector2* column); -extern inline void bgc_fp64_matrix2x2_get_column(const int number, const BGC_FP64_Matrix2x2* matrix, BGC_FP64_Vector2* column); +extern inline void bgc_fp32_matrix2x2_get_column(BGC_FP32_Vector2* column, const BGC_FP32_Matrix2x2* matrix, const int column_number); +extern inline void bgc_fp64_matrix2x2_get_column(BGC_FP64_Vector2* column, const BGC_FP64_Matrix2x2* matrix, const int column_number); -extern inline void bgc_fp32_matrix2x2_set_column(const int number, const BGC_FP32_Vector2* column, BGC_FP32_Matrix2x2* matrix); -extern inline void bgc_fp64_matrix2x2_set_column(const int number, const BGC_FP64_Vector2* column, BGC_FP64_Matrix2x2* matrix); +extern inline void bgc_fp32_matrix2x2_set_column(BGC_FP32_Matrix2x2* matrix, const int column_number, const BGC_FP32_Vector2* column); +extern inline void bgc_fp64_matrix2x2_set_column(BGC_FP64_Matrix2x2* matrix, const int column_number, const BGC_FP64_Vector2* column); -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_fp64_matrix2x2_add(const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2, BGC_FP64_Matrix2x2* sum); +extern inline void bgc_fp32_matrix2x2_add(BGC_FP32_Matrix2x2* sum, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2); +extern inline void bgc_fp64_matrix2x2_add(BGC_FP64_Matrix2x2* sum, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2); -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_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_fp32_matrix2x2_add_scaled(BGC_FP32_Matrix2x2* sum, const BGC_FP32_Matrix2x2* basic_matrix, const BGC_FP32_Matrix2x2* scalable_matrix, const float scale); +extern inline void bgc_fp64_matrix2x2_add_scaled(BGC_FP64_Matrix2x2* sum, const BGC_FP64_Matrix2x2* basic_matrix, const BGC_FP64_Matrix2x2* scalable_matrix, const double scale); -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_fp64_matrix2x2_subtract(const BGC_FP64_Matrix2x2* minuend, const BGC_FP64_Matrix2x2* subtrahend, BGC_FP64_Matrix2x2* difference); +extern inline void bgc_fp32_matrix2x2_subtract(BGC_FP32_Matrix2x2* difference, const BGC_FP32_Matrix2x2* minuend, const BGC_FP32_Matrix2x2* subtrahend); +extern inline void bgc_fp64_matrix2x2_subtract(BGC_FP64_Matrix2x2* difference, const BGC_FP64_Matrix2x2* minuend, const BGC_FP64_Matrix2x2* subtrahend); -extern inline void bgc_fp32_matrix2x2_multiply(const BGC_FP32_Matrix2x2* multiplicand, const float multiplier, BGC_FP32_Matrix2x2* product); -extern inline void bgc_fp64_matrix2x2_multiply(const BGC_FP64_Matrix2x2* multiplicand, const double multiplier, BGC_FP64_Matrix2x2* product); +extern inline void bgc_fp32_matrix2x2_multiply(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* multiplicand, const float multiplier); +extern inline void bgc_fp64_matrix2x2_multiply(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* multiplicand, const double multiplier); -extern inline void bgc_fp32_matrix2x2_divide(const BGC_FP32_Matrix2x2* dividend, const float divisor, BGC_FP32_Matrix2x2* quotient); -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_divide(BGC_FP32_Matrix2x2* quotient, const BGC_FP32_Matrix2x2* dividend, const float divisor); +extern inline void bgc_fp64_matrix2x2_divide(BGC_FP64_Matrix2x2* quotient, const BGC_FP64_Matrix2x2* dividend, const double divisor); -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_matrix2x2_interpolate(BGC_FP32_Matrix2x2* interpolation, const BGC_FP32_Matrix2x2* first, const BGC_FP32_Matrix2x2* second, const float phase); +extern inline void bgc_fp64_matrix2x2_interpolate(BGC_FP64_Matrix2x2* interpolation, const BGC_FP64_Matrix2x2* first, const BGC_FP64_Matrix2x2* second, const double phase); -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_matrix2x2_by_vector2(BGC_FP32_Vector2* product, const BGC_FP32_Matrix2x2* matrix, const BGC_FP32_Vector2* vector); +extern inline void bgc_fp64_multiply_matrix2x2_by_vector2(BGC_FP64_Vector2* product, const BGC_FP64_Matrix2x2* matrix, const BGC_FP64_Vector2* vector); -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); +extern inline void bgc_fp32_multiply_vector2_by_matrix2x2(BGC_FP32_Vector2* product, const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix2x2* matrix); +extern inline void bgc_fp64_multiply_vector2_by_matrix2x2(BGC_FP64_Vector2* product, const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix2x2* matrix); diff --git a/basic-geometry/matrix2x2.h b/basic-geometry/matrix2x2.h index e95d3a4..f84d444 100644 --- a/basic-geometry/matrix2x2.h +++ b/basic-geometry/matrix2x2.h @@ -3,7 +3,7 @@ #include "angle.h" #include "vector2.h" -#include "matrixes.h" +#include "matrices.h" // =================== Reset ==================== // @@ -43,7 +43,7 @@ inline void bgc_fp64_matrix2x2_make_identity(BGC_FP64_Matrix2x2* matrix) // ================ Set Diagonal ================ // -inline void bgc_fp32_matrix2x2_make_diagonal(const float d1, const float d2, BGC_FP32_Matrix2x2* matrix) +inline void bgc_fp32_matrix2x2_make_diagonal(BGC_FP32_Matrix2x2* matrix, const float d1, const float d2) { matrix->r1c1 = d1; matrix->r1c2 = 0.0f; @@ -51,7 +51,7 @@ inline void bgc_fp32_matrix2x2_make_diagonal(const float d1, const float d2, BGC matrix->r2c2 = d2; } -inline void bgc_fp64_matrix2x2_make_diagonal(const double d1, const double d2, BGC_FP64_Matrix2x2* matrix) +inline void bgc_fp64_matrix2x2_make_diagonal(BGC_FP64_Matrix2x2* matrix, const double d1, const double d2) { matrix->r1c1 = d1; matrix->r1c2 = 0.0; @@ -61,7 +61,7 @@ inline void bgc_fp64_matrix2x2_make_diagonal(const double d1, const double d2, B // ============== Rotation Matrix =============== // -inline void bgc_fp32_matrix2x2_make_for_turn(const float angle, const int angle_unit, BGC_FP32_Matrix2x2* matrix) +inline void bgc_fp32_matrix2x2_make_for_turn(BGC_FP32_Matrix2x2* matrix, const float angle, const int angle_unit) { const float radians = bgc_fp32_angle_to_radians(angle, angle_unit); const float cosine = cosf(radians); @@ -73,7 +73,7 @@ inline void bgc_fp32_matrix2x2_make_for_turn(const float angle, const int angle_ matrix->r2c2 = cosine; } -inline void bgc_fp64_matrix2x2_make_for_turn(const double angle, const int angle_unit, BGC_FP64_Matrix2x2* matrix) +inline void bgc_fp64_matrix2x2_make_for_turn(BGC_FP64_Matrix2x2* matrix, const double angle, const int angle_unit) { const double radians = bgc_fp64_angle_to_radians(angle, angle_unit); const double cosine = cos(radians); @@ -153,7 +153,7 @@ inline int bgc_fp64_matrix2x2_is_rotation(const BGC_FP64_Matrix2x2* matrix) // ==================== Copy ==================== // -inline void bgc_fp32_matrix2x2_copy(const BGC_FP32_Matrix2x2* source, BGC_FP32_Matrix2x2* destination) +inline void bgc_fp32_matrix2x2_copy(BGC_FP32_Matrix2x2* destination, const BGC_FP32_Matrix2x2* source) { destination->r1c1 = source->r1c1; destination->r1c2 = source->r1c2; @@ -162,7 +162,7 @@ inline void bgc_fp32_matrix2x2_copy(const BGC_FP32_Matrix2x2* source, BGC_FP32_M destination->r2c2 = source->r2c2; } -inline void bgc_fp64_matrix2x2_copy(const BGC_FP64_Matrix2x2* source, BGC_FP64_Matrix2x2* destination) +inline void bgc_fp64_matrix2x2_copy(BGC_FP64_Matrix2x2* destination, const BGC_FP64_Matrix2x2* source) { destination->r1c1 = source->r1c1; destination->r1c2 = source->r1c2; @@ -217,7 +217,7 @@ inline void bgc_fp64_matrix2x2_swap(BGC_FP64_Matrix2x2* matrix1, BGC_FP64_Matrix // ================== Convert =================== // -inline void bgc_fp64_matrix2x2_convert_to_fp32(const BGC_FP64_Matrix2x2* source, BGC_FP32_Matrix2x2* destination) +inline void bgc_fp64_matrix2x2_convert_to_fp32(BGC_FP32_Matrix2x2* destination, const BGC_FP64_Matrix2x2* source) { destination->r1c1 = (float)source->r1c1; destination->r1c2 = (float)source->r1c2; @@ -226,7 +226,7 @@ inline void bgc_fp64_matrix2x2_convert_to_fp32(const BGC_FP64_Matrix2x2* source, destination->r2c2 = (float)source->r2c2; } -inline void bgc_fp32_matrix2x2_convert_to_fp64(const BGC_FP32_Matrix2x2* source, BGC_FP64_Matrix2x2* destination) +inline void bgc_fp32_matrix2x2_convert_to_fp64(BGC_FP64_Matrix2x2* destination, const BGC_FP32_Matrix2x2* source) { destination->r1c1 = source->r1c1; destination->r1c2 = source->r1c2; @@ -237,7 +237,7 @@ inline void bgc_fp32_matrix2x2_convert_to_fp64(const BGC_FP32_Matrix2x2* source, // ================ Get Inverse ================= // -inline int bgc_fp32_matrix2x2_get_inverse(const BGC_FP32_Matrix2x2* matrix, BGC_FP32_Matrix2x2* inverse) +inline int bgc_fp32_matrix2x2_get_inverse(BGC_FP32_Matrix2x2* inverse, const BGC_FP32_Matrix2x2* matrix) { const float determinant = bgc_fp32_matrix2x2_get_determinant(matrix); @@ -262,7 +262,7 @@ inline int bgc_fp32_matrix2x2_get_inverse(const BGC_FP32_Matrix2x2* matrix, BGC_ return 1; } -inline int bgc_fp64_matrix2x2_get_inverse(const BGC_FP64_Matrix2x2* matrix, BGC_FP64_Matrix2x2* inverse) +inline int bgc_fp64_matrix2x2_get_inverse(BGC_FP64_Matrix2x2* inverse, const BGC_FP64_Matrix2x2* matrix) { const double determinant = bgc_fp64_matrix2x2_get_determinant(matrix); @@ -317,7 +317,7 @@ inline void bgc_fp64_matrix2x2_transpose(BGC_FP64_Matrix2x2* matrix) // =============== Get Transpose ================ // -inline void bgc_fp32_matrix2x2_get_transposed(const BGC_FP32_Matrix2x2* matrix, BGC_FP32_Matrix2x2* transposed) +inline void bgc_fp32_matrix2x2_get_transposed(BGC_FP32_Matrix2x2* transposed, const BGC_FP32_Matrix2x2* matrix) { const float r1c2 = matrix->r1c2; @@ -328,7 +328,7 @@ inline void bgc_fp32_matrix2x2_get_transposed(const BGC_FP32_Matrix2x2* matrix, transposed->r2c2 = matrix->r2c2; } -inline void bgc_fp64_matrix2x2_get_transposed(const BGC_FP64_Matrix2x2* matrix, BGC_FP64_Matrix2x2* transposed) +inline void bgc_fp64_matrix2x2_get_transposed(BGC_FP64_Matrix2x2* transposed, const BGC_FP64_Matrix2x2* matrix) { const double r1c2 = matrix->r1c2; @@ -341,15 +341,15 @@ inline void bgc_fp64_matrix2x2_get_transposed(const BGC_FP64_Matrix2x2* matrix, // ================== Get Row =================== // -inline void bgc_fp32_matrix2x2_get_row(const int number, const BGC_FP32_Matrix2x2* matrix, BGC_FP32_Vector2* row) +inline void bgc_fp32_matrix2x2_get_row(BGC_FP32_Vector2* row, const BGC_FP32_Matrix2x2* matrix, const int row_number) { - if (number == 1) { + if (row_number == 1) { row->x1 = matrix->r1c1; row->x2 = matrix->r1c2; return; } - if (number == 2) { + if (row_number == 2) { row->x1 = matrix->r2c1; row->x2 = matrix->r2c2; return; @@ -359,15 +359,15 @@ inline void bgc_fp32_matrix2x2_get_row(const int number, const BGC_FP32_Matrix2x row->x2 = 0.0f; } -inline void bgc_fp64_matrix2x2_get_row(const int number, const BGC_FP64_Matrix2x2* matrix, BGC_FP64_Vector2* row) +inline void bgc_fp64_matrix2x2_get_row(BGC_FP64_Vector2* row, const BGC_FP64_Matrix2x2* matrix, const int row_number) { - if (number == 1) { + if (row_number == 1) { row->x1 = matrix->r1c1; row->x2 = matrix->r1c2; return; } - if (number == 2) { + if (row_number == 2) { row->x1 = matrix->r2c1; row->x2 = matrix->r2c2; return; @@ -379,29 +379,29 @@ inline void bgc_fp64_matrix2x2_get_row(const int number, const BGC_FP64_Matrix2x // ================== Set Row =================== // -inline void bgc_fp32_matrix2x2_set_row(const int number, const BGC_FP32_Vector2* row, BGC_FP32_Matrix2x2* matrix) +inline void bgc_fp32_matrix2x2_set_row(BGC_FP32_Matrix2x2* matrix, const int row_number, const BGC_FP32_Vector2* row) { - if (number == 1) { + if (row_number == 1) { matrix->r1c1 = row->x1; matrix->r1c2 = row->x2; return; } - if (number == 2) { + if (row_number == 2) { matrix->r2c1 = row->x1; matrix->r2c2 = row->x2; } } -inline void bgc_fp64_matrix2x2_set_row(const int number, const BGC_FP64_Vector2* row, BGC_FP64_Matrix2x2* matrix) +inline void bgc_fp64_matrix2x2_set_row(BGC_FP64_Matrix2x2* matrix, const int row_number, const BGC_FP64_Vector2* row) { - if (number == 1) { + if (row_number == 1) { matrix->r1c1 = row->x1; matrix->r1c2 = row->x2; return; } - if (number == 2) { + if (row_number == 2) { matrix->r2c1 = row->x1; matrix->r2c2 = row->x2; } @@ -409,15 +409,15 @@ inline void bgc_fp64_matrix2x2_set_row(const int number, const BGC_FP64_Vector2* // ================= Get Column ================= // -inline void bgc_fp32_matrix2x2_get_column(const int number, const BGC_FP32_Matrix2x2* matrix, BGC_FP32_Vector2* column) +inline void bgc_fp32_matrix2x2_get_column(BGC_FP32_Vector2* column, const BGC_FP32_Matrix2x2* matrix, const int column_number) { - if (number == 1) { + if (column_number == 1) { column->x1 = matrix->r1c1; column->x2 = matrix->r2c1; return; } - if (number == 2) { + if (column_number == 2) { column->x1 = matrix->r1c2; column->x2 = matrix->r2c2; return; @@ -427,15 +427,15 @@ inline void bgc_fp32_matrix2x2_get_column(const int number, const BGC_FP32_Matri column->x2 = 0.0f; } -inline void bgc_fp64_matrix2x2_get_column(const int number, const BGC_FP64_Matrix2x2* matrix, BGC_FP64_Vector2* column) +inline void bgc_fp64_matrix2x2_get_column(BGC_FP64_Vector2* column, const BGC_FP64_Matrix2x2* matrix, const int column_number) { - if (number == 1) { + if (column_number == 1) { column->x1 = matrix->r1c1; column->x2 = matrix->r2c1; return; } - if (number == 2) { + if (column_number == 2) { column->x1 = matrix->r1c2; column->x2 = matrix->r2c2; return; @@ -447,29 +447,29 @@ inline void bgc_fp64_matrix2x2_get_column(const int number, const BGC_FP64_Matri // ================= Set Column ================= // -inline void bgc_fp32_matrix2x2_set_column(const int number, const BGC_FP32_Vector2* column, BGC_FP32_Matrix2x2* matrix) +inline void bgc_fp32_matrix2x2_set_column(BGC_FP32_Matrix2x2* matrix, const int column_number, const BGC_FP32_Vector2* column) { - if (number == 1) { + if (column_number == 1) { matrix->r1c1 = column->x1; matrix->r2c1 = column->x2; return; } - if (number == 2) { + if (column_number == 2) { matrix->r1c2 = column->x1; matrix->r2c2 = column->x2; } } -inline void bgc_fp64_matrix2x2_set_column(const int number, const BGC_FP64_Vector2* column, BGC_FP64_Matrix2x2* matrix) +inline void bgc_fp64_matrix2x2_set_column(BGC_FP64_Matrix2x2* matrix, const int column_number, const BGC_FP64_Vector2* column) { - if (number == 1) { + if (column_number == 1) { matrix->r1c1 = column->x1; matrix->r2c1 = column->x2; return; } - if (number == 2) { + if (column_number == 2) { matrix->r1c2 = column->x1; matrix->r2c2 = column->x2; } @@ -477,7 +477,7 @@ inline void bgc_fp64_matrix2x2_set_column(const int number, const BGC_FP64_Vecto // ==================== Add ===================== // -inline void bgc_fp32_matrix2x2_add(const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2, BGC_FP32_Matrix2x2* sum) +inline void bgc_fp32_matrix2x2_add(BGC_FP32_Matrix2x2* sum, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2) { sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; @@ -486,7 +486,7 @@ inline void bgc_fp32_matrix2x2_add(const BGC_FP32_Matrix2x2* matrix1, const BGC_ sum->r2c2 = matrix1->r2c2 + matrix2->r2c2; } -inline void bgc_fp64_matrix2x2_add(const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2, BGC_FP64_Matrix2x2* sum) +inline void bgc_fp64_matrix2x2_add(BGC_FP64_Matrix2x2* sum, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2) { sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; @@ -497,7 +497,7 @@ inline void bgc_fp64_matrix2x2_add(const BGC_FP64_Matrix2x2* matrix1, const BGC_ // ================= Add scaled ================= // -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) +inline void bgc_fp32_matrix2x2_add_scaled(BGC_FP32_Matrix2x2* sum, const BGC_FP32_Matrix2x2* basic_matrix, const BGC_FP32_Matrix2x2* scalable_matrix, const float scale) { sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; @@ -506,7 +506,7 @@ inline void bgc_fp32_matrix2x2_add_scaled(const BGC_FP32_Matrix2x2* basic_matrix sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale; } -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) +inline void bgc_fp64_matrix2x2_add_scaled(BGC_FP64_Matrix2x2* sum, const BGC_FP64_Matrix2x2* basic_matrix, const BGC_FP64_Matrix2x2* scalable_matrix, const double scale) { sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; @@ -517,7 +517,7 @@ inline void bgc_fp64_matrix2x2_add_scaled(const BGC_FP64_Matrix2x2* basic_matrix // ================== Subtract ================== // -inline void bgc_fp32_matrix2x2_subtract(const BGC_FP32_Matrix2x2* minuend, const BGC_FP32_Matrix2x2* subtrahend, BGC_FP32_Matrix2x2* difference) +inline void bgc_fp32_matrix2x2_subtract(BGC_FP32_Matrix2x2* difference, const BGC_FP32_Matrix2x2* minuend, const BGC_FP32_Matrix2x2* subtrahend) { difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; @@ -526,7 +526,7 @@ inline void bgc_fp32_matrix2x2_subtract(const BGC_FP32_Matrix2x2* minuend, const difference->r2c2 = minuend->r2c2 - subtrahend->r2c2; } -inline void bgc_fp64_matrix2x2_subtract(const BGC_FP64_Matrix2x2* minuend, const BGC_FP64_Matrix2x2* subtrahend, BGC_FP64_Matrix2x2* difference) +inline void bgc_fp64_matrix2x2_subtract(BGC_FP64_Matrix2x2* difference, const BGC_FP64_Matrix2x2* minuend, const BGC_FP64_Matrix2x2* subtrahend) { difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; @@ -537,7 +537,7 @@ inline void bgc_fp64_matrix2x2_subtract(const BGC_FP64_Matrix2x2* minuend, const // ================== Multiply ================== // -inline void bgc_fp32_matrix2x2_multiply(const BGC_FP32_Matrix2x2* multiplicand, const float multiplier, BGC_FP32_Matrix2x2* product) +inline void bgc_fp32_matrix2x2_multiply(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* multiplicand, const float multiplier) { product->r1c1 = multiplicand->r1c1 * multiplier; product->r1c2 = multiplicand->r1c2 * multiplier; @@ -546,7 +546,7 @@ inline void bgc_fp32_matrix2x2_multiply(const BGC_FP32_Matrix2x2* multiplicand, product->r2c2 = multiplicand->r2c2 * multiplier; } -inline void bgc_fp64_matrix2x2_multiply(const BGC_FP64_Matrix2x2* multiplicand, const double multiplier, BGC_FP64_Matrix2x2* product) +inline void bgc_fp64_matrix2x2_multiply(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* multiplicand, const double multiplier) { product->r1c1 = multiplicand->r1c1 * multiplier; product->r1c2 = multiplicand->r1c2 * multiplier; @@ -557,19 +557,19 @@ inline void bgc_fp64_matrix2x2_multiply(const BGC_FP64_Matrix2x2* multiplicand, // =================== Divide =================== // -inline void bgc_fp32_matrix2x2_divide(const BGC_FP32_Matrix2x2* dividend, const float divisor, BGC_FP32_Matrix2x2* quotient) +inline void bgc_fp32_matrix2x2_divide(BGC_FP32_Matrix2x2* quotient, const BGC_FP32_Matrix2x2* dividend, const float divisor) { - bgc_fp32_matrix2x2_multiply(dividend, 1.0f / divisor, quotient); + bgc_fp32_matrix2x2_multiply(quotient, dividend, 1.0f / divisor); } -inline void bgc_fp64_matrix2x2_divide(const BGC_FP64_Matrix2x2* dividend, const double divisor, BGC_FP64_Matrix2x2* quotient) +inline void bgc_fp64_matrix2x2_divide(BGC_FP64_Matrix2x2* quotient, const BGC_FP64_Matrix2x2* dividend, const double divisor) { - bgc_fp64_matrix2x2_multiply(dividend, 1.0 / divisor, quotient); + bgc_fp64_matrix2x2_multiply(quotient, dividend, 1.0 / divisor); } // ================ Interpolate ================= // -inline void bgc_fp32_matrix2x2_interpolate(const BGC_FP32_Matrix2x2* first, const BGC_FP32_Matrix2x2* second, const float phase, BGC_FP32_Matrix2x2* interpolation) +inline void bgc_fp32_matrix2x2_interpolate(BGC_FP32_Matrix2x2* interpolation, const BGC_FP32_Matrix2x2* first, const BGC_FP32_Matrix2x2* second, const float phase) { const float counter_phase = 1.0f - phase; @@ -580,7 +580,7 @@ inline void bgc_fp32_matrix2x2_interpolate(const BGC_FP32_Matrix2x2* first, cons interpolation->r2c2 = first->r2c2 * counter_phase + second->r2c2 * phase; } -inline void bgc_fp64_matrix2x2_interpolate(const BGC_FP64_Matrix2x2* first, const BGC_FP64_Matrix2x2* second, const double phase, BGC_FP64_Matrix2x2* interpolation) +inline void bgc_fp64_matrix2x2_interpolate(BGC_FP64_Matrix2x2* interpolation, const BGC_FP64_Matrix2x2* first, const BGC_FP64_Matrix2x2* second, const double phase) { const double counter_phase = 1.0 - phase; @@ -593,7 +593,7 @@ inline void bgc_fp64_matrix2x2_interpolate(const BGC_FP64_Matrix2x2* first, cons // ============ Right Vector Product ============ // -inline void bgc_fp32_multiply_matrix2x2_by_vector2(const BGC_FP32_Matrix2x2* matrix, const BGC_FP32_Vector2* vector, BGC_FP32_Vector2* product) +inline void bgc_fp32_multiply_matrix2x2_by_vector2(BGC_FP32_Vector2* product, const BGC_FP32_Matrix2x2* matrix, const BGC_FP32_Vector2* vector) { const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2; const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2; @@ -602,7 +602,7 @@ inline void bgc_fp32_multiply_matrix2x2_by_vector2(const BGC_FP32_Matrix2x2* mat product->x2 = x2; } -inline void bgc_fp64_multiply_matrix2x2_by_vector2(const BGC_FP64_Matrix2x2* matrix, const BGC_FP64_Vector2* vector, BGC_FP64_Vector2* product) +inline void bgc_fp64_multiply_matrix2x2_by_vector2(BGC_FP64_Vector2* product, const BGC_FP64_Matrix2x2* matrix, const BGC_FP64_Vector2* vector) { const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2; const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2; @@ -613,7 +613,7 @@ inline void bgc_fp64_multiply_matrix2x2_by_vector2(const BGC_FP64_Matrix2x2* mat // ============ 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) +inline void bgc_fp32_multiply_vector2_by_matrix2x2(BGC_FP32_Vector2* product, const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix2x2* matrix) { const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1; const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2; @@ -622,7 +622,7 @@ inline void bgc_fp32_multiply_vector2_by_matrix2x2(const BGC_FP32_Vector2* vecto 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) +inline void bgc_fp64_multiply_vector2_by_matrix2x2(BGC_FP64_Vector2* product, const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix2x2* matrix) { const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1; const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2; diff --git a/basic-geometry/matrix2x3.c b/basic-geometry/matrix2x3.c index 4e9fd90..b5a0e3f 100644 --- a/basic-geometry/matrix2x3.c +++ b/basic-geometry/matrix2x3.c @@ -3,50 +3,50 @@ extern inline void bgc_fp32_matrix2x3_reset(BGC_FP32_Matrix2x3* matrix); extern inline void bgc_fp64_matrix2x3_reset(BGC_FP64_Matrix2x3* matrix); -extern inline void bgc_fp32_matrix2x3_copy(const BGC_FP32_Matrix2x3* source, BGC_FP32_Matrix2x3* destination); -extern inline void bgc_fp64_matrix2x3_copy(const BGC_FP64_Matrix2x3* source, BGC_FP64_Matrix2x3* destination); +extern inline void bgc_fp32_matrix2x3_copy(BGC_FP32_Matrix2x3* destination, const BGC_FP32_Matrix2x3* source); +extern inline void bgc_fp64_matrix2x3_copy(BGC_FP64_Matrix2x3* destination, const BGC_FP64_Matrix2x3* source); extern inline void bgc_fp32_matrix2x3_swap(BGC_FP32_Matrix2x3* matrix1, BGC_FP32_Matrix2x3* matrix2); extern inline void bgc_fp64_matrix2x3_swap(BGC_FP64_Matrix2x3* matrix1, BGC_FP64_Matrix2x3* matrix2); -extern inline void bgc_fp64_matrix2x3_convert_to_fp32(const BGC_FP64_Matrix2x3* source, BGC_FP32_Matrix2x3* destination); -extern inline void bgc_fp32_matrix2x3_convert_to_fp64(const BGC_FP32_Matrix2x3* source, BGC_FP64_Matrix2x3* destination); +extern inline void bgc_fp32_matrix2x3_convert_to_fp64(BGC_FP64_Matrix2x3* destination, const BGC_FP32_Matrix2x3* source); +extern inline void bgc_fp64_matrix2x3_convert_to_fp32(BGC_FP32_Matrix2x3* destination, const BGC_FP64_Matrix2x3* source); -extern inline void bgc_fp32_matrix2x3_get_transposed(const BGC_FP32_Matrix3x2* matrix, BGC_FP32_Matrix2x3* transposed); -extern inline void bgc_fp64_matrix2x3_get_transposed(const BGC_FP64_Matrix3x2* matrix, BGC_FP64_Matrix2x3* transposed); +extern inline void bgc_fp32_matrix2x3_get_transposed(BGC_FP32_Matrix2x3* transposed, const BGC_FP32_Matrix3x2* matrix); +extern inline void bgc_fp64_matrix2x3_get_transposed(BGC_FP64_Matrix2x3* transposed, const BGC_FP64_Matrix3x2* 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_fp64_matrix2x3_get_row(const int number, const BGC_FP64_Matrix2x3* matrix, BGC_FP64_Vector2* row); +extern inline void bgc_fp32_matrix2x3_get_row(BGC_FP32_Vector2* row, const BGC_FP32_Matrix2x3* matrix, const int row_number); +extern inline void bgc_fp64_matrix2x3_get_row(BGC_FP64_Vector2* row, const BGC_FP64_Matrix2x3* matrix, const int row_number); -extern inline void bgc_fp32_matrix2x3_set_row(const int number, const BGC_FP32_Vector2* row, BGC_FP32_Matrix2x3* 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_fp32_matrix2x3_set_row(BGC_FP32_Matrix2x3* matrix, const int row_number, const BGC_FP32_Vector2* row); +extern inline void bgc_fp64_matrix2x3_set_row(BGC_FP64_Matrix2x3* matrix, const int row_number, const BGC_FP64_Vector2* row); -extern inline void bgc_fp32_matrix2x3_get_column(const int number, const BGC_FP32_Matrix2x3* matrix, BGC_FP32_Vector3* column); -extern inline void bgc_fp64_matrix2x3_get_column(const int number, const BGC_FP64_Matrix2x3* matrix, BGC_FP64_Vector3* column); +extern inline void bgc_fp32_matrix2x3_get_column(BGC_FP32_Vector3* column, const BGC_FP32_Matrix2x3* matrix, const int column_number); +extern inline void bgc_fp64_matrix2x3_get_column(BGC_FP64_Vector3* column, const BGC_FP64_Matrix2x3* matrix, const int column_number); -extern inline void bgc_fp32_matrix2x3_set_column(const int number, const BGC_FP32_Vector3* column, BGC_FP32_Matrix2x3* 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_fp32_matrix2x3_set_column(BGC_FP32_Matrix2x3* matrix, const int number, const BGC_FP32_Vector3* column); +extern inline void bgc_fp64_matrix2x3_set_column(BGC_FP64_Matrix2x3* matrix, const int number, const BGC_FP64_Vector3* column); -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_fp64_matrix2x3_add(const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x3* matrix2, BGC_FP64_Matrix2x3* sum); +extern inline void bgc_fp32_matrix2x3_add(BGC_FP32_Matrix2x3* sum, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x3* matrix2); +extern inline void bgc_fp64_matrix2x3_add(BGC_FP64_Matrix2x3* sum, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x3* matrix2); -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_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_fp32_matrix2x3_add_scaled(BGC_FP32_Matrix2x3* sum, const BGC_FP32_Matrix2x3* basic_matrix, const BGC_FP32_Matrix2x3* scalable_matrix, const float scale); +extern inline void bgc_fp64_matrix2x3_add_scaled(BGC_FP64_Matrix2x3* sum, const BGC_FP64_Matrix2x3* basic_matrix, const BGC_FP64_Matrix2x3* scalable_matrix, const double scale); -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_fp64_matrix2x3_subtract(const BGC_FP64_Matrix2x3* minuend, const BGC_FP64_Matrix2x3* subtrahend, BGC_FP64_Matrix2x3* difference); +extern inline void bgc_fp32_matrix2x3_subtract(BGC_FP32_Matrix2x3* difference, const BGC_FP32_Matrix2x3* minuend, const BGC_FP32_Matrix2x3* subtrahend); +extern inline void bgc_fp64_matrix2x3_subtract(BGC_FP64_Matrix2x3* difference, const BGC_FP64_Matrix2x3* minuend, const BGC_FP64_Matrix2x3* subtrahend); -extern inline void bgc_fp32_matrix2x3_multiply(const BGC_FP32_Matrix2x3* multiplicand, const float multiplier, BGC_FP32_Matrix2x3* product); -extern inline void bgc_fp64_matrix2x3_multiply(const BGC_FP64_Matrix2x3* multiplicand, const double multiplier, BGC_FP64_Matrix2x3* product); +extern inline void bgc_fp32_matrix2x3_multiply(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix2x3* multiplicand, const float multiplier); +extern inline void bgc_fp64_matrix2x3_multiply(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix2x3* multiplicand, const double multiplier); -extern inline void bgc_fp32_matrix2x3_divide(const BGC_FP32_Matrix2x3* dividend, const float divisor, BGC_FP32_Matrix2x3* quotient); -extern inline void bgc_fp64_matrix2x3_divide(const BGC_FP64_Matrix2x3* dividend, const double divisor, BGC_FP64_Matrix2x3* quotient); +extern inline void bgc_fp32_matrix2x3_divide(BGC_FP32_Matrix2x3* quotient, const BGC_FP32_Matrix2x3* dividend, const float divisor); +extern inline void bgc_fp64_matrix2x3_divide(BGC_FP64_Matrix2x3* quotient, const BGC_FP64_Matrix2x3* dividend, const double divisor); -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_fp64_matrix2x3_interpolate(const BGC_FP64_Matrix2x3* first, const BGC_FP64_Matrix2x3* second, const double phase, BGC_FP64_Matrix2x3* interpolation); +extern inline void bgc_fp32_matrix2x3_interpolate(BGC_FP32_Matrix2x3* interpolation, const BGC_FP32_Matrix2x3* first, const BGC_FP32_Matrix2x3* second, const float phase); +extern inline void bgc_fp64_matrix2x3_interpolate(BGC_FP64_Matrix2x3* interpolation, const BGC_FP64_Matrix2x3* first, const BGC_FP64_Matrix2x3* second, const double phase); -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_fp64_multiply_vector3_by_matrix2x3(const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix2x3* matrix, BGC_FP64_Vector2* product); +extern inline void bgc_fp32_multiply_vector3_by_matrix2x3(BGC_FP32_Vector2* product, const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix2x3* matrix); +extern inline void bgc_fp64_multiply_vector3_by_matrix2x3(BGC_FP64_Vector2* product, const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix2x3* matrix); -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_fp64_multiply_matrix2x3_by_vector2(const BGC_FP64_Matrix2x3* matrix, const BGC_FP64_Vector2* vector, BGC_FP64_Vector3* product); +extern inline void bgc_fp32_multiply_matrix2x3_by_vector2(BGC_FP32_Vector3* product, const BGC_FP32_Matrix2x3* matrix, const BGC_FP32_Vector2* vector); +extern inline void bgc_fp64_multiply_matrix2x3_by_vector2(BGC_FP64_Vector3* product, const BGC_FP64_Matrix2x3* matrix, const BGC_FP64_Vector2* vector); diff --git a/basic-geometry/matrix2x3.h b/basic-geometry/matrix2x3.h index 2dca456..7093a94 100644 --- a/basic-geometry/matrix2x3.h +++ b/basic-geometry/matrix2x3.h @@ -3,7 +3,7 @@ #include "vector2.h" #include "vector3.h" -#include "matrixes.h" +#include "matrices.h" // =================== Reset ==================== // @@ -33,7 +33,7 @@ inline void bgc_fp64_matrix2x3_reset(BGC_FP64_Matrix2x3* matrix) // ==================== Copy ==================== // -inline void bgc_fp32_matrix2x3_copy(const BGC_FP32_Matrix2x3* source, BGC_FP32_Matrix2x3* destination) +inline void bgc_fp32_matrix2x3_copy(BGC_FP32_Matrix2x3* destination, const BGC_FP32_Matrix2x3* source) { destination->r1c1 = source->r1c1; destination->r1c2 = source->r1c2; @@ -45,7 +45,7 @@ inline void bgc_fp32_matrix2x3_copy(const BGC_FP32_Matrix2x3* source, BGC_FP32_M destination->r3c2 = source->r3c2; } -inline void bgc_fp64_matrix2x3_copy(const BGC_FP64_Matrix2x3* source, BGC_FP64_Matrix2x3* destination) +inline void bgc_fp64_matrix2x3_copy(BGC_FP64_Matrix2x3* destination, const BGC_FP64_Matrix2x3* source) { destination->r1c1 = source->r1c1; destination->r1c2 = source->r1c2; @@ -121,7 +121,7 @@ inline void bgc_fp64_matrix2x3_swap(BGC_FP64_Matrix2x3* matrix1, BGC_FP64_Matrix // ================== Convert =================== // -inline void bgc_fp64_matrix2x3_convert_to_fp32(const BGC_FP64_Matrix2x3* source, BGC_FP32_Matrix2x3* destination) +inline void bgc_fp64_matrix2x3_convert_to_fp32(BGC_FP32_Matrix2x3* destination, const BGC_FP64_Matrix2x3* source) { destination->r1c1 = (float)source->r1c1; destination->r1c2 = (float)source->r1c2; @@ -133,7 +133,7 @@ inline void bgc_fp64_matrix2x3_convert_to_fp32(const BGC_FP64_Matrix2x3* source, destination->r3c2 = (float)source->r3c2; } -inline void bgc_fp32_matrix2x3_convert_to_fp64(const BGC_FP32_Matrix2x3* source, BGC_FP64_Matrix2x3* destination) +inline void bgc_fp32_matrix2x3_convert_to_fp64(BGC_FP64_Matrix2x3* destination, const BGC_FP32_Matrix2x3* source) { destination->r1c1 = source->r1c1; destination->r1c2 = source->r1c2; @@ -147,7 +147,7 @@ inline void bgc_fp32_matrix2x3_convert_to_fp64(const BGC_FP32_Matrix2x3* source, // ================= Transpose ================== // -inline void bgc_fp32_matrix2x3_get_transposed(const BGC_FP32_Matrix3x2* matrix, BGC_FP32_Matrix2x3* transposed) +inline void bgc_fp32_matrix2x3_get_transposed(BGC_FP32_Matrix2x3* transposed, const BGC_FP32_Matrix3x2* matrix) { transposed->r1c1 = matrix->r1c1; transposed->r1c2 = matrix->r2c1; @@ -159,7 +159,7 @@ inline void bgc_fp32_matrix2x3_get_transposed(const BGC_FP32_Matrix3x2* matrix, transposed->r3c2 = matrix->r2c3; } -inline void bgc_fp64_matrix2x3_get_transposed(const BGC_FP64_Matrix3x2* matrix, BGC_FP64_Matrix2x3* transposed) +inline void bgc_fp64_matrix2x3_get_transposed(BGC_FP64_Matrix2x3* transposed, const BGC_FP64_Matrix3x2* matrix) { transposed->r1c1 = matrix->r1c1; transposed->r1c2 = matrix->r2c1; @@ -173,21 +173,21 @@ inline void bgc_fp64_matrix2x3_get_transposed(const BGC_FP64_Matrix3x2* matrix, // ================== Get Row =================== // -inline void bgc_fp32_matrix2x3_get_row(const int number, const BGC_FP32_Matrix2x3* matrix, BGC_FP32_Vector2* row) +inline void bgc_fp32_matrix2x3_get_row(BGC_FP32_Vector2* row, const BGC_FP32_Matrix2x3* matrix, const int row_number) { - if (number == 1) { + if (row_number == 1) { row->x1 = matrix->r1c1; row->x2 = matrix->r1c2; return; } - if (number == 2) { + if (row_number == 2) { row->x1 = matrix->r2c1; row->x2 = matrix->r2c2; return; } - if (number == 3) { + if (row_number == 3) { row->x1 = matrix->r3c1; row->x2 = matrix->r3c2; return; @@ -197,21 +197,21 @@ inline void bgc_fp32_matrix2x3_get_row(const int number, const BGC_FP32_Matrix2x row->x2 = 0.0f; } -inline void bgc_fp64_matrix2x3_get_row(const int number, const BGC_FP64_Matrix2x3* matrix, BGC_FP64_Vector2* row) +inline void bgc_fp64_matrix2x3_get_row(BGC_FP64_Vector2* row, const BGC_FP64_Matrix2x3* matrix, const int row_number) { - if (number == 1) { + if (row_number == 1) { row->x1 = matrix->r1c1; row->x2 = matrix->r1c2; return; } - if (number == 2) { + if (row_number == 2) { row->x1 = matrix->r2c1; row->x2 = matrix->r2c2; return; } - if (number == 3) { + if (row_number == 3) { row->x1 = matrix->r3c1; row->x2 = matrix->r3c2; return; @@ -223,41 +223,41 @@ inline void bgc_fp64_matrix2x3_get_row(const int number, const BGC_FP64_Matrix2x // ================== Set Row =================== // -inline void bgc_fp32_matrix2x3_set_row(const int number, const BGC_FP32_Vector2* row, BGC_FP32_Matrix2x3* matrix) +inline void bgc_fp32_matrix2x3_set_row(BGC_FP32_Matrix2x3* matrix, const int row_number, const BGC_FP32_Vector2* row) { - if (number == 1) { + if (row_number == 1) { matrix->r1c1 = row->x1; matrix->r1c2 = row->x2; return; } - if (number == 2) { + if (row_number == 2) { matrix->r2c1 = row->x1; matrix->r2c2 = row->x2; return; } - if (number == 3) { + if (row_number == 3) { matrix->r3c1 = row->x1; matrix->r3c2 = row->x2; } } -inline void bgc_fp64_matrix2x3_set_row(const int number, const BGC_FP64_Vector2* row, BGC_FP64_Matrix2x3* matrix) +inline void bgc_fp64_matrix2x3_set_row(BGC_FP64_Matrix2x3* matrix, const int row_number, const BGC_FP64_Vector2* row) { - if (number == 1) { + if (row_number == 1) { matrix->r1c1 = row->x1; matrix->r1c2 = row->x2; return; } - if (number == 2) { + if (row_number == 2) { matrix->r2c1 = row->x1; matrix->r2c2 = row->x2; return; } - if (number == 3) { + if (row_number == 3) { matrix->r3c1 = row->x1; matrix->r3c2 = row->x2; } @@ -265,32 +265,32 @@ inline void bgc_fp64_matrix2x3_set_row(const int number, const BGC_FP64_Vector2* // ================= Get Column ================= // -inline void bgc_fp32_matrix2x3_get_column(const int number, const BGC_FP32_Matrix2x3* matrix, BGC_FP32_Vector3* column) +inline void bgc_fp32_matrix2x3_get_column(BGC_FP32_Vector3* column, const BGC_FP32_Matrix2x3* matrix, const int column_number) { - if (number == 1) { + if (column_number == 1) { column->x1 = matrix->r1c1; column->x2 = matrix->r2c1; column->x3 = matrix->r3c1; return; } - if (number == 2) { + if (column_number == 2) { column->x1 = matrix->r1c2; column->x2 = matrix->r2c2; column->x3 = matrix->r3c2; } } -inline void bgc_fp64_matrix2x3_get_column(const int number, const BGC_FP64_Matrix2x3* matrix, BGC_FP64_Vector3* column) +inline void bgc_fp64_matrix2x3_get_column(BGC_FP64_Vector3* column, const BGC_FP64_Matrix2x3* matrix, const int column_number) { - if (number == 1) { + if (column_number == 1) { column->x1 = matrix->r1c1; column->x2 = matrix->r2c1; column->x3 = matrix->r3c1; return; } - if (number == 2) { + if (column_number == 2) { column->x1 = matrix->r1c2; column->x2 = matrix->r2c2; column->x3 = matrix->r3c2; @@ -299,32 +299,32 @@ inline void bgc_fp64_matrix2x3_get_column(const int number, const BGC_FP64_Matri // ================= Set Column ================= // -inline void bgc_fp32_matrix2x3_set_column(const int number, const BGC_FP32_Vector3* column, BGC_FP32_Matrix2x3* matrix) +inline void bgc_fp32_matrix2x3_set_column(BGC_FP32_Matrix2x3* matrix, const int column_number, const BGC_FP32_Vector3* column) { - if (number == 1) { + if (column_number == 1) { matrix->r1c1 = column->x1; matrix->r2c1 = column->x2; matrix->r3c1 = column->x3; return; } - if (number == 2) { + if (column_number == 2) { matrix->r1c2 = column->x1; matrix->r2c2 = column->x2; matrix->r3c2 = column->x3; } } -inline void bgc_fp64_matrix2x3_set_column(const int number, const BGC_FP64_Vector3* column, BGC_FP64_Matrix2x3* matrix) +inline void bgc_fp64_matrix2x3_set_column(BGC_FP64_Matrix2x3* matrix, const int column_number, const BGC_FP64_Vector3* column) { - if (number == 1) { + if (column_number == 1) { matrix->r1c1 = column->x1; matrix->r2c1 = column->x2; matrix->r3c1 = column->x3; return; } - if (number == 2) { + if (column_number == 2) { matrix->r1c2 = column->x1; matrix->r2c2 = column->x2; matrix->r3c2 = column->x3; @@ -333,7 +333,7 @@ inline void bgc_fp64_matrix2x3_set_column(const int number, const BGC_FP64_Vecto // ==================== Add ===================== // -inline void bgc_fp32_matrix2x3_add(const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x3* matrix2, BGC_FP32_Matrix2x3* sum) +inline void bgc_fp32_matrix2x3_add(BGC_FP32_Matrix2x3* sum, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x3* matrix2) { sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; @@ -345,7 +345,7 @@ inline void bgc_fp32_matrix2x3_add(const BGC_FP32_Matrix2x3* matrix1, const BGC_ sum->r3c2 = matrix1->r3c2 + matrix2->r3c2; } -inline void bgc_fp64_matrix2x3_add(const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x3* matrix2, BGC_FP64_Matrix2x3* sum) +inline void bgc_fp64_matrix2x3_add(BGC_FP64_Matrix2x3* sum, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x3* matrix2) { sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; @@ -359,7 +359,7 @@ inline void bgc_fp64_matrix2x3_add(const BGC_FP64_Matrix2x3* matrix1, const BGC_ // ================= Add scaled ================= // -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) +inline void bgc_fp32_matrix2x3_add_scaled(BGC_FP32_Matrix2x3* sum, const BGC_FP32_Matrix2x3* basic_matrix, const BGC_FP32_Matrix2x3* scalable_matrix, const float scale) { sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; @@ -371,7 +371,7 @@ inline void bgc_fp32_matrix2x3_add_scaled(const BGC_FP32_Matrix2x3* basic_matrix sum->r3c2 = basic_matrix->r3c2 + scalable_matrix->r3c2 * scale; } -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) +inline void bgc_fp64_matrix2x3_add_scaled(BGC_FP64_Matrix2x3* sum, const BGC_FP64_Matrix2x3* basic_matrix, const BGC_FP64_Matrix2x3* scalable_matrix, const double scale) { sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; @@ -385,7 +385,7 @@ inline void bgc_fp64_matrix2x3_add_scaled(const BGC_FP64_Matrix2x3* basic_matrix // ================== Subtract ================== // -inline void bgc_fp32_matrix2x3_subtract(const BGC_FP32_Matrix2x3* minuend, const BGC_FP32_Matrix2x3* subtrahend, BGC_FP32_Matrix2x3* difference) +inline void bgc_fp32_matrix2x3_subtract(BGC_FP32_Matrix2x3* difference, const BGC_FP32_Matrix2x3* minuend, const BGC_FP32_Matrix2x3* subtrahend) { difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; @@ -397,7 +397,7 @@ inline void bgc_fp32_matrix2x3_subtract(const BGC_FP32_Matrix2x3* minuend, const difference->r3c2 = minuend->r3c2 - subtrahend->r3c2; } -inline void bgc_fp64_matrix2x3_subtract(const BGC_FP64_Matrix2x3* minuend, const BGC_FP64_Matrix2x3* subtrahend, BGC_FP64_Matrix2x3* difference) +inline void bgc_fp64_matrix2x3_subtract(BGC_FP64_Matrix2x3* difference, const BGC_FP64_Matrix2x3* minuend, const BGC_FP64_Matrix2x3* subtrahend) { difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; @@ -411,7 +411,7 @@ inline void bgc_fp64_matrix2x3_subtract(const BGC_FP64_Matrix2x3* minuend, const // ================== Multiply ================== // -inline void bgc_fp32_matrix2x3_multiply(const BGC_FP32_Matrix2x3* multiplicand, const float multiplier, BGC_FP32_Matrix2x3* product) +inline void bgc_fp32_matrix2x3_multiply(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix2x3* multiplicand, const float multiplier) { product->r1c1 = multiplicand->r1c1 * multiplier; product->r1c2 = multiplicand->r1c2 * multiplier; @@ -423,7 +423,7 @@ inline void bgc_fp32_matrix2x3_multiply(const BGC_FP32_Matrix2x3* multiplicand, product->r3c2 = multiplicand->r3c2 * multiplier; } -inline void bgc_fp64_matrix2x3_multiply(const BGC_FP64_Matrix2x3* multiplicand, const double multiplier, BGC_FP64_Matrix2x3* product) +inline void bgc_fp64_matrix2x3_multiply(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix2x3* multiplicand, const double multiplier) { product->r1c1 = multiplicand->r1c1 * multiplier; product->r1c2 = multiplicand->r1c2 * multiplier; @@ -437,19 +437,19 @@ inline void bgc_fp64_matrix2x3_multiply(const BGC_FP64_Matrix2x3* multiplicand, // =================== Divide =================== // -inline void bgc_fp32_matrix2x3_divide(const BGC_FP32_Matrix2x3* dividend, const float divisor, BGC_FP32_Matrix2x3* quotient) +inline void bgc_fp32_matrix2x3_divide(BGC_FP32_Matrix2x3* quotient, const BGC_FP32_Matrix2x3* dividend, const float divisor) { - bgc_fp32_matrix2x3_multiply(dividend, 1.0f / divisor, quotient); + bgc_fp32_matrix2x3_multiply(quotient, dividend, 1.0f / divisor); } -inline void bgc_fp64_matrix2x3_divide(const BGC_FP64_Matrix2x3* dividend, const double divisor, BGC_FP64_Matrix2x3* quotient) +inline void bgc_fp64_matrix2x3_divide(BGC_FP64_Matrix2x3* quotient, const BGC_FP64_Matrix2x3* dividend, const double divisor) { - bgc_fp64_matrix2x3_multiply(dividend, 1.0 / divisor, quotient); + bgc_fp64_matrix2x3_multiply(quotient, dividend, 1.0 / divisor); } // ================ Interpolate ================= // -inline void bgc_fp32_matrix2x3_interpolate(const BGC_FP32_Matrix2x3* first, const BGC_FP32_Matrix2x3* second, const float phase, BGC_FP32_Matrix2x3* interpolation) +inline void bgc_fp32_matrix2x3_interpolate(BGC_FP32_Matrix2x3* interpolation, const BGC_FP32_Matrix2x3* first, const BGC_FP32_Matrix2x3* second, const float phase) { const float couter_phase = 1.0f - phase; @@ -463,7 +463,7 @@ inline void bgc_fp32_matrix2x3_interpolate(const BGC_FP32_Matrix2x3* first, cons 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) +inline void bgc_fp64_matrix2x3_interpolate(BGC_FP64_Matrix2x3* interpolation, const BGC_FP64_Matrix2x3* first, const BGC_FP64_Matrix2x3* second, const double phase) { const double couter_phase = 1.0 - phase; @@ -479,13 +479,13 @@ inline void bgc_fp64_matrix2x3_interpolate(const BGC_FP64_Matrix2x3* first, cons // ============ Left Vector Product ============= // -inline void bgc_fp32_multiply_vector3_by_matrix2x3(const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix2x3* matrix, BGC_FP32_Vector2* product) +inline void bgc_fp32_multiply_vector3_by_matrix2x3(BGC_FP32_Vector2* product, const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix2x3* matrix) { product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1; product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2; } -inline void bgc_fp64_multiply_vector3_by_matrix2x3(const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix2x3* matrix, BGC_FP64_Vector2* product) +inline void bgc_fp64_multiply_vector3_by_matrix2x3(BGC_FP64_Vector2* product, const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix2x3* matrix) { product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1; product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2; @@ -493,14 +493,14 @@ inline void bgc_fp64_multiply_vector3_by_matrix2x3(const BGC_FP64_Vector3* vecto // ============ Right Vector Product ============ // -inline void bgc_fp32_multiply_matrix2x3_by_vector2(const BGC_FP32_Matrix2x3* matrix, const BGC_FP32_Vector2* vector, BGC_FP32_Vector3* product) +inline void bgc_fp32_multiply_matrix2x3_by_vector2(BGC_FP32_Vector3* product, const BGC_FP32_Matrix2x3* matrix, const BGC_FP32_Vector2* vector) { product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2; product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2; product->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2; } -inline void bgc_fp64_multiply_matrix2x3_by_vector2(const BGC_FP64_Matrix2x3* matrix, const BGC_FP64_Vector2* vector, BGC_FP64_Vector3* product) +inline void bgc_fp64_multiply_matrix2x3_by_vector2(BGC_FP64_Vector3* product, const BGC_FP64_Matrix2x3* matrix, const BGC_FP64_Vector2* vector) { product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2; product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2; diff --git a/basic-geometry/matrix3x2.c b/basic-geometry/matrix3x2.c index b62bec1..ee9b5e1 100644 --- a/basic-geometry/matrix3x2.c +++ b/basic-geometry/matrix3x2.c @@ -3,50 +3,50 @@ extern inline void bgc_fp32_matrix3x2_reset(BGC_FP32_Matrix3x2* matrix); extern inline void bgc_fp64_matrix3x2_reset(BGC_FP64_Matrix3x2* matrix); -extern inline void bgc_fp32_matrix3x2_copy(const BGC_FP32_Matrix3x2* source, BGC_FP32_Matrix3x2* destination); -extern inline void bgc_fp64_matrix3x2_copy(const BGC_FP64_Matrix3x2* source, BGC_FP64_Matrix3x2* destination); +extern inline void bgc_fp32_matrix3x2_copy(BGC_FP32_Matrix3x2* destination, const BGC_FP32_Matrix3x2* source); +extern inline void bgc_fp64_matrix3x2_copy(BGC_FP64_Matrix3x2* destination, const BGC_FP64_Matrix3x2* source); extern inline void bgc_fp32_matrix3x2_swap(BGC_FP32_Matrix3x2* matrix1, BGC_FP32_Matrix3x2* matrix2); extern inline void bgc_fp64_matrix3x2_swap(BGC_FP64_Matrix3x2* matrix1, BGC_FP64_Matrix3x2* matrix2); -extern inline void bgc_fp64_matrix3x2_convert_to_fp32(const BGC_FP64_Matrix3x2* source, BGC_FP32_Matrix3x2* destination); -extern inline void bgc_fp32_matrix3x2_convert_to_fp64(const BGC_FP32_Matrix3x2* source, BGC_FP64_Matrix3x2* destination); +extern inline void bgc_fp32_matrix3x2_convert_to_fp64(BGC_FP64_Matrix3x2* destination, const BGC_FP32_Matrix3x2* source); +extern inline void bgc_fp64_matrix3x2_convert_to_fp32(BGC_FP32_Matrix3x2* destination, const BGC_FP64_Matrix3x2* source); -extern inline void bgc_fp32_matrix3x2_get_transposed(const BGC_FP32_Matrix2x3* matrix, BGC_FP32_Matrix3x2* transposed); -extern inline void bgc_fp64_matrix3x2_get_transposed(const BGC_FP64_Matrix2x3* matrix, BGC_FP64_Matrix3x2* transposed); +extern inline void bgc_fp32_matrix3x2_get_transposed(BGC_FP32_Matrix3x2* transposed, const BGC_FP32_Matrix2x3* matrix); +extern inline void bgc_fp64_matrix3x2_get_transposed(BGC_FP64_Matrix3x2* transposed, const BGC_FP64_Matrix2x3* 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_fp64_matrix3x2_get_row(const int number, const BGC_FP64_Matrix3x2* matrix, BGC_FP64_Vector3* row); +extern inline void bgc_fp32_matrix3x2_get_row(BGC_FP32_Vector3* row, const BGC_FP32_Matrix3x2* matrix, const int row_number); +extern inline void bgc_fp64_matrix3x2_get_row(BGC_FP64_Vector3* row, const BGC_FP64_Matrix3x2* matrix, const int row_number); -extern inline void bgc_fp32_matrix3x2_set_row(const int number, const BGC_FP32_Vector3* row, BGC_FP32_Matrix3x2* 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_fp32_matrix3x2_set_row(BGC_FP32_Matrix3x2* matrix, const int row_number, const BGC_FP32_Vector3* row); +extern inline void bgc_fp64_matrix3x2_set_row(BGC_FP64_Matrix3x2* matrix, const int row_number, const BGC_FP64_Vector3* row); -extern inline void bgc_fp32_matrix3x2_get_column(const int number, const BGC_FP32_Matrix3x2* matrix, BGC_FP32_Vector2* column); -extern inline void bgc_fp64_matrix3x2_get_column(const int number, const BGC_FP64_Matrix3x2* matrix, BGC_FP64_Vector2* column); +extern inline void bgc_fp32_matrix3x2_get_column(BGC_FP32_Vector2* column, const BGC_FP32_Matrix3x2* matrix, const int column_number); +extern inline void bgc_fp64_matrix3x2_get_column(BGC_FP64_Vector2* column, const BGC_FP64_Matrix3x2* matrix, const int column_number); -extern inline void bgc_fp32_matrix3x2_set_column(const int number, const BGC_FP32_Vector2* column, BGC_FP32_Matrix3x2* 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_fp32_matrix3x2_set_column(BGC_FP32_Matrix3x2* matrix, const int column_number, const BGC_FP32_Vector2* column); +extern inline void bgc_fp64_matrix3x2_set_column(BGC_FP64_Matrix3x2* matrix, const int column_number, const BGC_FP64_Vector2* column); -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_fp64_matrix3x2_add(const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x2* matrix2, BGC_FP64_Matrix3x2* sum); +extern inline void bgc_fp32_matrix3x2_add(BGC_FP32_Matrix3x2* sum, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x2* matrix2); +extern inline void bgc_fp64_matrix3x2_add(BGC_FP64_Matrix3x2* sum, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x2* matrix2); -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_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_fp32_matrix3x2_add_scaled(BGC_FP32_Matrix3x2* sum, const BGC_FP32_Matrix3x2* basic_matrix, const BGC_FP32_Matrix3x2* scalable_matrix, const float scale); +extern inline void bgc_fp64_matrix3x2_add_scaled(BGC_FP64_Matrix3x2* sum, const BGC_FP64_Matrix3x2* basic_matrix, const BGC_FP64_Matrix3x2* scalable_matrix, const double scale); -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_fp64_matrix3x2_subtract(const BGC_FP64_Matrix3x2* minuend, const BGC_FP64_Matrix3x2* subtrahend, BGC_FP64_Matrix3x2* difference); +extern inline void bgc_fp32_matrix3x2_subtract(BGC_FP32_Matrix3x2* difference, const BGC_FP32_Matrix3x2* minuend, const BGC_FP32_Matrix3x2* subtrahend); +extern inline void bgc_fp64_matrix3x2_subtract(BGC_FP64_Matrix3x2* difference, const BGC_FP64_Matrix3x2* minuend, const BGC_FP64_Matrix3x2* subtrahend); -extern inline void bgc_fp32_matrix3x2_multiply(const BGC_FP32_Matrix3x2* multiplicand, const float multiplier, BGC_FP32_Matrix3x2* product); -extern inline void bgc_fp64_matrix3x2_multiply(const BGC_FP64_Matrix3x2* multiplicand, const double multiplier, BGC_FP64_Matrix3x2* product); +extern inline void bgc_fp32_matrix3x2_multiply(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix3x2* multiplicand, const float multiplier); +extern inline void bgc_fp64_matrix3x2_multiply(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix3x2* multiplicand, const double multiplier); -extern inline void bgc_fp32_matrix3x2_divide(const BGC_FP32_Matrix3x2* dividend, const float divisor, BGC_FP32_Matrix3x2* quotient); -extern inline void bgc_fp64_matrix3x2_divide(const BGC_FP64_Matrix3x2* dividend, const double divisor, BGC_FP64_Matrix3x2* quotient); +extern inline void bgc_fp32_matrix3x2_divide(BGC_FP32_Matrix3x2* quotient, const BGC_FP32_Matrix3x2* dividend, const float divisor); +extern inline void bgc_fp64_matrix3x2_divide(BGC_FP64_Matrix3x2* quotient, const BGC_FP64_Matrix3x2* dividend, const double divisor); -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_fp64_matrix3x2_interpolate(const BGC_FP64_Matrix3x2* first, const BGC_FP64_Matrix3x2* second, const double phase, BGC_FP64_Matrix3x2* interpolation); +extern inline void bgc_fp32_matrix3x2_interpolate(BGC_FP32_Matrix3x2* interpolation, const BGC_FP32_Matrix3x2* first, const BGC_FP32_Matrix3x2* second, const float phase); +extern inline void bgc_fp64_matrix3x2_interpolate(BGC_FP64_Matrix3x2* interpolation, const BGC_FP64_Matrix3x2* first, const BGC_FP64_Matrix3x2* second, const double phase); -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_fp64_multiply_vector2_by_matrix3x2(const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix3x2* matrix, BGC_FP64_Vector3* product); +extern inline void bgc_fp32_multiply_vector2_by_matrix3x2(BGC_FP32_Vector3* product, const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix3x2* matrix); +extern inline void bgc_fp64_multiply_vector2_by_matrix3x2(BGC_FP64_Vector3* product, const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix3x2* matrix); -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_fp64_multiply_matrix3x2_by_vector3(const BGC_FP64_Matrix3x2* matrix, const BGC_FP64_Vector3* vector, BGC_FP64_Vector2* product); +extern inline void bgc_fp32_multiply_matrix3x2_by_vector3(BGC_FP32_Vector2* product, const BGC_FP32_Matrix3x2* matrix, const BGC_FP32_Vector3* vector); +extern inline void bgc_fp64_multiply_matrix3x2_by_vector3(BGC_FP64_Vector2* product, const BGC_FP64_Matrix3x2* matrix, const BGC_FP64_Vector3* vector); diff --git a/basic-geometry/matrix3x2.h b/basic-geometry/matrix3x2.h index 1322a45..b219ddd 100644 --- a/basic-geometry/matrix3x2.h +++ b/basic-geometry/matrix3x2.h @@ -3,7 +3,7 @@ #include "vector2.h" #include "vector3.h" -#include "matrixes.h" +#include "matrices.h" // =================== Reset ==================== // @@ -31,7 +31,7 @@ inline void bgc_fp64_matrix3x2_reset(BGC_FP64_Matrix3x2* matrix) // ==================== Copy ==================== // -inline void bgc_fp32_matrix3x2_copy(const BGC_FP32_Matrix3x2* source, BGC_FP32_Matrix3x2* destination) +inline void bgc_fp32_matrix3x2_copy(BGC_FP32_Matrix3x2* destination, const BGC_FP32_Matrix3x2* source) { destination->r1c1 = source->r1c1; destination->r1c2 = source->r1c2; @@ -42,7 +42,7 @@ inline void bgc_fp32_matrix3x2_copy(const BGC_FP32_Matrix3x2* source, BGC_FP32_M destination->r2c3 = source->r2c3; } -inline void bgc_fp64_matrix3x2_copy(const BGC_FP64_Matrix3x2* source, BGC_FP64_Matrix3x2* destination) +inline void bgc_fp64_matrix3x2_copy(BGC_FP64_Matrix3x2* destination, const BGC_FP64_Matrix3x2* source) { destination->r1c1 = source->r1c1; destination->r1c2 = source->r1c2; @@ -111,7 +111,7 @@ inline void bgc_fp64_matrix3x2_swap(BGC_FP64_Matrix3x2* matrix1, BGC_FP64_Matrix // ================== Convert =================== // -inline void bgc_fp64_matrix3x2_convert_to_fp32(const BGC_FP64_Matrix3x2* source, BGC_FP32_Matrix3x2* destination) +inline void bgc_fp64_matrix3x2_convert_to_fp32(BGC_FP32_Matrix3x2* destination, const BGC_FP64_Matrix3x2* source) { destination->r1c1 = (float)source->r1c1; destination->r1c2 = (float)source->r1c2; @@ -122,7 +122,7 @@ inline void bgc_fp64_matrix3x2_convert_to_fp32(const BGC_FP64_Matrix3x2* source, destination->r2c3 = (float)source->r2c3; } -inline void bgc_fp32_matrix3x2_convert_to_fp64(const BGC_FP32_Matrix3x2* source, BGC_FP64_Matrix3x2* destination) +inline void bgc_fp32_matrix3x2_convert_to_fp64(BGC_FP64_Matrix3x2* destination, const BGC_FP32_Matrix3x2* source) { destination->r1c1 = source->r1c1; destination->r1c2 = source->r1c2; @@ -135,7 +135,7 @@ inline void bgc_fp32_matrix3x2_convert_to_fp64(const BGC_FP32_Matrix3x2* source, // ================= Transpose ================== // -inline void bgc_fp32_matrix3x2_get_transposed(const BGC_FP32_Matrix2x3* matrix, BGC_FP32_Matrix3x2* transposed) +inline void bgc_fp32_matrix3x2_get_transposed(BGC_FP32_Matrix3x2* transposed, const BGC_FP32_Matrix2x3* matrix) { transposed->r1c1 = matrix->r1c1; transposed->r1c2 = matrix->r2c1; @@ -146,7 +146,7 @@ inline void bgc_fp32_matrix3x2_get_transposed(const BGC_FP32_Matrix2x3* matrix, transposed->r2c3 = matrix->r3c2; } -inline void bgc_fp64_matrix3x2_get_transposed(const BGC_FP64_Matrix2x3* matrix, BGC_FP64_Matrix3x2* transposed) +inline void bgc_fp64_matrix3x2_get_transposed(BGC_FP64_Matrix3x2* transposed, const BGC_FP64_Matrix2x3* matrix) { transposed->r1c1 = matrix->r1c1; transposed->r1c2 = matrix->r2c1; @@ -159,9 +159,9 @@ inline void bgc_fp64_matrix3x2_get_transposed(const BGC_FP64_Matrix2x3* matrix, // ================== Get Row =================== // -inline void bgc_fp32_matrix3x2_get_row(const int number, const BGC_FP32_Matrix3x2* matrix, BGC_FP32_Vector3* row) +inline void bgc_fp32_matrix3x2_get_row(BGC_FP32_Vector3* row, const BGC_FP32_Matrix3x2* matrix, const int row_number) { - if (number == 1) + if (row_number == 1) { row->x1 = matrix->r1c1; row->x2 = matrix->r1c2; @@ -169,7 +169,7 @@ inline void bgc_fp32_matrix3x2_get_row(const int number, const BGC_FP32_Matrix3x return; } - if (number == 2) + if (row_number == 2) { row->x1 = matrix->r2c1; row->x2 = matrix->r2c2; @@ -182,9 +182,9 @@ inline void bgc_fp32_matrix3x2_get_row(const int number, const BGC_FP32_Matrix3x row->x3 = 0.0f; } -inline void bgc_fp64_matrix3x2_get_row(const int number, const BGC_FP64_Matrix3x2* matrix, BGC_FP64_Vector3* row) +inline void bgc_fp64_matrix3x2_get_row(BGC_FP64_Vector3* row, const BGC_FP64_Matrix3x2* matrix, const int row_number) { - if (number == 1) + if (row_number == 1) { row->x1 = matrix->r1c1; row->x2 = matrix->r1c2; @@ -192,7 +192,7 @@ inline void bgc_fp64_matrix3x2_get_row(const int number, const BGC_FP64_Matrix3x return; } - if (number == 2) + if (row_number == 2) { row->x1 = matrix->r2c1; row->x2 = matrix->r2c2; @@ -207,9 +207,9 @@ inline void bgc_fp64_matrix3x2_get_row(const int number, const BGC_FP64_Matrix3x // ================== Set Row =================== // -inline void bgc_fp32_matrix3x2_set_row(const int number, const BGC_FP32_Vector3* row, BGC_FP32_Matrix3x2* matrix) +inline void bgc_fp32_matrix3x2_set_row(BGC_FP32_Matrix3x2* matrix, const int row_number, const BGC_FP32_Vector3* row) { - if (number == 1) + if (row_number == 1) { matrix->r1c1 = row->x1; matrix->r1c2 = row->x2; @@ -217,7 +217,7 @@ inline void bgc_fp32_matrix3x2_set_row(const int number, const BGC_FP32_Vector3* return; } - if (number == 2) + if (row_number == 2) { matrix->r2c1 = row->x1; matrix->r2c2 = row->x2; @@ -225,9 +225,9 @@ inline void bgc_fp32_matrix3x2_set_row(const int number, const BGC_FP32_Vector3* } } -inline void bgc_fp64_matrix3x2_set_row(const int number, const BGC_FP64_Vector3* row, BGC_FP64_Matrix3x2* matrix) +inline void bgc_fp64_matrix3x2_set_row(BGC_FP64_Matrix3x2* matrix, const int row_number, const BGC_FP64_Vector3* row) { - if (number == 1) + if (row_number == 1) { matrix->r1c1 = row->x1; matrix->r1c2 = row->x2; @@ -235,7 +235,7 @@ inline void bgc_fp64_matrix3x2_set_row(const int number, const BGC_FP64_Vector3* return; } - if (number == 2) + if (row_number == 2) { matrix->r2c1 = row->x1; matrix->r2c2 = row->x2; @@ -245,23 +245,23 @@ inline void bgc_fp64_matrix3x2_set_row(const int number, const BGC_FP64_Vector3* // ================= Get Column ================= // -inline void bgc_fp32_matrix3x2_get_column(const int number, const BGC_FP32_Matrix3x2* matrix, BGC_FP32_Vector2* column) +inline void bgc_fp32_matrix3x2_get_column(BGC_FP32_Vector2* column, const BGC_FP32_Matrix3x2* matrix, const int column_number) { - if (number == 1) + if (column_number == 1) { column->x1 = matrix->r1c1; column->x2 = matrix->r2c1; return; } - if (number == 2) + if (column_number == 2) { column->x1 = matrix->r1c2; column->x2 = matrix->r2c2; return; } - if (number == 3) + if (column_number == 3) { column->x1 = matrix->r1c3; column->x2 = matrix->r2c3; @@ -272,23 +272,23 @@ inline void bgc_fp32_matrix3x2_get_column(const int number, const BGC_FP32_Matri column->x2 = 0.0f; } -inline void bgc_fp64_matrix3x2_get_column(const int number, const BGC_FP64_Matrix3x2* matrix, BGC_FP64_Vector2* column) +inline void bgc_fp64_matrix3x2_get_column(BGC_FP64_Vector2* column, const BGC_FP64_Matrix3x2* matrix, const int column_number) { - if (number == 1) + if (column_number == 1) { column->x1 = matrix->r1c1; column->x2 = matrix->r2c1; return; } - if (number == 2) + if (column_number == 2) { column->x1 = matrix->r1c2; column->x2 = matrix->r2c2; return; } - if (number == 3) + if (column_number == 3) { column->x1 = matrix->r1c3; column->x2 = matrix->r2c3; @@ -301,46 +301,46 @@ inline void bgc_fp64_matrix3x2_get_column(const int number, const BGC_FP64_Matri // ================= Set Column ================= // -inline void bgc_fp32_matrix3x2_set_column(const int number, const BGC_FP32_Vector2* column, BGC_FP32_Matrix3x2* matrix) +inline void bgc_fp32_matrix3x2_set_column(BGC_FP32_Matrix3x2* matrix, const int column_number, const BGC_FP32_Vector2* column) { - if (number == 1) + if (column_number == 1) { matrix->r1c1 = column->x1; matrix->r2c1 = column->x2; return; } - if (number == 2) + if (column_number == 2) { matrix->r1c2 = column->x1; matrix->r2c2 = column->x2; return; } - if (number == 3) + if (column_number == 3) { matrix->r1c3 = column->x1; matrix->r2c3 = column->x2; } } -inline void bgc_fp64_matrix3x2_set_column(const int number, const BGC_FP64_Vector2* column, BGC_FP64_Matrix3x2* matrix) +inline void bgc_fp64_matrix3x2_set_column(BGC_FP64_Matrix3x2* matrix, const int column_number, const BGC_FP64_Vector2* column) { - if (number == 1) + if (column_number == 1) { matrix->r1c1 = column->x1; matrix->r2c1 = column->x2; return; } - if (number == 2) + if (column_number == 2) { matrix->r1c2 = column->x1; matrix->r2c2 = column->x2; return; } - if (number == 3) + if (column_number == 3) { matrix->r1c3 = column->x1; matrix->r2c3 = column->x2; @@ -349,7 +349,7 @@ inline void bgc_fp64_matrix3x2_set_column(const int number, const BGC_FP64_Vecto // ==================== Add ===================== // -inline void bgc_fp32_matrix3x2_add(const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x2* matrix2, BGC_FP32_Matrix3x2* sum) +inline void bgc_fp32_matrix3x2_add(BGC_FP32_Matrix3x2* sum, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x2* matrix2) { sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; @@ -360,7 +360,7 @@ inline void bgc_fp32_matrix3x2_add(const BGC_FP32_Matrix3x2* matrix1, const BGC_ sum->r2c3 = matrix1->r2c3 + matrix2->r2c3; } -inline void bgc_fp64_matrix3x2_add(const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x2* matrix2, BGC_FP64_Matrix3x2* sum) +inline void bgc_fp64_matrix3x2_add(BGC_FP64_Matrix3x2* sum, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x2* matrix2) { sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; @@ -373,7 +373,7 @@ inline void bgc_fp64_matrix3x2_add(const BGC_FP64_Matrix3x2* matrix1, const BGC_ // ================= Add scaled ================= // -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) +inline void bgc_fp32_matrix3x2_add_scaled(BGC_FP32_Matrix3x2* sum, const BGC_FP32_Matrix3x2* basic_matrix, const BGC_FP32_Matrix3x2* scalable_matrix, const float scale) { sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; @@ -384,7 +384,7 @@ inline void bgc_fp32_matrix3x2_add_scaled(const BGC_FP32_Matrix3x2* basic_matrix sum->r2c3 = basic_matrix->r2c3 + scalable_matrix->r2c3 * scale; } -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) +inline void bgc_fp64_matrix3x2_add_scaled(BGC_FP64_Matrix3x2* sum, const BGC_FP64_Matrix3x2* basic_matrix, const BGC_FP64_Matrix3x2* scalable_matrix, const double scale) { sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; @@ -397,7 +397,7 @@ inline void bgc_fp64_matrix3x2_add_scaled(const BGC_FP64_Matrix3x2* basic_matrix // ================== Subtract ================== // -inline void bgc_fp32_matrix3x2_subtract(const BGC_FP32_Matrix3x2* minuend, const BGC_FP32_Matrix3x2* subtrahend, BGC_FP32_Matrix3x2* difference) +inline void bgc_fp32_matrix3x2_subtract(BGC_FP32_Matrix3x2* difference, const BGC_FP32_Matrix3x2* minuend, const BGC_FP32_Matrix3x2* subtrahend) { difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; @@ -408,7 +408,7 @@ inline void bgc_fp32_matrix3x2_subtract(const BGC_FP32_Matrix3x2* minuend, const difference->r2c3 = minuend->r2c3 - subtrahend->r2c3; } -inline void bgc_fp64_matrix3x2_subtract(const BGC_FP64_Matrix3x2* minuend, const BGC_FP64_Matrix3x2* subtrahend, BGC_FP64_Matrix3x2* difference) +inline void bgc_fp64_matrix3x2_subtract(BGC_FP64_Matrix3x2* difference, const BGC_FP64_Matrix3x2* minuend, const BGC_FP64_Matrix3x2* subtrahend) { difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; @@ -421,7 +421,7 @@ inline void bgc_fp64_matrix3x2_subtract(const BGC_FP64_Matrix3x2* minuend, const // ================== Multiply ================== // -inline void bgc_fp32_matrix3x2_multiply(const BGC_FP32_Matrix3x2* multiplicand, const float multiplier, BGC_FP32_Matrix3x2* product) +inline void bgc_fp32_matrix3x2_multiply(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix3x2* multiplicand, const float multiplier) { product->r1c1 = multiplicand->r1c1 * multiplier; product->r1c2 = multiplicand->r1c2 * multiplier; @@ -432,7 +432,7 @@ inline void bgc_fp32_matrix3x2_multiply(const BGC_FP32_Matrix3x2* multiplicand, product->r2c3 = multiplicand->r2c3 * multiplier; } -inline void bgc_fp64_matrix3x2_multiply(const BGC_FP64_Matrix3x2* multiplicand, const double multiplier, BGC_FP64_Matrix3x2* product) +inline void bgc_fp64_matrix3x2_multiply(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix3x2* multiplicand, const double multiplier) { product->r1c1 = multiplicand->r1c1 * multiplier; product->r1c2 = multiplicand->r1c2 * multiplier; @@ -445,19 +445,19 @@ inline void bgc_fp64_matrix3x2_multiply(const BGC_FP64_Matrix3x2* multiplicand, // =================== Divide =================== // -inline void bgc_fp32_matrix3x2_divide(const BGC_FP32_Matrix3x2* dividend, const float divisor, BGC_FP32_Matrix3x2* quotient) +inline void bgc_fp32_matrix3x2_divide(BGC_FP32_Matrix3x2* quotient, const BGC_FP32_Matrix3x2* dividend, const float divisor) { - bgc_fp32_matrix3x2_multiply(dividend, 1.0f / divisor, quotient); + bgc_fp32_matrix3x2_multiply(quotient, dividend, 1.0f / divisor); } -inline void bgc_fp64_matrix3x2_divide(const BGC_FP64_Matrix3x2* dividend, const double divisor, BGC_FP64_Matrix3x2* quotient) +inline void bgc_fp64_matrix3x2_divide(BGC_FP64_Matrix3x2* quotient, const BGC_FP64_Matrix3x2* dividend, const double divisor) { - bgc_fp64_matrix3x2_multiply(dividend, 1.0 / divisor, quotient); + bgc_fp64_matrix3x2_multiply(quotient, dividend, 1.0 / divisor); } // ================ Interpolate ================= // -inline void bgc_fp32_matrix3x2_interpolate(const BGC_FP32_Matrix3x2* first, const BGC_FP32_Matrix3x2* second, const float phase, BGC_FP32_Matrix3x2* interpolation) +inline void bgc_fp32_matrix3x2_interpolate(BGC_FP32_Matrix3x2* interpolation, const BGC_FP32_Matrix3x2* first, const BGC_FP32_Matrix3x2* second, const float phase) { const float couter_phase = 1.0f - phase; @@ -470,7 +470,7 @@ inline void bgc_fp32_matrix3x2_interpolate(const BGC_FP32_Matrix3x2* first, cons 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) +inline void bgc_fp64_matrix3x2_interpolate(BGC_FP64_Matrix3x2* interpolation, const BGC_FP64_Matrix3x2* first, const BGC_FP64_Matrix3x2* second, const double phase) { const double couter_phase = 1.0 - phase; @@ -485,14 +485,14 @@ inline void bgc_fp64_matrix3x2_interpolate(const BGC_FP64_Matrix3x2* first, cons // ============ Left Vector Product ============= // -inline void bgc_fp32_multiply_vector2_by_matrix3x2(const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix3x2* matrix, BGC_FP32_Vector3* product) +inline void bgc_fp32_multiply_vector2_by_matrix3x2(BGC_FP32_Vector3* product, const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix3x2* matrix) { product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1; product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2; product->x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3; } -inline void bgc_fp64_multiply_vector2_by_matrix3x2(const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix3x2* matrix, BGC_FP64_Vector3* product) +inline void bgc_fp64_multiply_vector2_by_matrix3x2(BGC_FP64_Vector3* product, const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix3x2* matrix) { product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1; product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2; @@ -501,13 +501,13 @@ inline void bgc_fp64_multiply_vector2_by_matrix3x2(const BGC_FP64_Vector2* vecto // ============ Right Vector Product ============ // -inline void bgc_fp32_multiply_matrix3x2_by_vector3(const BGC_FP32_Matrix3x2* matrix, const BGC_FP32_Vector3* vector, BGC_FP32_Vector2* product) +inline void bgc_fp32_multiply_matrix3x2_by_vector3(BGC_FP32_Vector2* product, const BGC_FP32_Matrix3x2* matrix, const BGC_FP32_Vector3* vector) { product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3; product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3; } -inline void bgc_fp64_multiply_matrix3x2_by_vector3(const BGC_FP64_Matrix3x2* matrix, const BGC_FP64_Vector3* vector, BGC_FP64_Vector2* product) +inline void bgc_fp64_multiply_matrix3x2_by_vector3(BGC_FP64_Vector2* product, const BGC_FP64_Matrix3x2* matrix, const BGC_FP64_Vector3* vector) { product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3; product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3; diff --git a/basic-geometry/matrix3x3.c b/basic-geometry/matrix3x3.c index da25253..4125e37 100644 --- a/basic-geometry/matrix3x3.c +++ b/basic-geometry/matrix3x3.c @@ -6,17 +6,17 @@ extern inline void bgc_fp64_matrix3x3_reset(BGC_FP64_Matrix3x3* matrix); extern inline void bgc_fp32_matrix3x3_make_identity(BGC_FP32_Matrix3x3* matrix); extern inline void bgc_fp64_matrix3x3_make_identity(BGC_FP64_Matrix3x3* 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_fp64_matrix3x3_make_diagonal(const double d1, const double d2, const double d3, BGC_FP64_Matrix3x3* matrix); +extern inline void bgc_fp32_matrix3x3_make_diagonal(BGC_FP32_Matrix3x3* matrix, const float d1, const float d2, const float d3); +extern inline void bgc_fp64_matrix3x3_make_diagonal(BGC_FP64_Matrix3x3* matrix, const double d1, const double d2, const double d3); -extern inline void bgc_fp32_matrix3x3_copy(const BGC_FP32_Matrix3x3* source, BGC_FP32_Matrix3x3* destination); -extern inline void bgc_fp64_matrix3x3_copy(const BGC_FP64_Matrix3x3* source, BGC_FP64_Matrix3x3* destination); +extern inline void bgc_fp32_matrix3x3_copy(BGC_FP32_Matrix3x3* destination, const BGC_FP32_Matrix3x3* source); +extern inline void bgc_fp64_matrix3x3_copy(BGC_FP64_Matrix3x3* destination, const BGC_FP64_Matrix3x3* source); extern inline void bgc_fp32_matrix3x3_swap(BGC_FP32_Matrix3x3* matrix1, BGC_FP32_Matrix3x3* matrix2); extern inline void bgc_fp64_matrix3x3_swap(BGC_FP64_Matrix3x3* matrix1, BGC_FP64_Matrix3x3* matrix2); -extern inline void bgc_fp64_matrix3x3_convert_to_fp32(const BGC_FP64_Matrix3x3* source, BGC_FP32_Matrix3x3* destination); -extern inline void bgc_fp32_matrix3x3_convert_to_fp64(const BGC_FP32_Matrix3x3* source, BGC_FP64_Matrix3x3* destination); +extern inline void bgc_fp64_matrix3x3_convert_to_fp32(BGC_FP32_Matrix3x3* destination, const BGC_FP64_Matrix3x3* source); +extern inline void bgc_fp32_matrix3x3_convert_to_fp64(BGC_FP64_Matrix3x3* destination, const BGC_FP32_Matrix3x3* source); extern inline float bgc_fp32_matrix3x3_get_determinant(const BGC_FP32_Matrix3x3* matrix); extern inline double bgc_fp64_matrix3x3_get_determinant(const BGC_FP64_Matrix3x3* matrix); @@ -36,48 +36,48 @@ extern inline int bgc_fp64_matrix3x3_invert(BGC_FP64_Matrix3x3* matrix); extern inline void bgc_fp32_matrix3x3_transpose(BGC_FP32_Matrix3x3* matrix); extern inline void bgc_fp64_matrix3x3_transpose(BGC_FP64_Matrix3x3* matrix); -extern inline void bgc_fp32_matrix3x3_get_transposed(const BGC_FP32_Matrix3x3* matrix, BGC_FP32_Matrix3x3* transposed); -extern inline void bgc_fp64_matrix3x3_get_transposed(const BGC_FP64_Matrix3x3* matrix, BGC_FP64_Matrix3x3* transposed); +extern inline void bgc_fp32_matrix3x3_get_transposed(BGC_FP32_Matrix3x3* transposed, const BGC_FP32_Matrix3x3* matrix); +extern inline void bgc_fp64_matrix3x3_get_transposed(BGC_FP64_Matrix3x3* transposed, const BGC_FP64_Matrix3x3* 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_fp64_matrix3x3_get_row(const int number, const BGC_FP64_Matrix3x3* matrix, BGC_FP64_Vector3* row); +extern inline void bgc_fp32_matrix3x3_get_row(BGC_FP32_Vector3* row, const BGC_FP32_Matrix3x3* matrix, const int row_number); +extern inline void bgc_fp64_matrix3x3_get_row(BGC_FP64_Vector3* row, const BGC_FP64_Matrix3x3* matrix, const int row_number); -extern inline void bgc_fp32_matrix3x3_set_row(const int number, const BGC_FP32_Vector3* row, BGC_FP32_Matrix3x3* 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_fp32_matrix3x3_set_row(BGC_FP32_Matrix3x3* matrix, const int row_number, const BGC_FP32_Vector3* row); +extern inline void bgc_fp64_matrix3x3_set_row(BGC_FP64_Matrix3x3* matrix, const int row_number, const BGC_FP64_Vector3* row); -extern inline void bgc_fp32_matrix3x3_get_column(const int number, const BGC_FP32_Matrix3x3* matrix, BGC_FP32_Vector3* column); -extern inline void bgc_fp64_matrix3x3_get_column(const int number, const BGC_FP64_Matrix3x3* matrix, BGC_FP64_Vector3* column); +extern inline void bgc_fp32_matrix3x3_get_column(BGC_FP32_Vector3* column, const BGC_FP32_Matrix3x3* matrix, const int column_number); +extern inline void bgc_fp64_matrix3x3_get_column(BGC_FP64_Vector3* column, const BGC_FP64_Matrix3x3* matrix, const int column_number); -extern inline void bgc_fp32_matrix3x3_set_column(const int number, const BGC_FP32_Vector3* column, BGC_FP32_Matrix3x3* matrix); -extern inline void bgc_fp64_matrix3x3_set_column(const int number, const BGC_FP64_Vector3* column, BGC_FP64_Matrix3x3* matrix); +extern inline void bgc_fp32_matrix3x3_set_column(BGC_FP32_Matrix3x3* matrix, const int column_number, const BGC_FP32_Vector3* column); +extern inline void bgc_fp64_matrix3x3_set_column(BGC_FP64_Matrix3x3* matrix, const int column_number, const BGC_FP64_Vector3* column); -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_fp64_matrix3x3_add(const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2, BGC_FP64_Matrix3x3* sum); +extern inline void bgc_fp32_matrix3x3_add(BGC_FP32_Matrix3x3* sum, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2); +extern inline void bgc_fp64_matrix3x3_add(BGC_FP64_Matrix3x3* sum, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2); -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_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_fp32_matrix3x3_add_scaled(BGC_FP32_Matrix3x3* sum, const BGC_FP32_Matrix3x3* basic_matrix, const BGC_FP32_Matrix3x3* scalable_matrix, const float scale); +extern inline void bgc_fp64_matrix3x3_add_scaled(BGC_FP64_Matrix3x3* sum, const BGC_FP64_Matrix3x3* basic_matrix, const BGC_FP64_Matrix3x3* scalable_matrix, const double scale); -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_fp64_matrix3x3_subtract(const BGC_FP64_Matrix3x3* minuend, const BGC_FP64_Matrix3x3* subtrahend, BGC_FP64_Matrix3x3* difference); +extern inline void bgc_fp32_matrix3x3_subtract(BGC_FP32_Matrix3x3* difference, const BGC_FP32_Matrix3x3* minuend, const BGC_FP32_Matrix3x3* subtrahend); +extern inline void bgc_fp64_matrix3x3_subtract(BGC_FP64_Matrix3x3* difference, const BGC_FP64_Matrix3x3* minuend, const BGC_FP64_Matrix3x3* subtrahend); -extern inline void bgc_fp32_matrix3x3_multiply(const BGC_FP32_Matrix3x3* multiplicand, const float multiplier, BGC_FP32_Matrix3x3* product); -extern inline void bgc_fp64_matrix3x3_multiply(const BGC_FP64_Matrix3x3* multiplicand, const double multiplier, BGC_FP64_Matrix3x3* product); +extern inline void bgc_fp32_matrix3x3_multiply(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix3x3* multiplicand, const float multiplier); +extern inline void bgc_fp64_matrix3x3_multiply(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix3x3* multiplicand, const double multiplier); -extern inline void bgc_fp32_matrix3x3_divide(const BGC_FP32_Matrix3x3* dividend, const float divisor, BGC_FP32_Matrix3x3* quotient); -extern inline void bgc_fp64_matrix3x3_divide(const BGC_FP64_Matrix3x3* dividend, const double divisor, BGC_FP64_Matrix3x3* quotient); +extern inline void bgc_fp32_matrix3x3_divide(BGC_FP32_Matrix3x3* quotient, const BGC_FP32_Matrix3x3* dividend, const float divisor); +extern inline void bgc_fp64_matrix3x3_divide(BGC_FP64_Matrix3x3* quotient, const BGC_FP64_Matrix3x3* dividend, const double divisor); -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_fp64_matrix3x3_interpolate(const BGC_FP64_Matrix3x3* first, const BGC_FP64_Matrix3x3* second, const double phase, BGC_FP64_Matrix3x3* interpolation); +extern inline void bgc_fp32_matrix3x3_interpolate(BGC_FP32_Matrix3x3* interpolation, const BGC_FP32_Matrix3x3* first, const BGC_FP32_Matrix3x3* second, const float phase); +extern inline void bgc_fp64_matrix3x3_interpolate(BGC_FP64_Matrix3x3* interpolation, const BGC_FP64_Matrix3x3* first, const BGC_FP64_Matrix3x3* second, const double phase); -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_fp64_multiply_vector3_by_matrix3x3(const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix3x3* matrix, BGC_FP64_Vector3* result); +extern inline void bgc_fp32_multiply_vector3_by_matrix3x3(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix3x3* matrix); +extern inline void bgc_fp64_multiply_vector3_by_matrix3x3(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix3x3* matrix); -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); +extern inline void bgc_fp32_multiply_matrix3x3_by_vector3(BGC_FP32_Vector3* product, const BGC_FP32_Matrix3x3* matrix, const BGC_FP32_Vector3* vector); +extern inline void bgc_fp64_multiply_matrix3x3_by_vector3(BGC_FP64_Vector3* product, const BGC_FP64_Matrix3x3* matrix, const BGC_FP64_Vector3* vector); // ================ Get Inverse ================= // -int bgc_fp32_matrix3x3_get_inverse(const BGC_FP32_Matrix3x3* matrix, BGC_FP32_Matrix3x3* inverse) +int bgc_fp32_matrix3x3_get_inverse(BGC_FP32_Matrix3x3* inverse, const BGC_FP32_Matrix3x3* matrix) { const float determinant = bgc_fp32_matrix3x3_get_determinant(matrix); @@ -114,7 +114,7 @@ int bgc_fp32_matrix3x3_get_inverse(const BGC_FP32_Matrix3x3* matrix, BGC_FP32_Ma return 1; } -int bgc_fp64_matrix3x3_get_inverse(const BGC_FP64_Matrix3x3* matrix, BGC_FP64_Matrix3x3* inverse) +int bgc_fp64_matrix3x3_get_inverse(BGC_FP64_Matrix3x3* inverse, const BGC_FP64_Matrix3x3* matrix) { const double determinant = bgc_fp64_matrix3x3_get_determinant(matrix); diff --git a/basic-geometry/matrix3x3.h b/basic-geometry/matrix3x3.h index 88ae111..18568bd 100644 --- a/basic-geometry/matrix3x3.h +++ b/basic-geometry/matrix3x3.h @@ -2,7 +2,7 @@ #define _BGC_MATRIX3X3_H_ #include "vector3.h" -#include "matrixes.h" +#include "matrices.h" // =================== Reset ==================== // @@ -70,7 +70,7 @@ inline void bgc_fp64_matrix3x3_make_identity(BGC_FP64_Matrix3x3* matrix) // ================ Set Diagonal ================ // -inline void bgc_fp32_matrix3x3_make_diagonal(const float d1, const float d2, const float d3, BGC_FP32_Matrix3x3* matrix) +inline void bgc_fp32_matrix3x3_make_diagonal(BGC_FP32_Matrix3x3* matrix, const float d1, const float d2, const float d3) { matrix->r1c1 = d1; matrix->r1c2 = 0.0f; @@ -85,7 +85,7 @@ inline void bgc_fp32_matrix3x3_make_diagonal(const float d1, const float d2, con matrix->r3c3 = d2; } -inline void bgc_fp64_matrix3x3_make_diagonal(const double d1, const double d2, const double d3, BGC_FP64_Matrix3x3* matrix) +inline void bgc_fp64_matrix3x3_make_diagonal(BGC_FP64_Matrix3x3* matrix, const double d1, const double d2, const double d3) { matrix->r1c1 = d1; matrix->r1c2 = 0.0; @@ -102,7 +102,7 @@ inline void bgc_fp64_matrix3x3_make_diagonal(const double d1, const double d2, c // ==================== Copy ==================== // -inline void bgc_fp32_matrix3x3_copy(const BGC_FP32_Matrix3x3* source, BGC_FP32_Matrix3x3* destination) +inline void bgc_fp32_matrix3x3_copy(BGC_FP32_Matrix3x3* destination, const BGC_FP32_Matrix3x3* source) { destination->r1c1 = source->r1c1; destination->r1c2 = source->r1c2; @@ -117,7 +117,7 @@ inline void bgc_fp32_matrix3x3_copy(const BGC_FP32_Matrix3x3* source, BGC_FP32_M destination->r3c3 = source->r3c3; } -inline void bgc_fp64_matrix3x3_copy(const BGC_FP64_Matrix3x3* source, BGC_FP64_Matrix3x3* destination) +inline void bgc_fp64_matrix3x3_copy(BGC_FP64_Matrix3x3* destination, const BGC_FP64_Matrix3x3* source) { destination->r1c1 = source->r1c1; destination->r1c2 = source->r1c2; @@ -214,7 +214,7 @@ inline void bgc_fp64_matrix3x3_swap(BGC_FP64_Matrix3x3* matrix1, BGC_FP64_Matrix // ================== Convert =================== // -inline void bgc_fp64_matrix3x3_convert_to_fp32(const BGC_FP64_Matrix3x3* source, BGC_FP32_Matrix3x3* destination) +inline void bgc_fp64_matrix3x3_convert_to_fp32(BGC_FP32_Matrix3x3* destination, const BGC_FP64_Matrix3x3* source) { destination->r1c1 = (float)source->r1c1; destination->r1c2 = (float)source->r1c2; @@ -229,7 +229,7 @@ inline void bgc_fp64_matrix3x3_convert_to_fp32(const BGC_FP64_Matrix3x3* source, destination->r3c3 = (float)source->r3c3; } -inline void bgc_fp32_matrix3x3_convert_to_fp64(const BGC_FP32_Matrix3x3* source, BGC_FP64_Matrix3x3* destination) +inline void bgc_fp32_matrix3x3_convert_to_fp64(BGC_FP64_Matrix3x3* destination, const BGC_FP32_Matrix3x3* source) { destination->r1c1 = source->r1c1; destination->r1c2 = source->r1c2; @@ -330,9 +330,9 @@ inline int bgc_fp64_matrix3x3_is_rotation(const BGC_FP64_Matrix3x3* matrix) // ================ Get Inverse ================= // -int bgc_fp32_matrix3x3_get_inverse(const BGC_FP32_Matrix3x3* matrix, BGC_FP32_Matrix3x3* inverse); +int bgc_fp32_matrix3x3_get_inverse(BGC_FP32_Matrix3x3* inverse, const BGC_FP32_Matrix3x3* matrix); -int bgc_fp64_matrix3x3_get_inverse(const BGC_FP64_Matrix3x3* matrix, BGC_FP64_Matrix3x3* inverse); +int bgc_fp64_matrix3x3_get_inverse(BGC_FP64_Matrix3x3* inverse, const BGC_FP64_Matrix3x3* matrix); // =================== Invert =================== // @@ -380,7 +380,7 @@ inline void bgc_fp64_matrix3x3_transpose(BGC_FP64_Matrix3x3* matrix) // =============== Get Transpose ================ // -inline void bgc_fp32_matrix3x3_get_transposed(const BGC_FP32_Matrix3x3* matrix, BGC_FP32_Matrix3x3* transposed) +inline void bgc_fp32_matrix3x3_get_transposed(BGC_FP32_Matrix3x3* transposed, const BGC_FP32_Matrix3x3* matrix) { transposed->r1c1 = matrix->r1c1; transposed->r2c2 = matrix->r2c2; @@ -399,7 +399,7 @@ inline void bgc_fp32_matrix3x3_get_transposed(const BGC_FP32_Matrix3x3* matrix, transposed->r3c2 = r2c3; } -inline void bgc_fp64_matrix3x3_get_transposed(const BGC_FP64_Matrix3x3* matrix, BGC_FP64_Matrix3x3* transposed) +inline void bgc_fp64_matrix3x3_get_transposed(BGC_FP64_Matrix3x3* transposed, const BGC_FP64_Matrix3x3* matrix) { transposed->r1c1 = matrix->r1c1; transposed->r2c2 = matrix->r2c2; @@ -420,9 +420,9 @@ inline void bgc_fp64_matrix3x3_get_transposed(const BGC_FP64_Matrix3x3* matrix, // ================== Get Row -================== // -inline void bgc_fp32_matrix3x3_get_row(const int number, const BGC_FP32_Matrix3x3* matrix, BGC_FP32_Vector3* row) +inline void bgc_fp32_matrix3x3_get_row(BGC_FP32_Vector3* row, const BGC_FP32_Matrix3x3* matrix, const int row_number) { - if (number == 1) + if (row_number == 1) { row->x1 = matrix->r1c1; row->x2 = matrix->r1c2; @@ -430,7 +430,7 @@ inline void bgc_fp32_matrix3x3_get_row(const int number, const BGC_FP32_Matrix3x return; } - if (number == 2) + if (row_number == 2) { row->x1 = matrix->r2c1; row->x2 = matrix->r2c2; @@ -438,7 +438,7 @@ inline void bgc_fp32_matrix3x3_get_row(const int number, const BGC_FP32_Matrix3x return; } - if (number == 3) + if (row_number == 3) { row->x1 = matrix->r3c1; row->x2 = matrix->r3c2; @@ -451,9 +451,9 @@ inline void bgc_fp32_matrix3x3_get_row(const int number, const BGC_FP32_Matrix3x row->x3 = 0.0f; } -inline void bgc_fp64_matrix3x3_get_row(const int number, const BGC_FP64_Matrix3x3* matrix, BGC_FP64_Vector3* row) +inline void bgc_fp64_matrix3x3_get_row(BGC_FP64_Vector3* row, const BGC_FP64_Matrix3x3* matrix, const int row_number) { - if (number == 1) + if (row_number == 1) { row->x1 = matrix->r1c1; row->x2 = matrix->r1c2; @@ -461,7 +461,7 @@ inline void bgc_fp64_matrix3x3_get_row(const int number, const BGC_FP64_Matrix3x return; } - if (number == 2) + if (row_number == 2) { row->x1 = matrix->r2c1; row->x2 = matrix->r2c2; @@ -469,7 +469,7 @@ inline void bgc_fp64_matrix3x3_get_row(const int number, const BGC_FP64_Matrix3x return; } - if (number == 3) + if (row_number == 3) { row->x1 = matrix->r3c1; row->x2 = matrix->r3c2; @@ -484,9 +484,9 @@ inline void bgc_fp64_matrix3x3_get_row(const int number, const BGC_FP64_Matrix3x // ================== Set Row =================== // -inline void bgc_fp32_matrix3x3_set_row(const int number, const BGC_FP32_Vector3* row, BGC_FP32_Matrix3x3* matrix) +inline void bgc_fp32_matrix3x3_set_row(BGC_FP32_Matrix3x3* matrix, const int row_number, const BGC_FP32_Vector3* row) { - if (number == 1) + if (row_number == 1) { matrix->r1c1 = row->x1; matrix->r1c2 = row->x2; @@ -494,7 +494,7 @@ inline void bgc_fp32_matrix3x3_set_row(const int number, const BGC_FP32_Vector3* return; } - if (number == 2) + if (row_number == 2) { matrix->r2c1 = row->x1; matrix->r2c2 = row->x2; @@ -502,7 +502,7 @@ inline void bgc_fp32_matrix3x3_set_row(const int number, const BGC_FP32_Vector3* return; } - if (number == 3) + if (row_number == 3) { matrix->r3c1 = row->x1; matrix->r3c2 = row->x2; @@ -510,9 +510,9 @@ inline void bgc_fp32_matrix3x3_set_row(const int number, const BGC_FP32_Vector3* } } -inline void bgc_fp64_matrix3x3_set_row(const int number, const BGC_FP64_Vector3* row, BGC_FP64_Matrix3x3* matrix) +inline void bgc_fp64_matrix3x3_set_row(BGC_FP64_Matrix3x3* matrix, const int row_number, const BGC_FP64_Vector3* row) { - if (number == 1) + if (row_number == 1) { matrix->r1c1 = row->x1; matrix->r1c2 = row->x2; @@ -520,7 +520,7 @@ inline void bgc_fp64_matrix3x3_set_row(const int number, const BGC_FP64_Vector3* return; } - if (number == 2) + if (row_number == 2) { matrix->r2c1 = row->x1; matrix->r2c2 = row->x2; @@ -528,7 +528,7 @@ inline void bgc_fp64_matrix3x3_set_row(const int number, const BGC_FP64_Vector3* return; } - if (number == 3) + if (row_number == 3) { matrix->r3c1 = row->x1; matrix->r3c2 = row->x2; @@ -538,9 +538,9 @@ inline void bgc_fp64_matrix3x3_set_row(const int number, const BGC_FP64_Vector3* // ================= Get Column ================= // -inline void bgc_fp32_matrix3x3_get_column(const int number, const BGC_FP32_Matrix3x3* matrix, BGC_FP32_Vector3* column) +inline void bgc_fp32_matrix3x3_get_column(BGC_FP32_Vector3* column, const BGC_FP32_Matrix3x3* matrix, const int column_number) { - if (number == 1) + if (column_number == 1) { column->x1 = matrix->r1c1; column->x2 = matrix->r2c1; @@ -548,7 +548,7 @@ inline void bgc_fp32_matrix3x3_get_column(const int number, const BGC_FP32_Matri return; } - if (number == 2) + if (column_number == 2) { column->x1 = matrix->r1c2; column->x2 = matrix->r2c2; @@ -556,7 +556,7 @@ inline void bgc_fp32_matrix3x3_get_column(const int number, const BGC_FP32_Matri return; } - if (number == 3) + if (column_number == 3) { column->x1 = matrix->r1c3; column->x2 = matrix->r2c3; @@ -569,9 +569,9 @@ inline void bgc_fp32_matrix3x3_get_column(const int number, const BGC_FP32_Matri column->x3 = 0.0f; } -inline void bgc_fp64_matrix3x3_get_column(const int number, const BGC_FP64_Matrix3x3* matrix, BGC_FP64_Vector3* column) +inline void bgc_fp64_matrix3x3_get_column(BGC_FP64_Vector3* column, const BGC_FP64_Matrix3x3* matrix, const int column_number) { - if (number == 1) + if (column_number == 1) { column->x1 = matrix->r1c1; column->x2 = matrix->r2c1; @@ -579,7 +579,7 @@ inline void bgc_fp64_matrix3x3_get_column(const int number, const BGC_FP64_Matri return; } - if (number == 2) + if (column_number == 2) { column->x1 = matrix->r1c2; column->x2 = matrix->r2c2; @@ -587,7 +587,7 @@ inline void bgc_fp64_matrix3x3_get_column(const int number, const BGC_FP64_Matri return; } - if (number == 3) + if (column_number == 3) { column->x1 = matrix->r1c3; column->x2 = matrix->r2c3; @@ -602,9 +602,9 @@ inline void bgc_fp64_matrix3x3_get_column(const int number, const BGC_FP64_Matri // ================= Set Column ================= // -inline void bgc_fp32_matrix3x3_set_column(const int number, const BGC_FP32_Vector3* column, BGC_FP32_Matrix3x3* matrix) +inline void bgc_fp32_matrix3x3_set_column(BGC_FP32_Matrix3x3* matrix, const int column_number, const BGC_FP32_Vector3* column) { - if (number == 1) + if (column_number == 1) { matrix->r1c1 = column->x1; matrix->r2c1 = column->x2; @@ -612,7 +612,7 @@ inline void bgc_fp32_matrix3x3_set_column(const int number, const BGC_FP32_Vecto return; } - if (number == 2) + if (column_number == 2) { matrix->r1c2 = column->x1; matrix->r2c2 = column->x2; @@ -620,7 +620,7 @@ inline void bgc_fp32_matrix3x3_set_column(const int number, const BGC_FP32_Vecto return; } - if (number == 3) + if (column_number == 3) { matrix->r1c3 = column->x1; matrix->r2c3 = column->x2; @@ -628,9 +628,9 @@ inline void bgc_fp32_matrix3x3_set_column(const int number, const BGC_FP32_Vecto } } -inline void bgc_fp64_matrix3x3_set_column(const int number, const BGC_FP64_Vector3* column, BGC_FP64_Matrix3x3* matrix) +inline void bgc_fp64_matrix3x3_set_column(BGC_FP64_Matrix3x3* matrix, const int column_number, const BGC_FP64_Vector3* column) { - if (number == 1) + if (column_number == 1) { matrix->r1c1 = column->x1; matrix->r2c1 = column->x2; @@ -638,7 +638,7 @@ inline void bgc_fp64_matrix3x3_set_column(const int number, const BGC_FP64_Vecto return; } - if (number == 2) + if (column_number == 2) { matrix->r1c2 = column->x1; matrix->r2c2 = column->x2; @@ -646,7 +646,7 @@ inline void bgc_fp64_matrix3x3_set_column(const int number, const BGC_FP64_Vecto return; } - if (number == 3) + if (column_number == 3) { matrix->r1c3 = column->x1; matrix->r2c3 = column->x2; @@ -656,7 +656,7 @@ inline void bgc_fp64_matrix3x3_set_column(const int number, const BGC_FP64_Vecto // ==================== Add ===================== // -inline void bgc_fp32_matrix3x3_add(const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2, BGC_FP32_Matrix3x3* sum) +inline void bgc_fp32_matrix3x3_add(BGC_FP32_Matrix3x3* sum, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2) { sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; @@ -671,7 +671,7 @@ inline void bgc_fp32_matrix3x3_add(const BGC_FP32_Matrix3x3* matrix1, const BGC_ sum->r3c3 = matrix1->r3c3 + matrix2->r3c3; } -inline void bgc_fp64_matrix3x3_add(const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2, BGC_FP64_Matrix3x3* sum) +inline void bgc_fp64_matrix3x3_add(BGC_FP64_Matrix3x3* sum, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2) { sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; @@ -688,7 +688,7 @@ inline void bgc_fp64_matrix3x3_add(const BGC_FP64_Matrix3x3* matrix1, const BGC_ // ================= Add scaled ================= // -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) +inline void bgc_fp32_matrix3x3_add_scaled(BGC_FP32_Matrix3x3* sum, const BGC_FP32_Matrix3x3* basic_matrix, const BGC_FP32_Matrix3x3* scalable_matrix, const float scale) { sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; @@ -703,7 +703,7 @@ inline void bgc_fp32_matrix3x3_add_scaled(const BGC_FP32_Matrix3x3* basic_matrix sum->r3c3 = basic_matrix->r3c3 + scalable_matrix->r3c3 * scale; } -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) +inline void bgc_fp64_matrix3x3_add_scaled(BGC_FP64_Matrix3x3* sum, const BGC_FP64_Matrix3x3* basic_matrix, const BGC_FP64_Matrix3x3* scalable_matrix, const double scale) { sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; @@ -720,7 +720,7 @@ inline void bgc_fp64_matrix3x3_add_scaled(const BGC_FP64_Matrix3x3* basic_matrix // ================== Subtract ================== // -inline void bgc_fp32_matrix3x3_subtract(const BGC_FP32_Matrix3x3* minuend, const BGC_FP32_Matrix3x3* subtrahend, BGC_FP32_Matrix3x3* difference) +inline void bgc_fp32_matrix3x3_subtract(BGC_FP32_Matrix3x3* difference, const BGC_FP32_Matrix3x3* minuend, const BGC_FP32_Matrix3x3* subtrahend) { difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; @@ -735,7 +735,7 @@ inline void bgc_fp32_matrix3x3_subtract(const BGC_FP32_Matrix3x3* minuend, const difference->r3c3 = minuend->r3c3 - subtrahend->r3c3; } -inline void bgc_fp64_matrix3x3_subtract(const BGC_FP64_Matrix3x3* minuend, const BGC_FP64_Matrix3x3* subtrahend, BGC_FP64_Matrix3x3* difference) +inline void bgc_fp64_matrix3x3_subtract(BGC_FP64_Matrix3x3* difference, const BGC_FP64_Matrix3x3* minuend, const BGC_FP64_Matrix3x3* subtrahend) { difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; @@ -752,7 +752,7 @@ inline void bgc_fp64_matrix3x3_subtract(const BGC_FP64_Matrix3x3* minuend, const // ================== Multiply ================== // -inline void bgc_fp32_matrix3x3_multiply(const BGC_FP32_Matrix3x3* multiplicand, const float multiplier, BGC_FP32_Matrix3x3* product) +inline void bgc_fp32_matrix3x3_multiply(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix3x3* multiplicand, const float multiplier) { product->r1c1 = multiplicand->r1c1 * multiplier; product->r1c2 = multiplicand->r1c2 * multiplier; @@ -767,7 +767,7 @@ inline void bgc_fp32_matrix3x3_multiply(const BGC_FP32_Matrix3x3* multiplicand, product->r3c3 = multiplicand->r3c3 * multiplier; } -inline void bgc_fp64_matrix3x3_multiply(const BGC_FP64_Matrix3x3* multiplicand, const double multiplier, BGC_FP64_Matrix3x3* product) +inline void bgc_fp64_matrix3x3_multiply(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix3x3* multiplicand, const double multiplier) { product->r1c1 = multiplicand->r1c1 * multiplier; product->r1c2 = multiplicand->r1c2 * multiplier; @@ -784,19 +784,19 @@ inline void bgc_fp64_matrix3x3_multiply(const BGC_FP64_Matrix3x3* multiplicand, // =================== Divide =================== // -inline void bgc_fp32_matrix3x3_divide(const BGC_FP32_Matrix3x3* dividend, const float divisor, BGC_FP32_Matrix3x3* quotient) +inline void bgc_fp32_matrix3x3_divide(BGC_FP32_Matrix3x3* quotient, const BGC_FP32_Matrix3x3* dividend, const float divisor) { - bgc_fp32_matrix3x3_multiply(dividend, 1.0f / divisor, quotient); + bgc_fp32_matrix3x3_multiply(quotient, dividend, 1.0f / divisor); } -inline void bgc_fp64_matrix3x3_divide(const BGC_FP64_Matrix3x3* dividend, const double divisor, BGC_FP64_Matrix3x3* quotient) +inline void bgc_fp64_matrix3x3_divide(BGC_FP64_Matrix3x3* quotient, const BGC_FP64_Matrix3x3* dividend, const double divisor) { - bgc_fp64_matrix3x3_multiply(dividend, 1.0 / divisor, quotient); + bgc_fp64_matrix3x3_multiply(quotient, dividend, 1.0 / divisor); } // ================ Interpolate ================= // -inline void bgc_fp32_matrix3x3_interpolate(const BGC_FP32_Matrix3x3* first, const BGC_FP32_Matrix3x3* second, const float phase, BGC_FP32_Matrix3x3* interpolation) +inline void bgc_fp32_matrix3x3_interpolate(BGC_FP32_Matrix3x3* interpolation, const BGC_FP32_Matrix3x3* first, const BGC_FP32_Matrix3x3* second, const float phase) { const float counter_phase = 1.0f - phase; @@ -813,7 +813,7 @@ inline void bgc_fp32_matrix3x3_interpolate(const BGC_FP32_Matrix3x3* first, cons 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) +inline void bgc_fp64_matrix3x3_interpolate(BGC_FP64_Matrix3x3* interpolation, const BGC_FP64_Matrix3x3* first, const BGC_FP64_Matrix3x3* second, const double phase) { const double counter_phase = 1.0 - phase; @@ -832,50 +832,50 @@ inline void bgc_fp64_matrix3x3_interpolate(const BGC_FP64_Matrix3x3* first, cons // ============ Left Vector Product ============= // -inline void bgc_fp32_multiply_vector3_by_matrix3x3(const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix3x3* matrix, BGC_FP32_Vector3* result) +inline void bgc_fp32_multiply_vector3_by_matrix3x3(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix3x3* matrix) { 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 x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3 + vector->x3 * matrix->r3c3; - result->x1 = x1; - result->x2 = x2; - result->x3 = x3; + product->x1 = x1; + product->x2 = x2; + product->x3 = x3; } -inline void bgc_fp64_multiply_vector3_by_matrix3x3(const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix3x3* matrix, BGC_FP64_Vector3* result) +inline void bgc_fp64_multiply_vector3_by_matrix3x3(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix3x3* matrix) { 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 x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3 + vector->x3 * matrix->r3c3; - result->x1 = x1; - result->x2 = x2; - result->x3 = x3; + product->x1 = x1; + product->x2 = x2; + product->x3 = x3; } // ============ Right Vector Product ============ // -inline void bgc_fp32_multiply_matrix3x3_by_vector3(const BGC_FP32_Matrix3x3* matrix, const BGC_FP32_Vector3* vector, BGC_FP32_Vector3* result) +inline void bgc_fp32_multiply_matrix3x3_by_vector3(BGC_FP32_Vector3* product, const BGC_FP32_Matrix3x3* matrix, const BGC_FP32_Vector3* vector) { 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 x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3; - result->x1 = x1; - result->x2 = x2; - result->x3 = x3; + product->x1 = x1; + product->x2 = x2; + product->x3 = x3; } -inline void bgc_fp64_multiply_matrix3x3_by_vector3(const BGC_FP64_Matrix3x3* matrix, const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* result) +inline void bgc_fp64_multiply_matrix3x3_by_vector3(BGC_FP64_Vector3* product, const BGC_FP64_Matrix3x3* matrix, const BGC_FP64_Vector3* vector) { 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 x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3; - result->x1 = x1; - result->x2 = x2; - result->x3 = x3; + product->x1 = x1; + product->x2 = x2; + product->x3 = x3; } #endif diff --git a/basic-geometry/matrixes.c b/basic-geometry/matrixes.c deleted file mode 100644 index 8d66497..0000000 --- a/basic-geometry/matrixes.c +++ /dev/null @@ -1,25 +0,0 @@ -#include "matrixes.h" - -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_fp64_multiply_matrix2x2_by_matrix2x2(const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2, BGC_FP64_Matrix2x2* product); - -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); - -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); - -extern inline void bgc_fp32_multiply_matrix2x3_by_matrix3x2(const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix3x2* matrix2, BGC_FP32_Matrix3x3* product); -extern inline void bgc_fp64_multiply_matrix2x3_by_matrix3x2(const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix3x2* matrix2, BGC_FP64_Matrix3x3* product); - -extern inline void bgc_fp32_multiply_matrix3x2_by_matrix2x3(const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix2x3* matrix2, BGC_FP32_Matrix2x2* product); -extern inline void bgc_fp64_multiply_matrix3x2_by_matrix2x3(const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix2x3* matrix2, BGC_FP64_Matrix2x2* product); - -extern inline void bgc_fp32_multiply_matrix3x2_by_matrix3x3(const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x3* matrix2, BGC_FP32_Matrix3x2* product); -extern inline void bgc_fp64_multiply_matrix3x2_by_matrix3x3(const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x3* matrix2, BGC_FP64_Matrix3x2* product); - -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); - -extern inline void bgc_fp32_multiply_matrix3x3_by_matrix3x3(const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2, BGC_FP32_Matrix3x3* product); -extern inline void bgc_fp64_multiply_matrix3x3_by_matrix3x3(const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2, BGC_FP64_Matrix3x3* product); diff --git a/basic-geometry/position2.c b/basic-geometry/position2.c index 9a47978..85eeb10 100644 --- a/basic-geometry/position2.c +++ b/basic-geometry/position2.c @@ -1,49 +1,49 @@ #include "position2.h" -extern inline void bgc_fp32_position2_reset(BGC_FP32_Position2 * node); -extern inline void bgc_fp64_position2_reset(BGC_FP64_Position2 * node); +extern inline void bgc_fp32_position2_reset(BGC_FP32_Position2* node); +extern inline void bgc_fp64_position2_reset(BGC_FP64_Position2* node); -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_fp64_position2_make(const BGC_FP64_CotesNumber * turn, const BGC_FP64_Vector2 * shift, BGC_FP64_Position2 * position); +extern inline void bgc_fp32_position2_make(BGC_FP32_Position2* position, const BGC_FP32_CotesNumber* turn, const BGC_FP32_Vector2* shift); +extern inline void bgc_fp64_position2_make(BGC_FP64_Position2* position, const BGC_FP64_CotesNumber* turn, const BGC_FP64_Vector2* shift); -extern inline void bgc_fp32_position2_copy(const BGC_FP32_Position2 * source, BGC_FP32_Position2 * destination); -extern inline void bgc_fp64_position2_copy(const BGC_FP64_Position2 * source, BGC_FP64_Position2 * destination); +extern inline void bgc_fp32_position2_copy(BGC_FP32_Position2* destination, const BGC_FP32_Position2* source); +extern inline void bgc_fp64_position2_copy(BGC_FP64_Position2* destination, const BGC_FP64_Position2* source); -extern inline void bgc_fp32_position2_swap(BGC_FP32_Position2 * first, BGC_FP32_Position2 * second); -extern inline void bgc_fp64_position2_swap(BGC_FP64_Position2 * first, BGC_FP64_Position2 * second); +extern inline void bgc_fp32_position2_swap(BGC_FP32_Position2* first, BGC_FP32_Position2* second); +extern inline void bgc_fp64_position2_swap(BGC_FP64_Position2* first, BGC_FP64_Position2* second); -extern inline void bgc_fp64_position2_convert_to_fp32(const BGC_FP64_Position2 * source, BGC_FP32_Position2 * destination); -extern inline void bgc_fp32_position2_convert_to_fp64(const BGC_FP32_Position2 * source, BGC_FP64_Position2 * destination); +extern inline void bgc_fp64_position2_convert_to_fp32(BGC_FP32_Position2* destination, const BGC_FP64_Position2* source); +extern inline void bgc_fp32_position2_convert_to_fp64(BGC_FP64_Position2* destination, const BGC_FP32_Position2* source); -extern inline int bgc_fp32_position2_is_idle(const BGC_FP32_Position2 * position); -extern inline int bgc_fp64_position2_is_idle(const BGC_FP64_Position2 * position); +extern inline int bgc_fp32_position2_is_idle(const BGC_FP32_Position2* position); +extern inline int bgc_fp64_position2_is_idle(const BGC_FP64_Position2* position); -extern inline void bgc_fp32_position2_invert(BGC_FP32_Position2 * position); -extern inline void bgc_fp64_position2_invert(BGC_FP64_Position2 * position); +extern inline void bgc_fp32_position2_invert(BGC_FP32_Position2* position); +extern inline void bgc_fp64_position2_invert(BGC_FP64_Position2* position); -extern inline void bgc_fp32_position2_get_inverse(const BGC_FP32_Position2 * position, BGC_FP32_Position2 * inverted); -extern inline void bgc_fp64_position2_get_inverse(const BGC_FP64_Position2 * position, BGC_FP64_Position2 * inverted); +extern inline void bgc_fp32_position2_get_inverse(BGC_FP32_Position2* inverted, const BGC_FP32_Position2* position); +extern inline void bgc_fp64_position2_get_inverse(BGC_FP64_Position2* inverted, const BGC_FP64_Position2* position); -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_fp64_position2_combine(const BGC_FP64_Position2 * first, const BGC_FP64_Position2 * second, BGC_FP64_Position2 * combination); +extern inline void bgc_fp32_position2_combine(BGC_FP32_Position2* combination, const BGC_FP32_Position2* first, const BGC_FP32_Position2* second); +extern inline void bgc_fp64_position2_combine(BGC_FP64_Position2* combination, const BGC_FP64_Position2* first, const BGC_FP64_Position2* second); -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_fp64_position2_exclude(const BGC_FP64_Position2 * base, const BGC_FP64_Position2 * excludand, BGC_FP64_Position2 * difference); +extern inline void bgc_fp32_position2_exclude(BGC_FP32_Position2* difference, const BGC_FP32_Position2* base, const BGC_FP32_Position2* excludand); +extern inline void bgc_fp64_position2_exclude(BGC_FP64_Position2* difference, const BGC_FP64_Position2* base, const BGC_FP64_Position2* excludand); -extern inline void bgc_fp32_position2_get_outward_affine(const BGC_FP32_Position2 * position, BGC_FP32_Affine2 * outward_affine_map); -extern inline void bgc_fp64_position2_get_outward_affine(const BGC_FP64_Position2 * position, BGC_FP64_Affine2 * outward_affine_map); +extern inline void bgc_fp32_position2_get_outward_affine(BGC_FP32_Affine2* outward_affine_map, const BGC_FP32_Position2* position); +extern inline void bgc_fp64_position2_get_outward_affine(BGC_FP64_Affine2* outward_affine_map, const BGC_FP64_Position2* position); -extern inline void bgc_fp32_position2_get_inward_affine(const BGC_FP32_Position2 * position, BGC_FP32_Affine2 * inward_affine_map); -extern inline void bgc_fp64_position2_get_inward_affine(const BGC_FP64_Position2 * position, BGC_FP64_Affine2 * inward_affine_map); +extern inline void bgc_fp32_position2_get_inward_affine(BGC_FP32_Affine2* inward_affine_map, const BGC_FP32_Position2* position); +extern inline void bgc_fp64_position2_get_inward_affine(BGC_FP64_Affine2* inward_affine_map, const BGC_FP64_Position2* position); -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_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_fp32_position2_transform_point_outwards(BGC_FP32_Vector2* outer_point, const BGC_FP32_Position2* position, const BGC_FP32_Vector2* inner_point); +extern inline void bgc_fp64_position2_transform_point_outwards(BGC_FP64_Vector2* outer_point, const BGC_FP64_Position2* position, const BGC_FP64_Vector2* inner_point); -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_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_point_inwards(BGC_FP32_Vector2* inner_point, const BGC_FP32_Position2* position, const BGC_FP32_Vector2* outer_point); +extern inline void bgc_fp64_position2_transform_point_inwards(BGC_FP64_Vector2* inner_point, const BGC_FP64_Position2* position, const BGC_FP64_Vector2* outer_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_outwards(BGC_FP32_Vector2* outer_vector, const BGC_FP32_Position2* position, const BGC_FP32_Vector2* inner_vector); +extern inline void bgc_fp64_position2_transform_vector_outwards(BGC_FP64_Vector2* outer_vector, const BGC_FP64_Position2* position, const BGC_FP64_Vector2* inner_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); +extern inline void bgc_fp32_position2_transform_vector_inwards(BGC_FP32_Vector2* inner_vector, const BGC_FP32_Position2* position, const BGC_FP32_Vector2* outer_vector); +extern inline void bgc_fp64_position2_transform_vector_inwards(BGC_FP64_Vector2* inner_vector, const BGC_FP64_Position2* position, const BGC_FP64_Vector2* outer_vector); diff --git a/basic-geometry/position2.h b/basic-geometry/position2.h index 307b1c3..aae0d8f 100644 --- a/basic-geometry/position2.h +++ b/basic-geometry/position2.h @@ -19,13 +19,13 @@ typedef struct { // ==================== Reset ==================== // -inline void bgc_fp32_position2_reset(BGC_FP32_Position2 * position) +inline void bgc_fp32_position2_reset(BGC_FP32_Position2* position) { bgc_fp32_cotes_number_reset(&position->turn); bgc_fp32_vector2_reset(&position->shift); } -inline void bgc_fp64_position2_reset(BGC_FP64_Position2 * position) +inline void bgc_fp64_position2_reset(BGC_FP64_Position2* position) { bgc_fp64_cotes_number_reset(&position->turn); bgc_fp64_vector2_reset(&position->shift); @@ -33,31 +33,31 @@ inline void bgc_fp64_position2_reset(BGC_FP64_Position2 * position) // ==================== Make ===================== // -inline void bgc_fp32_position2_make(const BGC_FP32_CotesNumber * turn, const BGC_FP32_Vector2 * shift, BGC_FP32_Position2 * position) +inline void bgc_fp32_position2_make(BGC_FP32_Position2* position, const BGC_FP32_CotesNumber* turn, const BGC_FP32_Vector2* shift) { - bgc_fp32_cotes_number_copy(turn, &position->turn); - bgc_fp32_vector2_copy(shift, &position->shift); + bgc_fp32_cotes_number_copy(&position->turn, turn); + bgc_fp32_vector2_copy(&position->shift, shift); } -inline void bgc_fp64_position2_make(const BGC_FP64_CotesNumber * turn, const BGC_FP64_Vector2 * shift, BGC_FP64_Position2 * position) +inline void bgc_fp64_position2_make(BGC_FP64_Position2* position, const BGC_FP64_CotesNumber* turn, const BGC_FP64_Vector2* shift) { - bgc_fp64_cotes_number_copy(turn, &position->turn); - bgc_fp64_vector2_copy(shift, &position->shift); + bgc_fp64_cotes_number_copy(&position->turn, turn); + bgc_fp64_vector2_copy(&position->shift, shift); } // ==================== Copy ===================== // -inline void bgc_fp32_position2_copy(const BGC_FP32_Position2 * source, BGC_FP32_Position2 * destination) +inline void bgc_fp32_position2_copy(BGC_FP32_Position2* destination, const BGC_FP32_Position2* source) { - bgc_fp32_cotes_number_copy(&source->turn, &destination->turn); - bgc_fp32_vector2_copy(&source->shift, &destination->shift); + bgc_fp32_cotes_number_copy(&destination->turn, &source->turn); + bgc_fp32_vector2_copy(&destination->shift, &source->shift); } -inline void bgc_fp64_position2_copy(const BGC_FP64_Position2 * source, BGC_FP64_Position2 * destination) +inline void bgc_fp64_position2_copy(BGC_FP64_Position2* destination, const BGC_FP64_Position2* source) { - bgc_fp64_cotes_number_copy(&source->turn, &destination->turn); - bgc_fp64_vector2_copy(&source->shift, &destination->shift); + bgc_fp64_cotes_number_copy(&destination->turn, &source->turn); + bgc_fp64_vector2_copy(&destination->shift, &source->shift); } // ==================== Swap ===================== // @@ -76,16 +76,16 @@ inline void bgc_fp64_position2_swap(BGC_FP64_Position2 * first, BGC_FP64_Positio // =================== Convert =================== // -inline void bgc_fp64_position2_convert_to_fp32(const BGC_FP64_Position2 * source, BGC_FP32_Position2 * destination) +inline void bgc_fp64_position2_convert_to_fp32(BGC_FP32_Position2* destination, const BGC_FP64_Position2 * source) { - bgc_fp64_cotes_number_convert_to_fp32(&source->turn, &destination->turn); - bgc_fp64_vector2_convert_to_fp32(&source->shift, &destination->shift); + bgc_fp64_cotes_number_convert_to_fp32(&destination->turn, &source->turn); + bgc_fp64_vector2_convert_to_fp32(&destination->shift, &source->shift); } -inline void bgc_fp32_position2_convert_to_fp64(const BGC_FP32_Position2 * source, BGC_FP64_Position2 * destination) +inline void bgc_fp32_position2_convert_to_fp64(BGC_FP64_Position2* destination, const BGC_FP32_Position2 * source) { - bgc_fp32_cotes_number_convert_to_fp64(&source->turn, &destination->turn); - bgc_fp32_vector2_convert_to_fp64(&source->shift, &destination->shift); + bgc_fp32_cotes_number_convert_to_fp64(&destination->turn, &source->turn); + bgc_fp32_vector2_convert_to_fp64(&destination->shift, &source->shift); } // =================== Is Idle =================== // @@ -104,156 +104,156 @@ inline int bgc_fp64_position2_is_idle(const BGC_FP64_Position2 * position) inline void bgc_fp32_position2_invert(BGC_FP32_Position2 * position) { - bgc_fp32_cotes_number_turn_vector_back(&position->turn, &position->shift, &position->shift); + bgc_fp32_cotes_number_turn_vector_back(&position->shift, &position->turn, &position->shift); bgc_fp32_cotes_number_revert(&position->turn); bgc_fp32_vector2_revert(&position->shift); } inline void bgc_fp64_position2_invert(BGC_FP64_Position2 * position) { - bgc_fp64_cotes_number_turn_vector_back(&position->turn, &position->shift, &position->shift); + bgc_fp64_cotes_number_turn_vector_back(&position->shift, &position->turn, &position->shift); bgc_fp64_cotes_number_revert(&position->turn); bgc_fp64_vector2_revert(&position->shift); } // ================= Get Inverse ================= // -inline void bgc_fp32_position2_get_inverse(const BGC_FP32_Position2 * position, BGC_FP32_Position2 * inverted) +inline void bgc_fp32_position2_get_inverse(BGC_FP32_Position2* inverted, const BGC_FP32_Position2 * position) { - bgc_fp32_cotes_number_turn_vector_back(&position->turn, &position->shift, &inverted->shift); - bgc_fp32_cotes_number_get_reverse(&position->turn, &inverted->turn); + bgc_fp32_cotes_number_turn_vector_back(&inverted->shift, &position->turn, &position->shift); + bgc_fp32_cotes_number_get_reverse(&inverted->turn, &position->turn); bgc_fp32_vector2_revert(&inverted->shift); } -inline void bgc_fp64_position2_get_inverse(const BGC_FP64_Position2 * position, BGC_FP64_Position2 * inverted) +inline void bgc_fp64_position2_get_inverse(BGC_FP64_Position2* inverted, const BGC_FP64_Position2 * position) { - bgc_fp64_cotes_number_turn_vector_back(&position->turn, &position->shift, &inverted->shift); - bgc_fp64_cotes_number_get_inverse(&position->turn, &inverted->turn); + bgc_fp64_cotes_number_turn_vector_back(&inverted->shift, &position->turn, &position->shift); + bgc_fp64_cotes_number_get_reverse(&inverted->turn, &position->turn); bgc_fp64_vector2_revert(&inverted->shift); } // =================== Combine =================== // -inline void bgc_fp32_position2_combine(const BGC_FP32_Position2 * first, const BGC_FP32_Position2 * second, BGC_FP32_Position2 * combination) +inline void bgc_fp32_position2_combine(BGC_FP32_Position2* combination, const BGC_FP32_Position2 * first, const BGC_FP32_Position2 * second) { BGC_FP32_Vector2 relative_shift; - bgc_fp32_cotes_number_turn_vector(&second->turn, &first->shift, &relative_shift); - bgc_fp32_cotes_number_combine(&first->turn, &second->turn, &combination->turn); - bgc_fp32_vector2_add(&relative_shift, &second->shift, &combination->shift); + bgc_fp32_cotes_number_turn_vector(&relative_shift, &second->turn, &first->shift); + bgc_fp32_cotes_number_combine(&combination->turn, &first->turn, &second->turn); + bgc_fp32_vector2_add(&combination->shift, &second->shift, &relative_shift); } -inline void bgc_fp64_position2_combine(const BGC_FP64_Position2 * first, const BGC_FP64_Position2 * second, BGC_FP64_Position2 * combination) +inline void bgc_fp64_position2_combine(BGC_FP64_Position2* combination, const BGC_FP64_Position2 * first, const BGC_FP64_Position2 * second) { BGC_FP64_Vector2 relative_shift; - bgc_fp64_cotes_number_turn_vector(&second->turn, &first->shift, &relative_shift); - bgc_fp64_cotes_number_combine(&first->turn, &second->turn, &combination->turn); - bgc_fp64_vector2_add(&relative_shift, &second->shift, &combination->shift); + bgc_fp64_cotes_number_turn_vector(&relative_shift, &second->turn, &first->shift); + bgc_fp64_cotes_number_combine(&combination->turn, &first->turn, &second->turn); + bgc_fp64_vector2_add(&combination->shift, &second->shift, &relative_shift); } // =================== Exclude =================== // -inline void bgc_fp32_position2_exclude(const BGC_FP32_Position2 * base, const BGC_FP32_Position2 * excludand, BGC_FP32_Position2 * difference) +inline void bgc_fp32_position2_exclude(BGC_FP32_Position2* difference, const BGC_FP32_Position2 * base, const BGC_FP32_Position2 * excludand) { BGC_FP32_Vector2 relative_shift; - bgc_fp32_vector2_subtract(&base->shift, &excludand->shift, &relative_shift); - bgc_fp32_cotes_number_turn_vector_back(&excludand->turn, &relative_shift, &difference->shift); - bgc_fp32_cotes_number_exclude(&base->turn, &excludand->turn, &difference->turn); + bgc_fp32_vector2_subtract(&relative_shift, &base->shift, &excludand->shift); + bgc_fp32_cotes_number_turn_vector_back(&difference->shift, &excludand->turn, &relative_shift); + bgc_fp32_cotes_number_exclude(&difference->turn, &base->turn, &excludand->turn); } -inline void bgc_fp64_position2_exclude(const BGC_FP64_Position2 * base, const BGC_FP64_Position2 * excludand, BGC_FP64_Position2 * difference) +inline void bgc_fp64_position2_exclude(BGC_FP64_Position2* difference, const BGC_FP64_Position2 * base, const BGC_FP64_Position2 * excludand) { BGC_FP64_Vector2 relative_shift; - bgc_fp64_vector2_subtract(&base->shift, &excludand->shift, &relative_shift); - bgc_fp64_cotes_number_turn_vector_back(&excludand->turn, &relative_shift, &difference->shift); - bgc_fp64_cotes_number_exclude(&base->turn, &excludand->turn, &difference->turn); + bgc_fp64_vector2_subtract(&relative_shift, &base->shift, &excludand->shift); + bgc_fp64_cotes_number_turn_vector_back(&difference->shift, &excludand->turn, &relative_shift); + bgc_fp64_cotes_number_exclude(&difference->turn, &base->turn, &excludand->turn); } // ============= Get Outward Affine ============== // -inline void bgc_fp32_position2_get_outward_affine(const BGC_FP32_Position2 * position, BGC_FP32_Affine2 * outward_affine_map) +inline void bgc_fp32_position2_get_outward_affine(BGC_FP32_Affine2* outward_affine_map, const BGC_FP32_Position2 * position) { - bgc_fp32_cotes_number_get_rotation_matrix(&position->turn, &outward_affine_map->distortion); - bgc_fp32_vector2_copy(&position->shift, &outward_affine_map->shift); + bgc_fp32_cotes_number_get_rotation_matrix(&outward_affine_map->distortion, &position->turn); + bgc_fp32_vector2_copy(&outward_affine_map->shift, &position->shift); } -inline void bgc_fp64_position2_get_outward_affine(const BGC_FP64_Position2 * position, BGC_FP64_Affine2 * outward_affine_map) +inline void bgc_fp64_position2_get_outward_affine(BGC_FP64_Affine2* outward_affine_map, const BGC_FP64_Position2 * position) { - bgc_fp64_cotes_number_get_rotation_matrix(&position->turn, &outward_affine_map->distortion); - bgc_fp64_vector2_copy(&position->shift, &outward_affine_map->shift); + bgc_fp64_cotes_number_get_rotation_matrix(&outward_affine_map->distortion, &position->turn); + bgc_fp64_vector2_copy(&outward_affine_map->shift, &position->shift); } // ============== Get Inward Affine ============== // -inline void bgc_fp32_position2_get_inward_affine(const BGC_FP32_Position2 * position, BGC_FP32_Affine2 * inward_affine_map) +inline void bgc_fp32_position2_get_inward_affine(BGC_FP32_Affine2* inward_affine_map, const BGC_FP32_Position2 * position) { - bgc_fp32_cotes_number_get_reverse_matrix(&position->turn, &inward_affine_map->distortion); - bgc_fp32_multiply_matrix2x2_by_vector2(&inward_affine_map->distortion, &position->shift, &inward_affine_map->shift); + bgc_fp32_cotes_number_get_reverse_matrix(&inward_affine_map->distortion, &position->turn); + bgc_fp32_multiply_matrix2x2_by_vector2(&inward_affine_map->shift, &inward_affine_map->distortion, &position->shift); bgc_fp32_vector2_revert(&inward_affine_map->shift); } -inline void bgc_fp64_position2_get_inward_affine(const BGC_FP64_Position2 * position, BGC_FP64_Affine2 * inward_affine_map) +inline void bgc_fp64_position2_get_inward_affine(BGC_FP64_Affine2* inward_affine_map, const BGC_FP64_Position2 * position) { - bgc_fp64_cotes_number_get_reverse_matrix(&position->turn, &inward_affine_map->distortion); - bgc_fp64_multiply_matrix2x2_by_vector2(&inward_affine_map->distortion, &position->shift, &inward_affine_map->shift); + bgc_fp64_cotes_number_get_reverse_matrix(&inward_affine_map->distortion, &position->turn); + bgc_fp64_multiply_matrix2x2_by_vector2(&inward_affine_map->shift, &inward_affine_map->distortion, &position->shift); bgc_fp64_vector2_revert(&inward_affine_map->shift); } // ========== Transform Point Outwards =========== // -inline void bgc_fp32_position2_transform_point_outwards(const BGC_FP32_Position2 * position, const BGC_FP32_Vector2 * inner_point, BGC_FP32_Vector2 * outer_point) +inline void bgc_fp32_position2_transform_point_outwards(BGC_FP32_Vector2* outer_point, const BGC_FP32_Position2 * position, const BGC_FP32_Vector2 * inner_point) { BGC_FP32_Vector2 turned_point; - bgc_fp32_cotes_number_turn_vector(&position->turn, inner_point, &turned_point); - bgc_fp32_vector2_add(&position->shift, &turned_point, outer_point); + bgc_fp32_cotes_number_turn_vector(&turned_point, &position->turn, inner_point); + bgc_fp32_vector2_add(outer_point, &position->shift, &turned_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) +inline void bgc_fp64_position2_transform_point_outwards(BGC_FP64_Vector2* outer_point, const BGC_FP64_Position2 * position, const BGC_FP64_Vector2 * inner_point) { BGC_FP64_Vector2 turned_point; - bgc_fp64_cotes_number_turn_vector(&position->turn, inner_point, &turned_point); - bgc_fp64_vector2_add(&position->shift, &turned_point, outer_point); + bgc_fp64_cotes_number_turn_vector(&turned_point, &position->turn, inner_point); + bgc_fp64_vector2_add(outer_point, &position->shift, &turned_point); } // =========== Transform Point Inwards =========== // -inline void bgc_fp32_position2_transform_point_inwards(const BGC_FP32_Position2 * position, const BGC_FP32_Vector2 * outer_point, BGC_FP32_Vector2 * inner_point) +inline void bgc_fp32_position2_transform_point_inwards(BGC_FP32_Vector2* inner_point, const BGC_FP32_Position2 * position, const BGC_FP32_Vector2 * outer_point) { BGC_FP32_Vector2 relative_point; - bgc_fp32_vector2_subtract(outer_point, &position->shift, &relative_point); - bgc_fp32_cotes_number_turn_vector_back(&position->turn, &relative_point, inner_point); + bgc_fp32_vector2_subtract(&relative_point, outer_point, &position->shift); + bgc_fp32_cotes_number_turn_vector_back(inner_point, &position->turn, &relative_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) +inline void bgc_fp64_position2_transform_point_inwards(BGC_FP64_Vector2* inner_point, const BGC_FP64_Position2 * position, const BGC_FP64_Vector2 * outer_point) { BGC_FP64_Vector2 relative_point; - bgc_fp64_vector2_subtract(outer_point, &position->shift, &relative_point); - bgc_fp64_cotes_number_turn_vector_back(&position->turn, &relative_point, inner_point); + bgc_fp64_vector2_subtract(&relative_point, outer_point, &position->shift); + bgc_fp64_cotes_number_turn_vector_back(inner_point, &position->turn, &relative_point); } // ========== Transform Vector Outwards ========== // -inline void bgc_fp32_position2_transform_vector_outwards(const BGC_FP32_Position2 * position, const BGC_FP32_Vector2 * inner_vector, BGC_FP32_Vector2 * outer_vector) +inline void bgc_fp32_position2_transform_vector_outwards(BGC_FP32_Vector2* outer_vector, const BGC_FP32_Position2 * position, const BGC_FP32_Vector2 * inner_vector) { - bgc_fp32_cotes_number_turn_vector(&position->turn, inner_vector, outer_vector); + bgc_fp32_cotes_number_turn_vector(outer_vector, &position->turn, inner_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) +inline void bgc_fp64_position2_transform_vector_outwards(BGC_FP64_Vector2* outer_vector, const BGC_FP64_Position2 * position, const BGC_FP64_Vector2 * inner_vector) { - bgc_fp64_cotes_number_turn_vector(&position->turn, inner_vector, outer_vector); + bgc_fp64_cotes_number_turn_vector(outer_vector, &position->turn, inner_vector); } // ========== Transform Vector Inwards =========== // -inline void bgc_fp32_position2_transform_vector_inwards(const BGC_FP32_Position2 * position, const BGC_FP32_Vector2 * outer_vector, BGC_FP32_Vector2 * inner_vector) +inline void bgc_fp32_position2_transform_vector_inwards(BGC_FP32_Vector2* inner_vector, const BGC_FP32_Position2 * position, const BGC_FP32_Vector2 * outer_vector) { - bgc_fp32_cotes_number_turn_vector_back(&position->turn, outer_vector, inner_vector); + bgc_fp32_cotes_number_turn_vector_back(inner_vector, &position->turn, outer_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) +inline void bgc_fp64_position2_transform_vector_inwards(BGC_FP64_Vector2* inner_vector, const BGC_FP64_Position2 * position, const BGC_FP64_Vector2 * outer_vector) { - bgc_fp64_cotes_number_turn_vector_back(&position->turn, outer_vector, inner_vector); + bgc_fp64_cotes_number_turn_vector_back(inner_vector, &position->turn, outer_vector); } #endif diff --git a/basic-geometry/position3.c b/basic-geometry/position3.c index 6d7f304..0a5533d 100644 --- a/basic-geometry/position3.c +++ b/basic-geometry/position3.c @@ -3,17 +3,17 @@ extern inline void bgc_fp32_position3_reset(BGC_FP32_Position3 * node); extern inline void bgc_fp64_position3_reset(BGC_FP64_Position3 * node); -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_fp64_position3_make(const BGC_FP64_Versor * turn, const BGC_FP64_Vector3 * shift, BGC_FP64_Position3 * position); +extern inline void bgc_fp32_position3_make(BGC_FP32_Position3* position, const BGC_FP32_Versor* turn, const BGC_FP32_Vector3* shift); +extern inline void bgc_fp64_position3_make(BGC_FP64_Position3* position, const BGC_FP64_Versor * turn, const BGC_FP64_Vector3 * shift); -extern inline void bgc_fp32_position3_copy(const BGC_FP32_Position3 * source, BGC_FP32_Position3 * destination); -extern inline void bgc_fp64_position3_copy(const BGC_FP64_Position3 * source, BGC_FP64_Position3 * destination); +extern inline void bgc_fp32_position3_copy(BGC_FP32_Position3* destination, const BGC_FP32_Position3* source); +extern inline void bgc_fp64_position3_copy(BGC_FP64_Position3* destination, const BGC_FP64_Position3 * source); extern inline void bgc_fp32_position3_swap(BGC_FP32_Position3 * first, BGC_FP32_Position3 * second); extern inline void bgc_fp64_position3_swap(BGC_FP64_Position3 * first, BGC_FP64_Position3 * second); -extern inline void bgc_fp64_position3_convert_to_fp32(const BGC_FP64_Position3 * source, BGC_FP32_Position3 * destination); -extern inline void bgc_fp32_position3_convert_to_fp64(const BGC_FP32_Position3 * source, BGC_FP64_Position3 * destination); +extern inline void bgc_fp32_position3_convert_to_fp64(BGC_FP64_Position3* destination,const BGC_FP32_Position3 * source); +extern inline void bgc_fp64_position3_convert_to_fp32(BGC_FP32_Position3* destination, const BGC_FP64_Position3* source); extern inline int bgc_fp32_position3_is_idle(const BGC_FP32_Position3 * position); extern inline int bgc_fp64_position3_is_idle(const BGC_FP64_Position3 * position); @@ -21,29 +21,29 @@ extern inline int bgc_fp64_position3_is_idle(const BGC_FP64_Position3 * position extern inline void bgc_fp32_position3_invert(BGC_FP32_Position3 * position); extern inline void bgc_fp64_position3_invert(BGC_FP64_Position3 * position); -extern inline void bgc_fp32_position3_get_inverse(const BGC_FP32_Position3 * position, BGC_FP32_Position3 * inverted); -extern inline void bgc_fp64_position3_get_inverse(const BGC_FP64_Position3 * position, BGC_FP64_Position3 * inverted); +extern inline void bgc_fp32_position3_get_inverse(BGC_FP32_Position3* inverse, const BGC_FP32_Position3* position); +extern inline void bgc_fp64_position3_get_inverse(BGC_FP64_Position3* inverse, const BGC_FP64_Position3 * position); -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_fp64_position3_combine(const BGC_FP64_Position3 * first, const BGC_FP64_Position3 * second, BGC_FP64_Position3 * combination); +extern inline void bgc_fp32_position3_combine(BGC_FP32_Position3* combination, const BGC_FP32_Position3* first, const BGC_FP32_Position3* second); +extern inline void bgc_fp64_position3_combine(BGC_FP64_Position3* combination, const BGC_FP64_Position3 * first, const BGC_FP64_Position3 * second); -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_fp64_position3_exclude(const BGC_FP64_Position3 * base, const BGC_FP64_Position3 * excludant, BGC_FP64_Position3 * difference); +extern inline void bgc_fp32_position3_exclude(BGC_FP32_Position3* difference, const BGC_FP32_Position3* base, const BGC_FP32_Position3* excludant); +extern inline void bgc_fp64_position3_exclude(BGC_FP64_Position3* difference, const BGC_FP64_Position3 * base, const BGC_FP64_Position3 * excludant); -extern inline void bgc_fp32_position3_get_outward_affine(const BGC_FP32_Position3 * position, BGC_FP32_Affine3 * outward_affine_map); -extern inline void bgc_fp64_position3_get_outward_affine(const BGC_FP64_Position3 * position, BGC_FP64_Affine3 * outward_affine_map); +extern inline void bgc_fp32_position3_get_outward_affine(BGC_FP32_Affine3* outward_affine_map, const BGC_FP32_Position3* position); +extern inline void bgc_fp64_position3_get_outward_affine(BGC_FP64_Affine3* outward_affine_map, const BGC_FP64_Position3 * position); -extern inline void bgc_fp32_position3_get_inward_affine(const BGC_FP32_Position3 * position, BGC_FP32_Affine3 * inward_affine_map); -extern inline void bgc_fp64_position3_get_inward_affine(const BGC_FP64_Position3 * position, BGC_FP64_Affine3 * inward_affine_map); +extern inline void bgc_fp32_position3_get_inward_affine(BGC_FP32_Affine3* inward_affine_map, const BGC_FP32_Position3* position); +extern inline void bgc_fp64_position3_get_inward_affine(BGC_FP64_Affine3* inward_affine_map, const BGC_FP64_Position3 * position); -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_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_fp32_position3_transform_point_outwards(BGC_FP32_Vector3* outer_point, const BGC_FP32_Position3* position, const BGC_FP32_Vector3* inner_point); +extern inline void bgc_fp64_position3_transform_point_outwards(BGC_FP64_Vector3* outer_point, const BGC_FP64_Position3 * position, const BGC_FP64_Vector3 * inner_point); -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_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_point_inwards(BGC_FP32_Vector3* inner_point, const BGC_FP32_Position3* position, const BGC_FP32_Vector3* outer_point); +extern inline void bgc_fp64_position3_transform_point_inwards(BGC_FP64_Vector3* inner_point, const BGC_FP64_Position3 * position, const BGC_FP64_Vector3 * outer_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_outwards(BGC_FP32_Vector3* outer_vector, const BGC_FP32_Position3* position, const BGC_FP32_Vector3* inner_vector); +extern inline void bgc_fp64_position3_transform_vector_outwards(BGC_FP64_Vector3* outer_vector, const BGC_FP64_Position3 * position, const BGC_FP64_Vector3 * inner_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); +extern inline void bgc_fp32_position3_transform_vector_inwards(BGC_FP32_Vector3* inner_vector, const BGC_FP32_Position3* position, const BGC_FP32_Vector3* outer_vector); +extern inline void bgc_fp64_position3_transform_vector_inwards(BGC_FP64_Vector3* inner_vector, const BGC_FP64_Position3 * position, const BGC_FP64_Vector3 * outer_vector); diff --git a/basic-geometry/position3.h b/basic-geometry/position3.h index f34685a..c563c54 100644 --- a/basic-geometry/position3.h +++ b/basic-geometry/position3.h @@ -33,30 +33,30 @@ inline void bgc_fp64_position3_reset(BGC_FP64_Position3 * position) // ==================== Make ===================== // -inline void bgc_fp32_position3_make(const BGC_FP32_Versor * turn, const BGC_FP32_Vector3 * shift, BGC_FP32_Position3 * position) +inline void bgc_fp32_position3_make(BGC_FP32_Position3* position, const BGC_FP32_Versor * turn, const BGC_FP32_Vector3 * shift) { - bgc_fp32_versor_copy(turn, &position->turn); - bgc_fp32_vector3_copy(shift, &position->shift); + bgc_fp32_versor_copy(&position->turn, turn); + bgc_fp32_vector3_copy(&position->shift, shift); } -inline void bgc_fp64_position3_make(const BGC_FP64_Versor * turn, const BGC_FP64_Vector3 * shift, BGC_FP64_Position3 * position) +inline void bgc_fp64_position3_make(BGC_FP64_Position3* position, const BGC_FP64_Versor * turn, const BGC_FP64_Vector3 * shift) { - bgc_fp64_versor_copy(turn, &position->turn); - bgc_fp64_vector3_copy(shift, &position->shift); + bgc_fp64_versor_copy(&position->turn, turn); + bgc_fp64_vector3_copy(&position->shift, shift); } // ==================== Copy ===================== // -inline void bgc_fp32_position3_copy(const BGC_FP32_Position3 * source, BGC_FP32_Position3 * destination) +inline void bgc_fp32_position3_copy(BGC_FP32_Position3* destination, const BGC_FP32_Position3 * source) { - bgc_fp32_versor_copy(&source->turn, &destination->turn); - bgc_fp32_vector3_copy(&source->shift, &destination->shift); + bgc_fp32_versor_copy(&destination->turn, &source->turn); + bgc_fp32_vector3_copy(&destination->shift, &source->shift); } -inline void bgc_fp64_position3_copy(const BGC_FP64_Position3 * source, BGC_FP64_Position3 * destination) +inline void bgc_fp64_position3_copy(BGC_FP64_Position3* destination, const BGC_FP64_Position3 * source) { - bgc_fp64_versor_copy(&source->turn, &destination->turn); - bgc_fp64_vector3_copy(&source->shift, &destination->shift); + bgc_fp64_versor_copy(&destination->turn, &source->turn); + bgc_fp64_vector3_copy(&destination->shift, &source->shift); } // ==================== Swap ===================== // @@ -75,16 +75,16 @@ inline void bgc_fp64_position3_swap(BGC_FP64_Position3 * first, BGC_FP64_Positio // =================== Convert =================== // -inline void bgc_fp64_position3_convert_to_fp32(const BGC_FP64_Position3 * source, BGC_FP32_Position3 * destination) +inline void bgc_fp32_position3_convert_to_fp64(BGC_FP64_Position3* destination, const BGC_FP32_Position3 * source) { - bgc_fp64_versor_convert_to_fp32(&source->turn, &destination->turn); - bgc_fp64_vector3_convert_to_fp32(&source->shift, &destination->shift); + bgc_fp32_versor_convert_to_fp64(&destination->turn, &source->turn); + bgc_fp32_vector3_convert_to_fp64(&destination->shift, &source->shift); } -inline void bgc_fp32_position3_convert_to_fp64(const BGC_FP32_Position3 * source, BGC_FP64_Position3 * destination) +inline void bgc_fp64_position3_convert_to_fp32(BGC_FP32_Position3* destination, const BGC_FP64_Position3* source) { - bgc_fp32_versor_convert_to_fp64(&source->turn, &destination->turn); - bgc_fp32_vector3_convert_to_fp64(&source->shift, &destination->shift); + bgc_fp64_versor_convert_to_fp32(&destination->turn, &source->turn); + bgc_fp64_vector3_convert_to_fp32(&destination->shift, &source->shift); } // =================== Is Idle =================== // @@ -103,156 +103,156 @@ inline int bgc_fp64_position3_is_idle(const BGC_FP64_Position3 * position) inline void bgc_fp32_position3_invert(BGC_FP32_Position3 * position) { - bgc_fp32_versor_turn_vector_back(&position->turn, &position->shift, &position->shift); + bgc_fp32_versor_turn_vector_back(&position->shift, &position->turn, &position->shift); bgc_fp32_versor_revert(&position->turn); bgc_fp32_vector3_revert(&position->shift); } inline void bgc_fp64_position3_invert(BGC_FP64_Position3 * position) { - bgc_fp64_versor_turn_vector_back(&position->turn, &position->shift, &position->shift); + bgc_fp64_versor_turn_vector_back(&position->shift, &position->turn, &position->shift); bgc_fp64_versor_revert(&position->turn); bgc_fp64_vector3_revert(&position->shift); } // ================= Get Inverse ================= // -inline void bgc_fp32_position3_get_inverse(const BGC_FP32_Position3 * position, BGC_FP32_Position3 * inverted) +inline void bgc_fp32_position3_get_inverse(BGC_FP32_Position3* inverse, const BGC_FP32_Position3 * position) { - bgc_fp32_versor_turn_vector_back(&position->turn, &position->shift, &inverted->shift); - bgc_fp32_versor_get_reverse(&position->turn, &inverted->turn); - bgc_fp32_vector3_revert(&inverted->shift); + bgc_fp32_versor_turn_vector_back(&inverse->shift, &position->turn, &position->shift); + bgc_fp32_versor_get_reverse(&inverse->turn, &position->turn); + bgc_fp32_vector3_revert(&inverse->shift); } -inline void bgc_fp64_position3_get_inverse(const BGC_FP64_Position3 * position, BGC_FP64_Position3 * inverted) +inline void bgc_fp64_position3_get_inverse(BGC_FP64_Position3* inverse, const BGC_FP64_Position3 * position) { - bgc_fp64_versor_turn_vector_back(&position->turn, &position->shift, &inverted->shift); - bgc_fp64_versor_get_reverse(&position->turn, &inverted->turn); - bgc_fp64_vector3_revert(&inverted->shift); + bgc_fp64_versor_turn_vector_back(&inverse->shift, &position->turn, &position->shift); + bgc_fp64_versor_get_reverse(&inverse->turn, &position->turn); + bgc_fp64_vector3_revert(&inverse->shift); } // =================== Combine =================== // -inline void bgc_fp32_position3_combine(const BGC_FP32_Position3 * first, const BGC_FP32_Position3 * second, BGC_FP32_Position3 * combination) +inline void bgc_fp32_position3_combine(BGC_FP32_Position3* combination, const BGC_FP32_Position3 * first, const BGC_FP32_Position3 * second) { BGC_FP32_Vector3 relative_shift; - bgc_fp32_versor_turn_vector(&second->turn, &first->shift, &relative_shift); - bgc_fp32_versor_combine(&first->turn, &second->turn, &combination->turn); - bgc_fp32_vector3_add(&relative_shift, &second->shift, &combination->shift); + bgc_fp32_versor_turn_vector(&relative_shift, &second->turn, &first->shift); + bgc_fp32_versor_combine(&combination->turn, &first->turn, &second->turn); + bgc_fp32_vector3_add(&combination->shift, &relative_shift, &second->shift); } -inline void bgc_fp64_position3_combine(const BGC_FP64_Position3 * first, const BGC_FP64_Position3 * second, BGC_FP64_Position3 * combination) +inline void bgc_fp64_position3_combine(BGC_FP64_Position3* combination, const BGC_FP64_Position3 * first, const BGC_FP64_Position3 * second) { BGC_FP64_Vector3 relative_shift; - bgc_fp64_versor_turn_vector(&second->turn, &first->shift, &relative_shift); - bgc_fp64_versor_combine(&first->turn, &second->turn, &combination->turn); - bgc_fp64_vector3_add(&relative_shift, &second->shift, &combination->shift); + bgc_fp64_versor_turn_vector(&relative_shift, &second->turn, &first->shift); + bgc_fp64_versor_combine(&combination->turn, &first->turn, &second->turn); + bgc_fp64_vector3_add(&combination->shift, &relative_shift, &second->shift); } // =================== Exclude =================== // -inline void bgc_fp32_position3_exclude(const BGC_FP32_Position3 * base, const BGC_FP32_Position3 * excludant, BGC_FP32_Position3 * difference) +inline void bgc_fp32_position3_exclude(BGC_FP32_Position3* difference, const BGC_FP32_Position3 * base, const BGC_FP32_Position3 * excludant) { BGC_FP32_Vector3 relative_shift; - bgc_fp32_vector3_subtract(&base->shift, &excludant->shift, &relative_shift); - bgc_fp32_versor_turn_vector_back(&excludant->turn, &relative_shift, &difference->shift); - bgc_fp32_versor_exclude(&base->turn, &excludant->turn, &difference->turn); + bgc_fp32_vector3_subtract(&relative_shift, &base->shift, &excludant->shift); + bgc_fp32_versor_turn_vector_back(&difference->shift, &excludant->turn, &relative_shift); + bgc_fp32_versor_exclude(&difference->turn, &base->turn, &excludant->turn); } -inline void bgc_fp64_position3_exclude(const BGC_FP64_Position3 * base, const BGC_FP64_Position3 * excludant, BGC_FP64_Position3 * difference) +inline void bgc_fp64_position3_exclude(BGC_FP64_Position3* difference, const BGC_FP64_Position3 * base, const BGC_FP64_Position3 * excludant) { BGC_FP64_Vector3 relative_shift; - bgc_fp64_vector3_subtract(&base->shift, &excludant->shift, &relative_shift); - bgc_fp64_versor_turn_vector_back(&excludant->turn, &relative_shift, &difference->shift); - bgc_fp64_versor_exclude(&base->turn, &excludant->turn, &difference->turn); + bgc_fp64_vector3_subtract(&relative_shift, &base->shift, &excludant->shift); + bgc_fp64_versor_turn_vector_back(&difference->shift, &excludant->turn, &relative_shift); + bgc_fp64_versor_exclude(&difference->turn, &base->turn, &excludant->turn); } // ============= Get Outward Affine ============== // -inline void bgc_fp32_position3_get_outward_affine(const BGC_FP32_Position3 * position, BGC_FP32_Affine3 * outward_affine_map) +inline void bgc_fp32_position3_get_outward_affine(BGC_FP32_Affine3* outward_affine_map, const BGC_FP32_Position3 * position) { - bgc_fp32_versor_get_rotation_matrix(&position->turn, &outward_affine_map->distortion); - bgc_fp32_vector3_copy(&position->shift, &outward_affine_map->shift); + bgc_fp32_versor_get_rotation_matrix(&outward_affine_map->distortion, &position->turn); + bgc_fp32_vector3_copy(&outward_affine_map->shift, &position->shift); } -inline void bgc_fp64_position3_get_outward_affine(const BGC_FP64_Position3 * position, BGC_FP64_Affine3 * outward_affine_map) +inline void bgc_fp64_position3_get_outward_affine(BGC_FP64_Affine3* outward_affine_map, const BGC_FP64_Position3 * position) { - bgc_fp64_versor_get_rotation_matrix(&position->turn, &outward_affine_map->distortion); - bgc_fp64_vector3_copy(&position->shift, &outward_affine_map->shift); + bgc_fp64_versor_get_rotation_matrix(&outward_affine_map->distortion, &position->turn); + bgc_fp64_vector3_copy(&outward_affine_map->shift, &position->shift); } // ============== Get Inward Affine ============== // -inline void bgc_fp32_position3_get_inward_affine(const BGC_FP32_Position3 * position, BGC_FP32_Affine3 * inward_affine_map) +inline void bgc_fp32_position3_get_inward_affine(BGC_FP32_Affine3* inward_affine_map, const BGC_FP32_Position3 * position) { - bgc_fp32_versor_get_reverse_matrix(&position->turn, &inward_affine_map->distortion); - bgc_fp32_multiply_matrix3x3_by_vector3(&inward_affine_map->distortion, &position->shift, &inward_affine_map->shift); + bgc_fp32_versor_get_reverse_matrix(&inward_affine_map->distortion, &position->turn); + bgc_fp32_multiply_matrix3x3_by_vector3(&inward_affine_map->shift, &inward_affine_map->distortion, &position->shift); bgc_fp32_vector3_revert(&inward_affine_map->shift); } -inline void bgc_fp64_position3_get_inward_affine(const BGC_FP64_Position3 * position, BGC_FP64_Affine3 * inward_affine_map) +inline void bgc_fp64_position3_get_inward_affine(BGC_FP64_Affine3* inward_affine_map, const BGC_FP64_Position3 * position) { - bgc_fp64_versor_get_reverse_matrix(&position->turn, &inward_affine_map->distortion); - bgc_fp64_multiply_matrix3x3_by_vector3(&inward_affine_map->distortion, &position->shift, &inward_affine_map->shift); + bgc_fp64_versor_get_reverse_matrix(&inward_affine_map->distortion, &position->turn); + bgc_fp64_multiply_matrix3x3_by_vector3(&inward_affine_map->shift, &inward_affine_map->distortion, &position->shift); bgc_fp64_vector3_revert(&inward_affine_map->shift); } // ========== Transform Point Outwards =========== // -inline void bgc_fp32_position3_transform_point_outwards(const BGC_FP32_Position3 * position, const BGC_FP32_Vector3 * inner_point, BGC_FP32_Vector3 * outer_point) +inline void bgc_fp32_position3_transform_point_outwards(BGC_FP32_Vector3* outer_point, const BGC_FP32_Position3 * position, const BGC_FP32_Vector3 * inner_point) { BGC_FP32_Vector3 turned_point; - bgc_fp32_versor_turn_vector(&position->turn, inner_point, &turned_point); - bgc_fp32_vector3_add(&position->shift, &turned_point, outer_point); + bgc_fp32_versor_turn_vector(&turned_point, &position->turn, inner_point); + bgc_fp32_vector3_add(outer_point, &position->shift, &turned_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) +inline void bgc_fp64_position3_transform_point_outwards(BGC_FP64_Vector3* outer_point, const BGC_FP64_Position3 * position, const BGC_FP64_Vector3 * inner_point) { BGC_FP64_Vector3 turned_point; - bgc_fp64_versor_turn_vector(&position->turn, inner_point, &turned_point); - bgc_fp64_vector3_add(&position->shift, &turned_point, outer_point); + bgc_fp64_versor_turn_vector(&turned_point, &position->turn, inner_point); + bgc_fp64_vector3_add(outer_point, &position->shift, &turned_point); } // =========== Transform Point Inwards =========== // -inline void bgc_fp32_position3_transform_point_inwards(const BGC_FP32_Position3 * position, const BGC_FP32_Vector3 * outer_point, BGC_FP32_Vector3 * inner_point) +inline void bgc_fp32_position3_transform_point_inwards(BGC_FP32_Vector3* inner_point, const BGC_FP32_Position3 * position, const BGC_FP32_Vector3 * outer_point) { BGC_FP32_Vector3 relative_point; - bgc_fp32_vector3_subtract(outer_point, &position->shift, &relative_point); - bgc_fp32_versor_turn_vector_back(&position->turn, &relative_point, inner_point); + bgc_fp32_vector3_subtract(&relative_point, outer_point, &position->shift); + bgc_fp32_versor_turn_vector_back(inner_point, &position->turn, &relative_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) +inline void bgc_fp64_position3_transform_point_inwards(BGC_FP64_Vector3* inner_point, const BGC_FP64_Position3 * position, const BGC_FP64_Vector3 * outer_point) { BGC_FP64_Vector3 relative_point; - bgc_fp64_vector3_subtract(outer_point, &position->shift, &relative_point); - bgc_fp64_versor_turn_vector_back(&position->turn, &relative_point, inner_point); + bgc_fp64_vector3_subtract(&relative_point, outer_point, &position->shift); + bgc_fp64_versor_turn_vector_back(inner_point, &position->turn, &relative_point); } // ========== Transform Vector Outwards ========== // -inline void bgc_fp32_position3_transform_vector_outwards(const BGC_FP32_Position3 * position, const BGC_FP32_Vector3 * inner_vector, BGC_FP32_Vector3 * outer_vector) +inline void bgc_fp32_position3_transform_vector_outwards(BGC_FP32_Vector3* outer_vector, const BGC_FP32_Position3 * position, const BGC_FP32_Vector3 * inner_vector) { - bgc_fp32_versor_turn_vector(&position->turn, inner_vector, outer_vector); + bgc_fp32_versor_turn_vector(outer_vector, &position->turn, inner_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) +inline void bgc_fp64_position3_transform_vector_outwards(BGC_FP64_Vector3* outer_vector, const BGC_FP64_Position3 * position, const BGC_FP64_Vector3 * inner_vector) { - bgc_fp64_versor_turn_vector(&position->turn, inner_vector, outer_vector); + bgc_fp64_versor_turn_vector(outer_vector, &position->turn, inner_vector); } // ========== Transform Vector Inwards =========== // -inline void bgc_fp32_position3_transform_vector_inwards(const BGC_FP32_Position3 * position, const BGC_FP32_Vector3 * outer_vector, BGC_FP32_Vector3 * inner_vector) +inline void bgc_fp32_position3_transform_vector_inwards(BGC_FP32_Vector3* inner_vector, const BGC_FP32_Position3 * position, const BGC_FP32_Vector3 * outer_vector) { - bgc_fp32_versor_turn_vector_back(&position->turn, outer_vector, inner_vector); + bgc_fp32_versor_turn_vector_back(inner_vector, &position->turn, outer_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) +inline void bgc_fp64_position3_transform_vector_inwards(BGC_FP64_Vector3* inner_vector, const BGC_FP64_Position3 * position, const BGC_FP64_Vector3 * outer_vector) { - bgc_fp64_versor_turn_vector_back(&position->turn, outer_vector, inner_vector); + bgc_fp64_versor_turn_vector_back(inner_vector, &position->turn, outer_vector); } #endif // _BGC_POSITION_H_INCLUDED_ diff --git a/basic-geometry/quaternion.c b/basic-geometry/quaternion.c index 3c27d5b..bedd7bf 100644 --- a/basic-geometry/quaternion.c +++ b/basic-geometry/quaternion.c @@ -7,8 +7,8 @@ extern inline void bgc_fp64_quaternion_reset(BGC_FP64_Quaternion* quaternion); extern inline void bgc_fp32_quaternion_make_unit(BGC_FP32_Quaternion* quaternion); extern inline void bgc_fp64_quaternion_make_unit(BGC_FP64_Quaternion* 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_fp64_quaternion_make(const double s0, const double x1, const double x2, const double x3, BGC_FP64_Quaternion* quaternion); +extern inline void bgc_fp32_quaternion_make(BGC_FP32_Quaternion* quaternion, const float s0, const float x1, const float x2, const float x3); +extern inline void bgc_fp64_quaternion_make(BGC_FP64_Quaternion* quaternion, const double s0, const double x1, const double x2, const double x3); extern inline float bgc_fp32_quaternion_get_square_modulus(const BGC_FP32_Quaternion* quaternion); extern inline double bgc_fp64_quaternion_get_square_modulus(const BGC_FP64_Quaternion* quaternion); @@ -22,84 +22,84 @@ extern inline int bgc_fp64_quaternion_is_zero(const BGC_FP64_Quaternion* quatern extern inline int bgc_fp32_quaternion_is_unit(const BGC_FP32_Quaternion* quaternion); extern inline int bgc_fp64_quaternion_is_unit(const BGC_FP64_Quaternion* quaternion); -extern inline void bgc_fp32_quaternion_copy(const BGC_FP32_Quaternion* source, BGC_FP32_Quaternion* destination); -extern inline void bgc_fp64_quaternion_copy(const BGC_FP64_Quaternion* source, BGC_FP64_Quaternion* destination); +extern inline void bgc_fp32_quaternion_copy(BGC_FP32_Quaternion* destination, const BGC_FP32_Quaternion* source); +extern inline void bgc_fp64_quaternion_copy(BGC_FP64_Quaternion* destination, const BGC_FP64_Quaternion* source); extern inline void bgc_fp32_quaternion_swap(BGC_FP32_Quaternion* quarternion1, BGC_FP32_Quaternion* quarternion2); extern inline void bgc_fp64_quaternion_swap(BGC_FP64_Quaternion* quarternion1, BGC_FP64_Quaternion* quarternion2); -extern inline void bgc_fp64_quaternion_convert_to_fp32(const BGC_FP64_Quaternion* source, BGC_FP32_Quaternion* destination); -extern inline void bgc_fp32_quaternion_convert_to_fp64(const BGC_FP32_Quaternion* source, BGC_FP64_Quaternion* destination); +extern inline void bgc_fp32_quaternion_convert_to_fp64(BGC_FP64_Quaternion* destination, const BGC_FP32_Quaternion* source); +extern inline void bgc_fp64_quaternion_convert_to_fp32(BGC_FP32_Quaternion* destination, const BGC_FP64_Quaternion* source); -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_fp64_quaternion_add(const BGC_FP64_Quaternion* quaternion1, const BGC_FP64_Quaternion* quaternion2, BGC_FP64_Quaternion* sum); +extern inline void bgc_fp32_quaternion_add(BGC_FP32_Quaternion* sum, const BGC_FP32_Quaternion* quaternion1, const BGC_FP32_Quaternion* quaternion2); +extern inline void bgc_fp64_quaternion_add(BGC_FP64_Quaternion* sum, const BGC_FP64_Quaternion* quaternion1, const BGC_FP64_Quaternion* quaternion2); -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_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_fp32_quaternion_add_scaled(BGC_FP32_Quaternion* sum, const BGC_FP32_Quaternion* basic_quaternion, const BGC_FP32_Quaternion* scalable_quaternion, const float scale); +extern inline void bgc_fp64_quaternion_add_scaled(BGC_FP64_Quaternion* sum, const BGC_FP64_Quaternion* basic_quaternion, const BGC_FP64_Quaternion* scalable_quaternion, const double scale); -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_fp64_quaternion_subtract(const BGC_FP64_Quaternion* minuend, const BGC_FP64_Quaternion* subtrahend, BGC_FP64_Quaternion* difference); +extern inline void bgc_fp32_quaternion_subtract(BGC_FP32_Quaternion* difference, const BGC_FP32_Quaternion* minuend, const BGC_FP32_Quaternion* subtrahend); +extern inline void bgc_fp64_quaternion_subtract(BGC_FP64_Quaternion* difference, const BGC_FP64_Quaternion* minuend, const BGC_FP64_Quaternion* subtrahend); -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_fp64_quaternion_get_product(const BGC_FP64_Quaternion* left, const BGC_FP64_Quaternion* right, BGC_FP64_Quaternion* product); +extern inline void bgc_fp32_quaternion_get_product(BGC_FP32_Quaternion* product, const BGC_FP32_Quaternion* left, const BGC_FP32_Quaternion* right); +extern inline void bgc_fp64_quaternion_get_product(BGC_FP64_Quaternion* product, const BGC_FP64_Quaternion* left, const BGC_FP64_Quaternion* right); -extern inline void bgc_fp32_quaternion_multiply(const BGC_FP32_Quaternion* multiplicand, const float multipier, BGC_FP32_Quaternion* product); -extern inline void bgc_fp64_quaternion_multiply(const BGC_FP64_Quaternion* multiplicand, const double multipier, BGC_FP64_Quaternion* product); +extern inline void bgc_fp32_quaternion_multiply(BGC_FP32_Quaternion* product, const BGC_FP32_Quaternion* multiplicand, const float multipier); +extern inline void bgc_fp64_quaternion_multiply(BGC_FP64_Quaternion* product, const BGC_FP64_Quaternion* multiplicand, const double multipier); -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_fp64_quaternion_get_ratio(const BGC_FP64_Quaternion* divident, const BGC_FP64_Quaternion* divisor, BGC_FP64_Quaternion* quotient); +extern inline int bgc_fp32_quaternion_get_ratio(BGC_FP32_Quaternion* quotient, const BGC_FP32_Quaternion* divident, const BGC_FP32_Quaternion* divisor); +extern inline int bgc_fp64_quaternion_get_ratio(BGC_FP64_Quaternion* quotient, const BGC_FP64_Quaternion* divident, const BGC_FP64_Quaternion* divisor); -extern inline void bgc_fp32_quaternion_divide(const BGC_FP32_Quaternion* dividend, const float divisor, BGC_FP32_Quaternion* quotient); -extern inline void bgc_fp64_quaternion_divide(const BGC_FP64_Quaternion* dividend, const double divisor, BGC_FP64_Quaternion* quotient); +extern inline void bgc_fp32_quaternion_divide(BGC_FP32_Quaternion* quotient, const BGC_FP32_Quaternion* dividend, const float divisor); +extern inline void bgc_fp64_quaternion_divide(BGC_FP64_Quaternion* quotient, const BGC_FP64_Quaternion* dividend, const double divisor); -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_fp64_quaternion_get_mean2(const BGC_FP64_Quaternion* vector1, const BGC_FP64_Quaternion* vector2, BGC_FP64_Quaternion* mean); +extern inline void bgc_fp32_quaternion_get_mean2(BGC_FP32_Quaternion* mean, const BGC_FP32_Quaternion* quaternion1, const BGC_FP32_Quaternion* quaternion2); +extern inline void bgc_fp64_quaternion_get_mean2(BGC_FP64_Quaternion* mean, const BGC_FP64_Quaternion* quaternion1, const BGC_FP64_Quaternion* quaternion2); -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_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_fp32_quaternion_get_mean3(BGC_FP32_Quaternion* mean, const BGC_FP32_Quaternion* quaternion1, const BGC_FP32_Quaternion* quaternion2, const BGC_FP32_Quaternion* quaternion3); +extern inline void bgc_fp64_quaternion_get_mean3(BGC_FP64_Quaternion* mean, const BGC_FP64_Quaternion* quaternion1, const BGC_FP64_Quaternion* quaternion2, const BGC_FP64_Quaternion* quaternion3); -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_fp64_quaternion_interpolate(const BGC_FP64_Quaternion* vector1, const BGC_FP64_Quaternion* vector2, const double phase, BGC_FP64_Quaternion* interpolation); +extern inline void bgc_fp32_quaternion_interpolate(BGC_FP32_Quaternion* interpolation, const BGC_FP32_Quaternion* quaternion1, const BGC_FP32_Quaternion* quaternion2, const float phase); +extern inline void bgc_fp64_quaternion_interpolate(BGC_FP64_Quaternion* interpolation, const BGC_FP64_Quaternion* quaternion1, const BGC_FP64_Quaternion* quaternion2, const double phase); extern inline void bgc_fp32_quaternion_conjugate(BGC_FP32_Quaternion* quaternion); extern inline void bgc_fp64_quaternion_conjugate(BGC_FP64_Quaternion* quaternion); -extern inline void bgc_fp32_quaternion_get_conjugate(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Quaternion* conjugate); -extern inline void bgc_fp64_quaternion_get_conjugate(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Quaternion* conjugate); +extern inline void bgc_fp32_quaternion_get_conjugate(BGC_FP32_Quaternion* conjugate, const BGC_FP32_Quaternion* quaternion); +extern inline void bgc_fp64_quaternion_get_conjugate(BGC_FP64_Quaternion* conjugate, const BGC_FP64_Quaternion* quaternion); extern inline void bgc_fp32_quaternion_revert(BGC_FP32_Quaternion* quaternion); extern inline void bgc_fp64_quaternion_revert(BGC_FP64_Quaternion* quaternion); -extern inline void bgc_fp32_quaternion_get_reverse(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Quaternion* opposite); -extern inline void bgc_fp64_quaternion_get_reverse(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Quaternion* opposite); +extern inline void bgc_fp32_quaternion_get_reverse(BGC_FP32_Quaternion* reverse, const BGC_FP32_Quaternion* quaternion); +extern inline void bgc_fp64_quaternion_get_reverse(BGC_FP64_Quaternion* reverse, const BGC_FP64_Quaternion* quaternion); extern inline int bgc_fp32_quaternion_invert(BGC_FP32_Quaternion* quaternion); extern inline int bgc_fp64_quaternion_invert(BGC_FP64_Quaternion* quaternion); -extern inline int bgc_fp32_quaternion_get_inverse(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Quaternion* inverse); -extern inline int bgc_fp64_quaternion_get_inverse(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Quaternion* inverse); +extern inline int bgc_fp32_quaternion_get_inverse(BGC_FP32_Quaternion* inverse, const BGC_FP32_Quaternion* quaternion); +extern inline int bgc_fp64_quaternion_get_inverse(BGC_FP64_Quaternion* inverse, const BGC_FP64_Quaternion* quaternion); extern inline int bgc_fp32_quaternion_normalize(BGC_FP32_Quaternion* quaternion); extern inline int bgc_fp64_quaternion_normalize(BGC_FP64_Quaternion* quaternion); -extern inline int bgc_fp32_quaternion_get_normalized(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Quaternion* normalized); -extern inline int bgc_fp64_quaternion_get_normalized(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Quaternion* normalized); +extern inline int bgc_fp32_quaternion_get_normalized(BGC_FP32_Quaternion* normalized, const BGC_FP32_Quaternion* quaternion); +extern inline int bgc_fp64_quaternion_get_normalized(BGC_FP64_Quaternion* normalized, const BGC_FP64_Quaternion* quaternion); -extern inline int bgc_fp32_quaternion_get_rotation_matrix(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Matrix3x3* rotation); -extern inline int bgc_fp64_quaternion_get_rotation_matrix(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Matrix3x3* rotation); +extern inline int bgc_fp32_quaternion_get_rotation_matrix(BGC_FP32_Matrix3x3* rotation, const BGC_FP32_Quaternion* quaternion); +extern inline int bgc_fp64_quaternion_get_rotation_matrix(BGC_FP64_Matrix3x3* rotation, const BGC_FP64_Quaternion* quaternion); -extern inline int bgc_fp32_quaternion_get_reverse_matrix(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Matrix3x3* reverse); -extern inline int bgc_fp64_quaternion_get_reverse_matrix(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Matrix3x3* reverse); +extern inline int bgc_fp32_quaternion_get_reverse_matrix(BGC_FP32_Matrix3x3* reverse, const BGC_FP32_Quaternion* quaternion); +extern inline int bgc_fp64_quaternion_get_reverse_matrix(BGC_FP64_Matrix3x3* reverse, const BGC_FP64_Quaternion* quaternion); -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_fp64_quaternion_get_both_matrices(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Matrix3x3* rotation, BGC_FP64_Matrix3x3* reverse); +extern inline int bgc_fp32_quaternion_get_both_matrices(BGC_FP32_Matrix3x3* rotation, BGC_FP32_Matrix3x3* reverse, const BGC_FP32_Quaternion* quaternion); +extern inline int bgc_fp64_quaternion_get_both_matrices(BGC_FP64_Matrix3x3* rotation, BGC_FP64_Matrix3x3* reverse, const BGC_FP64_Quaternion* quaternion); extern inline int bgc_fp32_quaternion_are_close(const BGC_FP32_Quaternion* quaternion1, const BGC_FP32_Quaternion* quaternion2); extern inline int bgc_fp64_quaternion_are_close(const BGC_FP64_Quaternion* quaternion1, const BGC_FP64_Quaternion* quaternion2); // =============== Get Exponation =============== // -int bgc_fp32_quaternion_get_exponation(const BGC_FP32_Quaternion* base, const float exponent, BGC_FP32_Quaternion* power) +int bgc_fp32_quaternion_get_exponation(BGC_FP32_Quaternion* power, const BGC_FP32_Quaternion* base, const float exponent) { const float s0s0 = base->s0 * base->s0; const float x1x1 = base->x1 * base->x1; @@ -140,7 +140,7 @@ int bgc_fp32_quaternion_get_exponation(const BGC_FP32_Quaternion* base, const fl return 1; } -int bgc_fp64_quaternion_get_exponation(const BGC_FP64_Quaternion* base, const double exponent, BGC_FP64_Quaternion* power) +int bgc_fp64_quaternion_get_exponation(BGC_FP64_Quaternion* power, const BGC_FP64_Quaternion* base, const double exponent) { const double s0s0 = base->s0 * base->s0; const double x1x1 = base->x1 * base->x1; diff --git a/basic-geometry/quaternion.h b/basic-geometry/quaternion.h index 1d7fbbf..b6491d2 100644 --- a/basic-geometry/quaternion.h +++ b/basic-geometry/quaternion.h @@ -17,7 +17,7 @@ typedef struct { // ==================== Reset =================== // -inline void bgc_fp32_quaternion_reset(BGC_FP32_Quaternion * quaternion) +inline void bgc_fp32_quaternion_reset(BGC_FP32_Quaternion* quaternion) { quaternion->s0 = 0.0f; quaternion->x1 = 0.0f; @@ -25,7 +25,7 @@ inline void bgc_fp32_quaternion_reset(BGC_FP32_Quaternion * quaternion) quaternion->x3 = 0.0f; } -inline void bgc_fp64_quaternion_reset(BGC_FP64_Quaternion * quaternion) +inline void bgc_fp64_quaternion_reset(BGC_FP64_Quaternion* quaternion) { quaternion->s0 = 0.0; quaternion->x1 = 0.0; @@ -35,7 +35,7 @@ inline void bgc_fp64_quaternion_reset(BGC_FP64_Quaternion * quaternion) // ================= Make Unit ================== // -inline void bgc_fp32_quaternion_make_unit(BGC_FP32_Quaternion * quaternion) +inline void bgc_fp32_quaternion_make_unit(BGC_FP32_Quaternion* quaternion) { quaternion->s0 = 1.0f; quaternion->x1 = 0.0f; @@ -43,7 +43,7 @@ inline void bgc_fp32_quaternion_make_unit(BGC_FP32_Quaternion * quaternion) quaternion->x3 = 0.0f; } -inline void bgc_fp64_quaternion_make_unit(BGC_FP64_Quaternion * quaternion) +inline void bgc_fp64_quaternion_make_unit(BGC_FP64_Quaternion* quaternion) { quaternion->s0 = 1.0; quaternion->x1 = 0.0; @@ -53,7 +53,7 @@ inline void bgc_fp64_quaternion_make_unit(BGC_FP64_Quaternion * quaternion) // ==================== Set ===================== // -inline void bgc_fp32_quaternion_make(const float s0, const float x1, const float x2, const float x3, BGC_FP32_Quaternion * quaternion) +inline void bgc_fp32_quaternion_make(BGC_FP32_Quaternion* quaternion, const float s0, const float x1, const float x2, const float x3) { quaternion->s0 = s0; quaternion->x1 = x1; @@ -61,7 +61,7 @@ inline void bgc_fp32_quaternion_make(const float s0, const float x1, const float quaternion->x3 = x3; } -inline void bgc_fp64_quaternion_make(const double s0, const double x1, const double x2, const double x3, BGC_FP64_Quaternion * quaternion) +inline void bgc_fp64_quaternion_make(BGC_FP64_Quaternion* quaternion, const double s0, const double x1, const double x2, const double x3) { quaternion->s0 = s0; quaternion->x1 = x1; @@ -119,7 +119,7 @@ inline int bgc_fp64_quaternion_is_unit(const BGC_FP64_Quaternion* quaternion) // ==================== Copy ==================== // -inline void bgc_fp32_quaternion_copy(const BGC_FP32_Quaternion* source, BGC_FP32_Quaternion* destination) +inline void bgc_fp32_quaternion_copy(BGC_FP32_Quaternion* destination, const BGC_FP32_Quaternion* source) { destination->s0 = source->s0; destination->x1 = source->x1; @@ -127,7 +127,7 @@ inline void bgc_fp32_quaternion_copy(const BGC_FP32_Quaternion* source, BGC_FP32 destination->x3 = source->x3; } -inline void bgc_fp64_quaternion_copy(const BGC_FP64_Quaternion* source, BGC_FP64_Quaternion* destination) +inline void bgc_fp64_quaternion_copy(BGC_FP64_Quaternion* destination, const BGC_FP64_Quaternion* source) { destination->s0 = source->s0; destination->x1 = source->x1; @@ -175,15 +175,7 @@ inline void bgc_fp64_quaternion_swap(BGC_FP64_Quaternion* quarternion1, BGC_FP64 // ================== Convert =================== // -inline void bgc_fp64_quaternion_convert_to_fp32(const BGC_FP64_Quaternion* source, BGC_FP32_Quaternion* destination) -{ - destination->s0 = (float)source->s0; - destination->x1 = (float)source->x1; - destination->x2 = (float)source->x2; - destination->x3 = (float)source->x3; -} - -inline void bgc_fp32_quaternion_convert_to_fp64(const BGC_FP32_Quaternion* source, BGC_FP64_Quaternion* destination) +inline void bgc_fp32_quaternion_convert_to_fp64(BGC_FP64_Quaternion* destination, const BGC_FP32_Quaternion* source) { destination->s0 = source->s0; destination->x1 = source->x1; @@ -191,9 +183,17 @@ inline void bgc_fp32_quaternion_convert_to_fp64(const BGC_FP32_Quaternion* sourc destination->x3 = source->x3; } +inline void bgc_fp64_quaternion_convert_to_fp32(BGC_FP32_Quaternion* destination, const BGC_FP64_Quaternion* source) +{ + destination->s0 = (float)source->s0; + destination->x1 = (float)source->x1; + destination->x2 = (float)source->x2; + destination->x3 = (float)source->x3; +} + // ==================== Add ===================== // -inline void bgc_fp32_quaternion_add(const BGC_FP32_Quaternion * quaternion1, const BGC_FP32_Quaternion * quaternion2, BGC_FP32_Quaternion * sum) +inline void bgc_fp32_quaternion_add(BGC_FP32_Quaternion* sum, const BGC_FP32_Quaternion* quaternion1, const BGC_FP32_Quaternion* quaternion2) { sum->s0 = quaternion1->s0 + quaternion2->s0; sum->x1 = quaternion1->x1 + quaternion2->x1; @@ -201,7 +201,7 @@ inline void bgc_fp32_quaternion_add(const BGC_FP32_Quaternion * quaternion1, con sum->x3 = quaternion1->x3 + quaternion2->x3; } -inline void bgc_fp64_quaternion_add(const BGC_FP64_Quaternion * quaternion1, const BGC_FP64_Quaternion * quaternion2, BGC_FP64_Quaternion * sum) +inline void bgc_fp64_quaternion_add(BGC_FP64_Quaternion* sum, const BGC_FP64_Quaternion* quaternion1, const BGC_FP64_Quaternion* quaternion2) { sum->s0 = quaternion1->s0 + quaternion2->s0; sum->x1 = quaternion1->x1 + quaternion2->x1; @@ -211,7 +211,7 @@ inline void bgc_fp64_quaternion_add(const BGC_FP64_Quaternion * quaternion1, con // ================= Add Scaled ================= // -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) +inline void bgc_fp32_quaternion_add_scaled(BGC_FP32_Quaternion* sum, const BGC_FP32_Quaternion* basic_quaternion, const BGC_FP32_Quaternion* scalable_quaternion, const float scale) { sum->s0 = basic_quaternion->s0 + scalable_quaternion->s0 * scale; sum->x1 = basic_quaternion->x1 + scalable_quaternion->x1 * scale; @@ -219,7 +219,7 @@ inline void bgc_fp32_quaternion_add_scaled(const BGC_FP32_Quaternion * basic_qua sum->x3 = basic_quaternion->x3 + scalable_quaternion->x3 * scale; } -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) +inline void bgc_fp64_quaternion_add_scaled(BGC_FP64_Quaternion* sum, const BGC_FP64_Quaternion* basic_quaternion, const BGC_FP64_Quaternion* scalable_quaternion, const double scale) { sum->s0 = basic_quaternion->s0 + scalable_quaternion->s0 * scale; sum->x1 = basic_quaternion->x1 + scalable_quaternion->x1 * scale; @@ -229,7 +229,7 @@ inline void bgc_fp64_quaternion_add_scaled(const BGC_FP64_Quaternion * basic_qua // ================== Subtract ================== // -inline void bgc_fp32_quaternion_subtract(const BGC_FP32_Quaternion * minuend, const BGC_FP32_Quaternion * subtrahend, BGC_FP32_Quaternion * difference) +inline void bgc_fp32_quaternion_subtract(BGC_FP32_Quaternion* difference, const BGC_FP32_Quaternion* minuend, const BGC_FP32_Quaternion* subtrahend) { difference->s0 = minuend->s0 - subtrahend->s0; difference->x1 = minuend->x1 - subtrahend->x1; @@ -237,7 +237,7 @@ inline void bgc_fp32_quaternion_subtract(const BGC_FP32_Quaternion * minuend, co difference->x3 = minuend->x3 - subtrahend->x3; } -inline void bgc_fp64_quaternion_subtract(const BGC_FP64_Quaternion * minuend, const BGC_FP64_Quaternion * subtrahend, BGC_FP64_Quaternion * difference) +inline void bgc_fp64_quaternion_subtract(BGC_FP64_Quaternion* difference, const BGC_FP64_Quaternion* minuend, const BGC_FP64_Quaternion* subtrahend) { difference->s0 = minuend->s0 - subtrahend->s0; difference->x1 = minuend->x1 - subtrahend->x1; @@ -247,7 +247,7 @@ inline void bgc_fp64_quaternion_subtract(const BGC_FP64_Quaternion * minuend, co // ================== Multiply ================== // -inline void bgc_fp32_quaternion_get_product(const BGC_FP32_Quaternion* left, const BGC_FP32_Quaternion* right, BGC_FP32_Quaternion* product) +inline void bgc_fp32_quaternion_get_product(BGC_FP32_Quaternion* product, const BGC_FP32_Quaternion* left, const BGC_FP32_Quaternion* right) { 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); @@ -260,7 +260,7 @@ inline void bgc_fp32_quaternion_get_product(const BGC_FP32_Quaternion* left, con product->x3 = x3; } -inline void bgc_fp64_quaternion_get_product(const BGC_FP64_Quaternion* left, const BGC_FP64_Quaternion* right, BGC_FP64_Quaternion* product) +inline void bgc_fp64_quaternion_get_product(BGC_FP64_Quaternion* product, const BGC_FP64_Quaternion* left, const BGC_FP64_Quaternion* right) { 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); @@ -273,7 +273,7 @@ inline void bgc_fp64_quaternion_get_product(const BGC_FP64_Quaternion* left, con product->x3 = x3; } -inline void bgc_fp32_quaternion_multiply(const BGC_FP32_Quaternion* multiplicand, const float multipier, BGC_FP32_Quaternion* product) +inline void bgc_fp32_quaternion_multiply(BGC_FP32_Quaternion* product, const BGC_FP32_Quaternion* multiplicand, const float multipier) { product->s0 = multiplicand->s0 * multipier; product->x1 = multiplicand->x1 * multipier; @@ -281,7 +281,7 @@ inline void bgc_fp32_quaternion_multiply(const BGC_FP32_Quaternion* multiplicand product->x3 = multiplicand->x3 * multipier; } -inline void bgc_fp64_quaternion_multiply(const BGC_FP64_Quaternion* multiplicand, const double multipier, BGC_FP64_Quaternion* product) +inline void bgc_fp64_quaternion_multiply(BGC_FP64_Quaternion* product, const BGC_FP64_Quaternion* multiplicand, const double multipier) { product->s0 = multiplicand->s0 * multipier; product->x1 = multiplicand->x1 * multipier; @@ -291,7 +291,7 @@ inline void bgc_fp64_quaternion_multiply(const BGC_FP64_Quaternion* multiplicand // =================== Divide =================== // -inline int bgc_fp32_quaternion_get_ratio(const BGC_FP32_Quaternion* divident, const BGC_FP32_Quaternion* divisor, BGC_FP32_Quaternion* quotient) +inline int bgc_fp32_quaternion_get_ratio(BGC_FP32_Quaternion* quotient, const BGC_FP32_Quaternion* divident, const BGC_FP32_Quaternion* divisor) { const float square_modulus = bgc_fp32_quaternion_get_square_modulus(divisor); @@ -314,7 +314,7 @@ inline int bgc_fp32_quaternion_get_ratio(const BGC_FP32_Quaternion* divident, co return 1; } -inline int bgc_fp64_quaternion_get_ratio(const BGC_FP64_Quaternion* divident, const BGC_FP64_Quaternion* divisor, BGC_FP64_Quaternion* quotient) +inline int bgc_fp64_quaternion_get_ratio(BGC_FP64_Quaternion* quotient, const BGC_FP64_Quaternion* divident, const BGC_FP64_Quaternion* divisor) { const double square_modulus = bgc_fp64_quaternion_get_square_modulus(divisor); @@ -337,55 +337,55 @@ inline int bgc_fp64_quaternion_get_ratio(const BGC_FP64_Quaternion* divident, co return 1; } -inline void bgc_fp32_quaternion_divide(const BGC_FP32_Quaternion* dividend, const float divisor, BGC_FP32_Quaternion* quotient) +inline void bgc_fp32_quaternion_divide(BGC_FP32_Quaternion* quotient, const BGC_FP32_Quaternion* dividend, const float divisor) { - bgc_fp32_quaternion_multiply(dividend, 1.0f / divisor, quotient); + bgc_fp32_quaternion_multiply(quotient, dividend, 1.0f / divisor); } -inline void bgc_fp64_quaternion_divide(const BGC_FP64_Quaternion* dividend, const double divisor, BGC_FP64_Quaternion* quotient) +inline void bgc_fp64_quaternion_divide(BGC_FP64_Quaternion* quotient, const BGC_FP64_Quaternion* dividend, const double divisor) { - bgc_fp64_quaternion_multiply(dividend, 1.0 / divisor, quotient); + bgc_fp64_quaternion_multiply(quotient, dividend, 1.0 / divisor); } // ================ Mean of Two ================= // -inline void bgc_fp32_quaternion_get_mean2(const BGC_FP32_Quaternion* vector1, const BGC_FP32_Quaternion* vector2, BGC_FP32_Quaternion* mean) +inline void bgc_fp32_quaternion_get_mean2(BGC_FP32_Quaternion* mean, const BGC_FP32_Quaternion* quaternion1, const BGC_FP32_Quaternion* quaternion2) { - mean->s0 = (vector1->s0 + vector2->s0) * 0.5f; - mean->x1 = (vector1->x1 + vector2->x1) * 0.5f; - mean->x2 = (vector1->x2 + vector2->x2) * 0.5f; - mean->x3 = (vector1->x3 + vector2->x3) * 0.5f; + mean->s0 = (quaternion1->s0 + quaternion2->s0) * 0.5f; + mean->x1 = (quaternion1->x1 + quaternion2->x1) * 0.5f; + mean->x2 = (quaternion1->x2 + quaternion2->x2) * 0.5f; + mean->x3 = (quaternion1->x3 + quaternion2->x3) * 0.5f; } -inline void bgc_fp64_quaternion_get_mean2(const BGC_FP64_Quaternion* vector1, const BGC_FP64_Quaternion* vector2, BGC_FP64_Quaternion* mean) +inline void bgc_fp64_quaternion_get_mean2(BGC_FP64_Quaternion* mean, const BGC_FP64_Quaternion* quaternion1, const BGC_FP64_Quaternion* quaternion2) { - mean->s0 = (vector1->s0 + vector2->s0) * 0.5f; - mean->x1 = (vector1->x1 + vector2->x1) * 0.5f; - mean->x2 = (vector1->x2 + vector2->x2) * 0.5f; - mean->x3 = (vector1->x3 + vector2->x3) * 0.5f; + mean->s0 = (quaternion1->s0 + quaternion2->s0) * 0.5f; + mean->x1 = (quaternion1->x1 + quaternion2->x1) * 0.5f; + mean->x2 = (quaternion1->x2 + quaternion2->x2) * 0.5f; + mean->x3 = (quaternion1->x3 + quaternion2->x3) * 0.5f; } // =============== Mean of Three ================ // -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) +inline void bgc_fp32_quaternion_get_mean3(BGC_FP32_Quaternion* mean, const BGC_FP32_Quaternion* quaternion1, const BGC_FP32_Quaternion* quaternion2, const BGC_FP32_Quaternion* quaternion3) { - mean->s0 = (vector1->s0 + vector2->s0 + vector3->s0) * BGC_FP32_ONE_THIRD; - mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP32_ONE_THIRD; - mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP32_ONE_THIRD; - mean->x3 = (vector1->x3 + vector2->x3 + vector3->x3) * BGC_FP32_ONE_THIRD; + mean->s0 = (quaternion1->s0 + quaternion2->s0 + quaternion3->s0) * BGC_FP32_ONE_THIRD; + mean->x1 = (quaternion1->x1 + quaternion2->x1 + quaternion3->x1) * BGC_FP32_ONE_THIRD; + mean->x2 = (quaternion1->x2 + quaternion2->x2 + quaternion3->x2) * BGC_FP32_ONE_THIRD; + mean->x3 = (quaternion1->x3 + quaternion2->x3 + quaternion3->x3) * BGC_FP32_ONE_THIRD; } -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) +inline void bgc_fp64_quaternion_get_mean3(BGC_FP64_Quaternion* mean, const BGC_FP64_Quaternion* quaternion1, const BGC_FP64_Quaternion* quaternion2, const BGC_FP64_Quaternion* quaternion3) { - mean->s0 = (vector1->s0 + vector2->s0 + vector3->s0) * BGC_FP64_ONE_THIRD; - mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP64_ONE_THIRD; - mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP64_ONE_THIRD; - mean->x3 = (vector1->x3 + vector2->x3 + vector3->x3) * BGC_FP64_ONE_THIRD; + mean->s0 = (quaternion1->s0 + quaternion2->s0 + quaternion3->s0) * BGC_FP64_ONE_THIRD; + mean->x1 = (quaternion1->x1 + quaternion2->x1 + quaternion3->x1) * BGC_FP64_ONE_THIRD; + mean->x2 = (quaternion1->x2 + quaternion2->x2 + quaternion3->x2) * BGC_FP64_ONE_THIRD; + mean->x3 = (quaternion1->x3 + quaternion2->x3 + quaternion3->x3) * BGC_FP64_ONE_THIRD; } // ============ Linear Interpolation ============ // -inline void bgc_fp32_quaternion_interpolate(const BGC_FP32_Quaternion* quaternion1, const BGC_FP32_Quaternion* quaternion2, const float phase, BGC_FP32_Quaternion* interpolation) +inline void bgc_fp32_quaternion_interpolate(BGC_FP32_Quaternion* interpolation, const BGC_FP32_Quaternion* quaternion1, const BGC_FP32_Quaternion* quaternion2, const float phase) { const float counter_phase = 1.0f - phase; @@ -395,7 +395,7 @@ inline void bgc_fp32_quaternion_interpolate(const BGC_FP32_Quaternion* quaternio interpolation->x3 = quaternion1->x3 * counter_phase + quaternion2->x3 * phase; } -inline void bgc_fp64_quaternion_interpolate(const BGC_FP64_Quaternion* quaternion1, const BGC_FP64_Quaternion* quaternion2, const double phase, BGC_FP64_Quaternion* interpolation) +inline void bgc_fp64_quaternion_interpolate(BGC_FP64_Quaternion* interpolation, const BGC_FP64_Quaternion* quaternion1, const BGC_FP64_Quaternion* quaternion2, const double phase) { const double counter_phase = 1.0 - phase; @@ -421,7 +421,7 @@ inline void bgc_fp64_quaternion_conjugate(BGC_FP64_Quaternion* quaternion) quaternion->x3 = -quaternion->x3; } -inline void bgc_fp32_quaternion_get_conjugate(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Quaternion* conjugate) +inline void bgc_fp32_quaternion_get_conjugate(BGC_FP32_Quaternion* conjugate, const BGC_FP32_Quaternion* quaternion) { conjugate->s0 = quaternion->s0; conjugate->x1 = -quaternion->x1; @@ -429,7 +429,7 @@ inline void bgc_fp32_quaternion_get_conjugate(const BGC_FP32_Quaternion* quatern conjugate->x3 = -quaternion->x3; } -inline void bgc_fp64_quaternion_get_conjugate(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Quaternion* conjugate) +inline void bgc_fp64_quaternion_get_conjugate(BGC_FP64_Quaternion* conjugate, const BGC_FP64_Quaternion* quaternion) { conjugate->s0 = quaternion->s0; conjugate->x1 = -quaternion->x1; @@ -455,25 +455,25 @@ inline void bgc_fp64_quaternion_revert(BGC_FP64_Quaternion* quaternion) quaternion->x3 = -quaternion->x3; } -inline void bgc_fp32_quaternion_get_reverse(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Quaternion* opposite) +inline void bgc_fp32_quaternion_get_reverse(BGC_FP32_Quaternion* reverse, const BGC_FP32_Quaternion* quaternion) { - opposite->s0 = -quaternion->s0; - opposite->x1 = -quaternion->x1; - opposite->x2 = -quaternion->x2; - opposite->x3 = -quaternion->x3; + reverse->s0 = -quaternion->s0; + reverse->x1 = -quaternion->x1; + reverse->x2 = -quaternion->x2; + reverse->x3 = -quaternion->x3; } -inline void bgc_fp64_quaternion_get_reverse(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Quaternion* opposite) +inline void bgc_fp64_quaternion_get_reverse(BGC_FP64_Quaternion* reverse, const BGC_FP64_Quaternion* quaternion) { - opposite->s0 = -quaternion->s0; - opposite->x1 = -quaternion->x1; - opposite->x2 = -quaternion->x2; - opposite->x3 = -quaternion->x3; + reverse->s0 = -quaternion->s0; + reverse->x1 = -quaternion->x1; + reverse->x2 = -quaternion->x2; + reverse->x3 = -quaternion->x3; } // =================== Invert =================== // -inline int bgc_fp32_quaternion_get_inverse(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Quaternion* inverse) +inline int bgc_fp32_quaternion_get_inverse(BGC_FP32_Quaternion* inverse, const BGC_FP32_Quaternion* quaternion) { const float square_modulus = bgc_fp32_quaternion_get_square_modulus(quaternion); @@ -491,7 +491,7 @@ inline int bgc_fp32_quaternion_get_inverse(const BGC_FP32_Quaternion* quaternion return 1; } -inline int bgc_fp64_quaternion_get_inverse(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Quaternion* inverse) +inline int bgc_fp64_quaternion_get_inverse(BGC_FP64_Quaternion* inverse, const BGC_FP64_Quaternion* quaternion) { const double square_modulus = bgc_fp64_quaternion_get_square_modulus(quaternion); @@ -565,12 +565,12 @@ inline int bgc_fp64_quaternion_normalize(BGC_FP64_Quaternion* quaternion) return 1; } -inline int bgc_fp32_quaternion_get_normalized(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Quaternion* normalized) +inline int bgc_fp32_quaternion_get_normalized(BGC_FP32_Quaternion* normalized, const BGC_FP32_Quaternion* quaternion) { const float square_modulus = bgc_fp32_quaternion_get_square_modulus(quaternion); if (bgc_fp32_is_square_unit(square_modulus)) { - bgc_fp32_quaternion_copy(quaternion, normalized); + bgc_fp32_quaternion_copy(normalized, quaternion); return 1; } @@ -579,16 +579,16 @@ inline int bgc_fp32_quaternion_get_normalized(const BGC_FP32_Quaternion* quatern return 0; } - bgc_fp32_quaternion_multiply(quaternion, sqrtf(1.0f / square_modulus), normalized); + bgc_fp32_quaternion_multiply(normalized, quaternion, sqrtf(1.0f / square_modulus)); return 1; } -inline int bgc_fp64_quaternion_get_normalized(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Quaternion* normalized) +inline int bgc_fp64_quaternion_get_normalized(BGC_FP64_Quaternion* normalized, const BGC_FP64_Quaternion* quaternion) { const double square_modulus = bgc_fp64_quaternion_get_square_modulus(quaternion); if (bgc_fp64_is_square_unit(square_modulus)) { - bgc_fp64_quaternion_copy(quaternion, normalized); + bgc_fp64_quaternion_copy(normalized, quaternion); return 1; } @@ -597,19 +597,19 @@ inline int bgc_fp64_quaternion_get_normalized(const BGC_FP64_Quaternion* quatern return 0; } - bgc_fp64_quaternion_multiply(quaternion, sqrt(1.0 / square_modulus), normalized); + bgc_fp64_quaternion_multiply(normalized, quaternion, sqrt(1.0 / square_modulus)); return 1; } // =============== Get Exponation =============== // -int bgc_fp32_quaternion_get_exponation(const BGC_FP32_Quaternion* base, const float exponent, BGC_FP32_Quaternion* power); +int bgc_fp32_quaternion_get_exponation(BGC_FP32_Quaternion* power, const BGC_FP32_Quaternion* base, const float exponent); -int bgc_fp64_quaternion_get_exponation(const BGC_FP64_Quaternion* base, const double exponent, BGC_FP64_Quaternion* power); +int bgc_fp64_quaternion_get_exponation(BGC_FP64_Quaternion* power, const BGC_FP64_Quaternion* base, const double exponent); // ============ Get Rotation Matrix ============= // -inline int bgc_fp32_quaternion_get_rotation_matrix(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Matrix3x3* rotation) +inline int bgc_fp32_quaternion_get_rotation_matrix(BGC_FP32_Matrix3x3* rotation, const BGC_FP32_Quaternion* quaternion) { const float s0s0 = quaternion->s0 * quaternion->s0; const float x1x1 = quaternion->x1 * quaternion->x1; @@ -650,7 +650,7 @@ inline int bgc_fp32_quaternion_get_rotation_matrix(const BGC_FP32_Quaternion* qu return 1; } -inline int bgc_fp64_quaternion_get_rotation_matrix(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Matrix3x3* rotation) +inline int bgc_fp64_quaternion_get_rotation_matrix(BGC_FP64_Matrix3x3* rotation, const BGC_FP64_Quaternion* quaternion) { const double s0s0 = quaternion->s0 * quaternion->s0; const double x1x1 = quaternion->x1 * quaternion->x1; @@ -693,7 +693,7 @@ inline int bgc_fp64_quaternion_get_rotation_matrix(const BGC_FP64_Quaternion* qu // ============= Get Reverse Matrix ============= // -inline int bgc_fp32_quaternion_get_reverse_matrix(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Matrix3x3* reverse) +inline int bgc_fp32_quaternion_get_reverse_matrix(BGC_FP32_Matrix3x3* reverse, const BGC_FP32_Quaternion* quaternion) { const float s0s0 = quaternion->s0 * quaternion->s0; const float x1x1 = quaternion->x1 * quaternion->x1; @@ -734,7 +734,7 @@ inline int bgc_fp32_quaternion_get_reverse_matrix(const BGC_FP32_Quaternion* qua return 1; } -inline int bgc_fp64_quaternion_get_reverse_matrix(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Matrix3x3* reverse) +inline int bgc_fp64_quaternion_get_reverse_matrix(BGC_FP64_Matrix3x3* reverse, const BGC_FP64_Quaternion* quaternion) { const double s0s0 = quaternion->s0 * quaternion->s0; const double x1x1 = quaternion->x1 * quaternion->x1; @@ -777,20 +777,20 @@ inline int bgc_fp64_quaternion_get_reverse_matrix(const BGC_FP64_Quaternion* qua // ============= Get Both Matrixes ============== // -inline int bgc_fp32_quaternion_get_both_matrices(const BGC_FP32_Quaternion* quaternion, BGC_FP32_Matrix3x3* rotation, BGC_FP32_Matrix3x3* reverse) +inline int bgc_fp32_quaternion_get_both_matrices(BGC_FP32_Matrix3x3* rotation, BGC_FP32_Matrix3x3* reverse, const BGC_FP32_Quaternion* quaternion) { - if (bgc_fp32_quaternion_get_reverse_matrix(quaternion, reverse)) { - bgc_fp32_matrix3x3_get_transposed(reverse, rotation); + if (bgc_fp32_quaternion_get_reverse_matrix(reverse, quaternion)) { + bgc_fp32_matrix3x3_get_transposed(rotation, reverse); return 1; } return 0; } -inline int bgc_fp64_quaternion_get_both_matrices(const BGC_FP64_Quaternion* quaternion, BGC_FP64_Matrix3x3* rotation, BGC_FP64_Matrix3x3* reverse) +inline int bgc_fp64_quaternion_get_both_matrices(BGC_FP64_Matrix3x3* rotation, BGC_FP64_Matrix3x3* reverse, const BGC_FP64_Quaternion* quaternion) { - if (bgc_fp64_quaternion_get_reverse_matrix(quaternion, reverse)) { - bgc_fp64_matrix3x3_get_transposed(reverse, rotation); + if (bgc_fp64_quaternion_get_reverse_matrix(reverse, quaternion)) { + bgc_fp64_matrix3x3_get_transposed(rotation, reverse); return 1; } diff --git a/basic-geometry/rotation3.h b/basic-geometry/rotation3.h index afaf09c..c1f39ac 100644 --- a/basic-geometry/rotation3.h +++ b/basic-geometry/rotation3.h @@ -72,7 +72,7 @@ inline void bgc_fp64_rotation3_make(const double x1, const double x2, const doub 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_fp32_vector3_get_normalized(axis, &rotation->axis)) { + if (bgc_fp32_vector3_get_normalized(&rotation->axis, axis)) { rotation->radians = bgc_fp32_angle_to_radians(angle, unit); } else { @@ -82,7 +82,7 @@ inline void bgc_fp32_rotation3_make_for_axis(const BGC_FP32_Vector3* axis, const 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_fp64_vector3_get_normalized(axis, &rotation->axis)) { + if (bgc_fp64_vector3_get_normalized(&rotation->axis, axis)) { rotation->radians = bgc_fp64_angle_to_radians(angle, unit); } else { diff --git a/basic-geometry/slerp.c b/basic-geometry/slerp.c index 5028b03..55274e9 100644 --- a/basic-geometry/slerp.c +++ b/basic-geometry/slerp.c @@ -3,16 +3,16 @@ extern inline void bgc_fp32_slerp_reset(BGC_FP32_Slerp* slerp); extern inline void bgc_fp64_slerp_reset(BGC_FP64_Slerp* 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_fp64_slerp_make_full(const BGC_FP64_Versor* start, const BGC_FP64_Versor* end, BGC_FP64_Slerp* slerp); +extern inline void bgc_fp32_slerp_make_full(BGC_FP32_Slerp* slerp, const BGC_FP32_Versor* start, const BGC_FP32_Versor* end); +extern inline void bgc_fp64_slerp_make_full(BGC_FP64_Slerp* slerp, const BGC_FP64_Versor* start, const BGC_FP64_Versor* end); -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_fp64_slerp_make_shortened(const BGC_FP64_Versor* start, const BGC_FP64_Versor* end, BGC_FP64_Slerp* slerp); +extern inline void bgc_fp32_slerp_make_shortened(BGC_FP32_Slerp* slerp, const BGC_FP32_Versor* start, const BGC_FP32_Versor* end); +extern inline void bgc_fp64_slerp_make_shortened(BGC_FP64_Slerp* slerp, const BGC_FP64_Versor* start, const BGC_FP64_Versor* end); -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_fp64_slerp_get_phase_versor(const BGC_FP64_Slerp* slerp, const double phase, BGC_FP64_Versor* result); +extern inline void bgc_fp32_slerp_get_phase_versor(BGC_FP32_Versor* versor, const BGC_FP32_Slerp* slerp, const float phase); +extern inline void bgc_fp64_slerp_get_phase_versor(BGC_FP64_Versor* versor, const BGC_FP64_Slerp* slerp, const double phase); -void bgc_fp32_slerp_make(const BGC_FP32_Versor* start, const BGC_FP32_Versor* augment, BGC_FP32_Slerp* slerp) +void bgc_fp32_slerp_make(BGC_FP32_Slerp* slerp, const BGC_FP32_Versor* start, const BGC_FP32_Versor* augment) { const float square_vector = augment->_x1 * augment->_x1 + augment->_x2 * augment->_x2 + augment->_x3 * augment->_x3; @@ -53,7 +53,7 @@ void bgc_fp32_slerp_make(const BGC_FP32_Versor* start, const BGC_FP32_Versor* au slerp->x3_sin_weight = multiplier * (augment->_x3 * start->_s0 - augment->_x2 * start->_x1 + augment->_x1 * start->_x2); } -void bgc_fp64_slerp_make(const BGC_FP64_Versor* start, const BGC_FP64_Versor* augment, BGC_FP64_Slerp* slerp) +void bgc_fp64_slerp_make(BGC_FP64_Slerp* slerp, const BGC_FP64_Versor* start, const BGC_FP64_Versor* augment) { const double square_vector = augment->_x1 * augment->_x1 + augment->_x2 * augment->_x2 + augment->_x3 * augment->_x3; diff --git a/basic-geometry/slerp.h b/basic-geometry/slerp.h index 5f533d3..0fccc95 100644 --- a/basic-geometry/slerp.h +++ b/basic-geometry/slerp.h @@ -53,75 +53,74 @@ inline void bgc_fp64_slerp_reset(BGC_FP64_Slerp* slerp) slerp->radians = 0.0; } -void bgc_fp32_slerp_make(const BGC_FP32_Versor* start, const BGC_FP32_Versor* augment, BGC_FP32_Slerp* slerp); +void bgc_fp32_slerp_make(BGC_FP32_Slerp* slerp, const BGC_FP32_Versor* start, const BGC_FP32_Versor* augment); +void bgc_fp64_slerp_make(BGC_FP64_Slerp* slerp, const BGC_FP64_Versor* start, const BGC_FP64_Versor* augment); -void bgc_fp64_slerp_make(const BGC_FP64_Versor* start, const BGC_FP64_Versor* augment, BGC_FP64_Slerp* slerp); - -inline void bgc_fp32_slerp_make_full(const BGC_FP32_Versor* start, const BGC_FP32_Versor* end, BGC_FP32_Slerp* slerp) +inline void bgc_fp32_slerp_make_full(BGC_FP32_Slerp* slerp, const BGC_FP32_Versor* start, const BGC_FP32_Versor* end) { BGC_FP32_Versor augment; - bgc_fp32_versor_exclude(end, start, &augment); + bgc_fp32_versor_exclude(&augment, end, start); - bgc_fp32_slerp_make(start, &augment, slerp); + bgc_fp32_slerp_make(slerp, start, &augment); } -inline void bgc_fp64_slerp_make_full(const BGC_FP64_Versor* start, const BGC_FP64_Versor* end, BGC_FP64_Slerp* slerp) +inline void bgc_fp64_slerp_make_full(BGC_FP64_Slerp* slerp, const BGC_FP64_Versor* start, const BGC_FP64_Versor* end) { BGC_FP64_Versor augment; - bgc_fp64_versor_exclude(end, start, &augment); + bgc_fp64_versor_exclude(&augment, end, start); - bgc_fp64_slerp_make(start, &augment, slerp); + bgc_fp64_slerp_make(slerp, start, &augment); } -inline void bgc_fp32_slerp_make_shortened(const BGC_FP32_Versor* start, const BGC_FP32_Versor* end, BGC_FP32_Slerp* slerp) +inline void bgc_fp32_slerp_make_shortened(BGC_FP32_Slerp* slerp, const BGC_FP32_Versor* start, const BGC_FP32_Versor* end) { BGC_FP32_Versor augment; - bgc_fp32_versor_exclude(end, start, &augment); + bgc_fp32_versor_exclude(&augment, end, start); bgc_fp32_versor_shorten(&augment); - bgc_fp32_slerp_make(start, &augment, slerp); + bgc_fp32_slerp_make(slerp, start, &augment); } -inline void bgc_fp64_slerp_make_shortened(const BGC_FP64_Versor* start, const BGC_FP64_Versor* end, BGC_FP64_Slerp* slerp) +inline void bgc_fp64_slerp_make_shortened(BGC_FP64_Slerp* slerp, const BGC_FP64_Versor* start, const BGC_FP64_Versor* end) { BGC_FP64_Versor augment; - bgc_fp64_versor_exclude(end, start, &augment); + bgc_fp64_versor_exclude(&augment, end, start); bgc_fp64_versor_shorten(&augment); - bgc_fp64_slerp_make(start, &augment, slerp); + bgc_fp64_slerp_make(slerp, start, &augment); } -inline void bgc_fp32_slerp_get_phase_versor(const BGC_FP32_Slerp* slerp, const float phase, BGC_FP32_Versor* result) +inline void bgc_fp32_slerp_get_phase_versor(BGC_FP32_Versor* versor, const BGC_FP32_Slerp* slerp, const float phase) { const float angle = slerp->radians * phase; const float cosine = cosf(angle); const float sine = sinf(angle); bgc_fp32_versor_make( + versor, slerp->s0_cos_weight * cosine + slerp->s0_sin_weight * sine, slerp->x1_cos_weight * cosine + slerp->x1_sin_weight * sine, slerp->x2_cos_weight * cosine + slerp->x2_sin_weight * sine, - slerp->x3_cos_weight * cosine + slerp->x3_sin_weight * sine, - result + slerp->x3_cos_weight * cosine + slerp->x3_sin_weight * sine ); } -inline void bgc_fp64_slerp_get_phase_versor(const BGC_FP64_Slerp* slerp, const double phase, BGC_FP64_Versor* result) +inline void bgc_fp64_slerp_get_phase_versor(BGC_FP64_Versor* versor, const BGC_FP64_Slerp* slerp, const double phase) { const double angle = slerp->radians * phase; const double cosine = cos(angle); const double sine = sin(angle); bgc_fp64_versor_make( + versor, slerp->s0_cos_weight * cosine + slerp->s0_sin_weight * sine, slerp->x1_cos_weight * cosine + slerp->x1_sin_weight * sine, slerp->x2_cos_weight * cosine + slerp->x2_sin_weight * sine, - slerp->x3_cos_weight * cosine + slerp->x3_sin_weight * sine, - result + slerp->x3_cos_weight * cosine + slerp->x3_sin_weight * sine ); } diff --git a/basic-geometry/vector2.c b/basic-geometry/vector2.c index 0df5f1c..06d18e3 100644 --- a/basic-geometry/vector2.c +++ b/basic-geometry/vector2.c @@ -3,8 +3,8 @@ extern inline void bgc_fp32_vector2_reset(BGC_FP32_Vector2* vector); extern inline void bgc_fp64_vector2_reset(BGC_FP64_Vector2* vector); -extern inline void bgc_fp32_vector2_make(const float x1, const float x2, BGC_FP32_Vector2* destination); -extern inline void bgc_fp64_vector2_make(const double x1, const double x2, BGC_FP64_Vector2* destination); +extern inline void bgc_fp32_vector2_make(BGC_FP32_Vector2* destination, const float x1, const float x2); +extern inline void bgc_fp64_vector2_make(BGC_FP64_Vector2* destination, const double x1, const double x2); extern inline float bgc_fp32_vector2_get_square_modulus(const BGC_FP32_Vector2* vector); extern inline double bgc_fp64_vector2_get_square_modulus(const BGC_FP64_Vector2* vector); @@ -18,50 +18,50 @@ extern inline int bgc_fp64_vector2_is_zero(const BGC_FP64_Vector2* vector); extern inline int bgc_fp32_vector2_is_unit(const BGC_FP32_Vector2* vector); extern inline int bgc_fp64_vector2_is_unit(const BGC_FP64_Vector2* vector); -extern inline void bgc_fp32_vector2_copy(const BGC_FP32_Vector2* source, BGC_FP32_Vector2* destination); -extern inline void bgc_fp64_vector2_copy(const BGC_FP64_Vector2* source, BGC_FP64_Vector2* destination); +extern inline void bgc_fp32_vector2_copy(BGC_FP32_Vector2* destination, const BGC_FP32_Vector2* source); +extern inline void bgc_fp64_vector2_copy(BGC_FP64_Vector2* destination, const BGC_FP64_Vector2* source); extern inline void bgc_fp32_vector2_swap(BGC_FP32_Vector2* vector1, BGC_FP32_Vector2* vector2); extern inline void bgc_fp64_vector2_swap(BGC_FP64_Vector2* vector1, BGC_FP64_Vector2* vector2); -extern inline void bgc_fp64_vector2_convert_to_fp32(const BGC_FP64_Vector2* source, BGC_FP32_Vector2* destination); -extern inline void bgc_fp32_vector2_convert_to_fp64(const BGC_FP32_Vector2* source, BGC_FP64_Vector2* destination); +extern inline void bgc_fp32_vector2_convert_to_fp64(BGC_FP64_Vector2* destination, const BGC_FP32_Vector2* source); +extern inline void bgc_fp64_vector2_convert_to_fp32(BGC_FP32_Vector2* destination, const BGC_FP64_Vector2* source); -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_fp64_vector2_add(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2, BGC_FP64_Vector2* sum); +extern inline void bgc_fp32_vector2_add(BGC_FP32_Vector2* sum, const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2); +extern inline void bgc_fp64_vector2_add(BGC_FP64_Vector2* sum, const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2); -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_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_fp32_vector2_add_scaled(BGC_FP32_Vector2* sum, const BGC_FP32_Vector2* basic_vector, const BGC_FP32_Vector2* scalable_vector, const float scale); +extern inline void bgc_fp64_vector2_add_scaled(BGC_FP64_Vector2* sum, const BGC_FP64_Vector2* basic_vector, const BGC_FP64_Vector2* scalable_vector, const double scale); -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_fp64_vector2_subtract(const BGC_FP64_Vector2* minuend, const BGC_FP64_Vector2* subtrahend, BGC_FP64_Vector2* difference); +extern inline void bgc_fp32_vector2_subtract(BGC_FP32_Vector2* difference, const BGC_FP32_Vector2* minuend, const BGC_FP32_Vector2* subtrahend); +extern inline void bgc_fp64_vector2_subtract(BGC_FP64_Vector2* difference, const BGC_FP64_Vector2* minuend, const BGC_FP64_Vector2* subtrahend); -extern inline void bgc_fp32_vector2_multiply(const BGC_FP32_Vector2* multiplicand, const float multiplier, BGC_FP32_Vector2* product); -extern inline void bgc_fp64_vector2_multiply(const BGC_FP64_Vector2* multiplicand, const double multiplier, BGC_FP64_Vector2* product); +extern inline void bgc_fp32_vector2_multiply(BGC_FP32_Vector2* product, const BGC_FP32_Vector2* multiplicand, const float multiplier); +extern inline void bgc_fp64_vector2_multiply(BGC_FP64_Vector2* product, const BGC_FP64_Vector2* multiplicand, const double multiplier); -extern inline void bgc_fp32_vector2_divide(const BGC_FP32_Vector2* dividend, const float divisor, BGC_FP32_Vector2* quotient); -extern inline void bgc_fp64_vector2_divide(const BGC_FP64_Vector2* dividend, const double divisor, BGC_FP64_Vector2* quotient); +extern inline void bgc_fp32_vector2_divide(BGC_FP32_Vector2* quotient, const BGC_FP32_Vector2* dividend, const float divisor); +extern inline void bgc_fp64_vector2_divide(BGC_FP64_Vector2* quotient, const BGC_FP64_Vector2* dividend, const double divisor); -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_fp64_vector2_get_middle2(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2, BGC_FP64_Vector2* middle); +extern inline void bgc_fp32_vector2_get_mean2(BGC_FP32_Vector2* mean, const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2); +extern inline void bgc_fp64_vector2_get_mean2(BGC_FP64_Vector2* mean, const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2); -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_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_fp32_vector2_get_mean3(BGC_FP32_Vector2* mean, const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2, const BGC_FP32_Vector2* vector3); +extern inline void bgc_fp64_vector2_get_mean3(BGC_FP64_Vector2* mean, const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2, const BGC_FP64_Vector2* vector3); -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_fp64_vector2_interpolate(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2, const double phase, BGC_FP64_Vector2* interpolation); +extern inline void bgc_fp32_vector2_interpolate(BGC_FP32_Vector2* interpolation, const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2, const float phase); +extern inline void bgc_fp64_vector2_interpolate(BGC_FP64_Vector2* interpolation, const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2, const double phase); extern inline void bgc_fp32_vector2_revert(BGC_FP32_Vector2* vector); extern inline void bgc_fp64_vector2_revert(BGC_FP64_Vector2* vector); -extern inline void bgc_fp32_vector2_get_reverse(const BGC_FP32_Vector2* vector, BGC_FP32_Vector2* reverse); -extern inline void bgc_fp64_vector2_get_reverse(const BGC_FP64_Vector2* vector, BGC_FP64_Vector2* reverse); +extern inline void bgc_fp32_vector2_get_reverse(BGC_FP32_Vector2* reverse, const BGC_FP32_Vector2* vector); +extern inline void bgc_fp64_vector2_get_reverse(BGC_FP64_Vector2* reverse, const BGC_FP64_Vector2* vector); extern inline int bgc_fp32_vector2_normalize(BGC_FP32_Vector2* vector); extern inline int bgc_fp64_vector2_normalize(BGC_FP64_Vector2* vector); -extern inline int bgc_fp32_vector2_get_normalized(const BGC_FP32_Vector2* vector, BGC_FP32_Vector2* normalized); -extern inline int bgc_fp64_vector2_get_normalized(const BGC_FP64_Vector2* vector, BGC_FP64_Vector2* normalized); +extern inline int bgc_fp32_vector2_get_normalized(BGC_FP32_Vector2* normalized, const BGC_FP32_Vector2* vector); +extern inline int bgc_fp64_vector2_get_normalized(BGC_FP64_Vector2* normalized, const BGC_FP64_Vector2* vector); extern inline float bgc_fp32_vector2_get_dot_product(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2); extern inline double bgc_fp64_vector2_get_dot_product(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2); diff --git a/basic-geometry/vector2.h b/basic-geometry/vector2.h index 9b42ebc..9f12d25 100644 --- a/basic-geometry/vector2.h +++ b/basic-geometry/vector2.h @@ -32,13 +32,13 @@ inline void bgc_fp64_vector2_reset(BGC_FP64_Vector2* vector) // ==================== Set ===================== // -inline void bgc_fp32_vector2_make(const float x1, const float x2, BGC_FP32_Vector2* destination) +inline void bgc_fp32_vector2_make(BGC_FP32_Vector2* destination, const float x1, const float x2) { destination->x1 = x1; destination->x2 = x2; } -inline void bgc_fp64_vector2_make(const double x1, const double x2, BGC_FP64_Vector2* destination) +inline void bgc_fp64_vector2_make(BGC_FP64_Vector2* destination, const double x1, const double x2) { destination->x1 = x1; destination->x2 = x2; @@ -90,13 +90,13 @@ inline int bgc_fp64_vector2_is_unit(const BGC_FP64_Vector2* vector) // ==================== Copy ==================== // -inline void bgc_fp32_vector2_copy(const BGC_FP32_Vector2* source, BGC_FP32_Vector2* destination) +inline void bgc_fp32_vector2_copy(BGC_FP32_Vector2* destination, const BGC_FP32_Vector2* source) { destination->x1 = source->x1; destination->x2 = source->x2; } -inline void bgc_fp64_vector2_copy(const BGC_FP64_Vector2* source, BGC_FP64_Vector2* destination) +inline void bgc_fp64_vector2_copy(BGC_FP64_Vector2* destination, const BGC_FP64_Vector2* source) { destination->x1 = source->x1; destination->x2 = source->x2; @@ -130,27 +130,27 @@ inline void bgc_fp64_vector2_swap(BGC_FP64_Vector2* vector1, BGC_FP64_Vector2* v // ================== Convert =================== // -inline void bgc_fp64_vector2_convert_to_fp32(const BGC_FP64_Vector2* source, BGC_FP32_Vector2* destination) -{ - destination->x1 = (float)source->x1; - destination->x2 = (float)source->x2; -} - -inline void bgc_fp32_vector2_convert_to_fp64(const BGC_FP32_Vector2* source, BGC_FP64_Vector2* destination) +inline void bgc_fp32_vector2_convert_to_fp64(BGC_FP64_Vector2* destination, const BGC_FP32_Vector2* source) { destination->x1 = source->x1; destination->x2 = source->x2; } +inline void bgc_fp64_vector2_convert_to_fp32(BGC_FP32_Vector2* destination, const BGC_FP64_Vector2* source) +{ + destination->x1 = (float)source->x1; + destination->x2 = (float)source->x2; +} + // ==================== Add ===================== // -inline void bgc_fp32_vector2_add(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2, BGC_FP32_Vector2* sum) +inline void bgc_fp32_vector2_add(BGC_FP32_Vector2* sum, const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2) { sum->x1 = vector1->x1 + vector2->x1; sum->x2 = vector1->x2 + vector2->x2; } -inline void bgc_fp64_vector2_add(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2, BGC_FP64_Vector2* sum) +inline void bgc_fp64_vector2_add(BGC_FP64_Vector2* sum, const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2) { sum->x1 = vector1->x1 + vector2->x1; sum->x2 = vector1->x2 + vector2->x2; @@ -158,13 +158,13 @@ inline void bgc_fp64_vector2_add(const BGC_FP64_Vector2* vector1, const BGC_FP64 // ================= Add scaled ================= // -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) +inline void bgc_fp32_vector2_add_scaled(BGC_FP32_Vector2* sum, const BGC_FP32_Vector2* basic_vector, const BGC_FP32_Vector2* scalable_vector, const float scale) { sum->x1 = basic_vector->x1 + scalable_vector->x1 * scale; sum->x2 = basic_vector->x2 + scalable_vector->x2 * scale; } -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) +inline void bgc_fp64_vector2_add_scaled(BGC_FP64_Vector2* sum, const BGC_FP64_Vector2* basic_vector, const BGC_FP64_Vector2* scalable_vector, const double scale) { sum->x1 = basic_vector->x1 + scalable_vector->x1 * scale; sum->x2 = basic_vector->x2 + scalable_vector->x2 * scale; @@ -172,13 +172,13 @@ inline void bgc_fp64_vector2_add_scaled(const BGC_FP64_Vector2* basic_vector, co // ================== Subtract ================== // -inline void bgc_fp32_vector2_subtract(const BGC_FP32_Vector2* minuend, const BGC_FP32_Vector2* subtrahend, BGC_FP32_Vector2* difference) +inline void bgc_fp32_vector2_subtract(BGC_FP32_Vector2* difference, const BGC_FP32_Vector2* minuend, const BGC_FP32_Vector2* subtrahend) { difference->x1 = minuend->x1 - subtrahend->x1; difference->x2 = minuend->x2 - subtrahend->x2; } -inline void bgc_fp64_vector2_subtract(const BGC_FP64_Vector2* minuend, const BGC_FP64_Vector2* subtrahend, BGC_FP64_Vector2* difference) +inline void bgc_fp64_vector2_subtract(BGC_FP64_Vector2* difference, const BGC_FP64_Vector2* minuend, const BGC_FP64_Vector2* subtrahend) { difference->x1 = minuend->x1 - subtrahend->x1; difference->x2 = minuend->x2 - subtrahend->x2; @@ -186,13 +186,13 @@ inline void bgc_fp64_vector2_subtract(const BGC_FP64_Vector2* minuend, const BGC // ================== Multiply ================== // -inline void bgc_fp32_vector2_multiply(const BGC_FP32_Vector2* multiplicand, const float multiplier, BGC_FP32_Vector2* product) +inline void bgc_fp32_vector2_multiply(BGC_FP32_Vector2* product, const BGC_FP32_Vector2* multiplicand, const float multiplier) { product->x1 = multiplicand->x1 * multiplier; product->x2 = multiplicand->x2 * multiplier; } -inline void bgc_fp64_vector2_multiply(const BGC_FP64_Vector2* multiplicand, const double multiplier, BGC_FP64_Vector2* product) +inline void bgc_fp64_vector2_multiply(BGC_FP64_Vector2* product, const BGC_FP64_Vector2* multiplicand, const double multiplier) { product->x1 = multiplicand->x1 * multiplier; product->x2 = multiplicand->x2 * multiplier; @@ -200,47 +200,47 @@ inline void bgc_fp64_vector2_multiply(const BGC_FP64_Vector2* multiplicand, cons // =================== Divide =================== // -inline void bgc_fp32_vector2_divide(const BGC_FP32_Vector2* dividend, const float divisor, BGC_FP32_Vector2* quotient) +inline void bgc_fp32_vector2_divide(BGC_FP32_Vector2* quotient, const BGC_FP32_Vector2* dividend, const float divisor) { - bgc_fp32_vector2_multiply(dividend, 1.0f / divisor, quotient); + bgc_fp32_vector2_multiply(quotient, dividend, 1.0f / divisor); } -inline void bgc_fp64_vector2_divide(const BGC_FP64_Vector2* dividend, const double divisor, BGC_FP64_Vector2* quotient) +inline void bgc_fp64_vector2_divide(BGC_FP64_Vector2* quotient, const BGC_FP64_Vector2* dividend, const double divisor) { - bgc_fp64_vector2_multiply(dividend, 1.0 / divisor, quotient); + bgc_fp64_vector2_multiply(quotient, dividend, 1.0 / divisor); } // ================ Mean of Two ================= // -inline void bgc_fp32_vector2_get_middle2(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2, BGC_FP32_Vector2* middle) +inline void bgc_fp32_vector2_get_mean2(BGC_FP32_Vector2* mean, const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2) { - middle->x1 = (vector1->x1 + vector2->x1) * 0.5f; - middle->x2 = (vector1->x2 + vector2->x2) * 0.5f; + mean->x1 = (vector1->x1 + vector2->x1) * 0.5f; + mean->x2 = (vector1->x2 + vector2->x2) * 0.5f; } -inline void bgc_fp64_vector2_get_middle2(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2, BGC_FP64_Vector2* middle) +inline void bgc_fp64_vector2_get_mean2(BGC_FP64_Vector2* mean, const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2) { - middle->x1 = (vector1->x1 + vector2->x1) * 0.5; - middle->x2 = (vector1->x2 + vector2->x2) * 0.5; + mean->x1 = (vector1->x1 + vector2->x1) * 0.5; + mean->x2 = (vector1->x2 + vector2->x2) * 0.5; } // =============== Mean of Three ================ // -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) +inline void bgc_fp32_vector2_get_mean3(BGC_FP32_Vector2* mean, const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2, const BGC_FP32_Vector2* vector3) { - middle->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP32_ONE_THIRD; - middle->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP32_ONE_THIRD; + mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP32_ONE_THIRD; + mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP32_ONE_THIRD; } -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) +inline void bgc_fp64_vector2_get_mean3(BGC_FP64_Vector2* mean, const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2, const BGC_FP64_Vector2* vector3) { - middle->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP64_ONE_THIRD; - middle->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP64_ONE_THIRD; + mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP64_ONE_THIRD; + mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP64_ONE_THIRD; } // =================== Linear =================== // -inline void bgc_fp32_vector2_interpolate(const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2, const float phase, BGC_FP32_Vector2* interpolation) +inline void bgc_fp32_vector2_interpolate(BGC_FP32_Vector2* interpolation, const BGC_FP32_Vector2* vector1, const BGC_FP32_Vector2* vector2, const float phase) { const float counter_phase = 1.0f - phase; @@ -248,7 +248,7 @@ inline void bgc_fp32_vector2_interpolate(const BGC_FP32_Vector2* vector1, const interpolation->x2 = vector1->x2 * counter_phase + vector2->x2 * phase; } -inline void bgc_fp64_vector2_interpolate(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2, const double phase, BGC_FP64_Vector2* interpolation) +inline void bgc_fp64_vector2_interpolate(BGC_FP64_Vector2* interpolation, const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2, const double phase) { const double counter_phase = 1.0 - phase; @@ -270,13 +270,13 @@ inline void bgc_fp64_vector2_revert(BGC_FP64_Vector2* vector) vector->x2 = -vector->x2; } -inline void bgc_fp32_vector2_get_reverse(const BGC_FP32_Vector2* vector, BGC_FP32_Vector2* reverse) +inline void bgc_fp32_vector2_get_reverse(BGC_FP32_Vector2* reverse, const BGC_FP32_Vector2* vector) { reverse->x1 = -vector->x1; reverse->x2 = -vector->x2; } -inline void bgc_fp64_vector2_get_reverse(const BGC_FP64_Vector2* vector, BGC_FP64_Vector2* reverse) +inline void bgc_fp64_vector2_get_reverse(BGC_FP64_Vector2* reverse, const BGC_FP64_Vector2* vector) { reverse->x1 = -vector->x1; reverse->x2 = -vector->x2; @@ -324,12 +324,12 @@ inline int bgc_fp64_vector2_normalize(BGC_FP64_Vector2* vector) return 1; } -inline int bgc_fp32_vector2_get_normalized(const BGC_FP32_Vector2* vector, BGC_FP32_Vector2* normalized) +inline int bgc_fp32_vector2_get_normalized(BGC_FP32_Vector2* normalized, const BGC_FP32_Vector2* vector) { const float square_modulus = bgc_fp32_vector2_get_square_modulus(vector); if (bgc_fp32_is_square_unit(square_modulus)) { - bgc_fp32_vector2_copy(vector, normalized); + bgc_fp32_vector2_copy(normalized, vector); return 1; } @@ -338,16 +338,16 @@ inline int bgc_fp32_vector2_get_normalized(const BGC_FP32_Vector2* vector, BGC_F return 0; } - bgc_fp32_vector2_multiply(vector, sqrtf(1.0f / square_modulus), normalized); + bgc_fp32_vector2_multiply(normalized, vector, sqrtf(1.0f / square_modulus)); return 1; } -inline int bgc_fp64_vector2_get_normalized(const BGC_FP64_Vector2* vector, BGC_FP64_Vector2* normalized) +inline int bgc_fp64_vector2_get_normalized(BGC_FP64_Vector2* normalized, const BGC_FP64_Vector2* vector) { const double square_modulus = bgc_fp64_vector2_get_square_modulus(vector); if (bgc_fp64_is_square_unit(square_modulus)) { - bgc_fp64_vector2_copy(vector, normalized); + bgc_fp64_vector2_copy(normalized, vector); return 1; } @@ -356,7 +356,7 @@ inline int bgc_fp64_vector2_get_normalized(const BGC_FP64_Vector2* vector, BGC_F return 0; } - bgc_fp64_vector2_multiply(vector, sqrt(1.0 / square_modulus), normalized); + bgc_fp64_vector2_multiply(normalized, vector, sqrt(1.0 / square_modulus)); return 1; } diff --git a/basic-geometry/vector3.c b/basic-geometry/vector3.c index 9b6e4dd..2740d11 100644 --- a/basic-geometry/vector3.c +++ b/basic-geometry/vector3.c @@ -3,8 +3,8 @@ extern inline void bgc_fp32_vector3_reset(BGC_FP32_Vector3* vector); extern inline void bgc_fp64_vector3_reset(BGC_FP64_Vector3* vector); -extern inline void bgc_fp32_vector3_make(const float x1, const float x2, const float x3, BGC_FP32_Vector3* destination); -extern inline void bgc_fp64_vector3_make(const double x1, const double x2, const double x3, BGC_FP64_Vector3* destination); +extern inline void bgc_fp32_vector3_make(BGC_FP32_Vector3* destination, const float x1, const float x2, const float x3); +extern inline void bgc_fp64_vector3_make(BGC_FP64_Vector3* destination, const double x1, const double x2, const double x3); extern inline float bgc_fp32_vector3_get_square_modulus(const BGC_FP32_Vector3* vector); extern inline double bgc_fp64_vector3_get_square_modulus(const BGC_FP64_Vector3* vector); @@ -18,50 +18,50 @@ extern inline int bgc_fp64_vector3_is_zero(const BGC_FP64_Vector3* vector); extern inline int bgc_fp32_vector3_is_unit(const BGC_FP32_Vector3* vector); extern inline int bgc_fp64_vector3_is_unit(const BGC_FP64_Vector3* vector); -extern inline void bgc_fp32_vector3_copy(const BGC_FP32_Vector3* source, BGC_FP32_Vector3* destination); -extern inline void bgc_fp64_vector3_copy(const BGC_FP64_Vector3* source, BGC_FP64_Vector3* destination); +extern inline void bgc_fp32_vector3_copy(BGC_FP32_Vector3* destination, const BGC_FP32_Vector3* source); +extern inline void bgc_fp64_vector3_copy(BGC_FP64_Vector3* destination, const BGC_FP64_Vector3* source); -extern inline void bgc_fp32_vector3_convert_to_fp64(const BGC_FP32_Vector3* source, BGC_FP64_Vector3* destination); -extern inline void bgc_fp64_vector3_convert_to_fp32(const BGC_FP64_Vector3* source, BGC_FP32_Vector3* destination); +extern inline void bgc_fp32_vector3_convert_to_fp64(BGC_FP64_Vector3* destination, const BGC_FP32_Vector3* source); +extern inline void bgc_fp64_vector3_convert_to_fp32(BGC_FP32_Vector3* destination, const BGC_FP64_Vector3* source); extern inline void bgc_fp32_vector3_swap(BGC_FP32_Vector3* vector1, BGC_FP32_Vector3* vector2); extern inline void bgc_fp64_vector3_swap(BGC_FP64_Vector3* vector1, BGC_FP64_Vector3* vector2); -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_fp64_vector3_add(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, BGC_FP64_Vector3* sum); +extern inline void bgc_fp32_vector3_add(BGC_FP32_Vector3* sum, const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2); +extern inline void bgc_fp64_vector3_add(BGC_FP64_Vector3* sum, const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2); -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_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_fp32_vector3_add_scaled(BGC_FP32_Vector3* sum, const BGC_FP32_Vector3* basic_vector, const BGC_FP32_Vector3* scalable_vector, const float scale); +extern inline void bgc_fp64_vector3_add_scaled(BGC_FP64_Vector3* sum, const BGC_FP64_Vector3* basic_vector, const BGC_FP64_Vector3* scalable_vector, const double scale); -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_fp64_vector3_subtract(const BGC_FP64_Vector3* minuend, const BGC_FP64_Vector3* subtrahend, BGC_FP64_Vector3* difference); +extern inline void bgc_fp32_vector3_subtract(BGC_FP32_Vector3* difference, const BGC_FP32_Vector3* minuend, const BGC_FP32_Vector3* subtrahend); +extern inline void bgc_fp64_vector3_subtract(BGC_FP64_Vector3* difference, const BGC_FP64_Vector3* minuend, const BGC_FP64_Vector3* subtrahend); -extern inline void bgc_fp32_vector3_multiply(const BGC_FP32_Vector3* multiplicand, const float multiplier, BGC_FP32_Vector3* product); -extern inline void bgc_fp64_vector3_multiply(const BGC_FP64_Vector3* multiplicand, const double multiplier, BGC_FP64_Vector3* product); +extern inline void bgc_fp32_vector3_multiply(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* multiplicand, const float multiplier); +extern inline void bgc_fp64_vector3_multiply(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* multiplicand, const double multiplier); -extern inline void bgc_fp32_vector3_divide(const BGC_FP32_Vector3* dividend, const float divisor, BGC_FP32_Vector3* quotient); -extern inline void bgc_fp64_vector3_divide(const BGC_FP64_Vector3* dividend, const double divisor, BGC_FP64_Vector3* quotient); +extern inline void bgc_fp32_vector3_divide(BGC_FP32_Vector3* quotient, const BGC_FP32_Vector3* dividend, const float divisor); +extern inline void bgc_fp64_vector3_divide(BGC_FP64_Vector3* quotient, const BGC_FP64_Vector3* dividend, const double divisor); -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_fp64_vector3_get_middle2(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, BGC_FP64_Vector3* middle); +extern inline void bgc_fp32_vector3_get_mean2(BGC_FP32_Vector3* mean, const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2); +extern inline void bgc_fp64_vector3_get_mean2(BGC_FP64_Vector3* mean, const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2); -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_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_fp32_vector3_get_mean3(BGC_FP32_Vector3* mean, const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const BGC_FP32_Vector3* vector3); +extern inline void bgc_fp64_vector3_get_mean3(BGC_FP64_Vector3* mean, const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const BGC_FP64_Vector3* vector3); -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_fp64_vector3_interpolate(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const double phase, BGC_FP64_Vector3* interpolation); +extern inline void bgc_fp32_vector3_interpolate(BGC_FP32_Vector3* interpolation, const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const float phase); +extern inline void bgc_fp64_vector3_interpolate(BGC_FP64_Vector3* interpolation, const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const double phase); extern inline void bgc_fp32_vector3_revert(BGC_FP32_Vector3* vector); extern inline void bgc_fp64_vector3_revert(BGC_FP64_Vector3* vector); -extern inline void bgc_fp32_vector3_get_reverse(const BGC_FP32_Vector3* vector, BGC_FP32_Vector3* reverse); -extern inline void bgc_fp64_vector3_get_reverse(const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* reverse); +extern inline void bgc_fp32_vector3_get_reverse(BGC_FP32_Vector3* reverse, const BGC_FP32_Vector3* vector); +extern inline void bgc_fp64_vector3_get_reverse(BGC_FP64_Vector3* reverse, const BGC_FP64_Vector3* vector); extern inline int bgc_fp32_vector3_normalize(BGC_FP32_Vector3* vector); extern inline int bgc_fp64_vector3_normalize(BGC_FP64_Vector3* vector); -extern inline int bgc_fp32_vector3_get_normalized(const BGC_FP32_Vector3* vector, BGC_FP32_Vector3* normalized); -extern inline int bgc_fp64_vector3_get_normalized(const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* normalized); +extern inline int bgc_fp32_vector3_get_normalized(BGC_FP32_Vector3* normalized, const BGC_FP32_Vector3* vector); +extern inline int bgc_fp64_vector3_get_normalized(BGC_FP64_Vector3* normalized, const BGC_FP64_Vector3* vector); extern inline float bgc_fp32_vector3_get_dot_product(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2); extern inline double bgc_fp64_vector3_get_dot_product(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2); @@ -69,11 +69,11 @@ extern inline double bgc_fp64_vector3_get_dot_product(const BGC_FP64_Vector3* ve 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_fp64_vector3_get_triple_product(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const BGC_FP64_Vector3* vector3); -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_fp64_vector3_get_cross_product(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, BGC_FP64_Vector3* result); +extern inline void bgc_fp32_vector3_get_cross_product(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2); +extern inline void bgc_fp64_vector3_get_cross_product(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2); -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_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 void bgc_fp32_vector3_get_double_cross(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const BGC_FP32_Vector3* vector3); +extern inline void bgc_fp64_vector3_get_double_cross(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const BGC_FP64_Vector3* vector3); extern inline float bgc_fp32_vector3_get_square_distance(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2); extern inline double bgc_fp64_vector3_get_square_distance(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2); @@ -116,7 +116,7 @@ float bgc_fp32_vector3_get_angle(const BGC_FP32_Vector3* vector1, const BGC_FP32 BGC_FP32_Vector3 cross_product; - bgc_fp32_vector3_get_cross_product(vector1, vector2, &cross_product); + bgc_fp32_vector3_get_cross_product(&cross_product, vector1, vector2); const float scalar = bgc_fp32_vector3_get_dot_product(vector1, vector2); @@ -143,7 +143,7 @@ double bgc_fp64_vector3_get_angle(const BGC_FP64_Vector3* vector1, const BGC_FP6 BGC_FP64_Vector3 cross_product; - bgc_fp64_vector3_get_cross_product(vector1, vector2, &cross_product); + bgc_fp64_vector3_get_cross_product(&cross_product, vector1, vector2); const double scalar = bgc_fp64_vector3_get_dot_product(vector1, vector2); diff --git a/basic-geometry/vector3.h b/basic-geometry/vector3.h index b7065af..e5dbe6f 100644 --- a/basic-geometry/vector3.h +++ b/basic-geometry/vector3.h @@ -36,14 +36,14 @@ inline void bgc_fp64_vector3_reset(BGC_FP64_Vector3* vector) // ==================== Set ===================== // -inline void bgc_fp32_vector3_make(const float x1, const float x2, const float x3, BGC_FP32_Vector3* destination) +inline void bgc_fp32_vector3_make(BGC_FP32_Vector3* destination, const float x1, const float x2, const float x3) { destination->x1 = x1; destination->x2 = x2; destination->x3 = x3; } -inline void bgc_fp64_vector3_make(const double x1, const double x2, const double x3, BGC_FP64_Vector3* destination) +inline void bgc_fp64_vector3_make(BGC_FP64_Vector3* destination, const double x1, const double x2, const double x3) { destination->x1 = x1; destination->x2 = x2; @@ -96,14 +96,14 @@ inline int bgc_fp64_vector3_is_unit(const BGC_FP64_Vector3* vector) // ==================== Copy ==================== // -inline void bgc_fp32_vector3_copy(const BGC_FP32_Vector3* source, BGC_FP32_Vector3* destination) +inline void bgc_fp32_vector3_copy(BGC_FP32_Vector3* destination, const BGC_FP32_Vector3* source) { destination->x1 = source->x1; destination->x2 = source->x2; destination->x3 = source->x3; } -inline void bgc_fp64_vector3_copy(const BGC_FP64_Vector3* source, BGC_FP64_Vector3* destination) +inline void bgc_fp64_vector3_copy(BGC_FP64_Vector3* destination, const BGC_FP64_Vector3* source) { destination->x1 = source->x1; destination->x2 = source->x2; @@ -144,30 +144,30 @@ inline void bgc_fp64_vector3_swap(BGC_FP64_Vector3* vector1, BGC_FP64_Vector3* v // ================== Convert =================== // -inline void bgc_fp64_vector3_convert_to_fp32(const BGC_FP64_Vector3* source, BGC_FP32_Vector3* destination) -{ - destination->x1 = (float)source->x1; - destination->x2 = (float)source->x2; - destination->x3 = (float)source->x3; -} - -inline void bgc_fp32_vector3_convert_to_fp64(const BGC_FP32_Vector3* source, BGC_FP64_Vector3* destination) +inline void bgc_fp32_vector3_convert_to_fp64(BGC_FP64_Vector3* destination, const BGC_FP32_Vector3* source) { destination->x1 = source->x1; destination->x2 = source->x2; destination->x3 = source->x3; } +inline void bgc_fp64_vector3_convert_to_fp32(BGC_FP32_Vector3* destination, const BGC_FP64_Vector3* source) +{ + destination->x1 = (float)source->x1; + destination->x2 = (float)source->x2; + destination->x3 = (float)source->x3; +} + // ==================== Add ===================== // -inline void bgc_fp32_vector3_add(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, BGC_FP32_Vector3* sum) +inline void bgc_fp32_vector3_add(BGC_FP32_Vector3* sum, const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2) { sum->x1 = vector1->x1 + vector2->x1; sum->x2 = vector1->x2 + vector2->x2; sum->x3 = vector1->x3 + vector2->x3; } -inline void bgc_fp64_vector3_add(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, BGC_FP64_Vector3* sum) +inline void bgc_fp64_vector3_add(BGC_FP64_Vector3* sum, const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2) { sum->x1 = vector1->x1 + vector2->x1; sum->x2 = vector1->x2 + vector2->x2; @@ -176,14 +176,14 @@ inline void bgc_fp64_vector3_add(const BGC_FP64_Vector3* vector1, const BGC_FP64 // ================= Add scaled ================= // -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) +inline void bgc_fp32_vector3_add_scaled(BGC_FP32_Vector3* sum, const BGC_FP32_Vector3* basic_vector, const BGC_FP32_Vector3* scalable_vector, const float scale) { sum->x1 = basic_vector->x1 + scalable_vector->x1 * scale; sum->x2 = basic_vector->x2 + scalable_vector->x2 * scale; sum->x3 = basic_vector->x3 + scalable_vector->x3 * scale; } -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) +inline void bgc_fp64_vector3_add_scaled(BGC_FP64_Vector3* sum, const BGC_FP64_Vector3* basic_vector, const BGC_FP64_Vector3* scalable_vector, const double scale) { sum->x1 = basic_vector->x1 + scalable_vector->x1 * scale; sum->x2 = basic_vector->x2 + scalable_vector->x2 * scale; @@ -192,14 +192,14 @@ inline void bgc_fp64_vector3_add_scaled(const BGC_FP64_Vector3* basic_vector, co // ================== Subtract ================== // -inline void bgc_fp32_vector3_subtract(const BGC_FP32_Vector3* minuend, const BGC_FP32_Vector3* subtrahend, BGC_FP32_Vector3* difference) +inline void bgc_fp32_vector3_subtract(BGC_FP32_Vector3* difference, const BGC_FP32_Vector3* minuend, const BGC_FP32_Vector3* subtrahend) { difference->x1 = minuend->x1 - subtrahend->x1; difference->x2 = minuend->x2 - subtrahend->x2; difference->x3 = minuend->x3 - subtrahend->x3; } -inline void bgc_fp64_vector3_subtract(const BGC_FP64_Vector3* minuend, const BGC_FP64_Vector3* subtrahend, BGC_FP64_Vector3* difference) +inline void bgc_fp64_vector3_subtract(BGC_FP64_Vector3* difference, const BGC_FP64_Vector3* minuend, const BGC_FP64_Vector3* subtrahend) { difference->x1 = minuend->x1 - subtrahend->x1; difference->x2 = minuend->x2 - subtrahend->x2; @@ -208,14 +208,14 @@ inline void bgc_fp64_vector3_subtract(const BGC_FP64_Vector3* minuend, const BGC // ================== Multiply ================== // -inline void bgc_fp32_vector3_multiply(const BGC_FP32_Vector3* multiplicand, const float multiplier, BGC_FP32_Vector3* product) +inline void bgc_fp32_vector3_multiply(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* multiplicand, const float multiplier) { product->x1 = multiplicand->x1 * multiplier; product->x2 = multiplicand->x2 * multiplier; product->x3 = multiplicand->x3 * multiplier; } -inline void bgc_fp64_vector3_multiply(const BGC_FP64_Vector3* multiplicand, const double multiplier, BGC_FP64_Vector3* product) +inline void bgc_fp64_vector3_multiply(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* multiplicand, const double multiplier) { product->x1 = multiplicand->x1 * multiplier; product->x2 = multiplicand->x2 * multiplier; @@ -224,51 +224,51 @@ inline void bgc_fp64_vector3_multiply(const BGC_FP64_Vector3* multiplicand, cons // =================== Divide =================== // -inline void bgc_fp32_vector3_divide(const BGC_FP32_Vector3* dividend, const float divisor, BGC_FP32_Vector3* quotient) +inline void bgc_fp32_vector3_divide(BGC_FP32_Vector3* quotient, const BGC_FP32_Vector3* dividend, const float divisor) { - bgc_fp32_vector3_multiply(dividend, 1.0f / divisor, quotient); + bgc_fp32_vector3_multiply(quotient, dividend, 1.0f / divisor); } -inline void bgc_fp64_vector3_divide(const BGC_FP64_Vector3* dividend, const double divisor, BGC_FP64_Vector3* quotient) +inline void bgc_fp64_vector3_divide(BGC_FP64_Vector3* quotient, const BGC_FP64_Vector3* dividend, const double divisor) { - bgc_fp64_vector3_multiply(dividend, 1.0 / divisor, quotient); + bgc_fp64_vector3_multiply(quotient, dividend, 1.0 / divisor); } // ================== Average2 ================== // -inline void bgc_fp32_vector3_get_middle2(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, BGC_FP32_Vector3* middle) +inline void bgc_fp32_vector3_get_mean2(BGC_FP32_Vector3* mean, const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2) { - middle->x1 = (vector1->x1 + vector2->x1) * 0.5f; - middle->x2 = (vector1->x2 + vector2->x2) * 0.5f; - middle->x3 = (vector1->x3 + vector2->x3) * 0.5f; + mean->x1 = (vector1->x1 + vector2->x1) * 0.5f; + mean->x2 = (vector1->x2 + vector2->x2) * 0.5f; + mean->x3 = (vector1->x3 + vector2->x3) * 0.5f; } -inline void bgc_fp64_vector3_get_middle2(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, BGC_FP64_Vector3* middle) +inline void bgc_fp64_vector3_get_mean2(BGC_FP64_Vector3* mean, const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2) { - middle->x1 = (vector1->x1 + vector2->x1) * 0.5; - middle->x2 = (vector1->x2 + vector2->x2) * 0.5; - middle->x3 = (vector1->x3 + vector2->x3) * 0.5; + mean->x1 = (vector1->x1 + vector2->x1) * 0.5; + mean->x2 = (vector1->x2 + vector2->x2) * 0.5; + mean->x3 = (vector1->x3 + vector2->x3) * 0.5; } // ================== Average3 ================== // -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) +inline void bgc_fp32_vector3_get_mean3(BGC_FP32_Vector3* mean, const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const BGC_FP32_Vector3* vector3) { - middle->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP32_ONE_THIRD; - middle->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP32_ONE_THIRD; - middle->x3 = (vector1->x3 + vector2->x3 + vector3->x3) * BGC_FP32_ONE_THIRD; + mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP32_ONE_THIRD; + mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP32_ONE_THIRD; + mean->x3 = (vector1->x3 + vector2->x3 + vector3->x3) * BGC_FP32_ONE_THIRD; } -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) +inline void bgc_fp64_vector3_get_mean3(BGC_FP64_Vector3* mean, const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const BGC_FP64_Vector3* vector3) { - middle->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP64_ONE_THIRD; - middle->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP64_ONE_THIRD; - middle->x3 = (vector1->x3 + vector2->x3 + vector3->x3) * BGC_FP64_ONE_THIRD; + mean->x1 = (vector1->x1 + vector2->x1 + vector3->x1) * BGC_FP64_ONE_THIRD; + mean->x2 = (vector1->x2 + vector2->x2 + vector3->x2) * BGC_FP64_ONE_THIRD; + mean->x3 = (vector1->x3 + vector2->x3 + vector3->x3) * BGC_FP64_ONE_THIRD; } // =================== Linear =================== // -inline void bgc_fp32_vector3_interpolate(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const float phase, BGC_FP32_Vector3* interpolation) +inline void bgc_fp32_vector3_interpolate(BGC_FP32_Vector3* interpolation, const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const float phase) { const float counter_phase = 1.0f - phase; @@ -277,7 +277,7 @@ inline void bgc_fp32_vector3_interpolate(const BGC_FP32_Vector3* vector1, const interpolation->x3 = vector1->x3 * counter_phase + vector2->x3 * phase; } -inline void bgc_fp64_vector3_interpolate(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const double phase, BGC_FP64_Vector3* interpolation) +inline void bgc_fp64_vector3_interpolate(BGC_FP64_Vector3* interpolation, const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const double phase) { const double counter_phase = 1.0 - phase; @@ -302,14 +302,14 @@ inline void bgc_fp64_vector3_revert(BGC_FP64_Vector3* vector) vector->x3 = -vector->x3; } -inline void bgc_fp32_vector3_get_reverse(const BGC_FP32_Vector3* vector, BGC_FP32_Vector3* reverse) +inline void bgc_fp32_vector3_get_reverse(BGC_FP32_Vector3* reverse, const BGC_FP32_Vector3* vector) { reverse->x1 = -vector->x1; reverse->x2 = -vector->x2; reverse->x3 = -vector->x3; } -inline void bgc_fp64_vector3_get_reverse(const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* reverse) +inline void bgc_fp64_vector3_get_reverse(BGC_FP64_Vector3* reverse, const BGC_FP64_Vector3* vector) { reverse->x1 = -vector->x1; reverse->x2 = -vector->x2; @@ -360,12 +360,12 @@ inline int bgc_fp64_vector3_normalize(BGC_FP64_Vector3* vector) return 1; } -inline int bgc_fp32_vector3_get_normalized(const BGC_FP32_Vector3* vector, BGC_FP32_Vector3* normalized) +inline int bgc_fp32_vector3_get_normalized(BGC_FP32_Vector3* normalized, const BGC_FP32_Vector3* vector) { const float square_modulus = bgc_fp32_vector3_get_square_modulus(vector); if (bgc_fp32_is_square_unit(square_modulus)) { - bgc_fp32_vector3_copy(vector, normalized); + bgc_fp32_vector3_copy(normalized, vector); return 1; } @@ -374,16 +374,16 @@ inline int bgc_fp32_vector3_get_normalized(const BGC_FP32_Vector3* vector, BGC_F return 0; } - bgc_fp32_vector3_multiply(vector, sqrtf(1.0f / square_modulus), normalized); + bgc_fp32_vector3_multiply(normalized, vector, sqrtf(1.0f / square_modulus)); return 1; } -inline int bgc_fp64_vector3_get_normalized(const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* normalized) +inline int bgc_fp64_vector3_get_normalized(BGC_FP64_Vector3* normalized, const BGC_FP64_Vector3* vector) { const double square_modulus = bgc_fp64_vector3_get_square_modulus(vector); if (bgc_fp64_is_square_unit(square_modulus)) { - bgc_fp64_vector3_copy(vector, normalized); + bgc_fp64_vector3_copy(normalized, vector); return 1; } @@ -392,7 +392,7 @@ inline int bgc_fp64_vector3_get_normalized(const BGC_FP64_Vector3* vector, BGC_F return 0; } - bgc_fp64_vector3_multiply(vector, sqrt(1.0 / square_modulus), normalized); + bgc_fp64_vector3_multiply(normalized, vector, sqrt(1.0 / square_modulus)); return 1; } @@ -426,7 +426,7 @@ inline double bgc_fp64_vector3_get_triple_product(const BGC_FP64_Vector3* vector // =============== Cross Product ================ // -inline void bgc_fp32_vector3_get_cross_product(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, BGC_FP32_Vector3* product) +inline void bgc_fp32_vector3_get_cross_product(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2) { const float x1 = vector1->x2 * vector2->x3 - vector1->x3 * vector2->x2; const float x2 = vector1->x3 * vector2->x1 - vector1->x1 * vector2->x3; @@ -437,7 +437,7 @@ inline void bgc_fp32_vector3_get_cross_product(const BGC_FP32_Vector3* vector1, product->x3 = x3; } -inline void bgc_fp64_vector3_get_cross_product(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, BGC_FP64_Vector3* product) +inline void bgc_fp64_vector3_get_cross_product(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2) { const double x1 = vector1->x2 * vector2->x3 - vector1->x3 * vector2->x2; const double x2 = vector1->x3 * vector2->x1 - vector1->x1 * vector2->x3; @@ -450,7 +450,7 @@ inline void bgc_fp64_vector3_get_cross_product(const BGC_FP64_Vector3* vector1, // ============ Double Cross 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) +inline void bgc_fp32_vector3_get_double_cross(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3* vector2, const BGC_FP32_Vector3* vector3) { const float ac = bgc_fp32_vector3_get_dot_product(vector1, vector3); const float ab = bgc_fp32_vector3_get_dot_product(vector1, vector2); @@ -460,7 +460,7 @@ inline void bgc_fp32_vector3_get_double_cross(const BGC_FP32_Vector3* vector1, c product->x3 = vector2->x3 * ac - vector3->x3 * ab; } -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) +inline void bgc_fp64_vector3_get_double_cross(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2, const BGC_FP64_Vector3* vector3) { const double ac = bgc_fp64_vector3_get_dot_product(vector1, vector3); const double ab = bgc_fp64_vector3_get_dot_product(vector1, vector2); @@ -561,7 +561,7 @@ inline int bgc_fp32_vector3_are_parallel(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3 product; - bgc_fp32_vector3_get_cross_product(vector1, vector2, &product); + bgc_fp32_vector3_get_cross_product(&product, vector1, vector2); return bgc_fp32_vector3_get_square_modulus(&product) <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 * square_modulus2; } @@ -577,7 +577,7 @@ inline int bgc_fp64_vector3_are_parallel(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3 product; - bgc_fp64_vector3_get_cross_product(vector1, vector2, &product); + bgc_fp64_vector3_get_cross_product(&product, vector1, vector2); return bgc_fp64_vector3_get_square_modulus(&product) <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 * square_modulus2; } @@ -633,7 +633,7 @@ inline int bgc_fp32_vector3_get_attitude(const BGC_FP32_Vector3* vector1, const BGC_FP32_Vector3 product; - bgc_fp32_vector3_get_cross_product(vector1, vector2, &product); + bgc_fp32_vector3_get_cross_product(&product, vector1, vector2); if (bgc_fp32_vector3_get_square_modulus(&product) > square_limit) { return BGC_ATTITUDE_ANY; @@ -661,7 +661,7 @@ inline int bgc_fp64_vector3_get_attitude(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3 product; - bgc_fp64_vector3_get_cross_product(vector1, vector2, &product); + bgc_fp64_vector3_get_cross_product(&product, vector1, vector2); if (bgc_fp64_vector3_get_square_modulus(&product) > square_limit) { return BGC_ATTITUDE_ANY; diff --git a/basic-geometry/versor.c b/basic-geometry/versor.c index 1d18825..f08187b 100644 --- a/basic-geometry/versor.c +++ b/basic-geometry/versor.c @@ -10,14 +10,14 @@ const BGC_FP64_Versor BGC_FP64_IDLE_VERSOR = { 1.0, 0.0, 0.0, 0.0 }; extern inline void bgc_fp32_versor_reset(BGC_FP32_Versor* versor); extern inline void bgc_fp64_versor_reset(BGC_FP64_Versor* 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_fp64_versor_make(const double s0, const double x1, const double x2, const double x3, BGC_FP64_Versor* versor); +extern inline void bgc_fp32_versor_make(BGC_FP32_Versor* versor, const float s0, const float x1, const float x2, const float x3); +extern inline void bgc_fp64_versor_make(BGC_FP64_Versor* versor, const double s0, const double x1, const double x2, const double x3); -extern inline void bgc_fp32_versor_make_for_rotation(const BGC_FP32_Rotation3* rotation, BGC_FP32_Versor* result); -extern inline void bgc_fp64_versor_make_for_rotation(const BGC_FP64_Rotation3* rotation, BGC_FP64_Versor* result); +extern inline void bgc_fp32_versor_make_for_rotation(BGC_FP32_Versor* versor, const BGC_FP32_Rotation3* rotation); +extern inline void bgc_fp64_versor_make_for_rotation(BGC_FP64_Versor* versor, const BGC_FP64_Rotation3* rotation); -extern inline void bgc_fp32_versor_copy(const BGC_FP32_Versor* source, BGC_FP32_Versor* destination); -extern inline void bgc_fp64_versor_copy(const BGC_FP64_Versor* source, BGC_FP64_Versor* destination); +extern inline void bgc_fp32_versor_copy(BGC_FP32_Versor* destination, const BGC_FP32_Versor* source); +extern inline void bgc_fp64_versor_copy(BGC_FP64_Versor* destination, const BGC_FP64_Versor* source); extern inline void bgc_fp32_versor_swap(BGC_FP32_Versor* versor1, BGC_FP32_Versor* versor2); extern inline void bgc_fp64_versor_swap(BGC_FP64_Versor* versor1, BGC_FP64_Versor* versor2); @@ -25,50 +25,50 @@ extern inline void bgc_fp64_versor_swap(BGC_FP64_Versor* versor1, BGC_FP64_Verso extern inline int bgc_fp32_versor_is_idle(const BGC_FP32_Versor* versor); extern inline int bgc_fp64_versor_is_idle(const BGC_FP64_Versor* versor); -extern inline void bgc_fp64_versor_convert_to_fp32(const BGC_FP64_Versor* source, BGC_FP32_Versor* destination); -extern inline void bgc_fp32_versor_convert_to_fp64(const BGC_FP32_Versor* source, BGC_FP64_Versor* destination); +extern inline void bgc_fp32_versor_convert_to_fp64(BGC_FP64_Versor* destination, const BGC_FP32_Versor* source); +extern inline void bgc_fp64_versor_convert_to_fp32(BGC_FP32_Versor* destination, const BGC_FP64_Versor* source); extern inline void bgc_fp32_versor_shorten(BGC_FP32_Versor* versor); extern inline void bgc_fp64_versor_shorten(BGC_FP64_Versor* versor); -extern inline void bgc_fp32_versor_get_shortened(const BGC_FP32_Versor* versor, BGC_FP32_Versor* shortened); -extern inline void bgc_fp64_versor_get_shortened(const BGC_FP64_Versor* versor, BGC_FP64_Versor* shortened); +extern inline void bgc_fp32_versor_get_shortened(BGC_FP32_Versor* shortened, const BGC_FP32_Versor* versor); +extern inline void bgc_fp64_versor_get_shortened(BGC_FP64_Versor* shortened, const BGC_FP64_Versor* versor); extern inline void bgc_fp32_versor_alternate(BGC_FP32_Versor* versor); extern inline void bgc_fp64_versor_alternate(BGC_FP64_Versor* versor); -extern inline void bgc_fp32_versor_get_alternative(const BGC_FP32_Versor* versor, BGC_FP32_Versor* opposite); -extern inline void bgc_fp64_versor_get_alternative(const BGC_FP64_Versor* versor, BGC_FP64_Versor* opposite); +extern inline void bgc_fp32_versor_get_alternative(BGC_FP32_Versor* alternative, const BGC_FP32_Versor* versor); +extern inline void bgc_fp64_versor_get_alternative(BGC_FP64_Versor* alternative, const BGC_FP64_Versor* versor); extern inline void bgc_fp32_versor_revert(BGC_FP32_Versor* versor); extern inline void bgc_fp64_versor_revert(BGC_FP64_Versor* versor); -extern inline void bgc_fp32_versor_get_reverse(const BGC_FP32_Versor* versor, BGC_FP32_Versor* inverse); -extern inline void bgc_fp64_versor_get_reverse(const BGC_FP64_Versor* versor, BGC_FP64_Versor* inverse); +extern inline void bgc_fp32_versor_get_reverse(BGC_FP32_Versor* inverse, const BGC_FP32_Versor* versor); +extern inline void bgc_fp64_versor_get_reverse(BGC_FP64_Versor* inverse, const BGC_FP64_Versor* versor); -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_fp64_versor_combine(const BGC_FP64_Versor* first, const BGC_FP64_Versor* second, BGC_FP64_Versor* result); +extern inline void bgc_fp32_versor_combine(BGC_FP32_Versor* combination, const BGC_FP32_Versor* first, const BGC_FP32_Versor* second); +extern inline void bgc_fp64_versor_combine(BGC_FP64_Versor* combination, const BGC_FP64_Versor* first, const BGC_FP64_Versor* second); -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_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_fp32_versor_combine3(BGC_FP32_Versor* combination, const BGC_FP32_Versor* first, const BGC_FP32_Versor* second, const BGC_FP32_Versor* third); +extern inline void bgc_fp64_versor_combine3(BGC_FP64_Versor* combination, const BGC_FP64_Versor* first, const BGC_FP64_Versor* second, const BGC_FP64_Versor* third); -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_fp64_versor_exclude(const BGC_FP64_Versor* base, const BGC_FP64_Versor* excludant, BGC_FP64_Versor* difference); +extern inline void bgc_fp32_versor_exclude(BGC_FP32_Versor* difference, const BGC_FP32_Versor* base, const BGC_FP32_Versor* excludant); +extern inline void bgc_fp64_versor_exclude(BGC_FP64_Versor* difference, const BGC_FP64_Versor* base, const BGC_FP64_Versor* excludant); -extern inline void bgc_fp32_versor_get_rotation_matrix(const BGC_FP32_Versor* versor, BGC_FP32_Matrix3x3* matrix); -extern inline void bgc_fp64_versor_get_rotation_matrix(const BGC_FP64_Versor* versor, BGC_FP64_Matrix3x3* matrix); +extern inline void bgc_fp32_versor_get_rotation_matrix(BGC_FP32_Matrix3x3* matrix, const BGC_FP32_Versor* versor); +extern inline void bgc_fp64_versor_get_rotation_matrix(BGC_FP64_Matrix3x3* matrix, const BGC_FP64_Versor* versor); -extern inline void bgc_fp32_versor_get_reverse_matrix(const BGC_FP32_Versor* versor, BGC_FP32_Matrix3x3* matrix); -extern inline void bgc_fp64_versor_get_reverse_matrix(const BGC_FP64_Versor* versor, BGC_FP64_Matrix3x3* matrix); +extern inline void bgc_fp32_versor_get_reverse_matrix(BGC_FP32_Matrix3x3* matrix, const BGC_FP32_Versor* versor); +extern inline void bgc_fp64_versor_get_reverse_matrix(BGC_FP64_Matrix3x3* matrix, const BGC_FP64_Versor* versor); -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_fp64_versor_get_both_matrices(const BGC_FP64_Versor* versor, BGC_FP64_Matrix3x3* rotation, BGC_FP64_Matrix3x3* reverse); +extern inline void bgc_fp32_versor_get_both_matrices(BGC_FP32_Matrix3x3* rotation, BGC_FP32_Matrix3x3* reverse, const BGC_FP32_Versor* versor); +extern inline void bgc_fp64_versor_get_both_matrices(BGC_FP64_Matrix3x3* rotation, BGC_FP64_Matrix3x3* reverse, const BGC_FP64_Versor* versor); -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_fp64_versor_turn_vector(const BGC_FP64_Versor* versor, const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* result); +extern inline void bgc_fp32_versor_turn_vector(BGC_FP32_Vector3* turned_vector, const BGC_FP32_Versor* versor, const BGC_FP32_Vector3* vector); +extern inline void bgc_fp64_versor_turn_vector(BGC_FP64_Vector3* turned_vector, const BGC_FP64_Versor* versor, const BGC_FP64_Vector3* vector); -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_fp64_versor_turn_vector_back(const BGC_FP64_Versor* versor, const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* result); +extern inline void bgc_fp32_versor_turn_vector_back(BGC_FP32_Vector3* turned_vector, const BGC_FP32_Versor* versor, const BGC_FP32_Vector3* vector); +extern inline void bgc_fp64_versor_turn_vector_back(BGC_FP64_Vector3* turned_vector, const BGC_FP64_Versor* versor, const BGC_FP64_Vector3* vector); extern inline int bgc_fp32_versor_are_close(const BGC_FP32_Versor* versor1, const BGC_FP32_Versor* versor2); extern inline int bgc_fp64_versor_are_close(const BGC_FP64_Versor* versor1, const BGC_FP64_Versor* versor2); @@ -117,12 +117,12 @@ void _bgc_fp64_versor_normalize(BGC_FP64_Versor* versor) // ================== Set Turn ================== // -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_fp32_versor_make_for_turn(BGC_FP32_Versor* versor, const float x1, const float x2, const float x3, const float angle, const int unit) { const float square_vector = x1 * x1 + x2 * x2 + x3 * x3; if (square_vector <= BGC_FP32_SQUARE_EPSYLON) { - bgc_fp32_versor_reset(result); + bgc_fp32_versor_reset(versor); return; } @@ -131,21 +131,21 @@ void bgc_fp32_versor_make_for_turn(const float x1, const float x2, const float x const float sine = sinf(half_angle); if (bgc_fp32_is_zero(sine)) { - bgc_fp32_versor_reset(result); + bgc_fp32_versor_reset(versor); return; } const float multiplier = sine / sqrtf(square_vector); - bgc_fp32_versor_make(cosf(half_angle), x1 * multiplier, x2 * multiplier, x3 * multiplier, result); + bgc_fp32_versor_make(versor, cosf(half_angle), x1 * multiplier, x2 * multiplier, x3 * multiplier); } -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) +void bgc_fp64_versor_make_for_turn(BGC_FP64_Versor* versor, const double x1, const double x2, const double x3, const double angle, const int unit) { const double square_vector = x1 * x1 + x2 * x2 + x3 * x3; if (square_vector <= BGC_FP64_SQUARE_EPSYLON) { - bgc_fp64_versor_reset(result); + bgc_fp64_versor_reset(versor); return; } @@ -154,22 +154,22 @@ void bgc_fp64_versor_make_for_turn(const double x1, const double x2, const doubl const double sine = sin(half_angle); if (bgc_fp64_is_zero(sine)) { - bgc_fp64_versor_reset(result); + bgc_fp64_versor_reset(versor); return; } const double multiplier = sine / sqrt(square_vector); - bgc_fp64_versor_make(cos(half_angle), x1 * multiplier, x2 * multiplier, x3 * multiplier, result); + bgc_fp64_versor_make(versor, cos(half_angle), x1 * multiplier, x2 * multiplier, x3 * multiplier); } // ========= Make Direction Difference ========== // -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) +static int _bgc_fp32_versor_make_direction_turn(BGC_FP32_Versor* versor, const BGC_FP32_Vector3* start, const BGC_FP32_Vector3* end, const float square_modulus_product) { BGC_FP32_Vector3 orthogonal_axis; - bgc_fp32_vector3_get_cross_product(start, end, &orthogonal_axis); + bgc_fp32_vector3_get_cross_product(&orthogonal_axis, start, end); const float scalar_product = bgc_fp32_vector3_get_dot_product(start, end); const float square_modulus = bgc_fp32_vector3_get_square_modulus(&orthogonal_axis); @@ -181,7 +181,7 @@ static int _bgc_fp32_versor_make_direction_turn(const BGC_FP32_Vector3* start, c const float multiplier = sinf(angle) * sqrtf(1.0f / square_modulus); - bgc_fp32_versor_make(cosf(angle), orthogonal_axis.x1 * multiplier, orthogonal_axis.x2 * multiplier, orthogonal_axis.x3 * multiplier, result); + bgc_fp32_versor_make(versor, cosf(angle), orthogonal_axis.x1 * multiplier, orthogonal_axis.x2 * multiplier, orthogonal_axis.x3 * multiplier); return BGC_SOME_TURN; } @@ -189,15 +189,15 @@ static int _bgc_fp32_versor_make_direction_turn(const BGC_FP32_Vector3* start, c return BGC_OPPOSITE; } - bgc_fp32_versor_reset(result); + bgc_fp32_versor_reset(versor); return BGC_ZERO_TURN; } -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) +static int _bgc_fp64_versor_make_direction_turn(BGC_FP64_Versor* versor, const BGC_FP64_Vector3* start, const BGC_FP64_Vector3* end, const double square_modulus_product) { BGC_FP64_Vector3 orthogonal_axis; - bgc_fp64_vector3_get_cross_product(start, end, &orthogonal_axis); + bgc_fp64_vector3_get_cross_product(&orthogonal_axis, start, end); const double scalar_product = bgc_fp64_vector3_get_dot_product(start, end); const double square_modulus = bgc_fp64_vector3_get_square_modulus(&orthogonal_axis); @@ -209,7 +209,7 @@ static int _bgc_fp64_versor_make_direction_turn(const BGC_FP64_Vector3* start, c const double multiplier = sin(angle) * sqrt(1.0f / square_modulus); - bgc_fp64_versor_make(cos(angle), orthogonal_axis.x1 * multiplier, orthogonal_axis.x2 * multiplier, orthogonal_axis.x3 * multiplier, result); + bgc_fp64_versor_make(versor, cos(angle), orthogonal_axis.x1 * multiplier, orthogonal_axis.x2 * multiplier, orthogonal_axis.x3 * multiplier); return BGC_SOME_TURN; } @@ -217,34 +217,34 @@ static int _bgc_fp64_versor_make_direction_turn(const BGC_FP64_Vector3* start, c return BGC_OPPOSITE; } - bgc_fp64_versor_reset(result); + bgc_fp64_versor_reset(versor); return BGC_ZERO_TURN; } -int bgc_fp32_versor_make_direction_difference(const BGC_FP32_Vector3* start, const BGC_FP32_Vector3* end, BGC_FP32_Versor* result) +int bgc_fp32_versor_make_direction_difference(BGC_FP32_Versor* versor, const BGC_FP32_Vector3* start, const BGC_FP32_Vector3* end) { const float start_square_modulus = bgc_fp32_vector3_get_square_modulus(start); const float end_square_modulus = bgc_fp32_vector3_get_square_modulus(end); if (start_square_modulus <= BGC_FP32_SQUARE_EPSYLON || end_square_modulus <= BGC_FP32_SQUARE_EPSYLON) { - bgc_fp32_versor_reset(result); + bgc_fp32_versor_reset(versor); return BGC_ZERO_TURN; } - return _bgc_fp32_versor_make_direction_turn(start, end, start_square_modulus * end_square_modulus, result); + return _bgc_fp32_versor_make_direction_turn(versor, start, end, start_square_modulus * end_square_modulus); } -int bgc_fp64_versor_make_direction_difference(const BGC_FP64_Vector3* start, const BGC_FP64_Vector3* end, BGC_FP64_Versor* result) +int bgc_fp64_versor_make_direction_difference(BGC_FP64_Versor* versor, const BGC_FP64_Vector3* start, const BGC_FP64_Vector3* end) { const double start_square_modulus = bgc_fp64_vector3_get_square_modulus(start); const double end_square_modulus = bgc_fp64_vector3_get_square_modulus(end); if (start_square_modulus <= BGC_FP64_SQUARE_EPSYLON || end_square_modulus <= BGC_FP64_SQUARE_EPSYLON) { - bgc_fp64_versor_reset(result); + bgc_fp64_versor_reset(versor); return BGC_ZERO_TURN; } - return _bgc_fp64_versor_make_direction_turn(start, end, start_square_modulus * end_square_modulus, result); + return _bgc_fp64_versor_make_direction_turn(versor, start, end, start_square_modulus * end_square_modulus); } // =============== Set Directions =============== // @@ -290,17 +290,17 @@ static int _bgc_fp64_versor_validate_basis(const double primary_square_modulus, } int bgc_fp32_versor_make_basis_difference( + BGC_FP32_Versor* versor, const BGC_FP32_Vector3* initial_primary_direction, const BGC_FP32_Vector3* initial_auxiliary_direction, const BGC_FP32_Vector3* final_primary_direction, - const BGC_FP32_Vector3* final_auxiliary_direction, - BGC_FP32_Versor* result + const BGC_FP32_Vector3* final_auxiliary_direction ) { BGC_FP32_Vector3 initial_orthogonal_direction, turned_orthogonal_direction, final_orthogonal_direction; // Step 1: Validate initial basis: - bgc_fp32_vector3_get_cross_product(initial_primary_direction, initial_auxiliary_direction, &initial_orthogonal_direction); + bgc_fp32_vector3_get_cross_product(&initial_orthogonal_direction, initial_primary_direction, initial_auxiliary_direction); const float initial_primary_square_modulus = bgc_fp32_vector3_get_square_modulus(initial_primary_direction); const float initial_auxiliary_square_modulus = bgc_fp32_vector3_get_square_modulus(initial_auxiliary_direction); @@ -313,7 +313,7 @@ int bgc_fp32_versor_make_basis_difference( } // Step 1: Validate final basis: - bgc_fp32_vector3_get_cross_product(final_primary_direction, final_auxiliary_direction, &final_orthogonal_direction); + bgc_fp32_vector3_get_cross_product(&final_orthogonal_direction, final_primary_direction, final_auxiliary_direction); const float final_primary_square_modulus = bgc_fp32_vector3_get_square_modulus(final_primary_direction); const float final_auxiliary_square_modulus = bgc_fp32_vector3_get_square_modulus(final_auxiliary_direction); @@ -326,52 +326,52 @@ int bgc_fp32_versor_make_basis_difference( } // Step 3: Validate normalize orthogonal vectors: - bgc_fp32_vector3_divide(&initial_orthogonal_direction, sqrtf(initial_orthogonal_square_modulus), &initial_orthogonal_direction); - bgc_fp32_vector3_divide(&final_orthogonal_direction, sqrtf(final_orthogonal_square_modulus), &final_orthogonal_direction); + bgc_fp32_vector3_divide(&initial_orthogonal_direction, &initial_orthogonal_direction, sqrtf(initial_orthogonal_square_modulus)); + bgc_fp32_vector3_divide(&final_orthogonal_direction, &final_orthogonal_direction, sqrtf(final_orthogonal_square_modulus)); BGC_FP32_Versor turn1, turn2; // Step 4: Find 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); + int turn1_code = _bgc_fp32_versor_make_direction_turn(&turn1, initial_primary_direction, final_primary_direction, initial_primary_square_modulus * final_primary_square_modulus); if (turn1_code == BGC_OPPOSITE) { - bgc_fp32_versor_make(0.0f, initial_orthogonal_direction.x1, initial_orthogonal_direction.x2, initial_orthogonal_direction.x3, &turn1); + bgc_fp32_versor_make(&turn1, 0.0f, initial_orthogonal_direction.x1, initial_orthogonal_direction.x2, initial_orthogonal_direction.x3); } - bgc_fp32_versor_turn_vector(&turn1, &initial_orthogonal_direction, &turned_orthogonal_direction); + bgc_fp32_versor_turn_vector(&turned_orthogonal_direction, &turn1, &initial_orthogonal_direction); // Step 5: Find turn2: - int turn2_code = _bgc_fp32_versor_make_direction_turn(&turned_orthogonal_direction, &final_orthogonal_direction, 1.0f, &turn2); + int turn2_code = _bgc_fp32_versor_make_direction_turn(&turn2, &turned_orthogonal_direction, &final_orthogonal_direction, 1.0f); if (turn2_code == BGC_OPPOSITE) { const float turn2_multiplier = sqrtf(1.0f / final_primary_square_modulus); - bgc_fp32_versor_make(0.0f, + bgc_fp32_versor_make(&turn2, + 0.0f, final_primary_direction->x1 * turn2_multiplier, final_primary_direction->x2 * turn2_multiplier, - final_primary_direction->x3 * turn2_multiplier, - &turn2 + final_primary_direction->x3 * turn2_multiplier ); } // Step 6: Combine turn1 and turn2: - bgc_fp32_versor_combine(&turn1, &turn2, result); + bgc_fp32_versor_combine(versor, &turn1, &turn2); return BGC_SUCCESS; } int bgc_fp64_versor_make_basis_difference( + BGC_FP64_Versor* versor, const BGC_FP64_Vector3* initial_primary_direction, const BGC_FP64_Vector3* initial_auxiliary_direction, const BGC_FP64_Vector3* final_primary_direction, - const BGC_FP64_Vector3* final_auxiliary_direction, - BGC_FP64_Versor* result + const BGC_FP64_Vector3* final_auxiliary_direction ) { BGC_FP64_Vector3 initial_orthogonal_direction, turned_orthogonal_direction, final_orthogonal_direction; // Step 1: Validate initial basis: - bgc_fp64_vector3_get_cross_product(initial_primary_direction, initial_auxiliary_direction, &initial_orthogonal_direction); + bgc_fp64_vector3_get_cross_product(&initial_orthogonal_direction, initial_primary_direction, initial_auxiliary_direction); const double initial_primary_square_modulus = bgc_fp64_vector3_get_square_modulus(initial_primary_direction); const double initial_auxiliary_square_modulus = bgc_fp64_vector3_get_square_modulus(initial_auxiliary_direction); @@ -384,7 +384,7 @@ int bgc_fp64_versor_make_basis_difference( } // Step 1: Validate final basis: - bgc_fp64_vector3_get_cross_product(final_primary_direction, final_auxiliary_direction, &final_orthogonal_direction); + bgc_fp64_vector3_get_cross_product(&final_orthogonal_direction, final_primary_direction, final_auxiliary_direction); const double final_primary_square_modulus = bgc_fp64_vector3_get_square_modulus(final_primary_direction); const double final_auxiliary_square_modulus = bgc_fp64_vector3_get_square_modulus(final_auxiliary_direction); @@ -397,43 +397,43 @@ int bgc_fp64_versor_make_basis_difference( } // Step 3: Validate normalize orthogonal vectors: - bgc_fp64_vector3_divide(&initial_orthogonal_direction, sqrt(initial_orthogonal_square_modulus), &initial_orthogonal_direction); - bgc_fp64_vector3_divide(&final_orthogonal_direction, sqrt(final_orthogonal_square_modulus), &final_orthogonal_direction); + bgc_fp64_vector3_divide(&initial_orthogonal_direction, &initial_orthogonal_direction, sqrt(initial_orthogonal_square_modulus)); + bgc_fp64_vector3_divide(&final_orthogonal_direction, &final_orthogonal_direction, sqrt(final_orthogonal_square_modulus)); BGC_FP64_Versor turn1, turn2; // Step 4: Find 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); + int turn1_code = _bgc_fp64_versor_make_direction_turn(&turn1, initial_primary_direction, final_primary_direction, initial_primary_square_modulus * final_primary_square_modulus); if (turn1_code == BGC_OPPOSITE) { - bgc_fp64_versor_make(0.0, initial_orthogonal_direction.x1, initial_orthogonal_direction.x2, initial_orthogonal_direction.x3, &turn1); + bgc_fp64_versor_make(&turn1, 0.0, initial_orthogonal_direction.x1, initial_orthogonal_direction.x2, initial_orthogonal_direction.x3); } - bgc_fp64_versor_turn_vector(&turn1, &initial_orthogonal_direction, &turned_orthogonal_direction); + bgc_fp64_versor_turn_vector(&turned_orthogonal_direction, &turn1, &initial_orthogonal_direction); // Step 5: Find turn2: - int turn2_code = _bgc_fp64_versor_make_direction_turn(&turned_orthogonal_direction, &final_orthogonal_direction, 1.0f, &turn2); + int turn2_code = _bgc_fp64_versor_make_direction_turn(&turn2, &turned_orthogonal_direction, &final_orthogonal_direction, 1.0f); if (turn2_code == BGC_OPPOSITE) { const double turn2_multiplier = sqrt(1.0 / final_primary_square_modulus); - bgc_fp64_versor_make(0.0, + bgc_fp64_versor_make(&turn2, + 0.0, final_primary_direction->x1 * turn2_multiplier, final_primary_direction->x2 * turn2_multiplier, - final_primary_direction->x3 * turn2_multiplier, - &turn2 + final_primary_direction->x3 * turn2_multiplier ); } // Step 6: Combine turn1 and turn2: - bgc_fp64_versor_combine(&turn1, &turn2, result); + bgc_fp64_versor_combine(versor, &turn1, &turn2); return BGC_SUCCESS; } // =============== Get Exponation =============== // -void bgc_fp32_versor_get_exponation(const BGC_FP32_Versor* base, const float exponent, BGC_FP32_Versor* power) +void bgc_fp32_versor_get_exponation(BGC_FP32_Versor* power, const BGC_FP32_Versor* base, const float exponent) { const float square_vector = base->_x1 * base->_x1 + base->_x2 * base->_x2 + base->_x3 * base->_x3; @@ -448,10 +448,10 @@ void bgc_fp32_versor_get_exponation(const BGC_FP32_Versor* base, const float exp const float multiplier = sinf(angle) / vector_modulus; - bgc_fp32_versor_make(cosf(angle), base->_x1 * multiplier, base->_x2 * multiplier, base->_x3 * multiplier, power); + bgc_fp32_versor_make(power, cosf(angle), base->_x1 * multiplier, base->_x2 * multiplier, base->_x3 * multiplier); } -void bgc_fp64_versor_get_exponation(const BGC_FP64_Versor* base, const double exponent, BGC_FP64_Versor* power) +void bgc_fp64_versor_get_exponation(BGC_FP64_Versor* power, const BGC_FP64_Versor* base, const double exponent) { const double square_vector = base->_x1 * base->_x1 + base->_x2 * base->_x2 + base->_x3 * base->_x3; @@ -466,12 +466,12 @@ void bgc_fp64_versor_get_exponation(const BGC_FP64_Versor* base, const double ex const double multiplier = sin(angle) / vector_modulus; - bgc_fp64_versor_make(cos(angle), base->_x1 * multiplier, base->_x2 * multiplier, base->_x3 * multiplier, power); + bgc_fp64_versor_make(power, cos(angle), base->_x1 * multiplier, base->_x2 * multiplier, base->_x3 * multiplier); } // ============ Sphere Interpolation ============ // -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_fp32_versor_spherically_interpolate(BGC_FP32_Versor* interpolation, const BGC_FP32_Versor* start, const BGC_FP32_Versor* end, const float phase) { 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); @@ -481,8 +481,8 @@ void bgc_fp32_versor_spherically_interpolate(const BGC_FP32_Versor* start, const 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 - if (square_vector <= BGC_FP32_SQUARE_EPSYLON || square_vector != square_vector) { - bgc_fp32_versor_copy(end, result); + if (square_vector <= BGC_FP32_SQUARE_EPSYLON || isnan(square_vector)) { + bgc_fp32_versor_copy(interpolation, end); return; } @@ -498,15 +498,15 @@ void bgc_fp32_versor_spherically_interpolate(const BGC_FP32_Versor* start, const // Combining of starting orientation with the turning bgc_fp32_versor_make( + interpolation, (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_x2 * start->_s0 + turn_s0 * start->_x2) - (turn_x1 * start->_x3 - turn_x3 * start->_x1), - (turn_x3 * start->_s0 + turn_s0 * start->_x3) - (turn_x2 * start->_x1 - turn_x1 * start->_x2), - result + (turn_x3 * start->_s0 + turn_s0 * start->_x3) - (turn_x2 * start->_x1 - turn_x1 * start->_x2) ); } -void bgc_fp64_versor_spherically_interpolate(const BGC_FP64_Versor* start, const BGC_FP64_Versor* end, const double phase, BGC_FP64_Versor* result) +void bgc_fp64_versor_spherically_interpolate(BGC_FP64_Versor* interpolation, const BGC_FP64_Versor* start, const BGC_FP64_Versor* end, const double phase) { 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); @@ -516,8 +516,8 @@ void bgc_fp64_versor_spherically_interpolate(const BGC_FP64_Versor* start, const 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 - if (square_vector <= BGC_FP64_SQUARE_EPSYLON || square_vector != square_vector) { - bgc_fp64_versor_copy(end, result); + if (square_vector <= BGC_FP64_SQUARE_EPSYLON || isnan(square_vector)) { + bgc_fp64_versor_copy(interpolation, end); return; } @@ -533,22 +533,22 @@ void bgc_fp64_versor_spherically_interpolate(const BGC_FP64_Versor* start, const // Combining of starting orientation with the turning bgc_fp64_versor_make( + interpolation, (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_x2 * start->_s0 + turn_s0 * start->_x2) - (turn_x1 * start->_x3 - turn_x3 * start->_x1), - (turn_x3 * start->_s0 + turn_s0 * start->_x3) - (turn_x2 * start->_x1 - turn_x1 * start->_x2), - result + (turn_x3 * start->_s0 + turn_s0 * start->_x3) - (turn_x2 * start->_x1 - turn_x1 * start->_x2) ); } // ================ Get Rotation ================ // -void bgc_fp32_versor_get_rotation(const BGC_FP32_Versor* versor, BGC_FP32_Rotation3* result) +void bgc_fp32_versor_get_rotation(BGC_FP32_Rotation3* rotation, const BGC_FP32_Versor* versor) { const float square_modulus = versor->_x1 * versor->_x1 + versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3; if (square_modulus <= BGC_FP32_SQUARE_EPSYLON) { - bgc_fp32_rotation3_reset(result); + bgc_fp32_rotation3_reset(rotation); return; } @@ -556,19 +556,19 @@ void bgc_fp32_versor_get_rotation(const BGC_FP32_Versor* versor, BGC_FP32_Rotati const float multiplier = 1.0f / vector_modulus; - result->radians = 2.0f * atan2f(vector_modulus, versor->_s0); + rotation->radians = 2.0f * atan2f(vector_modulus, versor->_s0); - result->axis.x1 = versor->_x1 * multiplier; - result->axis.x2 = versor->_x2 * multiplier; - result->axis.x3 = versor->_x3 * multiplier; + rotation->axis.x1 = versor->_x1 * multiplier; + rotation->axis.x2 = versor->_x2 * multiplier; + rotation->axis.x3 = versor->_x3 * multiplier; } -void bgc_fp64_versor_get_rotation(const BGC_FP64_Versor* versor, BGC_FP64_Rotation3* result) +void bgc_fp64_versor_get_rotation(BGC_FP64_Rotation3* rotation, const BGC_FP64_Versor* versor) { const double square_modulus = versor->_x1 * versor->_x1 + versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3; if (square_modulus <= BGC_FP64_SQUARE_EPSYLON) { - bgc_fp64_rotation3_reset(result); + bgc_fp64_rotation3_reset(rotation); return; } @@ -576,9 +576,9 @@ void bgc_fp64_versor_get_rotation(const BGC_FP64_Versor* versor, BGC_FP64_Rotati const double multiplier = 1.0 / vector_modulus; - result->radians = 2.0 * atan2(vector_modulus, versor->_s0); + rotation->radians = 2.0 * atan2(vector_modulus, versor->_s0); - result->axis.x1 = versor->_x1 * multiplier; - result->axis.x2 = versor->_x2 * multiplier; - result->axis.x3 = versor->_x3 * multiplier; + rotation->axis.x1 = versor->_x1 * multiplier; + rotation->axis.x2 = versor->_x2 * multiplier; + rotation->axis.x3 = versor->_x3 * multiplier; } diff --git a/basic-geometry/versor.h b/basic-geometry/versor.h index 570dbae..ee3b4de 100644 --- a/basic-geometry/versor.h +++ b/basic-geometry/versor.h @@ -62,7 +62,7 @@ void _bgc_fp32_versor_normalize(BGC_FP32_Versor* twin); void _bgc_fp64_versor_normalize(BGC_FP64_Versor* twin); -inline void bgc_fp32_versor_make(const float s0, const float x1, const float x2, const float x3, BGC_FP32_Versor* versor) +inline void bgc_fp32_versor_make(BGC_FP32_Versor* versor, const float s0, const float x1, const float x2, const float x3) { versor->_s0 = s0; versor->_x1 = x1; @@ -76,7 +76,7 @@ inline void bgc_fp32_versor_make(const float s0, const float x1, const float x2, } } -inline void bgc_fp64_versor_make(const double s0, const double x1, const double x2, const double x3, BGC_FP64_Versor* versor) +inline void bgc_fp64_versor_make(BGC_FP64_Versor* versor, const double s0, const double x1, const double x2, const double x3) { versor->_s0 = s0; versor->_x1 = x1; @@ -92,49 +92,49 @@ inline void bgc_fp64_versor_make(const double s0, const double x1, const double // ================== Set Turn ================== // -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_fp32_versor_make_for_turn(BGC_FP32_Versor* versor, const float x1, const float x2, const float x3, const float angle, const int unit); -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); +void bgc_fp64_versor_make_for_turn(BGC_FP64_Versor* versor, const double x1, const double x2, const double x3, const double angle, const int unit); // ================ Set Rotation ================ // -inline void bgc_fp32_versor_make_for_rotation(const BGC_FP32_Rotation3* rotation, BGC_FP32_Versor* result) +inline void bgc_fp32_versor_make_for_rotation(BGC_FP32_Versor* versor, const BGC_FP32_Rotation3* rotation) { - bgc_fp32_versor_make_for_turn(rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BGC_ANGLE_UNIT_RADIANS, result); + bgc_fp32_versor_make_for_turn(versor, rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BGC_ANGLE_UNIT_RADIANS); } -inline void bgc_fp64_versor_make_for_rotation(const BGC_FP64_Rotation3* rotation, BGC_FP64_Versor* result) +inline void bgc_fp64_versor_make_for_rotation(BGC_FP64_Versor* versor, const BGC_FP64_Rotation3* rotation) { - bgc_fp64_versor_make_for_turn(rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BGC_ANGLE_UNIT_RADIANS, result); + bgc_fp64_versor_make_for_turn(versor, rotation->axis.x1, rotation->axis.x2, rotation->axis.x3, rotation->radians, BGC_ANGLE_UNIT_RADIANS); } // ========= Make Direction Difference ========== // -int bgc_fp32_versor_make_direction_difference(const BGC_FP32_Vector3* start, const BGC_FP32_Vector3* end, BGC_FP32_Versor* result); +int bgc_fp32_versor_make_direction_difference(BGC_FP32_Versor* difference, const BGC_FP32_Vector3* start, const BGC_FP32_Vector3* end); -int bgc_fp64_versor_make_direction_difference(const BGC_FP64_Vector3* start, const BGC_FP64_Vector3* end, BGC_FP64_Versor* result); +int bgc_fp64_versor_make_direction_difference(BGC_FP64_Versor* difference, const BGC_FP64_Vector3* start, const BGC_FP64_Vector3* end); // =============== Set Directions =============== // int bgc_fp32_versor_make_basis_difference( + BGC_FP32_Versor* versor, const BGC_FP32_Vector3* initial_primary_direction, const BGC_FP32_Vector3* initial_auxiliary_direction, const BGC_FP32_Vector3* final_primary_direction, - const BGC_FP32_Vector3* final_auxiliary_direction, - BGC_FP32_Versor* result + const BGC_FP32_Vector3* final_auxiliary_direction ); int bgc_fp64_versor_make_basis_difference( + BGC_FP64_Versor* versor, const BGC_FP64_Vector3* initial_primary_direction, const BGC_FP64_Vector3* initial_auxiliary_direction, const BGC_FP64_Vector3* final_primary_direction, - const BGC_FP64_Vector3* final_auxiliary_direction, - BGC_FP64_Versor* result + const BGC_FP64_Vector3* final_auxiliary_direction ); // ==================== Copy ==================== // -inline void bgc_fp32_versor_copy(const BGC_FP32_Versor* source, BGC_FP32_Versor* destination) +inline void bgc_fp32_versor_copy(BGC_FP32_Versor* destination, const BGC_FP32_Versor* source) { destination->_s0 = source->_s0; destination->_x1 = source->_x1; @@ -142,7 +142,7 @@ inline void bgc_fp32_versor_copy(const BGC_FP32_Versor* source, BGC_FP32_Versor* destination->_x3 = source->_x3; } -inline void bgc_fp64_versor_copy(const BGC_FP64_Versor* source, BGC_FP64_Versor* destination) +inline void bgc_fp64_versor_copy(BGC_FP64_Versor* destination, const BGC_FP64_Versor* source) { destination->_s0 = source->_s0; destination->_x1 = source->_x1; @@ -202,25 +202,25 @@ inline int bgc_fp64_versor_is_idle(const BGC_FP64_Versor* versor) // ================== Convert =================== // -inline void bgc_fp64_versor_convert_to_fp32(const BGC_FP64_Versor* source, BGC_FP32_Versor* destination) -{ - bgc_fp32_versor_make( - (float)source->_s0, - (float)source->_x1, - (float)source->_x2, - (float)source->_x3, - destination - ); -} - -inline void bgc_fp32_versor_convert_to_fp64(const BGC_FP32_Versor* source, BGC_FP64_Versor* destination) +inline void bgc_fp32_versor_convert_to_fp64(BGC_FP64_Versor* destination, const BGC_FP32_Versor* source) { bgc_fp64_versor_make( + destination, source->_s0, source->_x1, source->_x2, - source->_x3, - destination + source->_x3 + ); +} + +inline void bgc_fp64_versor_convert_to_fp32(BGC_FP32_Versor* destination, const BGC_FP64_Versor* source) +{ + bgc_fp32_versor_make( + destination, + (float)source->_s0, + (float)source->_x1, + (float)source->_x2, + (float)source->_x3 ); } @@ -246,7 +246,7 @@ inline void bgc_fp64_versor_shorten(BGC_FP64_Versor* versor) } } -inline void bgc_fp32_versor_get_shortened(const BGC_FP32_Versor* versor, BGC_FP32_Versor* shortened) +inline void bgc_fp32_versor_get_shortened(BGC_FP32_Versor* shortened, const BGC_FP32_Versor* versor) { if (versor->_s0 >= 0.0f) { shortened->_s0 = versor->_s0; @@ -262,7 +262,7 @@ inline void bgc_fp32_versor_get_shortened(const BGC_FP32_Versor* versor, BGC_FP3 shortened->_x3 = -versor->_x3; } -inline void bgc_fp64_versor_get_shortened(const BGC_FP64_Versor* versor, BGC_FP64_Versor* shortened) +inline void bgc_fp64_versor_get_shortened(BGC_FP64_Versor* shortened, const BGC_FP64_Versor* versor) { if (versor->_s0 >= 0.0) { shortened->_s0 = versor->_s0; @@ -296,20 +296,20 @@ inline void bgc_fp64_versor_alternate(BGC_FP64_Versor* versor) versor->_x3 = -versor->_x3; } -inline void bgc_fp32_versor_get_alternative(const BGC_FP32_Versor* versor, BGC_FP32_Versor* opposite) +inline void bgc_fp32_versor_get_alternative(BGC_FP32_Versor* alternative, const BGC_FP32_Versor* versor) { - opposite->_s0 = -versor->_s0; - opposite->_x1 = -versor->_x1; - opposite->_x2 = -versor->_x2; - opposite->_x3 = -versor->_x3; + alternative->_s0 = -versor->_s0; + alternative->_x1 = -versor->_x1; + alternative->_x2 = -versor->_x2; + alternative->_x3 = -versor->_x3; } -inline void bgc_fp64_versor_get_alternative(const BGC_FP64_Versor* versor, BGC_FP64_Versor* opposite) +inline void bgc_fp64_versor_get_alternative(BGC_FP64_Versor* alternative, const BGC_FP64_Versor* versor) { - opposite->_s0 = -versor->_s0; - opposite->_x1 = -versor->_x1; - opposite->_x2 = -versor->_x2; - opposite->_x3 = -versor->_x3; + alternative->_s0 = -versor->_s0; + alternative->_x1 = -versor->_x1; + alternative->_x2 = -versor->_x2; + alternative->_x3 = -versor->_x3; } // =================== Invert =================== // @@ -328,7 +328,7 @@ inline void bgc_fp64_versor_revert(BGC_FP64_Versor* versor) versor->_x3 = -versor->_x3; } -inline void bgc_fp32_versor_get_reverse(const BGC_FP32_Versor* versor, BGC_FP32_Versor* inverse) +inline void bgc_fp32_versor_get_reverse(BGC_FP32_Versor* inverse, const BGC_FP32_Versor* versor) { inverse->_s0 = versor->_s0; inverse->_x1 = -versor->_x1; @@ -336,7 +336,7 @@ inline void bgc_fp32_versor_get_reverse(const BGC_FP32_Versor* versor, BGC_FP32_ inverse->_x3 = -versor->_x3; } -inline void bgc_fp64_versor_get_reverse(const BGC_FP64_Versor* versor, BGC_FP64_Versor* inverse) +inline void bgc_fp64_versor_get_reverse(BGC_FP64_Versor* inverse, const BGC_FP64_Versor* versor) { inverse->_s0 = versor->_s0; inverse->_x1 = -versor->_x1; @@ -346,37 +346,37 @@ inline void bgc_fp64_versor_get_reverse(const BGC_FP64_Versor* versor, BGC_FP64_ // =============== Get Exponation =============== // -void bgc_fp32_versor_get_exponation(const BGC_FP32_Versor* base, const float exponent, BGC_FP32_Versor* power); +void bgc_fp32_versor_get_exponation(BGC_FP32_Versor* power, const BGC_FP32_Versor* base, const float exponent); -void bgc_fp64_versor_get_exponation(const BGC_FP64_Versor* base, const double exponent, BGC_FP64_Versor* power); +void bgc_fp64_versor_get_exponation(BGC_FP64_Versor* power, const BGC_FP64_Versor* base, const double exponent); // ================ Combination ================= // -inline void bgc_fp32_versor_combine(const BGC_FP32_Versor* first, const BGC_FP32_Versor* second, BGC_FP32_Versor* result) +inline void bgc_fp32_versor_combine(BGC_FP32_Versor* combination, const BGC_FP32_Versor* first, const BGC_FP32_Versor* second) { bgc_fp32_versor_make( + combination, (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->_x2 * first->_s0 + second->_s0 * first->_x2) - (second->_x1 * first->_x3 - second->_x3 * first->_x1), - (second->_x3 * first->_s0 + second->_s0 * first->_x3) - (second->_x2 * first->_x1 - second->_x1 * first->_x2), - result + (second->_x3 * first->_s0 + second->_s0 * first->_x3) - (second->_x2 * first->_x1 - second->_x1 * first->_x2) ); } -inline void bgc_fp64_versor_combine(const BGC_FP64_Versor* first, const BGC_FP64_Versor* second, BGC_FP64_Versor* result) +inline void bgc_fp64_versor_combine(BGC_FP64_Versor* combination, const BGC_FP64_Versor* first, const BGC_FP64_Versor* second) { bgc_fp64_versor_make( + combination, (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->_x2 * first->_s0 + second->_s0 * first->_x2) - (second->_x1 * first->_x3 - second->_x3 * first->_x1), - (second->_x3 * first->_s0 + second->_s0 * first->_x3) - (second->_x2 * first->_x1 - second->_x1 * first->_x2), - result + (second->_x3 * first->_s0 + second->_s0 * first->_x3) - (second->_x2 * first->_x1 - second->_x1 * first->_x2) ); } // ============ Combination of three ============ // -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) +inline void bgc_fp32_versor_combine3(BGC_FP32_Versor* combination, const BGC_FP32_Versor* first, const BGC_FP32_Versor* second, const BGC_FP32_Versor* third) { 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); @@ -384,15 +384,15 @@ inline void bgc_fp32_versor_combine3(const BGC_FP32_Versor* first, const BGC_FP3 const float x3 = (second->_x3 * first->_s0 + second->_s0 * first->_x3) - (second->_x2 * first->_x1 - second->_x1 * first->_x2); bgc_fp32_versor_make( + combination, (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->_x2 * s0 + third->_s0 * x2) - (third->_x1 * x3 - third->_x3 * x1), - (third->_x3 * s0 + third->_s0 * x3) - (third->_x2 * x1 - third->_x1 * x2), - result + (third->_x3 * s0 + third->_s0 * x3) - (third->_x2 * x1 - third->_x1 * x2) ); } -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) +inline void bgc_fp64_versor_combine3(BGC_FP64_Versor* combination, const BGC_FP64_Versor* first, const BGC_FP64_Versor* second, const BGC_FP64_Versor* third) { 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); @@ -400,53 +400,53 @@ inline void bgc_fp64_versor_combine3(const BGC_FP64_Versor* first, const BGC_FP6 const double x3 = (second->_x3 * first->_s0 + second->_s0 * first->_x3) - (second->_x2 * first->_x1 - second->_x1 * first->_x2); bgc_fp64_versor_make( + combination, (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->_x2 * s0 + third->_s0 * x2) - (third->_x1 * x3 - third->_x3 * x1), - (third->_x3 * s0 + third->_s0 * x3) - (third->_x2 * x1 - third->_x1 * x2), - result + (third->_x3 * s0 + third->_s0 * x3) - (third->_x2 * x1 - third->_x1 * x2) ); } // ================= Exclusion ================== // -inline void bgc_fp32_versor_exclude(const BGC_FP32_Versor* base, const BGC_FP32_Versor* excludant, BGC_FP32_Versor* difference) +inline void bgc_fp32_versor_exclude(BGC_FP32_Versor* difference, const BGC_FP32_Versor* base, const BGC_FP32_Versor* excludant) { bgc_fp32_versor_make( + difference, (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->_x2 * excludant->_s0 + base->_x1 * excludant->_x3) - (base->_s0 * excludant->_x2 + base->_x3 * excludant->_x1), - (base->_x3 * excludant->_s0 + base->_x2 * excludant->_x1) - (base->_s0 * excludant->_x3 + base->_x1 * excludant->_x2), - difference + (base->_x3 * excludant->_s0 + base->_x2 * excludant->_x1) - (base->_s0 * excludant->_x3 + base->_x1 * excludant->_x2) ); } -inline void bgc_fp64_versor_exclude(const BGC_FP64_Versor* base, const BGC_FP64_Versor* excludant, BGC_FP64_Versor* difference) +inline void bgc_fp64_versor_exclude(BGC_FP64_Versor* difference, const BGC_FP64_Versor* base, const BGC_FP64_Versor* excludant) { bgc_fp64_versor_make( + difference, (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->_x2 * excludant->_s0 + base->_x1 * excludant->_x3) - (base->_s0 * excludant->_x2 + base->_x3 * excludant->_x1), - (base->_x3 * excludant->_s0 + base->_x2 * excludant->_x1) - (base->_s0 * excludant->_x3 + base->_x1 * excludant->_x2), - difference + (base->_x3 * excludant->_s0 + base->_x2 * excludant->_x1) - (base->_s0 * excludant->_x3 + base->_x1 * excludant->_x2) ); } // ============ Sphere Interpolation ============ // -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_fp32_versor_spherically_interpolate(BGC_FP32_Versor* interpolation, const BGC_FP32_Versor* start, const BGC_FP32_Versor* end, const float phase); -void bgc_fp64_versor_spherically_interpolate(const BGC_FP64_Versor* start, const BGC_FP64_Versor* end, const double phase, BGC_FP64_Versor* result); +void bgc_fp64_versor_spherically_interpolate(BGC_FP64_Versor* interpolation, const BGC_FP64_Versor* start, const BGC_FP64_Versor* end, const double phase); // ================ Get Rotation ================ // -void bgc_fp32_versor_get_rotation(const BGC_FP32_Versor* versor, BGC_FP32_Rotation3* result); +void bgc_fp32_versor_get_rotation(BGC_FP32_Rotation3* rotation, const BGC_FP32_Versor* versor); -void bgc_fp64_versor_get_rotation(const BGC_FP64_Versor* versor, BGC_FP64_Rotation3* result); +void bgc_fp64_versor_get_rotation(BGC_FP64_Rotation3* rotation, const BGC_FP64_Versor* versor); // ============ Get Rotation Matrix ============= // -inline void bgc_fp32_versor_get_rotation_matrix(const BGC_FP32_Versor* versor, BGC_FP32_Matrix3x3* matrix) +inline void bgc_fp32_versor_get_rotation_matrix(BGC_FP32_Matrix3x3* matrix, const BGC_FP32_Versor* versor) { const float s0s0 = versor->_s0 * versor->_s0; const float x1x1 = versor->_x1 * versor->_x1; @@ -473,7 +473,7 @@ inline void bgc_fp32_versor_get_rotation_matrix(const BGC_FP32_Versor* versor, B matrix->r1c3 = 2.0f * (x1x3 + s0x2); } -inline void bgc_fp64_versor_get_rotation_matrix(const BGC_FP64_Versor* versor, BGC_FP64_Matrix3x3* matrix) +inline void bgc_fp64_versor_get_rotation_matrix(BGC_FP64_Matrix3x3* matrix, const BGC_FP64_Versor* versor) { const double s0s0 = versor->_s0 * versor->_s0; const double x1x1 = versor->_x1 * versor->_x1; @@ -502,7 +502,7 @@ inline void bgc_fp64_versor_get_rotation_matrix(const BGC_FP64_Versor* versor, B // ============= Get Reverse Matrix ============= // -inline void bgc_fp32_versor_get_reverse_matrix(const BGC_FP32_Versor* versor, BGC_FP32_Matrix3x3* matrix) +inline void bgc_fp32_versor_get_reverse_matrix(BGC_FP32_Matrix3x3* matrix, const BGC_FP32_Versor* versor) { const float s0s0 = versor->_s0 * versor->_s0; const float x1x1 = versor->_x1 * versor->_x1; @@ -529,7 +529,7 @@ inline void bgc_fp32_versor_get_reverse_matrix(const BGC_FP32_Versor* versor, BG matrix->r1c3 = 2.0f * (x1x3 - s0x2); } -inline void bgc_fp64_versor_get_reverse_matrix(const BGC_FP64_Versor* versor, BGC_FP64_Matrix3x3* matrix) +inline void bgc_fp64_versor_get_reverse_matrix(BGC_FP64_Matrix3x3* matrix, const BGC_FP64_Versor* versor) { const double s0s0 = versor->_s0 * versor->_s0; const double x1x1 = versor->_x1 * versor->_x1; @@ -558,21 +558,21 @@ inline void bgc_fp64_versor_get_reverse_matrix(const BGC_FP64_Versor* versor, BG // ============= Get Both Matrixes ============== // -inline void bgc_fp32_versor_get_both_matrices(const BGC_FP32_Versor* versor, BGC_FP32_Matrix3x3* rotation, BGC_FP32_Matrix3x3* reverse) +inline void bgc_fp32_versor_get_both_matrices(BGC_FP32_Matrix3x3* rotation, BGC_FP32_Matrix3x3* reverse, const BGC_FP32_Versor* versor) { - bgc_fp32_versor_get_reverse_matrix(versor, reverse); - bgc_fp32_matrix3x3_get_transposed(reverse, rotation); + bgc_fp32_versor_get_reverse_matrix(reverse, versor); + bgc_fp32_matrix3x3_get_transposed(rotation, reverse); } -inline void bgc_fp64_versor_get_both_matrices(const BGC_FP64_Versor* versor, BGC_FP64_Matrix3x3* rotation, BGC_FP64_Matrix3x3* reverse) +inline void bgc_fp64_versor_get_both_matrices(BGC_FP64_Matrix3x3* rotation, BGC_FP64_Matrix3x3* reverse, const BGC_FP64_Versor* versor) { - bgc_fp64_versor_get_reverse_matrix(versor, reverse); - bgc_fp64_matrix3x3_get_transposed(reverse, rotation); + bgc_fp64_versor_get_reverse_matrix(reverse, versor); + bgc_fp64_matrix3x3_get_transposed(rotation, reverse); } // ================ Turn Vector ================= // -inline void bgc_fp32_versor_turn_vector(const BGC_FP32_Versor* versor, const BGC_FP32_Vector3* vector, BGC_FP32_Vector3* result) +inline void bgc_fp32_versor_turn_vector(BGC_FP32_Vector3* turned_vector, const BGC_FP32_Versor* versor, const BGC_FP32_Vector3* vector) { 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); @@ -582,12 +582,12 @@ inline void bgc_fp32_versor_turn_vector(const BGC_FP32_Versor* versor, const BGC const float x2 = (vector->x2 + tx2 * versor->_s0) + (versor->_x3 * tx1 - versor->_x1 * tx3); const float x3 = (vector->x3 + tx3 * versor->_s0) + (versor->_x1 * tx2 - versor->_x2 * tx1); - result->x1 = x1; - result->x2 = x2; - result->x3 = x3; + turned_vector->x1 = x1; + turned_vector->x2 = x2; + turned_vector->x3 = x3; } -inline void bgc_fp64_versor_turn_vector(const BGC_FP64_Versor* versor, const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* result) +inline void bgc_fp64_versor_turn_vector(BGC_FP64_Vector3* turned_vector, const BGC_FP64_Versor* versor, const BGC_FP64_Vector3* vector) { 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); @@ -597,14 +597,14 @@ inline void bgc_fp64_versor_turn_vector(const BGC_FP64_Versor* versor, const BGC const double x2 = (vector->x2 + tx2 * versor->_s0) + (versor->_x3 * tx1 - versor->_x1 * tx3); const double x3 = (vector->x3 + tx3 * versor->_s0) + (versor->_x1 * tx2 - versor->_x2 * tx1); - result->x1 = x1; - result->x2 = x2; - result->x3 = x3; + turned_vector->x1 = x1; + turned_vector->x2 = x2; + turned_vector->x3 = x3; } // ============== Turn Vector Back ============== // -inline void bgc_fp32_versor_turn_vector_back(const BGC_FP32_Versor* versor, const BGC_FP32_Vector3* vector, BGC_FP32_Vector3* result) +inline void bgc_fp32_versor_turn_vector_back(BGC_FP32_Vector3* turned_vector, const BGC_FP32_Versor* versor, const BGC_FP32_Vector3* vector) { 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); @@ -614,12 +614,12 @@ inline void bgc_fp32_versor_turn_vector_back(const BGC_FP32_Versor* versor, cons const float x2 = (vector->x2 - tx2 * versor->_s0) + (versor->_x3 * tx1 - versor->_x1 * tx3); const float x3 = (vector->x3 - tx3 * versor->_s0) + (versor->_x1 * tx2 - versor->_x2 * tx1); - result->x1 = x1; - result->x2 = x2; - result->x3 = x3; + turned_vector->x1 = x1; + turned_vector->x2 = x2; + turned_vector->x3 = x3; } -inline void bgc_fp64_versor_turn_vector_back(const BGC_FP64_Versor* versor, const BGC_FP64_Vector3* vector, BGC_FP64_Vector3* result) +inline void bgc_fp64_versor_turn_vector_back(BGC_FP64_Vector3* turned_vector, const BGC_FP64_Versor* versor, const BGC_FP64_Vector3* vector) { 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); @@ -629,9 +629,9 @@ inline void bgc_fp64_versor_turn_vector_back(const BGC_FP64_Versor* versor, cons const double x2 = (vector->x2 - tx2 * versor->_s0) + (versor->_x3 * tx1 - versor->_x1 * tx3); const double x3 = (vector->x3 - tx3 * versor->_s0) + (versor->_x1 * tx2 - versor->_x2 * tx1); - result->x1 = x1; - result->x2 = x2; - result->x3 = x3; + turned_vector->x1 = x1; + turned_vector->x2 = x2; + turned_vector->x3 = x3; } // ================== Are Close ================= // From 043cc72c8132cad507d5e12770f0ee6cc71926c1 Mon Sep 17 00:00:00 2001 From: Andrey Pokidov Date: Mon, 2 Feb 2026 20:44:10 +0700 Subject: [PATCH 3/9] =?UTF-8?q?=D0=9D=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F,=20=D0=B0=20=D1=82=D0=B0=D0=BA=D0=B6=D0=B5?= =?UTF-8?q?=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=B3=D0=BE=D0=BC=D0=BE=D0=B3=D0=B5=D0=BD=D0=BD=D0=BE=D0=B3?= =?UTF-8?q?=D0=BE=20=D1=82=D1=80=D1=91=D1=85=D0=BC=D0=B5=D1=80=D0=BD=D0=BE?= =?UTF-8?q?=D0=B3=D0=BE=20=D0=B2=D0=B5=D0=BA=D1=82=D0=BE=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Geometry.workspace | 2 +- basic-geometry-test/basic-geometry-test.cbp | 180 ----- basic-geometry/basic-geometry.cbp | 12 +- basic-geometry/complex.c | 4 +- basic-geometry/complex.h | 34 +- basic-geometry/cotes-number.c | 4 +- basic-geometry/cotes-number.h | 36 +- basic-geometry/hg-vector3.c | 28 + basic-geometry/hg-vector3.h | 190 +++++ basic-geometry/matrices.h | 388 +++++----- basic-geometry/matrix2x2.h | 396 +++++----- basic-geometry/matrix2x3.h | 404 +++++----- basic-geometry/matrix3x2.h | 404 +++++----- basic-geometry/matrix3x3.c | 72 +- basic-geometry/matrix3x3.h | 780 ++++++++++---------- basic-geometry/quaternion.c | 4 +- basic-geometry/quaternion.h | 112 +-- basic-geometry/slerp.c | 4 +- basic-geometry/utilities.h | 36 +- basic-geometry/vector2.c | 8 +- basic-geometry/vector2.h | 56 +- basic-geometry/vector3.c | 8 +- basic-geometry/vector3.h | 48 +- basic-geometry/versor.c | 40 +- basic-geometry/versor.h | 80 +- 25 files changed, 1686 insertions(+), 1644 deletions(-) create mode 100644 basic-geometry/hg-vector3.c create mode 100644 basic-geometry/hg-vector3.h diff --git a/Geometry.workspace b/Geometry.workspace index e53afab..cd8d7cc 100644 --- a/Geometry.workspace +++ b/Geometry.workspace @@ -1,12 +1,12 @@ + - diff --git a/basic-geometry-test/basic-geometry-test.cbp b/basic-geometry-test/basic-geometry-test.cbp index 77109a6..74356e5 100644 --- a/basic-geometry-test/basic-geometry-test.cbp +++ b/basic-geometry-test/basic-geometry-test.cbp @@ -51,186 +51,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/basic-geometry/basic-geometry.cbp b/basic-geometry/basic-geometry.cbp index bed02d1..ef4457c 100644 --- a/basic-geometry/basic-geometry.cbp +++ b/basic-geometry/basic-geometry.cbp @@ -64,6 +64,14 @@ + + + + + + @@ -80,10 +88,6 @@ - - - diff --git a/basic-geometry/complex.c b/basic-geometry/complex.c index b5f6788..af68316 100644 --- a/basic-geometry/complex.c +++ b/basic-geometry/complex.c @@ -90,7 +90,7 @@ void bgc_fp32_complex_get_exponation(BGC_FP32_Complex* power, const BGC_FP32_Com { const float square_modulus = bgc_fp32_complex_get_square_modulus(base); - if (square_modulus <= BGC_FP32_SQUARE_EPSYLON) { + if (square_modulus <= BGC_FP32_SQUARE_EPSILON) { power->real = 0.0f; power->imaginary = 0.0f; return; @@ -110,7 +110,7 @@ void bgc_fp64_complex_get_exponation(BGC_FP64_Complex* power, const BGC_FP64_Com { const double square_modulus = bgc_fp64_complex_get_square_modulus(base); - if (square_modulus <= BGC_FP64_SQUARE_EPSYLON) { + if (square_modulus <= BGC_FP64_SQUARE_EPSILON) { power->real = 0.0; power->imaginary = 0.0; return; diff --git a/basic-geometry/complex.h b/basic-geometry/complex.h index 6bd26a2..d1e3587 100644 --- a/basic-geometry/complex.h +++ b/basic-geometry/complex.h @@ -70,12 +70,12 @@ inline double bgc_fp64_complex_get_modulus(const BGC_FP64_Complex* number) inline int bgc_fp32_complex_is_zero(const BGC_FP32_Complex* number) { - return bgc_fp32_complex_get_square_modulus(number) <= BGC_FP32_SQUARE_EPSYLON; + return bgc_fp32_complex_get_square_modulus(number) <= BGC_FP32_SQUARE_EPSILON; } inline int bgc_fp64_complex_is_zero(const BGC_FP64_Complex* number) { - return bgc_fp64_complex_get_square_modulus(number) <= BGC_FP64_SQUARE_EPSYLON; + return bgc_fp64_complex_get_square_modulus(number) <= BGC_FP64_SQUARE_EPSILON; } inline int bgc_fp32_complex_is_unit(const BGC_FP32_Complex* number) @@ -178,7 +178,7 @@ inline int bgc_fp32_complex_normalize(BGC_FP32_Complex* number) return 1; } - if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) { return 0; } @@ -198,7 +198,7 @@ inline int bgc_fp64_complex_normalize(BGC_FP64_Complex* number) return 1; } - if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) { return 0; } @@ -220,7 +220,7 @@ inline int bgc_fp32_complex_get_normalized(BGC_FP32_Complex* normalized, const B return 1; } - if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) { normalized->real = 0.0f; normalized->imaginary = 0.0f; return 0; @@ -244,7 +244,7 @@ inline int bgc_fp64_complex_get_normalized(BGC_FP64_Complex* normalized, const B return 1; } - if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) { normalized->real = 0.0; normalized->imaginary = 0.0; return 0; @@ -288,7 +288,7 @@ inline int bgc_fp32_complex_get_inverse(BGC_FP32_Complex* inverse, const BGC_FP3 { const float square_modulus = bgc_fp32_complex_get_square_modulus(number); - if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) { return 0; } @@ -304,7 +304,7 @@ inline int bgc_fp64_complex_get_inverse(BGC_FP64_Complex* inverse, const BGC_FP6 { const double square_modulus = bgc_fp64_complex_get_square_modulus(number); - if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) { return 0; } @@ -368,7 +368,7 @@ inline void bgc_fp32_complex_subtract(BGC_FP32_Complex* difference, const BGC_FP difference->imaginary = minuend->imaginary - subtrahend->imaginary; } -inline void bgc_fp64_complex_subtract(const BGC_FP64_Complex* minuend, const BGC_FP64_Complex* subtrahend, BGC_FP64_Complex* difference) +inline void bgc_fp64_complex_subtract(BGC_FP64_Complex* difference, const BGC_FP64_Complex* minuend, const BGC_FP64_Complex* subtrahend) { difference->real = minuend->real - subtrahend->real; difference->imaginary = minuend->imaginary - subtrahend->imaginary; @@ -414,7 +414,7 @@ inline int bgc_fp32_complex_get_ratio(BGC_FP32_Complex* quotient, const BGC_FP32 { const float square_modulus = bgc_fp32_complex_get_square_modulus(divisor); - if (square_modulus <= BGC_FP32_SQUARE_EPSYLON) { + if (square_modulus <= BGC_FP32_SQUARE_EPSILON) { return 0; } @@ -433,7 +433,7 @@ inline int bgc_fp64_complex_get_ratio(BGC_FP64_Complex* quotient, const BGC_FP64 { const double square_modulus = bgc_fp64_complex_get_square_modulus(divisor); - if (square_modulus <= BGC_FP64_SQUARE_EPSYLON) { + if (square_modulus <= BGC_FP64_SQUARE_EPSILON) { return 0; } @@ -518,11 +518,11 @@ inline int bgc_fp32_complex_are_close(const BGC_FP32_Complex* number1, const BGC const float square_distance = d_real * d_real + d_imaginary * d_imaginary; - if (square_modulus1 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT) { - return square_distance <= BGC_FP32_SQUARE_EPSYLON; + if (square_modulus1 <= BGC_FP32_EPSILON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP32_EPSILON_EFFECTIVENESS_LIMIT) { + return square_distance <= BGC_FP32_SQUARE_EPSILON; } - return square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus2; + return square_distance <= BGC_FP32_SQUARE_EPSILON * square_modulus1 && square_distance <= BGC_FP32_SQUARE_EPSILON * square_modulus2; } inline int bgc_fp64_complex_are_close(const BGC_FP64_Complex* number1, const BGC_FP64_Complex* number2) @@ -535,11 +535,11 @@ inline int bgc_fp64_complex_are_close(const BGC_FP64_Complex* number1, const BGC const double square_distance = d_real * d_real + d_imaginary * d_imaginary; - if (square_modulus1 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT) { - return square_distance <= BGC_FP64_SQUARE_EPSYLON; + if (square_modulus1 <= BGC_FP64_EPSILON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP64_EPSILON_EFFECTIVENESS_LIMIT) { + return square_distance <= BGC_FP64_SQUARE_EPSILON; } - return square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus2; + return square_distance <= BGC_FP64_SQUARE_EPSILON * square_modulus1 && square_distance <= BGC_FP64_SQUARE_EPSILON * square_modulus2; } #endif diff --git a/basic-geometry/cotes-number.c b/basic-geometry/cotes-number.c index f7b99a7..610e15b 100644 --- a/basic-geometry/cotes-number.c +++ b/basic-geometry/cotes-number.c @@ -62,7 +62,7 @@ void _bgc_fp32_cotes_number_normalize(BGC_FP32_CotesNumber* number) { const float square_modulus = number->_cos * number->_cos + number->_sin * number->_sin; - if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) { number->_cos = 1.0f; number->_sin = 0.0f; return; @@ -78,7 +78,7 @@ void _bgc_fp64_cotes_number_normalize(BGC_FP64_CotesNumber* number) { const double square_modulus = number->_cos * number->_cos + number->_sin * number->_sin; - if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) { number->_cos = 1.0; number->_sin = 0.0; return; diff --git a/basic-geometry/cotes-number.h b/basic-geometry/cotes-number.h index f40a3d5..f37c000 100644 --- a/basic-geometry/cotes-number.h +++ b/basic-geometry/cotes-number.h @@ -250,36 +250,36 @@ inline void bgc_fp64_cotes_number_exclude(BGC_FP64_CotesNumber* difference, cons inline void bgc_fp32_cotes_number_get_rotation_matrix(BGC_FP32_Matrix2x2* matrix, const BGC_FP32_CotesNumber* number) { - matrix->r1c1 = number->_cos; - matrix->r1c2 = -number->_sin; - matrix->r2c1 = number->_sin; - matrix->r2c2 = number->_cos; + matrix->row1_col1 = number->_cos; + matrix->row1_col2 = -number->_sin; + matrix->row2_col1 = number->_sin; + matrix->row2_col2 = number->_cos; } inline void bgc_fp64_cotes_number_get_rotation_matrix(BGC_FP64_Matrix2x2* matrix, const BGC_FP64_CotesNumber* number) { - matrix->r1c1 = number->_cos; - matrix->r1c2 = -number->_sin; - matrix->r2c1 = number->_sin; - matrix->r2c2 = number->_cos; + matrix->row1_col1 = number->_cos; + matrix->row1_col2 = -number->_sin; + matrix->row2_col1 = number->_sin; + matrix->row2_col2 = number->_cos; } // ============== Reverse Matrix ================ // inline void bgc_fp32_cotes_number_get_reverse_matrix(BGC_FP32_Matrix2x2* matrix, const BGC_FP32_CotesNumber* number) { - matrix->r1c1 = number->_cos; - matrix->r1c2 = number->_sin; - matrix->r2c1 = -number->_sin; - matrix->r2c2 = number->_cos; + matrix->row1_col1 = number->_cos; + matrix->row1_col2 = number->_sin; + matrix->row2_col1 = -number->_sin; + matrix->row2_col2 = number->_cos; } inline void bgc_fp64_cotes_number_get_reverse_matrix(BGC_FP64_Matrix2x2* matrix, const BGC_FP64_CotesNumber* number) { - matrix->r1c1 = number->_cos; - matrix->r1c2 = number->_sin; - matrix->r2c1 = -number->_sin; - matrix->r2c2 = number->_cos; + matrix->row1_col1 = number->_cos; + matrix->row1_col2 = number->_sin; + matrix->row2_col1 = -number->_sin; + matrix->row2_col2 = number->_cos; } // ================ Turn Vector ================= // @@ -329,7 +329,7 @@ inline int bgc_fp32_cotes_number_are_close(const BGC_FP32_CotesNumber* number1, const float d_cos = number1->_cos - number2->_cos; const float d_sin = number1->_sin - number2->_sin; - return d_cos * d_cos + d_sin * d_sin <= BGC_FP32_SQUARE_EPSYLON; + return d_cos * d_cos + d_sin * d_sin <= BGC_FP32_SQUARE_EPSILON; } inline int bgc_fp64_cotes_number_are_close(const BGC_FP64_CotesNumber* number1, const BGC_FP64_CotesNumber* number2) @@ -337,7 +337,7 @@ inline int bgc_fp64_cotes_number_are_close(const BGC_FP64_CotesNumber* number1, const double d_cos = number1->_cos - number2->_cos; const double d_sin = number1->_sin - number2->_sin; - return d_cos * d_cos + d_sin * d_sin <= BGC_FP64_SQUARE_EPSYLON; + return d_cos * d_cos + d_sin * d_sin <= BGC_FP64_SQUARE_EPSILON; } #endif diff --git a/basic-geometry/hg-vector3.c b/basic-geometry/hg-vector3.c new file mode 100644 index 0000000..02d5a59 --- /dev/null +++ b/basic-geometry/hg-vector3.c @@ -0,0 +1,28 @@ +#include "./hg-vector3.h" + +extern inline void bgc_fp32_hg_vector3_reset_point(BGC_FP32_HgVector3* homogeneous_vector); +extern inline void bgc_fp64_hg_vector3_reset_point(BGC_FP64_HgVector3* homogeneous_vector); + +extern inline void bgc_fp32_hg_vector3_reset_vector(BGC_FP32_HgVector3* homogeneous_vector); +extern inline void bgc_fp64_hg_vector3_reset_vector(BGC_FP64_HgVector3* homogeneous_vector); + +extern inline void bgc_fp32_hg_vector3_make(BGC_FP32_HgVector3* homogeneous_vector, const float x1, const float x2, const float x3, const float ratio); +extern inline void bgc_fp64_hg_vector3_make(BGC_FP64_HgVector3* homogeneous_vector, const double x1, const double x2, const double x3, const double ratio); + +extern inline void bgc_fp32_hg_vector3_make_point(BGC_FP32_HgVector3* homogeneous_vector, const BGC_FP32_Vector3* regular_vector); +extern inline void bgc_fp64_hg_vector3_make_point(BGC_FP64_HgVector3* homogeneous_vector, const BGC_FP64_Vector3* regular_vector); + +extern inline void bgc_fp32_hg_vector3_make_vector(BGC_FP32_HgVector3* homogeneous_vector, const BGC_FP32_Vector3* regular_vector); +extern inline void bgc_fp64_hg_vector3_make_vector(BGC_FP64_HgVector3* homogeneous_vector, const BGC_FP64_Vector3* regular_vector); + +extern inline int bgc_fp32_hg_vector3_is_point(const BGC_FP32_HgVector3* homogeneous_vector); +extern inline int bgc_fp64_hg_vector3_is_point(const BGC_FP64_HgVector3* homogeneous_vector); + +extern inline int bgc_fp32_hg_vector3_is_vector(const BGC_FP32_HgVector3* homogeneous_vector); +extern inline int bgc_fp64_hg_vector3_is_vector(const BGC_FP64_HgVector3* homogeneous_vector); + +extern inline void bgc_fp32_hg_vector3_copy(BGC_FP32_HgVector3* destination, const BGC_FP32_HgVector3* source); +extern inline void bgc_fp64_hg_vector3_copy(BGC_FP64_HgVector3* destination, const BGC_FP64_HgVector3* source); + +extern inline void bgc_fp32_hg_vector3_swap(BGC_FP32_HgVector3* first, BGC_FP32_HgVector3* second); +extern inline void bgc_fp64_hg_vector3_swap(BGC_FP64_HgVector3* first, BGC_FP64_HgVector3* second); diff --git a/basic-geometry/hg-vector3.h b/basic-geometry/hg-vector3.h new file mode 100644 index 0000000..73db4dd --- /dev/null +++ b/basic-geometry/hg-vector3.h @@ -0,0 +1,190 @@ +#ifndef _BGC_HG_VECTOR3_H_INCLUDED_ +#define _BGC_HG_VECTOR3_H_INCLUDED_ + +#include "./vector3.h" + +// ================== Vector3 =================== // + +// Homogeneous 3D Vector +typedef struct +{ + float x1, x2, x3, ratio; +} BGC_FP32_HgVector3; + +// Homogeneous 3D Vector +typedef struct +{ + double x1, x2, x3, ratio; +} BGC_FP64_HgVector3; + +// ================ Reset Point ================= // + +inline void bgc_fp32_hg_vector3_reset_point(BGC_FP32_HgVector3* homogeneous_vector) +{ + homogeneous_vector->x1 = 0.0f; + homogeneous_vector->x2 = 0.0f; + homogeneous_vector->x3 = 0.0f; + homogeneous_vector->ratio = 1.0f; +} + +inline void bgc_fp64_hg_vector3_reset_point(BGC_FP64_HgVector3* homogeneous_vector) +{ + homogeneous_vector->x1 = 0.0; + homogeneous_vector->x2 = 0.0; + homogeneous_vector->x3 = 0.0; + homogeneous_vector->ratio = 1.0; +} + +// ================ Reset Point ================= // + +inline void bgc_fp32_hg_vector3_reset_vector(BGC_FP32_HgVector3* homogeneous_vector) +{ + homogeneous_vector->x1 = 0.0f; + homogeneous_vector->x2 = 0.0f; + homogeneous_vector->x3 = 0.0f; + homogeneous_vector->ratio = 0.0f; +} + +inline void bgc_fp64_hg_vector3_reset_vector(BGC_FP64_HgVector3* homogeneous_vector) +{ + homogeneous_vector->x1 = 0.0; + homogeneous_vector->x2 = 0.0; + homogeneous_vector->x3 = 0.0; + homogeneous_vector->ratio = 0.0; +} + +// ==================== Make ==================== // + +inline void bgc_fp32_hg_vector3_make(BGC_FP32_HgVector3* homogeneous_vector, const float x1, const float x2, const float x3, const float ratio) +{ + homogeneous_vector->x1 = x1; + homogeneous_vector->x2 = x2; + homogeneous_vector->x3 = x3; + homogeneous_vector->ratio = ratio; +} + +inline void bgc_fp64_hg_vector3_make(BGC_FP64_HgVector3* homogeneous_vector, const double x1, const double x2, const double x3, const double ratio) +{ + homogeneous_vector->x1 = x1; + homogeneous_vector->x2 = x2; + homogeneous_vector->x3 = x3; + homogeneous_vector->ratio = ratio; +} + +// ================= Make Point ================= // + +inline void bgc_fp32_hg_vector3_make_point(BGC_FP32_HgVector3* homogeneous_vector, const BGC_FP32_Vector3* regular_vector) +{ + homogeneous_vector->x1 = regular_vector->x1; + homogeneous_vector->x2 = regular_vector->x2; + homogeneous_vector->x3 = regular_vector->x3; + homogeneous_vector->ratio = 1.0f; +} + +inline void bgc_fp64_hg_vector3_make_point(BGC_FP64_HgVector3* homogeneous_vector, const BGC_FP64_Vector3* regular_vector) +{ + homogeneous_vector->x1 = regular_vector->x1; + homogeneous_vector->x2 = regular_vector->x2; + homogeneous_vector->x3 = regular_vector->x3; + homogeneous_vector->ratio = 1.0; +} + +// ================ Make Vector ================= // + +inline void bgc_fp32_hg_vector3_make_vector(BGC_FP32_HgVector3* homogeneous_vector, const BGC_FP32_Vector3* regular_vector) +{ + homogeneous_vector->x1 = regular_vector->x1; + homogeneous_vector->x2 = regular_vector->x2; + homogeneous_vector->x3 = regular_vector->x3; + homogeneous_vector->ratio = 0.0f; +} + +inline void bgc_fp64_hg_vector3_make_vector(BGC_FP64_HgVector3* homogeneous_vector, const BGC_FP64_Vector3* regular_vector) +{ + homogeneous_vector->x1 = regular_vector->x1; + homogeneous_vector->x2 = regular_vector->x2; + homogeneous_vector->x3 = regular_vector->x3; + homogeneous_vector->ratio = 0.0; +} + +// ================== Is Point ================== // + +inline int bgc_fp32_hg_vector3_is_point(const BGC_FP32_HgVector3* homogeneous_vector) +{ + return !bgc_fp32_is_zero(homogeneous_vector->ratio); +} + +inline int bgc_fp64_hg_vector3_is_point(const BGC_FP64_HgVector3* homogeneous_vector) +{ + return !bgc_fp64_is_zero(homogeneous_vector->ratio); +} + +// ================= Is Vector ================== // + +inline int bgc_fp32_hg_vector3_is_vector(const BGC_FP32_HgVector3* homogeneous_vector) +{ + return bgc_fp32_is_zero(homogeneous_vector->ratio); +} + +inline int bgc_fp64_hg_vector3_is_vector(const BGC_FP64_HgVector3* homogeneous_vector) +{ + return bgc_fp64_is_zero(homogeneous_vector->ratio); +} + +// ==================== Copy ==================== // + +inline void bgc_fp32_hg_vector3_copy(BGC_FP32_HgVector3* destination, const BGC_FP32_HgVector3* source) +{ + destination->x1 = source->x1; + destination->x2 = source->x2; + destination->x3 = source->x3; + destination->ratio = source->ratio; +} + +inline void bgc_fp64_hg_vector3_copy(BGC_FP64_HgVector3* destination, const BGC_FP64_HgVector3* source) +{ + destination->x1 = source->x1; + destination->x2 = source->x2; + destination->x3 = source->x3; + destination->ratio = source->ratio; +} + +// ==================== Swap ==================== // + +inline void bgc_fp32_hg_vector3_swap(BGC_FP32_HgVector3* first, BGC_FP32_HgVector3* second) +{ + const float x1 = first->x1; + const float x2 = first->x2; + const float x3 = first->x3; + const float ratio = first->ratio; + + first->x1 = second->x1; + first->x2 = second->x2; + first->x3 = second->x3; + first->ratio = second->ratio; + + second->x1 = x1; + second->x2 = x2; + second->x3 = x3; + second->ratio = ratio; +} + +inline void bgc_fp64_hg_vector3_swap(BGC_FP64_HgVector3* first, BGC_FP64_HgVector3* second) +{ + const double x1 = first->x1; + const double x2 = first->x2; + const double x3 = first->x3; + const double ratio = first->ratio; + + first->x1 = second->x1; + first->x2 = second->x2; + first->x3 = second->x3; + first->ratio = second->ratio; + + second->x1 = x1; + second->x2 = x2; + second->x3 = x3; + second->ratio = ratio; +} + +#endif diff --git a/basic-geometry/matrices.h b/basic-geometry/matrices.h index 3f2180e..4044b37 100644 --- a/basic-geometry/matrices.h +++ b/basic-geometry/matrices.h @@ -4,361 +4,361 @@ // ================== Matrix2x2 ================= // typedef struct { - float r1c1, r1c2; - float r2c1, r2c2; + float row1_col1, row1_col2; + float row2_col1, row2_col2; } BGC_FP32_Matrix2x2; typedef struct { - double r1c1, r1c2; - double r2c1, r2c2; + double row1_col1, row1_col2; + double row2_col1, row2_col2; } BGC_FP64_Matrix2x2; // ================== Matrix2x3 ================= // typedef struct { - float r1c1, r1c2; - float r2c1, r2c2; - float r3c1, r3c2; + float row1_col1, row1_col2; + float row2_col1, row2_col2; + float row3_col1, row3_col2; } BGC_FP32_Matrix2x3; typedef struct { - double r1c1, r1c2; - double r2c1, r2c2; - double r3c1, r3c2; + double row1_col1, row1_col2; + double row2_col1, row2_col2; + double row3_col1, row3_col2; } BGC_FP64_Matrix2x3; // ================== Matrix3x2 ================= // typedef struct { - float r1c1, r1c2, r1c3; - float r2c1, r2c2, r2c3; + float row1_col1, row1_col2, row1_col3; + float row2_col1, row2_col2, row2_col3; } BGC_FP32_Matrix3x2; typedef struct { - double r1c1, r1c2, r1c3; - double r2c1, r2c2, r2c3; + double row1_col1, row1_col2, row1_col3; + double row2_col1, row2_col2, row2_col3; } BGC_FP64_Matrix3x2; // ================== Matrix3x3 ================= // typedef struct { - float r1c1, r1c2, r1c3; - float r2c1, r2c2, r2c3; - float r3c1, r3c2, r3c3; + float row1_col1, row1_col2, row1_col3; + float row2_col1, row2_col2, row2_col3; + float row3_col1, row3_col2, row3_col3; } BGC_FP32_Matrix3x3; typedef struct { - double r1c1, r1c2, r1c3; - double r2c1, r2c2, r2c3; - double r3c1, r3c2, r3c3; + double row1_col1, row1_col2, row1_col3; + double row2_col1, row2_col2, row2_col3; + double row3_col1, row3_col2, row3_col3; } BGC_FP64_Matrix3x3; // ========== Matrix Product 2x2 at 2x2 ========= // inline void bgc_fp32_multiply_matrix2x2_by_matrix2x2(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2) { - const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1; - const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2; + const float row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1; + const float row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2; - const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1; - const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2; + const float row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1; + const float row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2; - product->r1c1 = r1c1; - product->r1c2 = r1c2; + product->row1_col1 = row1_col1; + product->row1_col2 = row1_col2; - product->r2c1 = r2c1; - product->r2c2 = r2c2; + product->row2_col1 = row2_col1; + product->row2_col2 = row2_col2; } inline void bgc_fp64_multiply_matrix2x2_by_matrix2x2(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2) { - const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1; - const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2; + const double row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1; + const double row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2; - const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1; - const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2; + const double row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1; + const double row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2; - product->r1c1 = r1c1; - product->r1c2 = r1c2; + product->row1_col1 = row1_col1; + product->row1_col2 = row1_col2; - product->r2c1 = r2c1; - product->r2c2 = r2c2; + product->row2_col1 = row2_col1; + product->row2_col2 = row2_col2; } // ========== Matrix Product 2x2 at 3x2 ========= // inline void bgc_fp32_multiply_matrix2x2_by_matrix3x2(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix3x2* matrix2) { - 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 row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1; + const float row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2; + const float row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3; - 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; + const float row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1; + const float row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2; + const float row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3; - product->r1c1 = r1c1; - product->r1c2 = r1c2; - product->r1c3 = r1c3; + product->row1_col1 = row1_col1; + product->row1_col2 = row1_col2; + product->row1_col3 = row1_col3; - product->r2c1 = r2c1; - product->r2c2 = r2c2; - product->r2c3 = r2c3; + product->row2_col1 = row2_col1; + product->row2_col2 = row2_col2; + product->row2_col3 = row2_col3; } inline void bgc_fp64_multiply_matrix2x2_by_matrix3x2(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix3x2* matrix2) { - 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 row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1; + const double row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2; + const double row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3; - 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; + const double row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1; + const double row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2; + const double row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3; - product->r1c1 = r1c1; - product->r1c2 = r1c2; - product->r1c3 = r1c3; + product->row1_col1 = row1_col1; + product->row1_col2 = row1_col2; + product->row1_col3 = row1_col3; - product->r2c1 = r2c1; - product->r2c2 = r2c2; - product->r2c3 = r2c3; + product->row2_col1 = row2_col1; + product->row2_col2 = row2_col2; + product->row2_col3 = row2_col3; } // ========== Matrix Product 2x3 at 2x2 ========= // inline void bgc_fp32_multiply_matrix2x3_by_matrix2x2(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x2* matrix2) { - const float r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1; - const float r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2; + const float row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1; + const float row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2; - const float r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1; - const float r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2; + const float row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1; + const float row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2; - const float r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1; - const float r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2; + const float row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1; + const float row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2; - product->r1c1 = r1c1; - product->r1c2 = r1c2; + product->row1_col1 = row1_col1; + product->row1_col2 = row1_col2; - product->r2c1 = r2c1; - product->r2c2 = r2c2; + product->row2_col1 = row2_col1; + product->row2_col2 = row2_col2; - product->r3c1 = r3c1; - product->r3c2 = r3c2; + product->row3_col1 = row3_col1; + product->row3_col2 = row3_col2; } inline void bgc_fp64_multiply_matrix2x3_by_matrix2x2(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x2* matrix2) { - const double r1c1 = matrix1->r1c1 * matrix2->r1c1 + matrix1->r1c2 * matrix2->r2c1; - const double r1c2 = matrix1->r1c1 * matrix2->r1c2 + matrix1->r1c2 * matrix2->r2c2; + const double row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1; + const double row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2; - const double r2c1 = matrix1->r2c1 * matrix2->r1c1 + matrix1->r2c2 * matrix2->r2c1; - const double r2c2 = matrix1->r2c1 * matrix2->r1c2 + matrix1->r2c2 * matrix2->r2c2; + const double row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1; + const double row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2; - const double r3c1 = matrix1->r3c1 * matrix2->r1c1 + matrix1->r3c2 * matrix2->r2c1; - const double r3c2 = matrix1->r3c1 * matrix2->r1c2 + matrix1->r3c2 * matrix2->r2c2; + const double row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1; + const double row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2; - product->r1c1 = r1c1; - product->r1c2 = r1c2; + product->row1_col1 = row1_col1; + product->row1_col2 = row1_col2; - product->r2c1 = r2c1; - product->r2c2 = r2c2; + product->row2_col1 = row2_col1; + product->row2_col2 = row2_col2; - product->r3c1 = r3c1; - product->r3c2 = r3c2; + product->row3_col1 = row3_col1; + product->row3_col2 = row3_col2; } // ========== Matrix Product 2x3 at 3x2 ========= // inline void bgc_fp32_multiply_matrix2x3_by_matrix3x2(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix3x2* matrix2) { - 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->row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1; + product->row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2; + product->row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3; - 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->row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1; + product->row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2; + product->row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3; - 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; + product->row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1; + product->row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2; + product->row3_col3 = matrix1->row3_col1 * matrix2->row1_col3 + matrix1->row3_col2 * matrix2->row2_col3; } inline void bgc_fp64_multiply_matrix2x3_by_matrix3x2(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix3x2* matrix2) { - 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->row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1; + product->row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2; + product->row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3; - 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->row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1; + product->row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2; + product->row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3; - 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; + product->row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1; + product->row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2; + product->row3_col3 = matrix1->row3_col1 * matrix2->row1_col3 + matrix1->row3_col2 * matrix2->row2_col3; } // ========== Matrix Product 3x2 at 2x3 ========= // inline void bgc_fp32_multiply_matrix3x2_by_matrix2x3(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix2x3* matrix2) { - 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->row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1; + product->row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2; - 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; + product->row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1; + product->row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2; } inline void bgc_fp64_multiply_matrix3x2_by_matrix2x3(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix2x3* matrix2) { - 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->row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1; + product->row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2; - 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; + product->row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1; + product->row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2; } // ========== Matrix Product 3x2 at 3x3 ========= // inline void bgc_fp32_multiply_matrix3x2_by_matrix3x3(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x3* matrix2) { - 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 row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1; + const float row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2; + const float row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3 + matrix1->row1_col3 * matrix2->row3_col3; - 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 row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1; + const float row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2; + const float row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3 + matrix1->row2_col3 * matrix2->row3_col3; - product->r1c1 = r1c1; - product->r1c2 = r1c2; - product->r1c3 = r1c3; + product->row1_col1 = row1_col1; + product->row1_col2 = row1_col2; + product->row1_col3 = row1_col3; - product->r2c1 = r2c1; - product->r2c2 = r2c2; - product->r2c3 = r2c3; + product->row2_col1 = row2_col1; + product->row2_col2 = row2_col2; + product->row2_col3 = row2_col3; } inline void bgc_fp64_multiply_matrix3x2_by_matrix3x3(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x3* matrix2) { - 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 row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1; + const double row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2; + const double row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3 + matrix1->row1_col3 * matrix2->row3_col3; - 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 row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1; + const double row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2; + const double row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3 + matrix1->row2_col3 * matrix2->row3_col3; - product->r1c1 = r1c1; - product->r1c2 = r1c2; - product->r1c3 = r1c3; + product->row1_col1 = row1_col1; + product->row1_col2 = row1_col2; + product->row1_col3 = row1_col3; - product->r2c1 = r2c1; - product->r2c2 = r2c2; - product->r2c3 = r2c3; + product->row2_col1 = row2_col1; + product->row2_col2 = row2_col2; + product->row2_col3 = row2_col3; } // ========== Matrix Product 3x3 at 2x3 ========= // inline void bgc_fp32_multiply_matrix3x3_by_matrix2x3(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix2x3* matrix2) { - 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 row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1; + const float row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2; - 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 row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1; + const float row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2; - 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 row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1 + matrix1->row3_col3 * matrix2->row3_col1; + const float row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2 + matrix1->row3_col3 * matrix2->row3_col2; - product->r1c1 = r1c1; - product->r1c2 = r1c2; + product->row1_col1 = row1_col1; + product->row1_col2 = row1_col2; - product->r2c1 = r2c1; - product->r2c2 = r2c2; + product->row2_col1 = row2_col1; + product->row2_col2 = row2_col2; - product->r3c1 = r3c1; - product->r3c2 = r3c2; + product->row3_col1 = row3_col1; + product->row3_col2 = row3_col2; } inline void bgc_fp64_multiply_matrix3x3_by_matrix2x3(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix2x3* matrix2) { - 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 row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1; + const double row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2; - 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 row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1; + const double row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2; - 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 row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1 + matrix1->row3_col3 * matrix2->row3_col1; + const double row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2 + matrix1->row3_col3 * matrix2->row3_col2; - product->r1c1 = r1c1; - product->r1c2 = r1c2; + product->row1_col1 = row1_col1; + product->row1_col2 = row1_col2; - product->r2c1 = r2c1; - product->r2c2 = r2c2; + product->row2_col1 = row2_col1; + product->row2_col2 = row2_col2; - product->r3c1 = r3c1; - product->r3c2 = r3c2; + product->row3_col1 = row3_col1; + product->row3_col2 = row3_col2; } // ========== Matrix Product 3x3 at 3x3 ========= // inline void bgc_fp32_multiply_matrix3x3_by_matrix3x3(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2) { - 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 row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1; + const float row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2; + const float row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3 + matrix1->row1_col3 * matrix2->row3_col3; - 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 row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1; + const float row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2; + const float row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3 + matrix1->row2_col3 * matrix2->row3_col3; - 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; + const float row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1 + matrix1->row3_col3 * matrix2->row3_col1; + const float row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2 + matrix1->row3_col3 * matrix2->row3_col2; + const float row3_col3 = matrix1->row3_col1 * matrix2->row1_col3 + matrix1->row3_col2 * matrix2->row2_col3 + matrix1->row3_col3 * matrix2->row3_col3; - product->r1c1 = r1c1; - product->r1c2 = r1c2; - product->r1c3 = r1c3; + product->row1_col1 = row1_col1; + product->row1_col2 = row1_col2; + product->row1_col3 = row1_col3; - product->r2c1 = r2c1; - product->r2c2 = r2c2; - product->r2c3 = r2c3; + product->row2_col1 = row2_col1; + product->row2_col2 = row2_col2; + product->row2_col3 = row2_col3; - product->r3c1 = r3c1; - product->r3c2 = r3c2; - product->r3c3 = r3c3; + product->row3_col1 = row3_col1; + product->row3_col2 = row3_col2; + product->row3_col3 = row3_col3; } inline void bgc_fp64_multiply_matrix3x3_by_matrix3x3(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2) { - 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 row1_col1 = matrix1->row1_col1 * matrix2->row1_col1 + matrix1->row1_col2 * matrix2->row2_col1 + matrix1->row1_col3 * matrix2->row3_col1; + const double row1_col2 = matrix1->row1_col1 * matrix2->row1_col2 + matrix1->row1_col2 * matrix2->row2_col2 + matrix1->row1_col3 * matrix2->row3_col2; + const double row1_col3 = matrix1->row1_col1 * matrix2->row1_col3 + matrix1->row1_col2 * matrix2->row2_col3 + matrix1->row1_col3 * matrix2->row3_col3; - 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 row2_col1 = matrix1->row2_col1 * matrix2->row1_col1 + matrix1->row2_col2 * matrix2->row2_col1 + matrix1->row2_col3 * matrix2->row3_col1; + const double row2_col2 = matrix1->row2_col1 * matrix2->row1_col2 + matrix1->row2_col2 * matrix2->row2_col2 + matrix1->row2_col3 * matrix2->row3_col2; + const double row2_col3 = matrix1->row2_col1 * matrix2->row1_col3 + matrix1->row2_col2 * matrix2->row2_col3 + matrix1->row2_col3 * matrix2->row3_col3; - 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; + const double row3_col1 = matrix1->row3_col1 * matrix2->row1_col1 + matrix1->row3_col2 * matrix2->row2_col1 + matrix1->row3_col3 * matrix2->row3_col1; + const double row3_col2 = matrix1->row3_col1 * matrix2->row1_col2 + matrix1->row3_col2 * matrix2->row2_col2 + matrix1->row3_col3 * matrix2->row3_col2; + const double row3_col3 = matrix1->row3_col1 * matrix2->row1_col3 + matrix1->row3_col2 * matrix2->row2_col3 + matrix1->row3_col3 * matrix2->row3_col3; - product->r1c1 = r1c1; - product->r1c2 = r1c2; - product->r1c3 = r1c3; + product->row1_col1 = row1_col1; + product->row1_col2 = row1_col2; + product->row1_col3 = row1_col3; - product->r2c1 = r2c1; - product->r2c2 = r2c2; - product->r2c3 = r2c3; + product->row2_col1 = row2_col1; + product->row2_col2 = row2_col2; + product->row2_col3 = row2_col3; - product->r3c1 = r3c1; - product->r3c2 = r3c2; - product->r3c3 = r3c3; + product->row3_col1 = row3_col1; + product->row3_col2 = row3_col2; + product->row3_col3 = row3_col3; } #endif // _BGC_MATRIX_TYPES_H_ diff --git a/basic-geometry/matrix2x2.h b/basic-geometry/matrix2x2.h index f84d444..941a84b 100644 --- a/basic-geometry/matrix2x2.h +++ b/basic-geometry/matrix2x2.h @@ -9,54 +9,54 @@ inline void bgc_fp32_matrix2x2_reset(BGC_FP32_Matrix2x2* matrix) { - matrix->r1c1 = 0.0f; - matrix->r1c2 = 0.0f; - matrix->r2c1 = 0.0f; - matrix->r2c2 = 0.0f; + matrix->row1_col1 = 0.0f; + matrix->row1_col2 = 0.0f; + matrix->row2_col1 = 0.0f; + matrix->row2_col2 = 0.0f; } inline void bgc_fp64_matrix2x2_reset(BGC_FP64_Matrix2x2* matrix) { - matrix->r1c1 = 0.0; - matrix->r1c2 = 0.0; - matrix->r2c1 = 0.0; - matrix->r2c2 = 0.0; + matrix->row1_col1 = 0.0; + matrix->row1_col2 = 0.0; + matrix->row2_col1 = 0.0; + matrix->row2_col2 = 0.0; } // ================== Identity ================== // inline void bgc_fp32_matrix2x2_make_identity(BGC_FP32_Matrix2x2* matrix) { - matrix->r1c1 = 1.0f; - matrix->r1c2 = 0.0f; - matrix->r2c1 = 0.0f; - matrix->r2c2 = 1.0f; + matrix->row1_col1 = 1.0f; + matrix->row1_col2 = 0.0f; + matrix->row2_col1 = 0.0f; + matrix->row2_col2 = 1.0f; } inline void bgc_fp64_matrix2x2_make_identity(BGC_FP64_Matrix2x2* matrix) { - matrix->r1c1 = 1.0; - matrix->r1c2 = 0.0; - matrix->r2c1 = 0.0; - matrix->r2c2 = 1.0; + matrix->row1_col1 = 1.0; + matrix->row1_col2 = 0.0; + matrix->row2_col1 = 0.0; + matrix->row2_col2 = 1.0; } // ================ Set Diagonal ================ // inline void bgc_fp32_matrix2x2_make_diagonal(BGC_FP32_Matrix2x2* matrix, const float d1, const float d2) { - matrix->r1c1 = d1; - matrix->r1c2 = 0.0f; - matrix->r2c1 = 0.0f; - matrix->r2c2 = d2; + matrix->row1_col1 = d1; + matrix->row1_col2 = 0.0f; + matrix->row2_col1 = 0.0f; + matrix->row2_col2 = d2; } inline void bgc_fp64_matrix2x2_make_diagonal(BGC_FP64_Matrix2x2* matrix, const double d1, const double d2) { - matrix->r1c1 = d1; - matrix->r1c2 = 0.0; - matrix->r2c1 = 0.0; - matrix->r2c2 = d2; + matrix->row1_col1 = d1; + matrix->row1_col2 = 0.0; + matrix->row2_col1 = 0.0; + matrix->row2_col2 = d2; } // ============== Rotation Matrix =============== // @@ -67,10 +67,10 @@ inline void bgc_fp32_matrix2x2_make_for_turn(BGC_FP32_Matrix2x2* matrix, const f const float cosine = cosf(radians); const float sine = sinf(radians); - matrix->r1c1 = cosine; - matrix->r1c2 = -sine; - matrix->r2c1 = sine; - matrix->r2c2 = cosine; + matrix->row1_col1 = cosine; + matrix->row1_col2 = -sine; + matrix->row2_col1 = sine; + matrix->row2_col2 = cosine; } inline void bgc_fp64_matrix2x2_make_for_turn(BGC_FP64_Matrix2x2* matrix, const double angle, const int angle_unit) @@ -79,36 +79,36 @@ inline void bgc_fp64_matrix2x2_make_for_turn(BGC_FP64_Matrix2x2* matrix, const d const double cosine = cos(radians); const double sine = sin(radians); - matrix->r1c1 = cosine; - matrix->r1c2 = -sine; - matrix->r2c1 = sine; - matrix->r2c2 = cosine; + matrix->row1_col1 = cosine; + matrix->row1_col2 = -sine; + matrix->row2_col1 = sine; + matrix->row2_col2 = cosine; } // ================ Determinant ================= // inline float bgc_fp32_matrix2x2_get_determinant(const BGC_FP32_Matrix2x2* matrix) { - return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1; + return matrix->row1_col1 * matrix->row2_col2 - matrix->row1_col2 * matrix->row2_col1; } inline double bgc_fp64_matrix2x2_get_determinant(const BGC_FP64_Matrix2x2* matrix) { - return matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1; + return matrix->row1_col1 * matrix->row2_col2 - matrix->row1_col2 * matrix->row2_col1; } // ================ Is Identity ================= // inline int bgc_fp32_matrix2x2_is_identity(const BGC_FP32_Matrix2x2* 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); + return bgc_fp32_is_unit(matrix->row1_col1) && bgc_fp32_is_zero(matrix->row1_col2) + && bgc_fp32_is_zero(matrix->row2_col1) && bgc_fp32_is_unit(matrix->row2_col2); } inline int bgc_fp64_matrix2x2_is_identity(const BGC_FP64_Matrix2x2* 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); + return bgc_fp64_is_unit(matrix->row1_col1) && bgc_fp64_is_zero(matrix->row1_col2) + && bgc_fp64_is_zero(matrix->row2_col1) && bgc_fp64_is_unit(matrix->row2_col2); } // ================ Is Singular ================= // @@ -129,11 +129,11 @@ inline int bgc_fp32_matrix2x2_is_rotation(const BGC_FP32_Matrix2x2* matrix) { BGC_FP32_Matrix2x2 product; - product.r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1; - product.r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2; + product.row1_col1 = matrix->row1_col1 * matrix->row1_col1 + matrix->row1_col2 * matrix->row2_col1; + product.row1_col2 = matrix->row1_col1 * matrix->row1_col2 + matrix->row1_col2 * matrix->row2_col2; - product.r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1; - product.r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2; + product.row2_col1 = matrix->row2_col1 * matrix->row1_col1 + matrix->row2_col2 * matrix->row2_col1; + product.row2_col2 = matrix->row2_col1 * matrix->row1_col2 + matrix->row2_col2 * matrix->row2_col2; return bgc_fp32_matrix2x2_is_identity(&product); } @@ -142,11 +142,11 @@ inline int bgc_fp64_matrix2x2_is_rotation(const BGC_FP64_Matrix2x2* matrix) { BGC_FP64_Matrix2x2 product; - product.r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1; - product.r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2; + product.row1_col1 = matrix->row1_col1 * matrix->row1_col1 + matrix->row1_col2 * matrix->row2_col1; + product.row1_col2 = matrix->row1_col1 * matrix->row1_col2 + matrix->row1_col2 * matrix->row2_col2; - product.r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1; - product.r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2; + product.row2_col1 = matrix->row2_col1 * matrix->row1_col1 + matrix->row2_col2 * matrix->row2_col1; + product.row2_col2 = matrix->row2_col1 * matrix->row1_col2 + matrix->row2_col2 * matrix->row2_col2; return bgc_fp64_matrix2x2_is_identity(&product); } @@ -155,84 +155,84 @@ inline int bgc_fp64_matrix2x2_is_rotation(const BGC_FP64_Matrix2x2* matrix) inline void bgc_fp32_matrix2x2_copy(BGC_FP32_Matrix2x2* destination, const BGC_FP32_Matrix2x2* source) { - destination->r1c1 = source->r1c1; - destination->r1c2 = source->r1c2; + destination->row1_col1 = source->row1_col1; + destination->row1_col2 = source->row1_col2; - destination->r2c1 = source->r2c1; - destination->r2c2 = source->r2c2; + destination->row2_col1 = source->row2_col1; + destination->row2_col2 = source->row2_col2; } inline void bgc_fp64_matrix2x2_copy(BGC_FP64_Matrix2x2* destination, const BGC_FP64_Matrix2x2* source) { - destination->r1c1 = source->r1c1; - destination->r1c2 = source->r1c2; + destination->row1_col1 = source->row1_col1; + destination->row1_col2 = source->row1_col2; - destination->r2c1 = source->r2c1; - destination->r2c2 = source->r2c2; + destination->row2_col1 = source->row2_col1; + destination->row2_col2 = source->row2_col2; } // ==================== Swap ==================== // inline void bgc_fp32_matrix2x2_swap(BGC_FP32_Matrix2x2* matrix1, BGC_FP32_Matrix2x2* matrix2) { - const float r1c1 = matrix2->r1c1; - const float r1c2 = matrix2->r1c2; + const float row1_col1 = matrix2->row1_col1; + const float row1_col2 = matrix2->row1_col2; - const float r2c1 = matrix2->r2c1; - const float r2c2 = matrix2->r2c2; + const float row2_col1 = matrix2->row2_col1; + const float row2_col2 = matrix2->row2_col2; - matrix2->r1c1 = matrix1->r1c1; - matrix2->r1c2 = matrix1->r1c2; + matrix2->row1_col1 = matrix1->row1_col1; + matrix2->row1_col2 = matrix1->row1_col2; - matrix2->r2c1 = matrix1->r2c1; - matrix2->r2c2 = matrix1->r2c2; + matrix2->row2_col1 = matrix1->row2_col1; + matrix2->row2_col2 = matrix1->row2_col2; - matrix1->r1c1 = r1c1; - matrix1->r1c2 = r1c2; + matrix1->row1_col1 = row1_col1; + matrix1->row1_col2 = row1_col2; - matrix1->r2c1 = r2c1; - matrix1->r2c2 = r2c2; + matrix1->row2_col1 = row2_col1; + matrix1->row2_col2 = row2_col2; } inline void bgc_fp64_matrix2x2_swap(BGC_FP64_Matrix2x2* matrix1, BGC_FP64_Matrix2x2* matrix2) { - const double r1c1 = matrix2->r1c1; - const double r1c2 = matrix2->r1c2; + const double row1_col1 = matrix2->row1_col1; + const double row1_col2 = matrix2->row1_col2; - const double r2c1 = matrix2->r2c1; - const double r2c2 = matrix2->r2c2; + const double row2_col1 = matrix2->row2_col1; + const double row2_col2 = matrix2->row2_col2; - matrix2->r1c1 = matrix1->r1c1; - matrix2->r1c2 = matrix1->r1c2; + matrix2->row1_col1 = matrix1->row1_col1; + matrix2->row1_col2 = matrix1->row1_col2; - matrix2->r2c1 = matrix1->r2c1; - matrix2->r2c2 = matrix1->r2c2; + matrix2->row2_col1 = matrix1->row2_col1; + matrix2->row2_col2 = matrix1->row2_col2; - matrix1->r1c1 = r1c1; - matrix1->r1c2 = r1c2; + matrix1->row1_col1 = row1_col1; + matrix1->row1_col2 = row1_col2; - matrix1->r2c1 = r2c1; - matrix1->r2c2 = r2c2; + matrix1->row2_col1 = row2_col1; + matrix1->row2_col2 = row2_col2; } // ================== Convert =================== // inline void bgc_fp64_matrix2x2_convert_to_fp32(BGC_FP32_Matrix2x2* destination, const BGC_FP64_Matrix2x2* source) { - destination->r1c1 = (float)source->r1c1; - destination->r1c2 = (float)source->r1c2; + destination->row1_col1 = (float)source->row1_col1; + destination->row1_col2 = (float)source->row1_col2; - destination->r2c1 = (float)source->r2c1; - destination->r2c2 = (float)source->r2c2; + destination->row2_col1 = (float)source->row2_col1; + destination->row2_col2 = (float)source->row2_col2; } inline void bgc_fp32_matrix2x2_convert_to_fp64(BGC_FP64_Matrix2x2* destination, const BGC_FP32_Matrix2x2* source) { - destination->r1c1 = source->r1c1; - destination->r1c2 = source->r1c2; + destination->row1_col1 = source->row1_col1; + destination->row1_col2 = source->row1_col2; - destination->r2c1 = source->r2c1; - destination->r2c2 = source->r2c2; + destination->row2_col1 = source->row2_col1; + destination->row2_col2 = source->row2_col2; } // ================ Get Inverse ================= // @@ -245,19 +245,19 @@ inline int bgc_fp32_matrix2x2_get_inverse(BGC_FP32_Matrix2x2* inverse, const BGC return 0; } - const float r1c1 = matrix->r2c2; - const float r1c2 = -matrix->r1c2; + const float row1_col1 = matrix->row2_col2; + const float row1_col2 = -matrix->row1_col2; - const float r2c1 = -matrix->r2c1; - const float r2c2 = matrix->r1c1; + const float row2_col1 = -matrix->row2_col1; + const float row2_col2 = matrix->row1_col1; const float multiplier = 1.0f / determinant; - inverse->r1c1 = r1c1 * multiplier; - inverse->r1c2 = r1c2 * multiplier; + inverse->row1_col1 = row1_col1 * multiplier; + inverse->row1_col2 = row1_col2 * multiplier; - inverse->r2c1 = r2c1 * multiplier; - inverse->r2c2 = r2c2 * multiplier; + inverse->row2_col1 = row2_col1 * multiplier; + inverse->row2_col2 = row2_col2 * multiplier; return 1; } @@ -270,19 +270,19 @@ inline int bgc_fp64_matrix2x2_get_inverse(BGC_FP64_Matrix2x2* inverse, const BGC return 0; } - const double r1c1 = matrix->r2c2; - const double r1c2 = -matrix->r1c2; + const double row1_col1 = matrix->row2_col2; + const double row1_col2 = -matrix->row1_col2; - const double r2c1 = -matrix->r2c1; - const double r2c2 = matrix->r1c1; + const double row2_col1 = -matrix->row2_col1; + const double row2_col2 = matrix->row1_col1; const double multiplier = 1.0 / determinant; - inverse->r1c1 = r1c1 * multiplier; - inverse->r1c2 = r1c2 * multiplier; + inverse->row1_col1 = row1_col1 * multiplier; + inverse->row1_col2 = row1_col2 * multiplier; - inverse->r2c1 = r2c1 * multiplier; - inverse->r2c2 = r2c2 * multiplier; + inverse->row2_col1 = row2_col1 * multiplier; + inverse->row2_col2 = row2_col2 * multiplier; return 1; } @@ -303,40 +303,40 @@ inline int bgc_fp64_matrix2x2_invert(BGC_FP64_Matrix2x2* matrix) inline void bgc_fp32_matrix2x2_transpose(BGC_FP32_Matrix2x2* matrix) { - const float r1c2 = matrix->r1c2; - matrix->r1c2 = matrix->r2c1; - matrix->r2c1 = r1c2; + const float row1_col2 = matrix->row1_col2; + matrix->row1_col2 = matrix->row2_col1; + matrix->row2_col1 = row1_col2; } inline void bgc_fp64_matrix2x2_transpose(BGC_FP64_Matrix2x2* matrix) { - const double r1c2 = matrix->r1c2; - matrix->r1c2 = matrix->r2c1; - matrix->r2c1 = r1c2; + const double row1_col2 = matrix->row1_col2; + matrix->row1_col2 = matrix->row2_col1; + matrix->row2_col1 = row1_col2; } // =============== Get Transpose ================ // inline void bgc_fp32_matrix2x2_get_transposed(BGC_FP32_Matrix2x2* transposed, const BGC_FP32_Matrix2x2* matrix) { - const float r1c2 = matrix->r1c2; + const float row1_col2 = matrix->row1_col2; - transposed->r1c1 = matrix->r1c1; - transposed->r1c2 = matrix->r2c1; + transposed->row1_col1 = matrix->row1_col1; + transposed->row1_col2 = matrix->row2_col1; - transposed->r2c1 = r1c2; - transposed->r2c2 = matrix->r2c2; + transposed->row2_col1 = row1_col2; + transposed->row2_col2 = matrix->row2_col2; } inline void bgc_fp64_matrix2x2_get_transposed(BGC_FP64_Matrix2x2* transposed, const BGC_FP64_Matrix2x2* matrix) { - const double r1c2 = matrix->r1c2; + const double row1_col2 = matrix->row1_col2; - transposed->r1c1 = matrix->r1c1; - transposed->r1c2 = matrix->r2c1; + transposed->row1_col1 = matrix->row1_col1; + transposed->row1_col2 = matrix->row2_col1; - transposed->r2c1 = r1c2; - transposed->r2c2 = matrix->r2c2; + transposed->row2_col1 = row1_col2; + transposed->row2_col2 = matrix->row2_col2; } // ================== Get Row =================== // @@ -344,14 +344,14 @@ inline void bgc_fp64_matrix2x2_get_transposed(BGC_FP64_Matrix2x2* transposed, co inline void bgc_fp32_matrix2x2_get_row(BGC_FP32_Vector2* row, const BGC_FP32_Matrix2x2* matrix, const int row_number) { if (row_number == 1) { - row->x1 = matrix->r1c1; - row->x2 = matrix->r1c2; + row->x1 = matrix->row1_col1; + row->x2 = matrix->row1_col2; return; } if (row_number == 2) { - row->x1 = matrix->r2c1; - row->x2 = matrix->r2c2; + row->x1 = matrix->row2_col1; + row->x2 = matrix->row2_col2; return; } @@ -362,14 +362,14 @@ inline void bgc_fp32_matrix2x2_get_row(BGC_FP32_Vector2* row, const BGC_FP32_Mat inline void bgc_fp64_matrix2x2_get_row(BGC_FP64_Vector2* row, const BGC_FP64_Matrix2x2* matrix, const int row_number) { if (row_number == 1) { - row->x1 = matrix->r1c1; - row->x2 = matrix->r1c2; + row->x1 = matrix->row1_col1; + row->x2 = matrix->row1_col2; return; } if (row_number == 2) { - row->x1 = matrix->r2c1; - row->x2 = matrix->r2c2; + row->x1 = matrix->row2_col1; + row->x2 = matrix->row2_col2; return; } @@ -382,28 +382,28 @@ inline void bgc_fp64_matrix2x2_get_row(BGC_FP64_Vector2* row, const BGC_FP64_Mat inline void bgc_fp32_matrix2x2_set_row(BGC_FP32_Matrix2x2* matrix, const int row_number, const BGC_FP32_Vector2* row) { if (row_number == 1) { - matrix->r1c1 = row->x1; - matrix->r1c2 = row->x2; + matrix->row1_col1 = row->x1; + matrix->row1_col2 = row->x2; return; } if (row_number == 2) { - matrix->r2c1 = row->x1; - matrix->r2c2 = row->x2; + matrix->row2_col1 = row->x1; + matrix->row2_col2 = row->x2; } } inline void bgc_fp64_matrix2x2_set_row(BGC_FP64_Matrix2x2* matrix, const int row_number, const BGC_FP64_Vector2* row) { if (row_number == 1) { - matrix->r1c1 = row->x1; - matrix->r1c2 = row->x2; + matrix->row1_col1 = row->x1; + matrix->row1_col2 = row->x2; return; } if (row_number == 2) { - matrix->r2c1 = row->x1; - matrix->r2c2 = row->x2; + matrix->row2_col1 = row->x1; + matrix->row2_col2 = row->x2; } } @@ -412,14 +412,14 @@ inline void bgc_fp64_matrix2x2_set_row(BGC_FP64_Matrix2x2* matrix, const int row inline void bgc_fp32_matrix2x2_get_column(BGC_FP32_Vector2* column, const BGC_FP32_Matrix2x2* matrix, const int column_number) { if (column_number == 1) { - column->x1 = matrix->r1c1; - column->x2 = matrix->r2c1; + column->x1 = matrix->row1_col1; + column->x2 = matrix->row2_col1; return; } if (column_number == 2) { - column->x1 = matrix->r1c2; - column->x2 = matrix->r2c2; + column->x1 = matrix->row1_col2; + column->x2 = matrix->row2_col2; return; } @@ -430,14 +430,14 @@ inline void bgc_fp32_matrix2x2_get_column(BGC_FP32_Vector2* column, const BGC_FP inline void bgc_fp64_matrix2x2_get_column(BGC_FP64_Vector2* column, const BGC_FP64_Matrix2x2* matrix, const int column_number) { if (column_number == 1) { - column->x1 = matrix->r1c1; - column->x2 = matrix->r2c1; + column->x1 = matrix->row1_col1; + column->x2 = matrix->row2_col1; return; } if (column_number == 2) { - column->x1 = matrix->r1c2; - column->x2 = matrix->r2c2; + column->x1 = matrix->row1_col2; + column->x2 = matrix->row2_col2; return; } @@ -450,28 +450,28 @@ inline void bgc_fp64_matrix2x2_get_column(BGC_FP64_Vector2* column, const BGC_FP inline void bgc_fp32_matrix2x2_set_column(BGC_FP32_Matrix2x2* matrix, const int column_number, const BGC_FP32_Vector2* column) { if (column_number == 1) { - matrix->r1c1 = column->x1; - matrix->r2c1 = column->x2; + matrix->row1_col1 = column->x1; + matrix->row2_col1 = column->x2; return; } if (column_number == 2) { - matrix->r1c2 = column->x1; - matrix->r2c2 = column->x2; + matrix->row1_col2 = column->x1; + matrix->row2_col2 = column->x2; } } inline void bgc_fp64_matrix2x2_set_column(BGC_FP64_Matrix2x2* matrix, const int column_number, const BGC_FP64_Vector2* column) { if (column_number == 1) { - matrix->r1c1 = column->x1; - matrix->r2c1 = column->x2; + matrix->row1_col1 = column->x1; + matrix->row2_col1 = column->x2; return; } if (column_number == 2) { - matrix->r1c2 = column->x1; - matrix->r2c2 = column->x2; + matrix->row1_col2 = column->x1; + matrix->row2_col2 = column->x2; } } @@ -479,80 +479,80 @@ inline void bgc_fp64_matrix2x2_set_column(BGC_FP64_Matrix2x2* matrix, const int inline void bgc_fp32_matrix2x2_add(BGC_FP32_Matrix2x2* sum, const BGC_FP32_Matrix2x2* matrix1, const BGC_FP32_Matrix2x2* matrix2) { - sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; - sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; + sum->row1_col1 = matrix1->row1_col1 + matrix2->row1_col1; + sum->row1_col2 = matrix1->row1_col2 + matrix2->row1_col2; - sum->r2c1 = matrix1->r2c1 + matrix2->r2c1; - sum->r2c2 = matrix1->r2c2 + matrix2->r2c2; + sum->row2_col1 = matrix1->row2_col1 + matrix2->row2_col1; + sum->row2_col2 = matrix1->row2_col2 + matrix2->row2_col2; } inline void bgc_fp64_matrix2x2_add(BGC_FP64_Matrix2x2* sum, const BGC_FP64_Matrix2x2* matrix1, const BGC_FP64_Matrix2x2* matrix2) { - sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; - sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; + sum->row1_col1 = matrix1->row1_col1 + matrix2->row1_col1; + sum->row1_col2 = matrix1->row1_col2 + matrix2->row1_col2; - sum->r2c1 = matrix1->r2c1 + matrix2->r2c1; - sum->r2c2 = matrix1->r2c2 + matrix2->r2c2; + sum->row2_col1 = matrix1->row2_col1 + matrix2->row2_col1; + sum->row2_col2 = matrix1->row2_col2 + matrix2->row2_col2; } // ================= Add scaled ================= // inline void bgc_fp32_matrix2x2_add_scaled(BGC_FP32_Matrix2x2* sum, const BGC_FP32_Matrix2x2* basic_matrix, const BGC_FP32_Matrix2x2* scalable_matrix, const float scale) { - sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; - sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; + sum->row1_col1 = basic_matrix->row1_col1 + scalable_matrix->row1_col1 * scale; + sum->row1_col2 = basic_matrix->row1_col2 + scalable_matrix->row1_col2 * scale; - sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale; - sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale; + sum->row2_col1 = basic_matrix->row2_col1 + scalable_matrix->row2_col1 * scale; + sum->row2_col2 = basic_matrix->row2_col2 + scalable_matrix->row2_col2 * scale; } inline void bgc_fp64_matrix2x2_add_scaled(BGC_FP64_Matrix2x2* sum, const BGC_FP64_Matrix2x2* basic_matrix, const BGC_FP64_Matrix2x2* scalable_matrix, const double scale) { - sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; - sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; + sum->row1_col1 = basic_matrix->row1_col1 + scalable_matrix->row1_col1 * scale; + sum->row1_col2 = basic_matrix->row1_col2 + scalable_matrix->row1_col2 * scale; - sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale; - sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale; + sum->row2_col1 = basic_matrix->row2_col1 + scalable_matrix->row2_col1 * scale; + sum->row2_col2 = basic_matrix->row2_col2 + scalable_matrix->row2_col2 * scale; } // ================== Subtract ================== // inline void bgc_fp32_matrix2x2_subtract(BGC_FP32_Matrix2x2* difference, const BGC_FP32_Matrix2x2* minuend, const BGC_FP32_Matrix2x2* subtrahend) { - difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; - difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; + difference->row1_col1 = minuend->row1_col1 - subtrahend->row1_col1; + difference->row1_col2 = minuend->row1_col2 - subtrahend->row1_col2; - difference->r2c1 = minuend->r2c1 - subtrahend->r2c1; - difference->r2c2 = minuend->r2c2 - subtrahend->r2c2; + difference->row2_col1 = minuend->row2_col1 - subtrahend->row2_col1; + difference->row2_col2 = minuend->row2_col2 - subtrahend->row2_col2; } inline void bgc_fp64_matrix2x2_subtract(BGC_FP64_Matrix2x2* difference, const BGC_FP64_Matrix2x2* minuend, const BGC_FP64_Matrix2x2* subtrahend) { - difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; - difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; + difference->row1_col1 = minuend->row1_col1 - subtrahend->row1_col1; + difference->row1_col2 = minuend->row1_col2 - subtrahend->row1_col2; - difference->r2c1 = minuend->r2c1 - subtrahend->r2c1; - difference->r2c2 = minuend->r2c2 - subtrahend->r2c2; + difference->row2_col1 = minuend->row2_col1 - subtrahend->row2_col1; + difference->row2_col2 = minuend->row2_col2 - subtrahend->row2_col2; } // ================== Multiply ================== // inline void bgc_fp32_matrix2x2_multiply(BGC_FP32_Matrix2x2* product, const BGC_FP32_Matrix2x2* multiplicand, const float multiplier) { - product->r1c1 = multiplicand->r1c1 * multiplier; - product->r1c2 = multiplicand->r1c2 * multiplier; + product->row1_col1 = multiplicand->row1_col1 * multiplier; + product->row1_col2 = multiplicand->row1_col2 * multiplier; - product->r2c1 = multiplicand->r2c1 * multiplier; - product->r2c2 = multiplicand->r2c2 * multiplier; + product->row2_col1 = multiplicand->row2_col1 * multiplier; + product->row2_col2 = multiplicand->row2_col2 * multiplier; } inline void bgc_fp64_matrix2x2_multiply(BGC_FP64_Matrix2x2* product, const BGC_FP64_Matrix2x2* multiplicand, const double multiplier) { - product->r1c1 = multiplicand->r1c1 * multiplier; - product->r1c2 = multiplicand->r1c2 * multiplier; + product->row1_col1 = multiplicand->row1_col1 * multiplier; + product->row1_col2 = multiplicand->row1_col2 * multiplier; - product->r2c1 = multiplicand->r2c1 * multiplier; - product->r2c2 = multiplicand->r2c2 * multiplier; + product->row2_col1 = multiplicand->row2_col1 * multiplier; + product->row2_col2 = multiplicand->row2_col2 * multiplier; } // =================== Divide =================== // @@ -573,30 +573,30 @@ inline void bgc_fp32_matrix2x2_interpolate(BGC_FP32_Matrix2x2* interpolation, co { 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->row1_col1 = first->row1_col1 * counter_phase + second->row1_col1 * phase; + interpolation->row1_col2 = first->row1_col2 * counter_phase + second->row1_col2 * phase; - interpolation->r2c1 = first->r2c1 * counter_phase + second->r2c1 * phase; - interpolation->r2c2 = first->r2c2 * counter_phase + second->r2c2 * phase; + interpolation->row2_col1 = first->row2_col1 * counter_phase + second->row2_col1 * phase; + interpolation->row2_col2 = first->row2_col2 * counter_phase + second->row2_col2 * phase; } inline void bgc_fp64_matrix2x2_interpolate(BGC_FP64_Matrix2x2* interpolation, const BGC_FP64_Matrix2x2* first, const BGC_FP64_Matrix2x2* second, const double phase) { 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->row1_col1 = first->row1_col1 * counter_phase + second->row1_col1 * phase; + interpolation->row1_col2 = first->row1_col2 * counter_phase + second->row1_col2 * phase; - interpolation->r2c1 = first->r2c1 * counter_phase + second->r2c1 * phase; - interpolation->r2c2 = first->r2c2 * counter_phase + second->r2c2 * phase; + interpolation->row2_col1 = first->row2_col1 * counter_phase + second->row2_col1 * phase; + interpolation->row2_col2 = first->row2_col2 * counter_phase + second->row2_col2 * phase; } // ============ Right Vector Product ============ // inline void bgc_fp32_multiply_matrix2x2_by_vector2(BGC_FP32_Vector2* product, const BGC_FP32_Matrix2x2* matrix, const BGC_FP32_Vector2* vector) { - const float x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2; - const float x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2; + const float x1 = matrix->row1_col1 * vector->x1 + matrix->row1_col2 * vector->x2; + const float x2 = matrix->row2_col1 * vector->x1 + matrix->row2_col2 * vector->x2; product->x1 = x1; product->x2 = x2; @@ -604,8 +604,8 @@ inline void bgc_fp32_multiply_matrix2x2_by_vector2(BGC_FP32_Vector2* product, co inline void bgc_fp64_multiply_matrix2x2_by_vector2(BGC_FP64_Vector2* product, const BGC_FP64_Matrix2x2* matrix, const BGC_FP64_Vector2* vector) { - const double x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2; - const double x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2; + const double x1 = matrix->row1_col1 * vector->x1 + matrix->row1_col2 * vector->x2; + const double x2 = matrix->row2_col1 * vector->x1 + matrix->row2_col2 * vector->x2; product->x1 = x1; product->x2 = x2; @@ -615,8 +615,8 @@ inline void bgc_fp64_multiply_matrix2x2_by_vector2(BGC_FP64_Vector2* product, co inline void bgc_fp32_multiply_vector2_by_matrix2x2(BGC_FP32_Vector2* product, const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix2x2* matrix) { - const float x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1; - const float x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2; + const float x1 = vector->x1 * matrix->row1_col1 + vector->x2 * matrix->row2_col1; + const float x2 = vector->x1 * matrix->row1_col2 + vector->x2 * matrix->row2_col2; product->x1 = x1; product->x2 = x2; @@ -624,8 +624,8 @@ inline void bgc_fp32_multiply_vector2_by_matrix2x2(BGC_FP32_Vector2* product, co inline void bgc_fp64_multiply_vector2_by_matrix2x2(BGC_FP64_Vector2* product, const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix2x2* matrix) { - const double x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1; - const double x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2; + const double x1 = vector->x1 * matrix->row1_col1 + vector->x2 * matrix->row2_col1; + const double x2 = vector->x1 * matrix->row1_col2 + vector->x2 * matrix->row2_col2; product->x1 = x1; product->x2 = x2; diff --git a/basic-geometry/matrix2x3.h b/basic-geometry/matrix2x3.h index 7093a94..b18e6ff 100644 --- a/basic-geometry/matrix2x3.h +++ b/basic-geometry/matrix2x3.h @@ -9,166 +9,166 @@ inline void bgc_fp32_matrix2x3_reset(BGC_FP32_Matrix2x3* matrix) { - matrix->r1c1 = 0.0f; - matrix->r1c2 = 0.0f; + matrix->row1_col1 = 0.0f; + matrix->row1_col2 = 0.0f; - matrix->r2c1 = 0.0f; - matrix->r2c2 = 0.0f; + matrix->row2_col1 = 0.0f; + matrix->row2_col2 = 0.0f; - matrix->r3c1 = 0.0f; - matrix->r3c2 = 0.0f; + matrix->row3_col1 = 0.0f; + matrix->row3_col2 = 0.0f; } inline void bgc_fp64_matrix2x3_reset(BGC_FP64_Matrix2x3* matrix) { - matrix->r1c1 = 0.0; - matrix->r1c2 = 0.0; + matrix->row1_col1 = 0.0; + matrix->row1_col2 = 0.0; - matrix->r2c1 = 0.0; - matrix->r2c2 = 0.0; + matrix->row2_col1 = 0.0; + matrix->row2_col2 = 0.0; - matrix->r3c1 = 0.0; - matrix->r3c2 = 0.0; + matrix->row3_col1 = 0.0; + matrix->row3_col2 = 0.0; } // ==================== Copy ==================== // inline void bgc_fp32_matrix2x3_copy(BGC_FP32_Matrix2x3* destination, const BGC_FP32_Matrix2x3* source) { - destination->r1c1 = source->r1c1; - destination->r1c2 = source->r1c2; + destination->row1_col1 = source->row1_col1; + destination->row1_col2 = source->row1_col2; - destination->r2c1 = source->r2c1; - destination->r2c2 = source->r2c2; + destination->row2_col1 = source->row2_col1; + destination->row2_col2 = source->row2_col2; - destination->r3c1 = source->r3c1; - destination->r3c2 = source->r3c2; + destination->row3_col1 = source->row3_col1; + destination->row3_col2 = source->row3_col2; } inline void bgc_fp64_matrix2x3_copy(BGC_FP64_Matrix2x3* destination, const BGC_FP64_Matrix2x3* source) { - destination->r1c1 = source->r1c1; - destination->r1c2 = source->r1c2; + destination->row1_col1 = source->row1_col1; + destination->row1_col2 = source->row1_col2; - destination->r2c1 = source->r2c1; - destination->r2c2 = source->r2c2; + destination->row2_col1 = source->row2_col1; + destination->row2_col2 = source->row2_col2; - destination->r3c1 = source->r3c1; - destination->r3c2 = source->r3c2; + destination->row3_col1 = source->row3_col1; + destination->row3_col2 = source->row3_col2; } // ==================== Swap ==================== // inline void bgc_fp32_matrix2x3_swap(BGC_FP32_Matrix2x3* matrix1, BGC_FP32_Matrix2x3* matrix2) { - const float r1c1 = matrix2->r1c1; - const float r1c2 = matrix2->r1c2; + const float row1_col1 = matrix2->row1_col1; + const float row1_col2 = matrix2->row1_col2; - const float r2c1 = matrix2->r2c1; - const float r2c2 = matrix2->r2c2; + const float row2_col1 = matrix2->row2_col1; + const float row2_col2 = matrix2->row2_col2; - const float r3c1 = matrix2->r3c1; - const float r3c2 = matrix2->r3c2; + const float row3_col1 = matrix2->row3_col1; + const float row3_col2 = matrix2->row3_col2; - matrix2->r1c1 = matrix1->r1c1; - matrix2->r1c2 = matrix1->r1c2; + matrix2->row1_col1 = matrix1->row1_col1; + matrix2->row1_col2 = matrix1->row1_col2; - matrix2->r2c1 = matrix1->r2c1; - matrix2->r2c2 = matrix1->r2c2; + matrix2->row2_col1 = matrix1->row2_col1; + matrix2->row2_col2 = matrix1->row2_col2; - matrix2->r3c1 = matrix1->r3c1; - matrix2->r3c2 = matrix1->r3c2; + matrix2->row3_col1 = matrix1->row3_col1; + matrix2->row3_col2 = matrix1->row3_col2; - matrix1->r1c1 = r1c1; - matrix1->r1c2 = r1c2; + matrix1->row1_col1 = row1_col1; + matrix1->row1_col2 = row1_col2; - matrix1->r2c1 = r2c1; - matrix1->r2c2 = r2c2; + matrix1->row2_col1 = row2_col1; + matrix1->row2_col2 = row2_col2; - matrix1->r3c1 = r3c1; - matrix1->r3c2 = r3c2; + matrix1->row3_col1 = row3_col1; + matrix1->row3_col2 = row3_col2; } inline void bgc_fp64_matrix2x3_swap(BGC_FP64_Matrix2x3* matrix1, BGC_FP64_Matrix2x3* matrix2) { - const double r1c1 = matrix2->r1c1; - const double r1c2 = matrix2->r1c2; + const double row1_col1 = matrix2->row1_col1; + const double row1_col2 = matrix2->row1_col2; - const double r2c1 = matrix2->r2c1; - const double r2c2 = matrix2->r2c2; + const double row2_col1 = matrix2->row2_col1; + const double row2_col2 = matrix2->row2_col2; - const double r3c1 = matrix2->r3c1; - const double r3c2 = matrix2->r3c2; + const double row3_col1 = matrix2->row3_col1; + const double row3_col2 = matrix2->row3_col2; - matrix2->r1c1 = matrix1->r1c1; - matrix2->r1c2 = matrix1->r1c2; + matrix2->row1_col1 = matrix1->row1_col1; + matrix2->row1_col2 = matrix1->row1_col2; - matrix2->r2c1 = matrix1->r2c1; - matrix2->r2c2 = matrix1->r2c2; + matrix2->row2_col1 = matrix1->row2_col1; + matrix2->row2_col2 = matrix1->row2_col2; - matrix2->r3c1 = matrix1->r3c1; - matrix2->r3c2 = matrix1->r3c2; + matrix2->row3_col1 = matrix1->row3_col1; + matrix2->row3_col2 = matrix1->row3_col2; - matrix1->r1c1 = r1c1; - matrix1->r1c2 = r1c2; + matrix1->row1_col1 = row1_col1; + matrix1->row1_col2 = row1_col2; - matrix1->r2c1 = r2c1; - matrix1->r2c2 = r2c2; + matrix1->row2_col1 = row2_col1; + matrix1->row2_col2 = row2_col2; - matrix1->r3c1 = r3c1; - matrix1->r3c2 = r3c2; + matrix1->row3_col1 = row3_col1; + matrix1->row3_col2 = row3_col2; } // ================== Convert =================== // inline void bgc_fp64_matrix2x3_convert_to_fp32(BGC_FP32_Matrix2x3* destination, const BGC_FP64_Matrix2x3* source) { - destination->r1c1 = (float)source->r1c1; - destination->r1c2 = (float)source->r1c2; + destination->row1_col1 = (float)source->row1_col1; + destination->row1_col2 = (float)source->row1_col2; - destination->r2c1 = (float)source->r2c1; - destination->r2c2 = (float)source->r2c2; + destination->row2_col1 = (float)source->row2_col1; + destination->row2_col2 = (float)source->row2_col2; - destination->r3c1 = (float)source->r3c1; - destination->r3c2 = (float)source->r3c2; + destination->row3_col1 = (float)source->row3_col1; + destination->row3_col2 = (float)source->row3_col2; } inline void bgc_fp32_matrix2x3_convert_to_fp64(BGC_FP64_Matrix2x3* destination, const BGC_FP32_Matrix2x3* source) { - destination->r1c1 = source->r1c1; - destination->r1c2 = source->r1c2; + destination->row1_col1 = source->row1_col1; + destination->row1_col2 = source->row1_col2; - destination->r2c1 = source->r2c1; - destination->r2c2 = source->r2c2; + destination->row2_col1 = source->row2_col1; + destination->row2_col2 = source->row2_col2; - destination->r3c1 = source->r3c1; - destination->r3c2 = source->r3c2; + destination->row3_col1 = source->row3_col1; + destination->row3_col2 = source->row3_col2; } // ================= Transpose ================== // inline void bgc_fp32_matrix2x3_get_transposed(BGC_FP32_Matrix2x3* transposed, const BGC_FP32_Matrix3x2* matrix) { - transposed->r1c1 = matrix->r1c1; - transposed->r1c2 = matrix->r2c1; + transposed->row1_col1 = matrix->row1_col1; + transposed->row1_col2 = matrix->row2_col1; - transposed->r2c1 = matrix->r1c2; - transposed->r2c2 = matrix->r2c2; + transposed->row2_col1 = matrix->row1_col2; + transposed->row2_col2 = matrix->row2_col2; - transposed->r3c1 = matrix->r1c3; - transposed->r3c2 = matrix->r2c3; + transposed->row3_col1 = matrix->row1_col3; + transposed->row3_col2 = matrix->row2_col3; } inline void bgc_fp64_matrix2x3_get_transposed(BGC_FP64_Matrix2x3* transposed, const BGC_FP64_Matrix3x2* matrix) { - transposed->r1c1 = matrix->r1c1; - transposed->r1c2 = matrix->r2c1; + transposed->row1_col1 = matrix->row1_col1; + transposed->row1_col2 = matrix->row2_col1; - transposed->r2c1 = matrix->r1c2; - transposed->r2c2 = matrix->r2c2; + transposed->row2_col1 = matrix->row1_col2; + transposed->row2_col2 = matrix->row2_col2; - transposed->r3c1 = matrix->r1c3; - transposed->r3c2 = matrix->r2c3; + transposed->row3_col1 = matrix->row1_col3; + transposed->row3_col2 = matrix->row2_col3; } // ================== Get Row =================== // @@ -176,20 +176,20 @@ inline void bgc_fp64_matrix2x3_get_transposed(BGC_FP64_Matrix2x3* transposed, co inline void bgc_fp32_matrix2x3_get_row(BGC_FP32_Vector2* row, const BGC_FP32_Matrix2x3* matrix, const int row_number) { if (row_number == 1) { - row->x1 = matrix->r1c1; - row->x2 = matrix->r1c2; + row->x1 = matrix->row1_col1; + row->x2 = matrix->row1_col2; return; } if (row_number == 2) { - row->x1 = matrix->r2c1; - row->x2 = matrix->r2c2; + row->x1 = matrix->row2_col1; + row->x2 = matrix->row2_col2; return; } if (row_number == 3) { - row->x1 = matrix->r3c1; - row->x2 = matrix->r3c2; + row->x1 = matrix->row3_col1; + row->x2 = matrix->row3_col2; return; } @@ -200,20 +200,20 @@ inline void bgc_fp32_matrix2x3_get_row(BGC_FP32_Vector2* row, const BGC_FP32_Mat inline void bgc_fp64_matrix2x3_get_row(BGC_FP64_Vector2* row, const BGC_FP64_Matrix2x3* matrix, const int row_number) { if (row_number == 1) { - row->x1 = matrix->r1c1; - row->x2 = matrix->r1c2; + row->x1 = matrix->row1_col1; + row->x2 = matrix->row1_col2; return; } if (row_number == 2) { - row->x1 = matrix->r2c1; - row->x2 = matrix->r2c2; + row->x1 = matrix->row2_col1; + row->x2 = matrix->row2_col2; return; } if (row_number == 3) { - row->x1 = matrix->r3c1; - row->x2 = matrix->r3c2; + row->x1 = matrix->row3_col1; + row->x2 = matrix->row3_col2; return; } @@ -226,40 +226,40 @@ inline void bgc_fp64_matrix2x3_get_row(BGC_FP64_Vector2* row, const BGC_FP64_Mat inline void bgc_fp32_matrix2x3_set_row(BGC_FP32_Matrix2x3* matrix, const int row_number, const BGC_FP32_Vector2* row) { if (row_number == 1) { - matrix->r1c1 = row->x1; - matrix->r1c2 = row->x2; + matrix->row1_col1 = row->x1; + matrix->row1_col2 = row->x2; return; } if (row_number == 2) { - matrix->r2c1 = row->x1; - matrix->r2c2 = row->x2; + matrix->row2_col1 = row->x1; + matrix->row2_col2 = row->x2; return; } if (row_number == 3) { - matrix->r3c1 = row->x1; - matrix->r3c2 = row->x2; + matrix->row3_col1 = row->x1; + matrix->row3_col2 = row->x2; } } inline void bgc_fp64_matrix2x3_set_row(BGC_FP64_Matrix2x3* matrix, const int row_number, const BGC_FP64_Vector2* row) { if (row_number == 1) { - matrix->r1c1 = row->x1; - matrix->r1c2 = row->x2; + matrix->row1_col1 = row->x1; + matrix->row1_col2 = row->x2; return; } if (row_number == 2) { - matrix->r2c1 = row->x1; - matrix->r2c2 = row->x2; + matrix->row2_col1 = row->x1; + matrix->row2_col2 = row->x2; return; } if (row_number == 3) { - matrix->r3c1 = row->x1; - matrix->r3c2 = row->x2; + matrix->row3_col1 = row->x1; + matrix->row3_col2 = row->x2; } } @@ -268,32 +268,32 @@ inline void bgc_fp64_matrix2x3_set_row(BGC_FP64_Matrix2x3* matrix, const int row inline void bgc_fp32_matrix2x3_get_column(BGC_FP32_Vector3* column, const BGC_FP32_Matrix2x3* matrix, const int column_number) { if (column_number == 1) { - column->x1 = matrix->r1c1; - column->x2 = matrix->r2c1; - column->x3 = matrix->r3c1; + column->x1 = matrix->row1_col1; + column->x2 = matrix->row2_col1; + column->x3 = matrix->row3_col1; return; } if (column_number == 2) { - column->x1 = matrix->r1c2; - column->x2 = matrix->r2c2; - column->x3 = matrix->r3c2; + column->x1 = matrix->row1_col2; + column->x2 = matrix->row2_col2; + column->x3 = matrix->row3_col2; } } inline void bgc_fp64_matrix2x3_get_column(BGC_FP64_Vector3* column, const BGC_FP64_Matrix2x3* matrix, const int column_number) { if (column_number == 1) { - column->x1 = matrix->r1c1; - column->x2 = matrix->r2c1; - column->x3 = matrix->r3c1; + column->x1 = matrix->row1_col1; + column->x2 = matrix->row2_col1; + column->x3 = matrix->row3_col1; return; } if (column_number == 2) { - column->x1 = matrix->r1c2; - column->x2 = matrix->r2c2; - column->x3 = matrix->r3c2; + column->x1 = matrix->row1_col2; + column->x2 = matrix->row2_col2; + column->x3 = matrix->row3_col2; } } @@ -302,32 +302,32 @@ inline void bgc_fp64_matrix2x3_get_column(BGC_FP64_Vector3* column, const BGC_FP inline void bgc_fp32_matrix2x3_set_column(BGC_FP32_Matrix2x3* matrix, const int column_number, const BGC_FP32_Vector3* column) { if (column_number == 1) { - matrix->r1c1 = column->x1; - matrix->r2c1 = column->x2; - matrix->r3c1 = column->x3; + matrix->row1_col1 = column->x1; + matrix->row2_col1 = column->x2; + matrix->row3_col1 = column->x3; return; } if (column_number == 2) { - matrix->r1c2 = column->x1; - matrix->r2c2 = column->x2; - matrix->r3c2 = column->x3; + matrix->row1_col2 = column->x1; + matrix->row2_col2 = column->x2; + matrix->row3_col2 = column->x3; } } inline void bgc_fp64_matrix2x3_set_column(BGC_FP64_Matrix2x3* matrix, const int column_number, const BGC_FP64_Vector3* column) { if (column_number == 1) { - matrix->r1c1 = column->x1; - matrix->r2c1 = column->x2; - matrix->r3c1 = column->x3; + matrix->row1_col1 = column->x1; + matrix->row2_col1 = column->x2; + matrix->row3_col1 = column->x3; return; } if (column_number == 2) { - matrix->r1c2 = column->x1; - matrix->r2c2 = column->x2; - matrix->r3c2 = column->x3; + matrix->row1_col2 = column->x1; + matrix->row2_col2 = column->x2; + matrix->row3_col2 = column->x3; } } @@ -335,104 +335,104 @@ inline void bgc_fp64_matrix2x3_set_column(BGC_FP64_Matrix2x3* matrix, const int inline void bgc_fp32_matrix2x3_add(BGC_FP32_Matrix2x3* sum, const BGC_FP32_Matrix2x3* matrix1, const BGC_FP32_Matrix2x3* matrix2) { - sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; - sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; + sum->row1_col1 = matrix1->row1_col1 + matrix2->row1_col1; + sum->row1_col2 = matrix1->row1_col2 + matrix2->row1_col2; - sum->r2c1 = matrix1->r2c1 + matrix2->r2c1; - sum->r2c2 = matrix1->r2c2 + matrix2->r2c2; + sum->row2_col1 = matrix1->row2_col1 + matrix2->row2_col1; + sum->row2_col2 = matrix1->row2_col2 + matrix2->row2_col2; - sum->r3c1 = matrix1->r3c1 + matrix2->r3c1; - sum->r3c2 = matrix1->r3c2 + matrix2->r3c2; + sum->row3_col1 = matrix1->row3_col1 + matrix2->row3_col1; + sum->row3_col2 = matrix1->row3_col2 + matrix2->row3_col2; } inline void bgc_fp64_matrix2x3_add(BGC_FP64_Matrix2x3* sum, const BGC_FP64_Matrix2x3* matrix1, const BGC_FP64_Matrix2x3* matrix2) { - sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; - sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; + sum->row1_col1 = matrix1->row1_col1 + matrix2->row1_col1; + sum->row1_col2 = matrix1->row1_col2 + matrix2->row1_col2; - sum->r2c1 = matrix1->r2c1 + matrix2->r2c1; - sum->r2c2 = matrix1->r2c2 + matrix2->r2c2; + sum->row2_col1 = matrix1->row2_col1 + matrix2->row2_col1; + sum->row2_col2 = matrix1->row2_col2 + matrix2->row2_col2; - sum->r3c1 = matrix1->r3c1 + matrix2->r3c1; - sum->r3c2 = matrix1->r3c2 + matrix2->r3c2; + sum->row3_col1 = matrix1->row3_col1 + matrix2->row3_col1; + sum->row3_col2 = matrix1->row3_col2 + matrix2->row3_col2; } // ================= Add scaled ================= // inline void bgc_fp32_matrix2x3_add_scaled(BGC_FP32_Matrix2x3* sum, const BGC_FP32_Matrix2x3* basic_matrix, const BGC_FP32_Matrix2x3* scalable_matrix, const float scale) { - sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; - sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; + sum->row1_col1 = basic_matrix->row1_col1 + scalable_matrix->row1_col1 * scale; + sum->row1_col2 = basic_matrix->row1_col2 + scalable_matrix->row1_col2 * scale; - sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale; - sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale; + sum->row2_col1 = basic_matrix->row2_col1 + scalable_matrix->row2_col1 * scale; + sum->row2_col2 = basic_matrix->row2_col2 + scalable_matrix->row2_col2 * scale; - sum->r3c1 = basic_matrix->r3c1 + scalable_matrix->r3c1 * scale; - sum->r3c2 = basic_matrix->r3c2 + scalable_matrix->r3c2 * scale; + sum->row3_col1 = basic_matrix->row3_col1 + scalable_matrix->row3_col1 * scale; + sum->row3_col2 = basic_matrix->row3_col2 + scalable_matrix->row3_col2 * scale; } inline void bgc_fp64_matrix2x3_add_scaled(BGC_FP64_Matrix2x3* sum, const BGC_FP64_Matrix2x3* basic_matrix, const BGC_FP64_Matrix2x3* scalable_matrix, const double scale) { - sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; - sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; + sum->row1_col1 = basic_matrix->row1_col1 + scalable_matrix->row1_col1 * scale; + sum->row1_col2 = basic_matrix->row1_col2 + scalable_matrix->row1_col2 * scale; - sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale; - sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale; + sum->row2_col1 = basic_matrix->row2_col1 + scalable_matrix->row2_col1 * scale; + sum->row2_col2 = basic_matrix->row2_col2 + scalable_matrix->row2_col2 * scale; - sum->r3c1 = basic_matrix->r3c1 + scalable_matrix->r3c1 * scale; - sum->r3c2 = basic_matrix->r3c2 + scalable_matrix->r3c2 * scale; + sum->row3_col1 = basic_matrix->row3_col1 + scalable_matrix->row3_col1 * scale; + sum->row3_col2 = basic_matrix->row3_col2 + scalable_matrix->row3_col2 * scale; } // ================== Subtract ================== // inline void bgc_fp32_matrix2x3_subtract(BGC_FP32_Matrix2x3* difference, const BGC_FP32_Matrix2x3* minuend, const BGC_FP32_Matrix2x3* subtrahend) { - difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; - difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; + difference->row1_col1 = minuend->row1_col1 - subtrahend->row1_col1; + difference->row1_col2 = minuend->row1_col2 - subtrahend->row1_col2; - difference->r2c1 = minuend->r2c1 - subtrahend->r2c1; - difference->r2c2 = minuend->r2c2 - subtrahend->r2c2; + difference->row2_col1 = minuend->row2_col1 - subtrahend->row2_col1; + difference->row2_col2 = minuend->row2_col2 - subtrahend->row2_col2; - difference->r3c1 = minuend->r3c1 - subtrahend->r3c1; - difference->r3c2 = minuend->r3c2 - subtrahend->r3c2; + difference->row3_col1 = minuend->row3_col1 - subtrahend->row3_col1; + difference->row3_col2 = minuend->row3_col2 - subtrahend->row3_col2; } inline void bgc_fp64_matrix2x3_subtract(BGC_FP64_Matrix2x3* difference, const BGC_FP64_Matrix2x3* minuend, const BGC_FP64_Matrix2x3* subtrahend) { - difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; - difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; + difference->row1_col1 = minuend->row1_col1 - subtrahend->row1_col1; + difference->row1_col2 = minuend->row1_col2 - subtrahend->row1_col2; - difference->r2c1 = minuend->r2c1 - subtrahend->r2c1; - difference->r2c2 = minuend->r2c2 - subtrahend->r2c2; + difference->row2_col1 = minuend->row2_col1 - subtrahend->row2_col1; + difference->row2_col2 = minuend->row2_col2 - subtrahend->row2_col2; - difference->r3c1 = minuend->r3c1 - subtrahend->r3c1; - difference->r3c2 = minuend->r3c2 - subtrahend->r3c2; + difference->row3_col1 = minuend->row3_col1 - subtrahend->row3_col1; + difference->row3_col2 = minuend->row3_col2 - subtrahend->row3_col2; } // ================== Multiply ================== // inline void bgc_fp32_matrix2x3_multiply(BGC_FP32_Matrix2x3* product, const BGC_FP32_Matrix2x3* multiplicand, const float multiplier) { - product->r1c1 = multiplicand->r1c1 * multiplier; - product->r1c2 = multiplicand->r1c2 * multiplier; + product->row1_col1 = multiplicand->row1_col1 * multiplier; + product->row1_col2 = multiplicand->row1_col2 * multiplier; - product->r2c1 = multiplicand->r2c1 * multiplier; - product->r2c2 = multiplicand->r2c2 * multiplier; + product->row2_col1 = multiplicand->row2_col1 * multiplier; + product->row2_col2 = multiplicand->row2_col2 * multiplier; - product->r3c1 = multiplicand->r3c1 * multiplier; - product->r3c2 = multiplicand->r3c2 * multiplier; + product->row3_col1 = multiplicand->row3_col1 * multiplier; + product->row3_col2 = multiplicand->row3_col2 * multiplier; } inline void bgc_fp64_matrix2x3_multiply(BGC_FP64_Matrix2x3* product, const BGC_FP64_Matrix2x3* multiplicand, const double multiplier) { - product->r1c1 = multiplicand->r1c1 * multiplier; - product->r1c2 = multiplicand->r1c2 * multiplier; + product->row1_col1 = multiplicand->row1_col1 * multiplier; + product->row1_col2 = multiplicand->row1_col2 * multiplier; - product->r2c1 = multiplicand->r2c1 * multiplier; - product->r2c2 = multiplicand->r2c2 * multiplier; + product->row2_col1 = multiplicand->row2_col1 * multiplier; + product->row2_col2 = multiplicand->row2_col2 * multiplier; - product->r3c1 = multiplicand->r3c1 * multiplier; - product->r3c2 = multiplicand->r3c2 * multiplier; + product->row3_col1 = multiplicand->row3_col1 * multiplier; + product->row3_col2 = multiplicand->row3_col2 * multiplier; } // =================== Divide =================== // @@ -453,58 +453,58 @@ inline void bgc_fp32_matrix2x3_interpolate(BGC_FP32_Matrix2x3* interpolation, co { 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->row1_col1 = first->row1_col1 * couter_phase + second->row1_col1 * phase; + interpolation->row1_col2 = first->row1_col2 * couter_phase + second->row1_col2 * phase; - interpolation->r2c1 = first->r2c1 * couter_phase + second->r2c1 * phase; - interpolation->r2c2 = first->r2c2 * couter_phase + second->r2c2 * phase; + interpolation->row2_col1 = first->row2_col1 * couter_phase + second->row2_col1 * phase; + interpolation->row2_col2 = first->row2_col2 * couter_phase + second->row2_col2 * phase; - interpolation->r3c1 = first->r3c1 * couter_phase + second->r3c1 * phase; - interpolation->r3c2 = first->r3c2 * couter_phase + second->r3c2 * phase; + interpolation->row3_col1 = first->row3_col1 * couter_phase + second->row3_col1 * phase; + interpolation->row3_col2 = first->row3_col2 * couter_phase + second->row3_col2 * phase; } inline void bgc_fp64_matrix2x3_interpolate(BGC_FP64_Matrix2x3* interpolation, const BGC_FP64_Matrix2x3* first, const BGC_FP64_Matrix2x3* second, const double phase) { 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->row1_col1 = first->row1_col1 * couter_phase + second->row1_col1 * phase; + interpolation->row1_col2 = first->row1_col2 * couter_phase + second->row1_col2 * phase; - interpolation->r2c1 = first->r2c1 * couter_phase + second->r2c1 * phase; - interpolation->r2c2 = first->r2c2 * couter_phase + second->r2c2 * phase; + interpolation->row2_col1 = first->row2_col1 * couter_phase + second->row2_col1 * phase; + interpolation->row2_col2 = first->row2_col2 * couter_phase + second->row2_col2 * phase; - interpolation->r3c1 = first->r3c1 * couter_phase + second->r3c1 * phase; - interpolation->r3c2 = first->r3c2 * couter_phase + second->r3c2 * phase; + interpolation->row3_col1 = first->row3_col1 * couter_phase + second->row3_col1 * phase; + interpolation->row3_col2 = first->row3_col2 * couter_phase + second->row3_col2 * phase; } // ============ Left Vector Product ============= // inline void bgc_fp32_multiply_vector3_by_matrix2x3(BGC_FP32_Vector2* product, const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix2x3* matrix) { - product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1; - product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2; + product->x1 = vector->x1 * matrix->row1_col1 + vector->x2 * matrix->row2_col1 + vector->x3 * matrix->row3_col1; + product->x2 = vector->x1 * matrix->row1_col2 + vector->x2 * matrix->row2_col2 + vector->x3 * matrix->row3_col2; } inline void bgc_fp64_multiply_vector3_by_matrix2x3(BGC_FP64_Vector2* product, const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix2x3* matrix) { - product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1 + vector->x3 * matrix->r3c1; - product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2 + vector->x3 * matrix->r3c2; + product->x1 = vector->x1 * matrix->row1_col1 + vector->x2 * matrix->row2_col1 + vector->x3 * matrix->row3_col1; + product->x2 = vector->x1 * matrix->row1_col2 + vector->x2 * matrix->row2_col2 + vector->x3 * matrix->row3_col2; } // ============ Right Vector Product ============ // inline void bgc_fp32_multiply_matrix2x3_by_vector2(BGC_FP32_Vector3* product, const BGC_FP32_Matrix2x3* matrix, const BGC_FP32_Vector2* vector) { - product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2; - product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2; - product->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2; + product->x1 = matrix->row1_col1 * vector->x1 + matrix->row1_col2 * vector->x2; + product->x2 = matrix->row2_col1 * vector->x1 + matrix->row2_col2 * vector->x2; + product->x3 = matrix->row3_col1 * vector->x1 + matrix->row3_col2 * vector->x2; } inline void bgc_fp64_multiply_matrix2x3_by_vector2(BGC_FP64_Vector3* product, const BGC_FP64_Matrix2x3* matrix, const BGC_FP64_Vector2* vector) { - product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2; - product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2; - product->x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2; + product->x1 = matrix->row1_col1 * vector->x1 + matrix->row1_col2 * vector->x2; + product->x2 = matrix->row2_col1 * vector->x1 + matrix->row2_col2 * vector->x2; + product->x3 = matrix->row3_col1 * vector->x1 + matrix->row3_col2 * vector->x2; } #endif diff --git a/basic-geometry/matrix3x2.h b/basic-geometry/matrix3x2.h index b219ddd..c9ce123 100644 --- a/basic-geometry/matrix3x2.h +++ b/basic-geometry/matrix3x2.h @@ -9,152 +9,152 @@ inline void bgc_fp32_matrix3x2_reset(BGC_FP32_Matrix3x2* matrix) { - matrix->r1c1 = 0.0f; - matrix->r1c2 = 0.0f; - matrix->r1c3 = 0.0f; + matrix->row1_col1 = 0.0f; + matrix->row1_col2 = 0.0f; + matrix->row1_col3 = 0.0f; - matrix->r2c1 = 0.0f; - matrix->r2c2 = 0.0f; - matrix->r2c3 = 0.0f; + matrix->row2_col1 = 0.0f; + matrix->row2_col2 = 0.0f; + matrix->row2_col3 = 0.0f; } inline void bgc_fp64_matrix3x2_reset(BGC_FP64_Matrix3x2* matrix) { - matrix->r1c1 = 0.0; - matrix->r1c2 = 0.0; - matrix->r1c3 = 0.0; + matrix->row1_col1 = 0.0; + matrix->row1_col2 = 0.0; + matrix->row1_col3 = 0.0; - matrix->r2c1 = 0.0; - matrix->r2c2 = 0.0; - matrix->r2c3 = 0.0; + matrix->row2_col1 = 0.0; + matrix->row2_col2 = 0.0; + matrix->row2_col3 = 0.0; } // ==================== Copy ==================== // inline void bgc_fp32_matrix3x2_copy(BGC_FP32_Matrix3x2* destination, const BGC_FP32_Matrix3x2* source) { - destination->r1c1 = source->r1c1; - destination->r1c2 = source->r1c2; - destination->r1c3 = source->r1c3; + destination->row1_col1 = source->row1_col1; + destination->row1_col2 = source->row1_col2; + destination->row1_col3 = source->row1_col3; - destination->r2c1 = source->r2c1; - destination->r2c2 = source->r2c2; - destination->r2c3 = source->r2c3; + destination->row2_col1 = source->row2_col1; + destination->row2_col2 = source->row2_col2; + destination->row2_col3 = source->row2_col3; } inline void bgc_fp64_matrix3x2_copy(BGC_FP64_Matrix3x2* destination, const BGC_FP64_Matrix3x2* source) { - destination->r1c1 = source->r1c1; - destination->r1c2 = source->r1c2; - destination->r1c3 = source->r1c3; + destination->row1_col1 = source->row1_col1; + destination->row1_col2 = source->row1_col2; + destination->row1_col3 = source->row1_col3; - destination->r2c1 = source->r2c1; - destination->r2c2 = source->r2c2; - destination->r2c3 = source->r2c3; + destination->row2_col1 = source->row2_col1; + destination->row2_col2 = source->row2_col2; + destination->row2_col3 = source->row2_col3; } // ==================== Swap ==================== // inline void bgc_fp32_matrix3x2_swap(BGC_FP32_Matrix3x2* matrix1, BGC_FP32_Matrix3x2* matrix2) { - const float r1c1 = matrix2->r1c1; - const float r1c2 = matrix2->r1c2; - const float r1c3 = matrix2->r1c3; + const float row1_col1 = matrix2->row1_col1; + const float row1_col2 = matrix2->row1_col2; + const float row1_col3 = matrix2->row1_col3; - const float r2c1 = matrix2->r2c1; - const float r2c2 = matrix2->r2c2; - const float r2c3 = matrix2->r2c3; + const float row2_col1 = matrix2->row2_col1; + const float row2_col2 = matrix2->row2_col2; + const float row2_col3 = matrix2->row2_col3; - matrix2->r1c1 = matrix1->r1c1; - matrix2->r1c2 = matrix1->r1c2; - matrix2->r1c3 = matrix1->r1c3; + matrix2->row1_col1 = matrix1->row1_col1; + matrix2->row1_col2 = matrix1->row1_col2; + matrix2->row1_col3 = matrix1->row1_col3; - matrix2->r2c1 = matrix1->r2c1; - matrix2->r2c2 = matrix1->r2c2; - matrix2->r2c3 = matrix1->r2c3; + matrix2->row2_col1 = matrix1->row2_col1; + matrix2->row2_col2 = matrix1->row2_col2; + matrix2->row2_col3 = matrix1->row2_col3; - matrix1->r1c1 = r1c1; - matrix1->r1c2 = r1c2; - matrix1->r1c3 = r1c3; + matrix1->row1_col1 = row1_col1; + matrix1->row1_col2 = row1_col2; + matrix1->row1_col3 = row1_col3; - matrix1->r2c1 = r2c1; - matrix1->r2c2 = r2c2; - matrix1->r2c3 = r2c3; + matrix1->row2_col1 = row2_col1; + matrix1->row2_col2 = row2_col2; + matrix1->row2_col3 = row2_col3; } inline void bgc_fp64_matrix3x2_swap(BGC_FP64_Matrix3x2* matrix1, BGC_FP64_Matrix3x2* matrix2) { - const double r1c1 = matrix2->r1c1; - const double r1c2 = matrix2->r1c2; - const double r1c3 = matrix2->r1c3; + const double row1_col1 = matrix2->row1_col1; + const double row1_col2 = matrix2->row1_col2; + const double row1_col3 = matrix2->row1_col3; - const double r2c1 = matrix2->r2c1; - const double r2c2 = matrix2->r2c2; - const double r2c3 = matrix2->r2c3; + const double row2_col1 = matrix2->row2_col1; + const double row2_col2 = matrix2->row2_col2; + const double row2_col3 = matrix2->row2_col3; - matrix2->r1c1 = matrix1->r1c1; - matrix2->r1c2 = matrix1->r1c2; - matrix2->r1c3 = matrix1->r1c3; + matrix2->row1_col1 = matrix1->row1_col1; + matrix2->row1_col2 = matrix1->row1_col2; + matrix2->row1_col3 = matrix1->row1_col3; - matrix2->r2c1 = matrix1->r2c1; - matrix2->r2c2 = matrix1->r2c2; - matrix2->r2c3 = matrix1->r2c3; + matrix2->row2_col1 = matrix1->row2_col1; + matrix2->row2_col2 = matrix1->row2_col2; + matrix2->row2_col3 = matrix1->row2_col3; - matrix1->r1c1 = r1c1; - matrix1->r1c2 = r1c2; - matrix1->r1c3 = r1c3; + matrix1->row1_col1 = row1_col1; + matrix1->row1_col2 = row1_col2; + matrix1->row1_col3 = row1_col3; - matrix1->r2c1 = r2c1; - matrix1->r2c2 = r2c2; - matrix1->r2c3 = r2c3; + matrix1->row2_col1 = row2_col1; + matrix1->row2_col2 = row2_col2; + matrix1->row2_col3 = row2_col3; } // ================== Convert =================== // inline void bgc_fp64_matrix3x2_convert_to_fp32(BGC_FP32_Matrix3x2* destination, const BGC_FP64_Matrix3x2* source) { - destination->r1c1 = (float)source->r1c1; - destination->r1c2 = (float)source->r1c2; - destination->r1c3 = (float)source->r1c3; + destination->row1_col1 = (float)source->row1_col1; + destination->row1_col2 = (float)source->row1_col2; + destination->row1_col3 = (float)source->row1_col3; - destination->r2c1 = (float)source->r2c1; - destination->r2c2 = (float)source->r2c2; - destination->r2c3 = (float)source->r2c3; + destination->row2_col1 = (float)source->row2_col1; + destination->row2_col2 = (float)source->row2_col2; + destination->row2_col3 = (float)source->row2_col3; } inline void bgc_fp32_matrix3x2_convert_to_fp64(BGC_FP64_Matrix3x2* destination, const BGC_FP32_Matrix3x2* source) { - destination->r1c1 = source->r1c1; - destination->r1c2 = source->r1c2; - destination->r1c3 = source->r1c3; + destination->row1_col1 = source->row1_col1; + destination->row1_col2 = source->row1_col2; + destination->row1_col3 = source->row1_col3; - destination->r2c1 = source->r2c1; - destination->r2c2 = source->r2c2; - destination->r2c3 = source->r2c3; + destination->row2_col1 = source->row2_col1; + destination->row2_col2 = source->row2_col2; + destination->row2_col3 = source->row2_col3; } // ================= Transpose ================== // inline void bgc_fp32_matrix3x2_get_transposed(BGC_FP32_Matrix3x2* transposed, const BGC_FP32_Matrix2x3* matrix) { - transposed->r1c1 = matrix->r1c1; - transposed->r1c2 = matrix->r2c1; - transposed->r1c3 = matrix->r3c1; + transposed->row1_col1 = matrix->row1_col1; + transposed->row1_col2 = matrix->row2_col1; + transposed->row1_col3 = matrix->row3_col1; - transposed->r2c1 = matrix->r1c2; - transposed->r2c2 = matrix->r2c2; - transposed->r2c3 = matrix->r3c2; + transposed->row2_col1 = matrix->row1_col2; + transposed->row2_col2 = matrix->row2_col2; + transposed->row2_col3 = matrix->row3_col2; } inline void bgc_fp64_matrix3x2_get_transposed(BGC_FP64_Matrix3x2* transposed, const BGC_FP64_Matrix2x3* matrix) { - transposed->r1c1 = matrix->r1c1; - transposed->r1c2 = matrix->r2c1; - transposed->r1c3 = matrix->r3c1; + transposed->row1_col1 = matrix->row1_col1; + transposed->row1_col2 = matrix->row2_col1; + transposed->row1_col3 = matrix->row3_col1; - transposed->r2c1 = matrix->r1c2; - transposed->r2c2 = matrix->r2c2; - transposed->r2c3 = matrix->r3c2; + transposed->row2_col1 = matrix->row1_col2; + transposed->row2_col2 = matrix->row2_col2; + transposed->row2_col3 = matrix->row3_col2; } // ================== Get Row =================== // @@ -163,17 +163,17 @@ inline void bgc_fp32_matrix3x2_get_row(BGC_FP32_Vector3* row, const BGC_FP32_Mat { if (row_number == 1) { - row->x1 = matrix->r1c1; - row->x2 = matrix->r1c2; - row->x3 = matrix->r1c3; + row->x1 = matrix->row1_col1; + row->x2 = matrix->row1_col2; + row->x3 = matrix->row1_col3; return; } if (row_number == 2) { - row->x1 = matrix->r2c1; - row->x2 = matrix->r2c2; - row->x3 = matrix->r2c3; + row->x1 = matrix->row2_col1; + row->x2 = matrix->row2_col2; + row->x3 = matrix->row2_col3; return; } @@ -186,17 +186,17 @@ inline void bgc_fp64_matrix3x2_get_row(BGC_FP64_Vector3* row, const BGC_FP64_Mat { if (row_number == 1) { - row->x1 = matrix->r1c1; - row->x2 = matrix->r1c2; - row->x3 = matrix->r1c3; + row->x1 = matrix->row1_col1; + row->x2 = matrix->row1_col2; + row->x3 = matrix->row1_col3; return; } if (row_number == 2) { - row->x1 = matrix->r2c1; - row->x2 = matrix->r2c2; - row->x3 = matrix->r2c3; + row->x1 = matrix->row2_col1; + row->x2 = matrix->row2_col2; + row->x3 = matrix->row2_col3; return; } @@ -211,17 +211,17 @@ inline void bgc_fp32_matrix3x2_set_row(BGC_FP32_Matrix3x2* matrix, const int row { if (row_number == 1) { - matrix->r1c1 = row->x1; - matrix->r1c2 = row->x2; - matrix->r1c3 = row->x3; + matrix->row1_col1 = row->x1; + matrix->row1_col2 = row->x2; + matrix->row1_col3 = row->x3; return; } if (row_number == 2) { - matrix->r2c1 = row->x1; - matrix->r2c2 = row->x2; - matrix->r2c3 = row->x3; + matrix->row2_col1 = row->x1; + matrix->row2_col2 = row->x2; + matrix->row2_col3 = row->x3; } } @@ -229,17 +229,17 @@ inline void bgc_fp64_matrix3x2_set_row(BGC_FP64_Matrix3x2* matrix, const int row { if (row_number == 1) { - matrix->r1c1 = row->x1; - matrix->r1c2 = row->x2; - matrix->r1c3 = row->x3; + matrix->row1_col1 = row->x1; + matrix->row1_col2 = row->x2; + matrix->row1_col3 = row->x3; return; } if (row_number == 2) { - matrix->r2c1 = row->x1; - matrix->r2c2 = row->x2; - matrix->r2c3 = row->x3; + matrix->row2_col1 = row->x1; + matrix->row2_col2 = row->x2; + matrix->row2_col3 = row->x3; } } @@ -249,22 +249,22 @@ inline void bgc_fp32_matrix3x2_get_column(BGC_FP32_Vector2* column, const BGC_FP { if (column_number == 1) { - column->x1 = matrix->r1c1; - column->x2 = matrix->r2c1; + column->x1 = matrix->row1_col1; + column->x2 = matrix->row2_col1; return; } if (column_number == 2) { - column->x1 = matrix->r1c2; - column->x2 = matrix->r2c2; + column->x1 = matrix->row1_col2; + column->x2 = matrix->row2_col2; return; } if (column_number == 3) { - column->x1 = matrix->r1c3; - column->x2 = matrix->r2c3; + column->x1 = matrix->row1_col3; + column->x2 = matrix->row2_col3; return; } @@ -276,22 +276,22 @@ inline void bgc_fp64_matrix3x2_get_column(BGC_FP64_Vector2* column, const BGC_FP { if (column_number == 1) { - column->x1 = matrix->r1c1; - column->x2 = matrix->r2c1; + column->x1 = matrix->row1_col1; + column->x2 = matrix->row2_col1; return; } if (column_number == 2) { - column->x1 = matrix->r1c2; - column->x2 = matrix->r2c2; + column->x1 = matrix->row1_col2; + column->x2 = matrix->row2_col2; return; } if (column_number == 3) { - column->x1 = matrix->r1c3; - column->x2 = matrix->r2c3; + column->x1 = matrix->row1_col3; + column->x2 = matrix->row2_col3; return; } @@ -305,22 +305,22 @@ inline void bgc_fp32_matrix3x2_set_column(BGC_FP32_Matrix3x2* matrix, const int { if (column_number == 1) { - matrix->r1c1 = column->x1; - matrix->r2c1 = column->x2; + matrix->row1_col1 = column->x1; + matrix->row2_col1 = column->x2; return; } if (column_number == 2) { - matrix->r1c2 = column->x1; - matrix->r2c2 = column->x2; + matrix->row1_col2 = column->x1; + matrix->row2_col2 = column->x2; return; } if (column_number == 3) { - matrix->r1c3 = column->x1; - matrix->r2c3 = column->x2; + matrix->row1_col3 = column->x1; + matrix->row2_col3 = column->x2; } } @@ -328,22 +328,22 @@ inline void bgc_fp64_matrix3x2_set_column(BGC_FP64_Matrix3x2* matrix, const int { if (column_number == 1) { - matrix->r1c1 = column->x1; - matrix->r2c1 = column->x2; + matrix->row1_col1 = column->x1; + matrix->row2_col1 = column->x2; return; } if (column_number == 2) { - matrix->r1c2 = column->x1; - matrix->r2c2 = column->x2; + matrix->row1_col2 = column->x1; + matrix->row2_col2 = column->x2; return; } if (column_number == 3) { - matrix->r1c3 = column->x1; - matrix->r2c3 = column->x2; + matrix->row1_col3 = column->x1; + matrix->row2_col3 = column->x2; } } @@ -351,96 +351,96 @@ inline void bgc_fp64_matrix3x2_set_column(BGC_FP64_Matrix3x2* matrix, const int inline void bgc_fp32_matrix3x2_add(BGC_FP32_Matrix3x2* sum, const BGC_FP32_Matrix3x2* matrix1, const BGC_FP32_Matrix3x2* matrix2) { - sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; - sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; - sum->r1c3 = matrix1->r1c3 + matrix2->r1c3; + sum->row1_col1 = matrix1->row1_col1 + matrix2->row1_col1; + sum->row1_col2 = matrix1->row1_col2 + matrix2->row1_col2; + sum->row1_col3 = matrix1->row1_col3 + matrix2->row1_col3; - sum->r2c1 = matrix1->r2c1 + matrix2->r2c1; - sum->r2c2 = matrix1->r2c2 + matrix2->r2c2; - sum->r2c3 = matrix1->r2c3 + matrix2->r2c3; + sum->row2_col1 = matrix1->row2_col1 + matrix2->row2_col1; + sum->row2_col2 = matrix1->row2_col2 + matrix2->row2_col2; + sum->row2_col3 = matrix1->row2_col3 + matrix2->row2_col3; } inline void bgc_fp64_matrix3x2_add(BGC_FP64_Matrix3x2* sum, const BGC_FP64_Matrix3x2* matrix1, const BGC_FP64_Matrix3x2* matrix2) { - sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; - sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; - sum->r1c3 = matrix1->r1c3 + matrix2->r1c3; + sum->row1_col1 = matrix1->row1_col1 + matrix2->row1_col1; + sum->row1_col2 = matrix1->row1_col2 + matrix2->row1_col2; + sum->row1_col3 = matrix1->row1_col3 + matrix2->row1_col3; - sum->r2c1 = matrix1->r2c1 + matrix2->r2c1; - sum->r2c2 = matrix1->r2c2 + matrix2->r2c2; - sum->r2c3 = matrix1->r2c3 + matrix2->r2c3; + sum->row2_col1 = matrix1->row2_col1 + matrix2->row2_col1; + sum->row2_col2 = matrix1->row2_col2 + matrix2->row2_col2; + sum->row2_col3 = matrix1->row2_col3 + matrix2->row2_col3; } // ================= Add scaled ================= // inline void bgc_fp32_matrix3x2_add_scaled(BGC_FP32_Matrix3x2* sum, const BGC_FP32_Matrix3x2* basic_matrix, const BGC_FP32_Matrix3x2* scalable_matrix, const float scale) { - sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; - sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; - sum->r1c3 = basic_matrix->r1c3 + scalable_matrix->r1c3 * scale; + sum->row1_col1 = basic_matrix->row1_col1 + scalable_matrix->row1_col1 * scale; + sum->row1_col2 = basic_matrix->row1_col2 + scalable_matrix->row1_col2 * scale; + sum->row1_col3 = basic_matrix->row1_col3 + scalable_matrix->row1_col3 * scale; - sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale; - sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale; - sum->r2c3 = basic_matrix->r2c3 + scalable_matrix->r2c3 * scale; + sum->row2_col1 = basic_matrix->row2_col1 + scalable_matrix->row2_col1 * scale; + sum->row2_col2 = basic_matrix->row2_col2 + scalable_matrix->row2_col2 * scale; + sum->row2_col3 = basic_matrix->row2_col3 + scalable_matrix->row2_col3 * scale; } inline void bgc_fp64_matrix3x2_add_scaled(BGC_FP64_Matrix3x2* sum, const BGC_FP64_Matrix3x2* basic_matrix, const BGC_FP64_Matrix3x2* scalable_matrix, const double scale) { - sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; - sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; - sum->r1c3 = basic_matrix->r1c3 + scalable_matrix->r1c3 * scale; + sum->row1_col1 = basic_matrix->row1_col1 + scalable_matrix->row1_col1 * scale; + sum->row1_col2 = basic_matrix->row1_col2 + scalable_matrix->row1_col2 * scale; + sum->row1_col3 = basic_matrix->row1_col3 + scalable_matrix->row1_col3 * scale; - sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale; - sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale; - sum->r2c3 = basic_matrix->r2c3 + scalable_matrix->r2c3 * scale; + sum->row2_col1 = basic_matrix->row2_col1 + scalable_matrix->row2_col1 * scale; + sum->row2_col2 = basic_matrix->row2_col2 + scalable_matrix->row2_col2 * scale; + sum->row2_col3 = basic_matrix->row2_col3 + scalable_matrix->row2_col3 * scale; } // ================== Subtract ================== // inline void bgc_fp32_matrix3x2_subtract(BGC_FP32_Matrix3x2* difference, const BGC_FP32_Matrix3x2* minuend, const BGC_FP32_Matrix3x2* subtrahend) { - difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; - difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; - difference->r1c3 = minuend->r1c3 - subtrahend->r1c3; + difference->row1_col1 = minuend->row1_col1 - subtrahend->row1_col1; + difference->row1_col2 = minuend->row1_col2 - subtrahend->row1_col2; + difference->row1_col3 = minuend->row1_col3 - subtrahend->row1_col3; - difference->r2c1 = minuend->r2c1 - subtrahend->r2c1; - difference->r2c2 = minuend->r2c2 - subtrahend->r2c2; - difference->r2c3 = minuend->r2c3 - subtrahend->r2c3; + difference->row2_col1 = minuend->row2_col1 - subtrahend->row2_col1; + difference->row2_col2 = minuend->row2_col2 - subtrahend->row2_col2; + difference->row2_col3 = minuend->row2_col3 - subtrahend->row2_col3; } inline void bgc_fp64_matrix3x2_subtract(BGC_FP64_Matrix3x2* difference, const BGC_FP64_Matrix3x2* minuend, const BGC_FP64_Matrix3x2* subtrahend) { - difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; - difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; - difference->r1c3 = minuend->r1c3 - subtrahend->r1c3; + difference->row1_col1 = minuend->row1_col1 - subtrahend->row1_col1; + difference->row1_col2 = minuend->row1_col2 - subtrahend->row1_col2; + difference->row1_col3 = minuend->row1_col3 - subtrahend->row1_col3; - difference->r2c1 = minuend->r2c1 - subtrahend->r2c1; - difference->r2c2 = minuend->r2c2 - subtrahend->r2c2; - difference->r2c3 = minuend->r2c3 - subtrahend->r2c3; + difference->row2_col1 = minuend->row2_col1 - subtrahend->row2_col1; + difference->row2_col2 = minuend->row2_col2 - subtrahend->row2_col2; + difference->row2_col3 = minuend->row2_col3 - subtrahend->row2_col3; } // ================== Multiply ================== // inline void bgc_fp32_matrix3x2_multiply(BGC_FP32_Matrix3x2* product, const BGC_FP32_Matrix3x2* multiplicand, const float multiplier) { - product->r1c1 = multiplicand->r1c1 * multiplier; - product->r1c2 = multiplicand->r1c2 * multiplier; - product->r1c3 = multiplicand->r1c3 * multiplier; + product->row1_col1 = multiplicand->row1_col1 * multiplier; + product->row1_col2 = multiplicand->row1_col2 * multiplier; + product->row1_col3 = multiplicand->row1_col3 * multiplier; - product->r2c1 = multiplicand->r2c1 * multiplier; - product->r2c2 = multiplicand->r2c2 * multiplier; - product->r2c3 = multiplicand->r2c3 * multiplier; + product->row2_col1 = multiplicand->row2_col1 * multiplier; + product->row2_col2 = multiplicand->row2_col2 * multiplier; + product->row2_col3 = multiplicand->row2_col3 * multiplier; } inline void bgc_fp64_matrix3x2_multiply(BGC_FP64_Matrix3x2* product, const BGC_FP64_Matrix3x2* multiplicand, const double multiplier) { - product->r1c1 = multiplicand->r1c1 * multiplier; - product->r1c2 = multiplicand->r1c2 * multiplier; - product->r1c3 = multiplicand->r1c3 * multiplier; + product->row1_col1 = multiplicand->row1_col1 * multiplier; + product->row1_col2 = multiplicand->row1_col2 * multiplier; + product->row1_col3 = multiplicand->row1_col3 * multiplier; - product->r2c1 = multiplicand->r2c1 * multiplier; - product->r2c2 = multiplicand->r2c2 * multiplier; - product->r2c3 = multiplicand->r2c3 * multiplier; + product->row2_col1 = multiplicand->row2_col1 * multiplier; + product->row2_col2 = multiplicand->row2_col2 * multiplier; + product->row2_col3 = multiplicand->row2_col3 * multiplier; } // =================== Divide =================== // @@ -461,56 +461,56 @@ inline void bgc_fp32_matrix3x2_interpolate(BGC_FP32_Matrix3x2* interpolation, co { 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->row1_col1 = first->row1_col1 * couter_phase + second->row1_col1 * phase; + interpolation->row1_col2 = first->row1_col2 * couter_phase + second->row1_col2 * phase; + interpolation->row1_col3 = first->row1_col3 * couter_phase + second->row1_col3 * 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; + interpolation->row2_col1 = first->row2_col1 * couter_phase + second->row2_col1 * phase; + interpolation->row2_col2 = first->row2_col2 * couter_phase + second->row2_col2 * phase; + interpolation->row2_col3 = first->row2_col3 * couter_phase + second->row2_col3 * phase; } inline void bgc_fp64_matrix3x2_interpolate(BGC_FP64_Matrix3x2* interpolation, const BGC_FP64_Matrix3x2* first, const BGC_FP64_Matrix3x2* second, const double phase) { 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->row1_col1 = first->row1_col1 * couter_phase + second->row1_col1 * phase; + interpolation->row1_col2 = first->row1_col2 * couter_phase + second->row1_col2 * phase; + interpolation->row1_col3 = first->row1_col3 * couter_phase + second->row1_col3 * 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; + interpolation->row2_col1 = first->row2_col1 * couter_phase + second->row2_col1 * phase; + interpolation->row2_col2 = first->row2_col2 * couter_phase + second->row2_col2 * phase; + interpolation->row2_col3 = first->row2_col3 * couter_phase + second->row2_col3 * phase; } // ============ Left Vector Product ============= // inline void bgc_fp32_multiply_vector2_by_matrix3x2(BGC_FP32_Vector3* product, const BGC_FP32_Vector2* vector, const BGC_FP32_Matrix3x2* matrix) { - product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1; - product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2; - product->x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3; + product->x1 = vector->x1 * matrix->row1_col1 + vector->x2 * matrix->row2_col1; + product->x2 = vector->x1 * matrix->row1_col2 + vector->x2 * matrix->row2_col2; + product->x3 = vector->x1 * matrix->row1_col3 + vector->x2 * matrix->row2_col3; } inline void bgc_fp64_multiply_vector2_by_matrix3x2(BGC_FP64_Vector3* product, const BGC_FP64_Vector2* vector, const BGC_FP64_Matrix3x2* matrix) { - product->x1 = vector->x1 * matrix->r1c1 + vector->x2 * matrix->r2c1; - product->x2 = vector->x1 * matrix->r1c2 + vector->x2 * matrix->r2c2; - product->x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3; + product->x1 = vector->x1 * matrix->row1_col1 + vector->x2 * matrix->row2_col1; + product->x2 = vector->x1 * matrix->row1_col2 + vector->x2 * matrix->row2_col2; + product->x3 = vector->x1 * matrix->row1_col3 + vector->x2 * matrix->row2_col3; } // ============ Right Vector Product ============ // inline void bgc_fp32_multiply_matrix3x2_by_vector3(BGC_FP32_Vector2* product, const BGC_FP32_Matrix3x2* matrix, const BGC_FP32_Vector3* vector) { - product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3; - product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3; + product->x1 = matrix->row1_col1 * vector->x1 + matrix->row1_col2 * vector->x2 + matrix->row1_col3 * vector->x3; + product->x2 = matrix->row2_col1 * vector->x1 + matrix->row2_col2 * vector->x2 + matrix->row2_col3 * vector->x3; } inline void bgc_fp64_multiply_matrix3x2_by_vector3(BGC_FP64_Vector2* product, const BGC_FP64_Matrix3x2* matrix, const BGC_FP64_Vector3* vector) { - product->x1 = matrix->r1c1 * vector->x1 + matrix->r1c2 * vector->x2 + matrix->r1c3 * vector->x3; - product->x2 = matrix->r2c1 * vector->x1 + matrix->r2c2 * vector->x2 + matrix->r2c3 * vector->x3; + product->x1 = matrix->row1_col1 * vector->x1 + matrix->row1_col2 * vector->x2 + matrix->row1_col3 * vector->x3; + product->x2 = matrix->row2_col1 * vector->x1 + matrix->row2_col2 * vector->x2 + matrix->row2_col3 * vector->x3; } #endif diff --git a/basic-geometry/matrix3x3.c b/basic-geometry/matrix3x3.c index 4125e37..eff063d 100644 --- a/basic-geometry/matrix3x3.c +++ b/basic-geometry/matrix3x3.c @@ -85,31 +85,31 @@ int bgc_fp32_matrix3x3_get_inverse(BGC_FP32_Matrix3x3* inverse, const BGC_FP32_M return 0; } - const float r1c1 = matrix->r2c2 * matrix->r3c3 - matrix->r2c3 * matrix->r3c2; - const float r1c2 = matrix->r1c3 * matrix->r3c2 - matrix->r1c2 * matrix->r3c3; - const float r1c3 = matrix->r1c2 * matrix->r2c3 - matrix->r1c3 * matrix->r2c2; + const float row1_col1 = matrix->row2_col2 * matrix->row3_col3 - matrix->row2_col3 * matrix->row3_col2; + const float row1_col2 = matrix->row1_col3 * matrix->row3_col2 - matrix->row1_col2 * matrix->row3_col3; + const float row1_col3 = matrix->row1_col2 * matrix->row2_col3 - matrix->row1_col3 * matrix->row2_col2; - const float r2c1 = matrix->r2c3 * matrix->r3c1 - matrix->r2c1 * matrix->r3c3; - const float r2c2 = matrix->r1c1 * matrix->r3c3 - matrix->r1c3 * matrix->r3c1; - const float r2c3 = matrix->r1c3 * matrix->r2c1 - matrix->r1c1 * matrix->r2c3; + const float row2_col1 = matrix->row2_col3 * matrix->row3_col1 - matrix->row2_col1 * matrix->row3_col3; + const float row2_col2 = matrix->row1_col1 * matrix->row3_col3 - matrix->row1_col3 * matrix->row3_col1; + const float row2_col3 = matrix->row1_col3 * matrix->row2_col1 - matrix->row1_col1 * matrix->row2_col3; - const float r3c1 = matrix->r2c1 * matrix->r3c2 - matrix->r2c2 * matrix->r3c1; - const float r3c2 = matrix->r1c2 * matrix->r3c1 - matrix->r1c1 * matrix->r3c2; - const float r3c3 = matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1; + const float row3_col1 = matrix->row2_col1 * matrix->row3_col2 - matrix->row2_col2 * matrix->row3_col1; + const float row3_col2 = matrix->row1_col2 * matrix->row3_col1 - matrix->row1_col1 * matrix->row3_col2; + const float row3_col3 = matrix->row1_col1 * matrix->row2_col2 - matrix->row1_col2 * matrix->row2_col1; const float multiplier = 1.0f / determinant; - inverse->r1c1 = r1c1 * multiplier; - inverse->r1c2 = r1c2 * multiplier; - inverse->r1c3 = r1c3 * multiplier; + inverse->row1_col1 = row1_col1 * multiplier; + inverse->row1_col2 = row1_col2 * multiplier; + inverse->row1_col3 = row1_col3 * multiplier; - inverse->r2c1 = r2c1 * multiplier; - inverse->r2c2 = r2c2 * multiplier; - inverse->r2c3 = r2c3 * multiplier; + inverse->row2_col1 = row2_col1 * multiplier; + inverse->row2_col2 = row2_col2 * multiplier; + inverse->row2_col3 = row2_col3 * multiplier; - inverse->r3c1 = r3c1 * multiplier; - inverse->r3c2 = r3c2 * multiplier; - inverse->r3c3 = r3c3 * multiplier; + inverse->row3_col1 = row3_col1 * multiplier; + inverse->row3_col2 = row3_col2 * multiplier; + inverse->row3_col3 = row3_col3 * multiplier; return 1; } @@ -122,31 +122,31 @@ int bgc_fp64_matrix3x3_get_inverse(BGC_FP64_Matrix3x3* inverse, const BGC_FP64_M return 0; } - const double r1c1 = matrix->r2c2 * matrix->r3c3 - matrix->r2c3 * matrix->r3c2; - const double r1c2 = matrix->r1c3 * matrix->r3c2 - matrix->r1c2 * matrix->r3c3; - const double r1c3 = matrix->r1c2 * matrix->r2c3 - matrix->r1c3 * matrix->r2c2; + const double row1_col1 = matrix->row2_col2 * matrix->row3_col3 - matrix->row2_col3 * matrix->row3_col2; + const double row1_col2 = matrix->row1_col3 * matrix->row3_col2 - matrix->row1_col2 * matrix->row3_col3; + const double row1_col3 = matrix->row1_col2 * matrix->row2_col3 - matrix->row1_col3 * matrix->row2_col2; - const double r2c1 = matrix->r2c3 * matrix->r3c1 - matrix->r2c1 * matrix->r3c3; - const double r2c2 = matrix->r1c1 * matrix->r3c3 - matrix->r1c3 * matrix->r3c1; - const double r2c3 = matrix->r1c3 * matrix->r2c1 - matrix->r1c1 * matrix->r2c3; + const double row2_col1 = matrix->row2_col3 * matrix->row3_col1 - matrix->row2_col1 * matrix->row3_col3; + const double row2_col2 = matrix->row1_col1 * matrix->row3_col3 - matrix->row1_col3 * matrix->row3_col1; + const double row2_col3 = matrix->row1_col3 * matrix->row2_col1 - matrix->row1_col1 * matrix->row2_col3; - const double r3c1 = matrix->r2c1 * matrix->r3c2 - matrix->r2c2 * matrix->r3c1; - const double r3c2 = matrix->r1c2 * matrix->r3c1 - matrix->r1c1 * matrix->r3c2; - const double r3c3 = matrix->r1c1 * matrix->r2c2 - matrix->r1c2 * matrix->r2c1; + const double row3_col1 = matrix->row2_col1 * matrix->row3_col2 - matrix->row2_col2 * matrix->row3_col1; + const double row3_col2 = matrix->row1_col2 * matrix->row3_col1 - matrix->row1_col1 * matrix->row3_col2; + const double row3_col3 = matrix->row1_col1 * matrix->row2_col2 - matrix->row1_col2 * matrix->row2_col1; const double multiplier = 1.0 / determinant; - inverse->r1c1 = r1c1 * multiplier; - inverse->r1c2 = r1c2 * multiplier; - inverse->r1c3 = r1c3 * multiplier; + inverse->row1_col1 = row1_col1 * multiplier; + inverse->row1_col2 = row1_col2 * multiplier; + inverse->row1_col3 = row1_col3 * multiplier; - inverse->r2c1 = r2c1 * multiplier; - inverse->r2c2 = r2c2 * multiplier; - inverse->r2c3 = r2c3 * multiplier; + inverse->row2_col1 = row2_col1 * multiplier; + inverse->row2_col2 = row2_col2 * multiplier; + inverse->row2_col3 = row2_col3 * multiplier; - inverse->r3c1 = r3c1 * multiplier; - inverse->r3c2 = r3c2 * multiplier; - inverse->r3c3 = r3c3 * multiplier; + inverse->row3_col1 = row3_col1 * multiplier; + inverse->row3_col2 = row3_col2 * multiplier; + inverse->row3_col3 = row3_col3 * multiplier; return 1; } diff --git a/basic-geometry/matrix3x3.h b/basic-geometry/matrix3x3.h index 18568bd..aaf646d 100644 --- a/basic-geometry/matrix3x3.h +++ b/basic-geometry/matrix3x3.h @@ -8,272 +8,272 @@ inline void bgc_fp32_matrix3x3_reset(BGC_FP32_Matrix3x3* matrix) { - matrix->r1c1 = 0.0f; - matrix->r1c2 = 0.0f; - matrix->r1c3 = 0.0f; + matrix->row1_col1 = 0.0f; + matrix->row1_col2 = 0.0f; + matrix->row1_col3 = 0.0f; - matrix->r2c1 = 0.0f; - matrix->r2c2 = 0.0f; - matrix->r2c3 = 0.0f; + matrix->row2_col1 = 0.0f; + matrix->row2_col2 = 0.0f; + matrix->row2_col3 = 0.0f; - matrix->r3c1 = 0.0f; - matrix->r3c2 = 0.0f; - matrix->r3c3 = 0.0f; + matrix->row3_col1 = 0.0f; + matrix->row3_col2 = 0.0f; + matrix->row3_col3 = 0.0f; } inline void bgc_fp64_matrix3x3_reset(BGC_FP64_Matrix3x3* matrix) { - matrix->r1c1 = 0.0; - matrix->r1c2 = 0.0; - matrix->r1c3 = 0.0; + matrix->row1_col1 = 0.0; + matrix->row1_col2 = 0.0; + matrix->row1_col3 = 0.0; - matrix->r2c1 = 0.0; - matrix->r2c2 = 0.0; - matrix->r2c3 = 0.0; + matrix->row2_col1 = 0.0; + matrix->row2_col2 = 0.0; + matrix->row2_col3 = 0.0; - matrix->r3c1 = 0.0; - matrix->r3c2 = 0.0; - matrix->r3c3 = 0.0; + matrix->row3_col1 = 0.0; + matrix->row3_col2 = 0.0; + matrix->row3_col3 = 0.0; } // ================== Identity ================== // inline void bgc_fp32_matrix3x3_make_identity(BGC_FP32_Matrix3x3* matrix) { - matrix->r1c1 = 1.0f; - matrix->r1c2 = 0.0f; - matrix->r1c3 = 0.0f; + matrix->row1_col1 = 1.0f; + matrix->row1_col2 = 0.0f; + matrix->row1_col3 = 0.0f; - matrix->r2c1 = 0.0f; - matrix->r2c2 = 1.0f; - matrix->r2c3 = 0.0f; + matrix->row2_col1 = 0.0f; + matrix->row2_col2 = 1.0f; + matrix->row2_col3 = 0.0f; - matrix->r3c1 = 0.0f; - matrix->r3c2 = 0.0f; - matrix->r3c3 = 1.0f; + matrix->row3_col1 = 0.0f; + matrix->row3_col2 = 0.0f; + matrix->row3_col3 = 1.0f; } inline void bgc_fp64_matrix3x3_make_identity(BGC_FP64_Matrix3x3* matrix) { - matrix->r1c1 = 1.0; - matrix->r1c2 = 0.0; - matrix->r1c3 = 0.0; + matrix->row1_col1 = 1.0; + matrix->row1_col2 = 0.0; + matrix->row1_col3 = 0.0; - matrix->r2c1 = 0.0; - matrix->r2c2 = 1.0; - matrix->r2c3 = 0.0; + matrix->row2_col1 = 0.0; + matrix->row2_col2 = 1.0; + matrix->row2_col3 = 0.0; - matrix->r3c1 = 0.0; - matrix->r3c2 = 0.0; - matrix->r3c3 = 1.0; + matrix->row3_col1 = 0.0; + matrix->row3_col2 = 0.0; + matrix->row3_col3 = 1.0; } // ================ Set Diagonal ================ // inline void bgc_fp32_matrix3x3_make_diagonal(BGC_FP32_Matrix3x3* matrix, const float d1, const float d2, const float d3) { - matrix->r1c1 = d1; - matrix->r1c2 = 0.0f; - matrix->r1c3 = 0.0f; + matrix->row1_col1 = d1; + matrix->row1_col2 = 0.0f; + matrix->row1_col3 = 0.0f; - matrix->r2c1 = 0.0f; - matrix->r2c2 = d2; - matrix->r2c3 = 0.0f; + matrix->row2_col1 = 0.0f; + matrix->row2_col2 = d2; + matrix->row2_col3 = 0.0f; - matrix->r3c1 = 0.0f; - matrix->r3c2 = 0.0f; - matrix->r3c3 = d2; + matrix->row3_col1 = 0.0f; + matrix->row3_col2 = 0.0f; + matrix->row3_col3 = d2; } inline void bgc_fp64_matrix3x3_make_diagonal(BGC_FP64_Matrix3x3* matrix, const double d1, const double d2, const double d3) { - matrix->r1c1 = d1; - matrix->r1c2 = 0.0; - matrix->r1c3 = 0.0; + matrix->row1_col1 = d1; + matrix->row1_col2 = 0.0; + matrix->row1_col3 = 0.0; - matrix->r2c1 = 0.0; - matrix->r2c2 = d2; - matrix->r2c3 = 0.0; + matrix->row2_col1 = 0.0; + matrix->row2_col2 = d2; + matrix->row2_col3 = 0.0; - matrix->r3c1 = 0.0; - matrix->r3c2 = 0.0; - matrix->r3c3 = d2; + matrix->row3_col1 = 0.0; + matrix->row3_col2 = 0.0; + matrix->row3_col3 = d2; } // ==================== Copy ==================== // inline void bgc_fp32_matrix3x3_copy(BGC_FP32_Matrix3x3* destination, const BGC_FP32_Matrix3x3* source) { - destination->r1c1 = source->r1c1; - destination->r1c2 = source->r1c2; - destination->r1c3 = source->r1c3; + destination->row1_col1 = source->row1_col1; + destination->row1_col2 = source->row1_col2; + destination->row1_col3 = source->row1_col3; - destination->r2c1 = source->r2c1; - destination->r2c2 = source->r2c2; - destination->r2c3 = source->r2c3; + destination->row2_col1 = source->row2_col1; + destination->row2_col2 = source->row2_col2; + destination->row2_col3 = source->row2_col3; - destination->r3c1 = source->r3c1; - destination->r3c2 = source->r3c2; - destination->r3c3 = source->r3c3; + destination->row3_col1 = source->row3_col1; + destination->row3_col2 = source->row3_col2; + destination->row3_col3 = source->row3_col3; } inline void bgc_fp64_matrix3x3_copy(BGC_FP64_Matrix3x3* destination, const BGC_FP64_Matrix3x3* source) { - destination->r1c1 = source->r1c1; - destination->r1c2 = source->r1c2; - destination->r1c3 = source->r1c3; + destination->row1_col1 = source->row1_col1; + destination->row1_col2 = source->row1_col2; + destination->row1_col3 = source->row1_col3; - destination->r2c1 = source->r2c1; - destination->r2c2 = source->r2c2; - destination->r2c3 = source->r2c3; + destination->row2_col1 = source->row2_col1; + destination->row2_col2 = source->row2_col2; + destination->row2_col3 = source->row2_col3; - destination->r3c1 = source->r3c1; - destination->r3c2 = source->r3c2; - destination->r3c3 = source->r3c3; + destination->row3_col1 = source->row3_col1; + destination->row3_col2 = source->row3_col2; + destination->row3_col3 = source->row3_col3; } // ==================== Swap ==================== // inline void bgc_fp32_matrix3x3_swap(BGC_FP32_Matrix3x3* matrix1, BGC_FP32_Matrix3x3* matrix2) { - const float r1c1 = matrix2->r1c1; - const float r1c2 = matrix2->r1c2; - const float r1c3 = matrix2->r1c3; + const float row1_col1 = matrix2->row1_col1; + const float row1_col2 = matrix2->row1_col2; + const float row1_col3 = matrix2->row1_col3; - const float r2c1 = matrix2->r2c1; - const float r2c2 = matrix2->r2c2; - const float r2c3 = matrix2->r2c3; + const float row2_col1 = matrix2->row2_col1; + const float row2_col2 = matrix2->row2_col2; + const float row2_col3 = matrix2->row2_col3; - const float r3c1 = matrix2->r3c1; - const float r3c2 = matrix2->r3c2; - const float r3c3 = matrix2->r3c3; + const float row3_col1 = matrix2->row3_col1; + const float row3_col2 = matrix2->row3_col2; + const float row3_col3 = matrix2->row3_col3; - matrix2->r1c1 = matrix1->r1c1; - matrix2->r1c2 = matrix1->r1c2; - matrix2->r1c3 = matrix1->r1c3; + matrix2->row1_col1 = matrix1->row1_col1; + matrix2->row1_col2 = matrix1->row1_col2; + matrix2->row1_col3 = matrix1->row1_col3; - matrix2->r2c1 = matrix1->r2c1; - matrix2->r2c2 = matrix1->r2c2; - matrix2->r2c3 = matrix1->r2c3; + matrix2->row2_col1 = matrix1->row2_col1; + matrix2->row2_col2 = matrix1->row2_col2; + matrix2->row2_col3 = matrix1->row2_col3; - matrix2->r3c1 = matrix1->r3c1; - matrix2->r3c2 = matrix1->r3c2; - matrix2->r3c3 = matrix1->r3c3; + matrix2->row3_col1 = matrix1->row3_col1; + matrix2->row3_col2 = matrix1->row3_col2; + matrix2->row3_col3 = matrix1->row3_col3; - matrix1->r1c1 = r1c1; - matrix1->r1c2 = r1c2; - matrix1->r1c3 = r1c3; + matrix1->row1_col1 = row1_col1; + matrix1->row1_col2 = row1_col2; + matrix1->row1_col3 = row1_col3; - matrix1->r2c1 = r2c1; - matrix1->r2c2 = r2c2; - matrix1->r2c3 = r2c3; + matrix1->row2_col1 = row2_col1; + matrix1->row2_col2 = row2_col2; + matrix1->row2_col3 = row2_col3; - matrix1->r3c1 = r3c1; - matrix1->r3c2 = r3c2; - matrix1->r3c3 = r3c3; + matrix1->row3_col1 = row3_col1; + matrix1->row3_col2 = row3_col2; + matrix1->row3_col3 = row3_col3; } inline void bgc_fp64_matrix3x3_swap(BGC_FP64_Matrix3x3* matrix1, BGC_FP64_Matrix3x3* matrix2) { - const double r1c1 = matrix2->r1c1; - const double r1c2 = matrix2->r1c2; - const double r1c3 = matrix2->r1c3; + const double row1_col1 = matrix2->row1_col1; + const double row1_col2 = matrix2->row1_col2; + const double row1_col3 = matrix2->row1_col3; - const double r2c1 = matrix2->r2c1; - const double r2c2 = matrix2->r2c2; - const double r2c3 = matrix2->r2c3; + const double row2_col1 = matrix2->row2_col1; + const double row2_col2 = matrix2->row2_col2; + const double row2_col3 = matrix2->row2_col3; - const double r3c1 = matrix2->r3c1; - const double r3c2 = matrix2->r3c2; - const double r3c3 = matrix2->r3c3; + const double row3_col1 = matrix2->row3_col1; + const double row3_col2 = matrix2->row3_col2; + const double row3_col3 = matrix2->row3_col3; - matrix2->r1c1 = matrix1->r1c1; - matrix2->r1c2 = matrix1->r1c2; - matrix2->r1c3 = matrix1->r1c3; + matrix2->row1_col1 = matrix1->row1_col1; + matrix2->row1_col2 = matrix1->row1_col2; + matrix2->row1_col3 = matrix1->row1_col3; - matrix2->r2c1 = matrix1->r2c1; - matrix2->r2c2 = matrix1->r2c2; - matrix2->r2c3 = matrix1->r2c3; + matrix2->row2_col1 = matrix1->row2_col1; + matrix2->row2_col2 = matrix1->row2_col2; + matrix2->row2_col3 = matrix1->row2_col3; - matrix2->r3c1 = matrix1->r3c1; - matrix2->r3c2 = matrix1->r3c2; - matrix2->r3c3 = matrix1->r3c3; + matrix2->row3_col1 = matrix1->row3_col1; + matrix2->row3_col2 = matrix1->row3_col2; + matrix2->row3_col3 = matrix1->row3_col3; - matrix1->r1c1 = r1c1; - matrix1->r1c2 = r1c2; - matrix1->r1c3 = r1c3; + matrix1->row1_col1 = row1_col1; + matrix1->row1_col2 = row1_col2; + matrix1->row1_col3 = row1_col3; - matrix1->r2c1 = r2c1; - matrix1->r2c2 = r2c2; - matrix1->r2c3 = r2c3; + matrix1->row2_col1 = row2_col1; + matrix1->row2_col2 = row2_col2; + matrix1->row2_col3 = row2_col3; - matrix1->r3c1 = r3c1; - matrix1->r3c2 = r3c2; - matrix1->r3c3 = r3c3; + matrix1->row3_col1 = row3_col1; + matrix1->row3_col2 = row3_col2; + matrix1->row3_col3 = row3_col3; } // ================== Convert =================== // inline void bgc_fp64_matrix3x3_convert_to_fp32(BGC_FP32_Matrix3x3* destination, const BGC_FP64_Matrix3x3* source) { - destination->r1c1 = (float)source->r1c1; - destination->r1c2 = (float)source->r1c2; - destination->r1c3 = (float)source->r1c3; + destination->row1_col1 = (float)source->row1_col1; + destination->row1_col2 = (float)source->row1_col2; + destination->row1_col3 = (float)source->row1_col3; - destination->r2c1 = (float)source->r2c1; - destination->r2c2 = (float)source->r2c2; - destination->r2c3 = (float)source->r2c3; + destination->row2_col1 = (float)source->row2_col1; + destination->row2_col2 = (float)source->row2_col2; + destination->row2_col3 = (float)source->row2_col3; - destination->r3c1 = (float)source->r3c1; - destination->r3c2 = (float)source->r3c2; - destination->r3c3 = (float)source->r3c3; + destination->row3_col1 = (float)source->row3_col1; + destination->row3_col2 = (float)source->row3_col2; + destination->row3_col3 = (float)source->row3_col3; } inline void bgc_fp32_matrix3x3_convert_to_fp64(BGC_FP64_Matrix3x3* destination, const BGC_FP32_Matrix3x3* source) { - destination->r1c1 = source->r1c1; - destination->r1c2 = source->r1c2; - destination->r1c3 = source->r1c3; + destination->row1_col1 = source->row1_col1; + destination->row1_col2 = source->row1_col2; + destination->row1_col3 = source->row1_col3; - destination->r2c1 = source->r2c1; - destination->r2c2 = source->r2c2; - destination->r2c3 = source->r2c3; + destination->row2_col1 = source->row2_col1; + destination->row2_col2 = source->row2_col2; + destination->row2_col3 = source->row2_col3; - destination->r3c1 = source->r3c1; - destination->r3c2 = source->r3c2; - destination->r3c3 = source->r3c3; + destination->row3_col1 = source->row3_col1; + destination->row3_col2 = source->row3_col2; + destination->row3_col3 = source->row3_col3; } // ================ Determinant ================= // inline float bgc_fp32_matrix3x3_get_determinant(const BGC_FP32_Matrix3x3* matrix) { - return matrix->r1c1 * (matrix->r2c2 * matrix->r3c3 - matrix->r2c3 * matrix->r3c2) - + matrix->r1c2 * (matrix->r2c3 * matrix->r3c1 - matrix->r2c1 * matrix->r3c3) - + matrix->r1c3 * (matrix->r2c1 * matrix->r3c2 - matrix->r2c2 * matrix->r3c1); + return matrix->row1_col1 * (matrix->row2_col2 * matrix->row3_col3 - matrix->row2_col3 * matrix->row3_col2) + + matrix->row1_col2 * (matrix->row2_col3 * matrix->row3_col1 - matrix->row2_col1 * matrix->row3_col3) + + matrix->row1_col3 * (matrix->row2_col1 * matrix->row3_col2 - matrix->row2_col2 * matrix->row3_col1); } inline double bgc_fp64_matrix3x3_get_determinant(const BGC_FP64_Matrix3x3* matrix) { - return matrix->r1c1 * (matrix->r2c2 * matrix->r3c3 - matrix->r2c3 * matrix->r3c2) - + matrix->r1c2 * (matrix->r2c3 * matrix->r3c1 - matrix->r2c1 * matrix->r3c3) - + matrix->r1c3 * (matrix->r2c1 * matrix->r3c2 - matrix->r2c2 * matrix->r3c1); + return matrix->row1_col1 * (matrix->row2_col2 * matrix->row3_col3 - matrix->row2_col3 * matrix->row3_col2) + + matrix->row1_col2 * (matrix->row2_col3 * matrix->row3_col1 - matrix->row2_col1 * matrix->row3_col3) + + matrix->row1_col3 * (matrix->row2_col1 * matrix->row3_col2 - matrix->row2_col2 * matrix->row3_col1); } // ================ Is Identity ================= // inline int bgc_fp32_matrix3x3_is_identity(const BGC_FP32_Matrix3x3* 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); + return bgc_fp32_is_unit(matrix->row1_col1) && bgc_fp32_is_zero(matrix->row1_col2) && bgc_fp32_is_zero(matrix->row1_col3) + && bgc_fp32_is_zero(matrix->row2_col1) && bgc_fp32_is_unit(matrix->row2_col2) && bgc_fp32_is_zero(matrix->row2_col3) + && bgc_fp32_is_zero(matrix->row3_col1) && bgc_fp32_is_zero(matrix->row3_col2) && bgc_fp32_is_unit(matrix->row3_col3); } inline int bgc_fp64_matrix3x3_is_identity(const BGC_FP64_Matrix3x3* 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); + return bgc_fp64_is_unit(matrix->row1_col1) && bgc_fp64_is_zero(matrix->row1_col2) && bgc_fp64_is_zero(matrix->row1_col3) + && bgc_fp64_is_zero(matrix->row2_col1) && bgc_fp64_is_unit(matrix->row2_col2) && bgc_fp64_is_zero(matrix->row2_col3) + && bgc_fp64_is_zero(matrix->row3_col1) && bgc_fp64_is_zero(matrix->row3_col2) && bgc_fp64_is_unit(matrix->row3_col3); } // ================ Is Singular ================= // @@ -294,17 +294,17 @@ inline int bgc_fp32_matrix3x3_is_rotation(const BGC_FP32_Matrix3x3* matrix) { BGC_FP32_Matrix3x3 product; - product.r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1 + matrix->r1c3 * matrix->r3c1; - product.r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2 + matrix->r1c3 * matrix->r3c2; - product.r1c3 = matrix->r1c1 * matrix->r1c3 + matrix->r1c2 * matrix->r2c3 + matrix->r1c3 * matrix->r3c3; + product.row1_col1 = matrix->row1_col1 * matrix->row1_col1 + matrix->row1_col2 * matrix->row2_col1 + matrix->row1_col3 * matrix->row3_col1; + product.row1_col2 = matrix->row1_col1 * matrix->row1_col2 + matrix->row1_col2 * matrix->row2_col2 + matrix->row1_col3 * matrix->row3_col2; + product.row1_col3 = matrix->row1_col1 * matrix->row1_col3 + matrix->row1_col2 * matrix->row2_col3 + matrix->row1_col3 * matrix->row3_col3; - product.r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1 + matrix->r2c3 * matrix->r3c1; - product.r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2 + matrix->r2c3 * matrix->r3c2; - product.r2c3 = matrix->r2c1 * matrix->r1c3 + matrix->r2c2 * matrix->r2c3 + matrix->r2c3 * matrix->r3c3; + product.row2_col1 = matrix->row2_col1 * matrix->row1_col1 + matrix->row2_col2 * matrix->row2_col1 + matrix->row2_col3 * matrix->row3_col1; + product.row2_col2 = matrix->row2_col1 * matrix->row1_col2 + matrix->row2_col2 * matrix->row2_col2 + matrix->row2_col3 * matrix->row3_col2; + product.row2_col3 = matrix->row2_col1 * matrix->row1_col3 + matrix->row2_col2 * matrix->row2_col3 + matrix->row2_col3 * matrix->row3_col3; - product.r3c1 = matrix->r3c1 * matrix->r1c1 + matrix->r3c2 * matrix->r2c1 + matrix->r3c3 * matrix->r3c1; - product.r3c2 = matrix->r3c1 * matrix->r1c2 + matrix->r3c2 * matrix->r2c2 + matrix->r3c3 * matrix->r3c2; - product.r3c3 = matrix->r3c1 * matrix->r1c3 + matrix->r3c2 * matrix->r2c3 + matrix->r3c3 * matrix->r3c3; + product.row3_col1 = matrix->row3_col1 * matrix->row1_col1 + matrix->row3_col2 * matrix->row2_col1 + matrix->row3_col3 * matrix->row3_col1; + product.row3_col2 = matrix->row3_col1 * matrix->row1_col2 + matrix->row3_col2 * matrix->row2_col2 + matrix->row3_col3 * matrix->row3_col2; + product.row3_col3 = matrix->row3_col1 * matrix->row1_col3 + matrix->row3_col2 * matrix->row2_col3 + matrix->row3_col3 * matrix->row3_col3; return bgc_fp32_matrix3x3_is_identity(&product); } @@ -313,17 +313,17 @@ inline int bgc_fp64_matrix3x3_is_rotation(const BGC_FP64_Matrix3x3* matrix) { BGC_FP64_Matrix3x3 product; - product.r1c1 = matrix->r1c1 * matrix->r1c1 + matrix->r1c2 * matrix->r2c1 + matrix->r1c3 * matrix->r3c1; - product.r1c2 = matrix->r1c1 * matrix->r1c2 + matrix->r1c2 * matrix->r2c2 + matrix->r1c3 * matrix->r3c2; - product.r1c3 = matrix->r1c1 * matrix->r1c3 + matrix->r1c2 * matrix->r2c3 + matrix->r1c3 * matrix->r3c3; + product.row1_col1 = matrix->row1_col1 * matrix->row1_col1 + matrix->row1_col2 * matrix->row2_col1 + matrix->row1_col3 * matrix->row3_col1; + product.row1_col2 = matrix->row1_col1 * matrix->row1_col2 + matrix->row1_col2 * matrix->row2_col2 + matrix->row1_col3 * matrix->row3_col2; + product.row1_col3 = matrix->row1_col1 * matrix->row1_col3 + matrix->row1_col2 * matrix->row2_col3 + matrix->row1_col3 * matrix->row3_col3; - product.r2c1 = matrix->r2c1 * matrix->r1c1 + matrix->r2c2 * matrix->r2c1 + matrix->r2c3 * matrix->r3c1; - product.r2c2 = matrix->r2c1 * matrix->r1c2 + matrix->r2c2 * matrix->r2c2 + matrix->r2c3 * matrix->r3c2; - product.r2c3 = matrix->r2c1 * matrix->r1c3 + matrix->r2c2 * matrix->r2c3 + matrix->r2c3 * matrix->r3c3; + product.row2_col1 = matrix->row2_col1 * matrix->row1_col1 + matrix->row2_col2 * matrix->row2_col1 + matrix->row2_col3 * matrix->row3_col1; + product.row2_col2 = matrix->row2_col1 * matrix->row1_col2 + matrix->row2_col2 * matrix->row2_col2 + matrix->row2_col3 * matrix->row3_col2; + product.row2_col3 = matrix->row2_col1 * matrix->row1_col3 + matrix->row2_col2 * matrix->row2_col3 + matrix->row2_col3 * matrix->row3_col3; - product.r3c1 = matrix->r3c1 * matrix->r1c1 + matrix->r3c2 * matrix->r2c1 + matrix->r3c3 * matrix->r3c1; - product.r3c2 = matrix->r3c1 * matrix->r1c2 + matrix->r3c2 * matrix->r2c2 + matrix->r3c3 * matrix->r3c2; - product.r3c3 = matrix->r3c1 * matrix->r1c3 + matrix->r3c2 * matrix->r2c3 + matrix->r3c3 * matrix->r3c3; + product.row3_col1 = matrix->row3_col1 * matrix->row1_col1 + matrix->row3_col2 * matrix->row2_col1 + matrix->row3_col3 * matrix->row3_col1; + product.row3_col2 = matrix->row3_col1 * matrix->row1_col2 + matrix->row3_col2 * matrix->row2_col2 + matrix->row3_col3 * matrix->row3_col2; + product.row3_col3 = matrix->row3_col1 * matrix->row1_col3 + matrix->row3_col2 * matrix->row2_col3 + matrix->row3_col3 * matrix->row3_col3; return bgc_fp64_matrix3x3_is_identity(&product); } @@ -350,72 +350,72 @@ inline int bgc_fp64_matrix3x3_invert(BGC_FP64_Matrix3x3* matrix) 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; + const float row1_col2 = matrix->row1_col2; + const float row1_col3 = matrix->row1_col3; + const float row2_col3 = matrix->row2_col3; - matrix->r1c2 = matrix->r2c1; - matrix->r1c3 = matrix->r3c1; - matrix->r2c3 = matrix->r3c2; + matrix->row1_col2 = matrix->row2_col1; + matrix->row1_col3 = matrix->row3_col1; + matrix->row2_col3 = matrix->row3_col2; - matrix->r2c1 = r1c2; - matrix->r3c1 = r1c3; - matrix->r3c2 = r2c3; + matrix->row2_col1 = row1_col2; + matrix->row3_col1 = row1_col3; + matrix->row3_col2 = row2_col3; } 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; + const double row1_col2 = matrix->row1_col2; + const double row1_col3 = matrix->row1_col3; + const double row2_col3 = matrix->row2_col3; - matrix->r1c2 = matrix->r2c1; - matrix->r1c3 = matrix->r3c1; - matrix->r2c3 = matrix->r3c2; + matrix->row1_col2 = matrix->row2_col1; + matrix->row1_col3 = matrix->row3_col1; + matrix->row2_col3 = matrix->row3_col2; - matrix->r2c1 = r1c2; - matrix->r3c1 = r1c3; - matrix->r3c2 = r2c3; + matrix->row2_col1 = row1_col2; + matrix->row3_col1 = row1_col3; + matrix->row3_col2 = row2_col3; } // =============== Get Transpose ================ // inline void bgc_fp32_matrix3x3_get_transposed(BGC_FP32_Matrix3x3* transposed, const BGC_FP32_Matrix3x3* matrix) { - transposed->r1c1 = matrix->r1c1; - transposed->r2c2 = matrix->r2c2; - transposed->r3c3 = matrix->r3c3; + transposed->row1_col1 = matrix->row1_col1; + transposed->row2_col2 = matrix->row2_col2; + transposed->row3_col3 = matrix->row3_col3; - const float r1c2 = matrix->r1c2; - const float r1c3 = matrix->r1c3; - const float r2c3 = matrix->r2c3; + const float row1_col2 = matrix->row1_col2; + const float row1_col3 = matrix->row1_col3; + const float row2_col3 = matrix->row2_col3; - transposed->r1c2 = matrix->r2c1; - transposed->r1c3 = matrix->r3c1; - transposed->r2c3 = matrix->r3c2; + transposed->row1_col2 = matrix->row2_col1; + transposed->row1_col3 = matrix->row3_col1; + transposed->row2_col3 = matrix->row3_col2; - transposed->r2c1 = r1c2; - transposed->r3c1 = r1c3; - transposed->r3c2 = r2c3; + transposed->row2_col1 = row1_col2; + transposed->row3_col1 = row1_col3; + transposed->row3_col2 = row2_col3; } inline void bgc_fp64_matrix3x3_get_transposed(BGC_FP64_Matrix3x3* transposed, const BGC_FP64_Matrix3x3* matrix) { - transposed->r1c1 = matrix->r1c1; - transposed->r2c2 = matrix->r2c2; - transposed->r3c3 = matrix->r3c3; + transposed->row1_col1 = matrix->row1_col1; + transposed->row2_col2 = matrix->row2_col2; + transposed->row3_col3 = matrix->row3_col3; - const double r1c2 = matrix->r1c2; - const double r1c3 = matrix->r1c3; - const double r2c3 = matrix->r2c3; + const double row1_col2 = matrix->row1_col2; + const double row1_col3 = matrix->row1_col3; + const double row2_col3 = matrix->row2_col3; - transposed->r1c2 = matrix->r2c1; - transposed->r1c3 = matrix->r3c1; - transposed->r2c3 = matrix->r3c2; + transposed->row1_col2 = matrix->row2_col1; + transposed->row1_col3 = matrix->row3_col1; + transposed->row2_col3 = matrix->row3_col2; - transposed->r2c1 = r1c2; - transposed->r3c1 = r1c3; - transposed->r3c2 = r2c3; + transposed->row2_col1 = row1_col2; + transposed->row3_col1 = row1_col3; + transposed->row3_col2 = row2_col3; } // ================== Get Row -================== // @@ -424,25 +424,25 @@ inline void bgc_fp32_matrix3x3_get_row(BGC_FP32_Vector3* row, const BGC_FP32_Mat { if (row_number == 1) { - row->x1 = matrix->r1c1; - row->x2 = matrix->r1c2; - row->x3 = matrix->r1c3; + row->x1 = matrix->row1_col1; + row->x2 = matrix->row1_col2; + row->x3 = matrix->row1_col3; return; } if (row_number == 2) { - row->x1 = matrix->r2c1; - row->x2 = matrix->r2c2; - row->x3 = matrix->r2c3; + row->x1 = matrix->row2_col1; + row->x2 = matrix->row2_col2; + row->x3 = matrix->row2_col3; return; } if (row_number == 3) { - row->x1 = matrix->r3c1; - row->x2 = matrix->r3c2; - row->x3 = matrix->r3c3; + row->x1 = matrix->row3_col1; + row->x2 = matrix->row3_col2; + row->x3 = matrix->row3_col3; return; } @@ -455,25 +455,25 @@ inline void bgc_fp64_matrix3x3_get_row(BGC_FP64_Vector3* row, const BGC_FP64_Mat { if (row_number == 1) { - row->x1 = matrix->r1c1; - row->x2 = matrix->r1c2; - row->x3 = matrix->r1c3; + row->x1 = matrix->row1_col1; + row->x2 = matrix->row1_col2; + row->x3 = matrix->row1_col3; return; } if (row_number == 2) { - row->x1 = matrix->r2c1; - row->x2 = matrix->r2c2; - row->x3 = matrix->r2c3; + row->x1 = matrix->row2_col1; + row->x2 = matrix->row2_col2; + row->x3 = matrix->row2_col3; return; } if (row_number == 3) { - row->x1 = matrix->r3c1; - row->x2 = matrix->r3c2; - row->x3 = matrix->r3c3; + row->x1 = matrix->row3_col1; + row->x2 = matrix->row3_col2; + row->x3 = matrix->row3_col3; return; } @@ -488,25 +488,25 @@ inline void bgc_fp32_matrix3x3_set_row(BGC_FP32_Matrix3x3* matrix, const int row { if (row_number == 1) { - matrix->r1c1 = row->x1; - matrix->r1c2 = row->x2; - matrix->r1c3 = row->x3; + matrix->row1_col1 = row->x1; + matrix->row1_col2 = row->x2; + matrix->row1_col3 = row->x3; return; } if (row_number == 2) { - matrix->r2c1 = row->x1; - matrix->r2c2 = row->x2; - matrix->r2c3 = row->x3; + matrix->row2_col1 = row->x1; + matrix->row2_col2 = row->x2; + matrix->row2_col3 = row->x3; return; } if (row_number == 3) { - matrix->r3c1 = row->x1; - matrix->r3c2 = row->x2; - matrix->r3c3 = row->x3; + matrix->row3_col1 = row->x1; + matrix->row3_col2 = row->x2; + matrix->row3_col3 = row->x3; } } @@ -514,25 +514,25 @@ inline void bgc_fp64_matrix3x3_set_row(BGC_FP64_Matrix3x3* matrix, const int row { if (row_number == 1) { - matrix->r1c1 = row->x1; - matrix->r1c2 = row->x2; - matrix->r1c3 = row->x3; + matrix->row1_col1 = row->x1; + matrix->row1_col2 = row->x2; + matrix->row1_col3 = row->x3; return; } if (row_number == 2) { - matrix->r2c1 = row->x1; - matrix->r2c2 = row->x2; - matrix->r2c3 = row->x3; + matrix->row2_col1 = row->x1; + matrix->row2_col2 = row->x2; + matrix->row2_col3 = row->x3; return; } if (row_number == 3) { - matrix->r3c1 = row->x1; - matrix->r3c2 = row->x2; - matrix->r3c3 = row->x3; + matrix->row3_col1 = row->x1; + matrix->row3_col2 = row->x2; + matrix->row3_col3 = row->x3; } } @@ -542,25 +542,25 @@ inline void bgc_fp32_matrix3x3_get_column(BGC_FP32_Vector3* column, const BGC_FP { if (column_number == 1) { - column->x1 = matrix->r1c1; - column->x2 = matrix->r2c1; - column->x3 = matrix->r3c1; + column->x1 = matrix->row1_col1; + column->x2 = matrix->row2_col1; + column->x3 = matrix->row3_col1; return; } if (column_number == 2) { - column->x1 = matrix->r1c2; - column->x2 = matrix->r2c2; - column->x3 = matrix->r3c2; + column->x1 = matrix->row1_col2; + column->x2 = matrix->row2_col2; + column->x3 = matrix->row3_col2; return; } if (column_number == 3) { - column->x1 = matrix->r1c3; - column->x2 = matrix->r2c3; - column->x3 = matrix->r3c3; + column->x1 = matrix->row1_col3; + column->x2 = matrix->row2_col3; + column->x3 = matrix->row3_col3; return; } @@ -573,25 +573,25 @@ inline void bgc_fp64_matrix3x3_get_column(BGC_FP64_Vector3* column, const BGC_FP { if (column_number == 1) { - column->x1 = matrix->r1c1; - column->x2 = matrix->r2c1; - column->x3 = matrix->r3c1; + column->x1 = matrix->row1_col1; + column->x2 = matrix->row2_col1; + column->x3 = matrix->row3_col1; return; } if (column_number == 2) { - column->x1 = matrix->r1c2; - column->x2 = matrix->r2c2; - column->x3 = matrix->r3c2; + column->x1 = matrix->row1_col2; + column->x2 = matrix->row2_col2; + column->x3 = matrix->row3_col2; return; } if (column_number == 3) { - column->x1 = matrix->r1c3; - column->x2 = matrix->r2c3; - column->x3 = matrix->r3c3; + column->x1 = matrix->row1_col3; + column->x2 = matrix->row2_col3; + column->x3 = matrix->row3_col3; return; } @@ -606,25 +606,25 @@ inline void bgc_fp32_matrix3x3_set_column(BGC_FP32_Matrix3x3* matrix, const int { if (column_number == 1) { - matrix->r1c1 = column->x1; - matrix->r2c1 = column->x2; - matrix->r3c1 = column->x3; + matrix->row1_col1 = column->x1; + matrix->row2_col1 = column->x2; + matrix->row3_col1 = column->x3; return; } if (column_number == 2) { - matrix->r1c2 = column->x1; - matrix->r2c2 = column->x2; - matrix->r3c2 = column->x3; + matrix->row1_col2 = column->x1; + matrix->row2_col2 = column->x2; + matrix->row3_col2 = column->x3; return; } if (column_number == 3) { - matrix->r1c3 = column->x1; - matrix->r2c3 = column->x2; - matrix->r3c3 = column->x3; + matrix->row1_col3 = column->x1; + matrix->row2_col3 = column->x2; + matrix->row3_col3 = column->x3; } } @@ -632,25 +632,25 @@ inline void bgc_fp64_matrix3x3_set_column(BGC_FP64_Matrix3x3* matrix, const int { if (column_number == 1) { - matrix->r1c1 = column->x1; - matrix->r2c1 = column->x2; - matrix->r3c1 = column->x3; + matrix->row1_col1 = column->x1; + matrix->row2_col1 = column->x2; + matrix->row3_col1 = column->x3; return; } if (column_number == 2) { - matrix->r1c2 = column->x1; - matrix->r2c2 = column->x2; - matrix->r3c2 = column->x3; + matrix->row1_col2 = column->x1; + matrix->row2_col2 = column->x2; + matrix->row3_col2 = column->x3; return; } if (column_number == 3) { - matrix->r1c3 = column->x1; - matrix->r2c3 = column->x2; - matrix->r3c3 = column->x3; + matrix->row1_col3 = column->x1; + matrix->row2_col3 = column->x2; + matrix->row3_col3 = column->x3; } } @@ -658,128 +658,128 @@ inline void bgc_fp64_matrix3x3_set_column(BGC_FP64_Matrix3x3* matrix, const int inline void bgc_fp32_matrix3x3_add(BGC_FP32_Matrix3x3* sum, const BGC_FP32_Matrix3x3* matrix1, const BGC_FP32_Matrix3x3* matrix2) { - sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; - sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; - sum->r1c3 = matrix1->r1c3 + matrix2->r1c3; + sum->row1_col1 = matrix1->row1_col1 + matrix2->row1_col1; + sum->row1_col2 = matrix1->row1_col2 + matrix2->row1_col2; + sum->row1_col3 = matrix1->row1_col3 + matrix2->row1_col3; - sum->r2c1 = matrix1->r2c1 + matrix2->r2c1; - sum->r2c2 = matrix1->r2c2 + matrix2->r2c2; - sum->r2c3 = matrix1->r2c3 + matrix2->r2c3; + sum->row2_col1 = matrix1->row2_col1 + matrix2->row2_col1; + sum->row2_col2 = matrix1->row2_col2 + matrix2->row2_col2; + sum->row2_col3 = matrix1->row2_col3 + matrix2->row2_col3; - sum->r3c1 = matrix1->r3c1 + matrix2->r3c1; - sum->r3c2 = matrix1->r3c2 + matrix2->r3c2; - sum->r3c3 = matrix1->r3c3 + matrix2->r3c3; + sum->row3_col1 = matrix1->row3_col1 + matrix2->row3_col1; + sum->row3_col2 = matrix1->row3_col2 + matrix2->row3_col2; + sum->row3_col3 = matrix1->row3_col3 + matrix2->row3_col3; } inline void bgc_fp64_matrix3x3_add(BGC_FP64_Matrix3x3* sum, const BGC_FP64_Matrix3x3* matrix1, const BGC_FP64_Matrix3x3* matrix2) { - sum->r1c1 = matrix1->r1c1 + matrix2->r1c1; - sum->r1c2 = matrix1->r1c2 + matrix2->r1c2; - sum->r1c3 = matrix1->r1c3 + matrix2->r1c3; + sum->row1_col1 = matrix1->row1_col1 + matrix2->row1_col1; + sum->row1_col2 = matrix1->row1_col2 + matrix2->row1_col2; + sum->row1_col3 = matrix1->row1_col3 + matrix2->row1_col3; - sum->r2c1 = matrix1->r2c1 + matrix2->r2c1; - sum->r2c2 = matrix1->r2c2 + matrix2->r2c2; - sum->r2c3 = matrix1->r2c3 + matrix2->r2c3; + sum->row2_col1 = matrix1->row2_col1 + matrix2->row2_col1; + sum->row2_col2 = matrix1->row2_col2 + matrix2->row2_col2; + sum->row2_col3 = matrix1->row2_col3 + matrix2->row2_col3; - sum->r3c1 = matrix1->r3c1 + matrix2->r3c1; - sum->r3c2 = matrix1->r3c2 + matrix2->r3c2; - sum->r3c3 = matrix1->r3c3 + matrix2->r3c3; + sum->row3_col1 = matrix1->row3_col1 + matrix2->row3_col1; + sum->row3_col2 = matrix1->row3_col2 + matrix2->row3_col2; + sum->row3_col3 = matrix1->row3_col3 + matrix2->row3_col3; } // ================= Add scaled ================= // inline void bgc_fp32_matrix3x3_add_scaled(BGC_FP32_Matrix3x3* sum, const BGC_FP32_Matrix3x3* basic_matrix, const BGC_FP32_Matrix3x3* scalable_matrix, const float scale) { - sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; - sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; - sum->r1c3 = basic_matrix->r1c3 + scalable_matrix->r1c3 * scale; + sum->row1_col1 = basic_matrix->row1_col1 + scalable_matrix->row1_col1 * scale; + sum->row1_col2 = basic_matrix->row1_col2 + scalable_matrix->row1_col2 * scale; + sum->row1_col3 = basic_matrix->row1_col3 + scalable_matrix->row1_col3 * scale; - sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale; - sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale; - sum->r2c3 = basic_matrix->r2c3 + scalable_matrix->r2c3 * scale; + sum->row2_col1 = basic_matrix->row2_col1 + scalable_matrix->row2_col1 * scale; + sum->row2_col2 = basic_matrix->row2_col2 + scalable_matrix->row2_col2 * scale; + sum->row2_col3 = basic_matrix->row2_col3 + scalable_matrix->row2_col3 * scale; - sum->r3c1 = basic_matrix->r3c1 + scalable_matrix->r3c1 * scale; - sum->r3c2 = basic_matrix->r3c2 + scalable_matrix->r3c2 * scale; - sum->r3c3 = basic_matrix->r3c3 + scalable_matrix->r3c3 * scale; + sum->row3_col1 = basic_matrix->row3_col1 + scalable_matrix->row3_col1 * scale; + sum->row3_col2 = basic_matrix->row3_col2 + scalable_matrix->row3_col2 * scale; + sum->row3_col3 = basic_matrix->row3_col3 + scalable_matrix->row3_col3 * scale; } inline void bgc_fp64_matrix3x3_add_scaled(BGC_FP64_Matrix3x3* sum, const BGC_FP64_Matrix3x3* basic_matrix, const BGC_FP64_Matrix3x3* scalable_matrix, const double scale) { - sum->r1c1 = basic_matrix->r1c1 + scalable_matrix->r1c1 * scale; - sum->r1c2 = basic_matrix->r1c2 + scalable_matrix->r1c2 * scale; - sum->r1c3 = basic_matrix->r1c3 + scalable_matrix->r1c3 * scale; + sum->row1_col1 = basic_matrix->row1_col1 + scalable_matrix->row1_col1 * scale; + sum->row1_col2 = basic_matrix->row1_col2 + scalable_matrix->row1_col2 * scale; + sum->row1_col3 = basic_matrix->row1_col3 + scalable_matrix->row1_col3 * scale; - sum->r2c1 = basic_matrix->r2c1 + scalable_matrix->r2c1 * scale; - sum->r2c2 = basic_matrix->r2c2 + scalable_matrix->r2c2 * scale; - sum->r2c3 = basic_matrix->r2c3 + scalable_matrix->r2c3 * scale; + sum->row2_col1 = basic_matrix->row2_col1 + scalable_matrix->row2_col1 * scale; + sum->row2_col2 = basic_matrix->row2_col2 + scalable_matrix->row2_col2 * scale; + sum->row2_col3 = basic_matrix->row2_col3 + scalable_matrix->row2_col3 * scale; - sum->r3c1 = basic_matrix->r3c1 + scalable_matrix->r3c1 * scale; - sum->r3c2 = basic_matrix->r3c2 + scalable_matrix->r3c2 * scale; - sum->r3c3 = basic_matrix->r3c3 + scalable_matrix->r3c3 * scale; + sum->row3_col1 = basic_matrix->row3_col1 + scalable_matrix->row3_col1 * scale; + sum->row3_col2 = basic_matrix->row3_col2 + scalable_matrix->row3_col2 * scale; + sum->row3_col3 = basic_matrix->row3_col3 + scalable_matrix->row3_col3 * scale; } // ================== Subtract ================== // inline void bgc_fp32_matrix3x3_subtract(BGC_FP32_Matrix3x3* difference, const BGC_FP32_Matrix3x3* minuend, const BGC_FP32_Matrix3x3* subtrahend) { - difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; - difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; - difference->r1c3 = minuend->r1c3 - subtrahend->r1c3; + difference->row1_col1 = minuend->row1_col1 - subtrahend->row1_col1; + difference->row1_col2 = minuend->row1_col2 - subtrahend->row1_col2; + difference->row1_col3 = minuend->row1_col3 - subtrahend->row1_col3; - difference->r2c1 = minuend->r2c1 - subtrahend->r2c1; - difference->r2c2 = minuend->r2c2 - subtrahend->r2c2; - difference->r2c3 = minuend->r2c3 - subtrahend->r2c3; + difference->row2_col1 = minuend->row2_col1 - subtrahend->row2_col1; + difference->row2_col2 = minuend->row2_col2 - subtrahend->row2_col2; + difference->row2_col3 = minuend->row2_col3 - subtrahend->row2_col3; - difference->r3c1 = minuend->r3c1 - subtrahend->r3c1; - difference->r3c2 = minuend->r3c2 - subtrahend->r3c2; - difference->r3c3 = minuend->r3c3 - subtrahend->r3c3; + difference->row3_col1 = minuend->row3_col1 - subtrahend->row3_col1; + difference->row3_col2 = minuend->row3_col2 - subtrahend->row3_col2; + difference->row3_col3 = minuend->row3_col3 - subtrahend->row3_col3; } inline void bgc_fp64_matrix3x3_subtract(BGC_FP64_Matrix3x3* difference, const BGC_FP64_Matrix3x3* minuend, const BGC_FP64_Matrix3x3* subtrahend) { - difference->r1c1 = minuend->r1c1 - subtrahend->r1c1; - difference->r1c2 = minuend->r1c2 - subtrahend->r1c2; - difference->r1c3 = minuend->r1c3 - subtrahend->r1c3; + difference->row1_col1 = minuend->row1_col1 - subtrahend->row1_col1; + difference->row1_col2 = minuend->row1_col2 - subtrahend->row1_col2; + difference->row1_col3 = minuend->row1_col3 - subtrahend->row1_col3; - difference->r2c1 = minuend->r2c1 - subtrahend->r2c1; - difference->r2c2 = minuend->r2c2 - subtrahend->r2c2; - difference->r2c3 = minuend->r2c3 - subtrahend->r2c3; + difference->row2_col1 = minuend->row2_col1 - subtrahend->row2_col1; + difference->row2_col2 = minuend->row2_col2 - subtrahend->row2_col2; + difference->row2_col3 = minuend->row2_col3 - subtrahend->row2_col3; - difference->r3c1 = minuend->r3c1 - subtrahend->r3c1; - difference->r3c2 = minuend->r3c2 - subtrahend->r3c2; - difference->r3c3 = minuend->r3c3 - subtrahend->r3c3; + difference->row3_col1 = minuend->row3_col1 - subtrahend->row3_col1; + difference->row3_col2 = minuend->row3_col2 - subtrahend->row3_col2; + difference->row3_col3 = minuend->row3_col3 - subtrahend->row3_col3; } // ================== Multiply ================== // inline void bgc_fp32_matrix3x3_multiply(BGC_FP32_Matrix3x3* product, const BGC_FP32_Matrix3x3* multiplicand, const float multiplier) { - product->r1c1 = multiplicand->r1c1 * multiplier; - product->r1c2 = multiplicand->r1c2 * multiplier; - product->r1c3 = multiplicand->r1c3 * multiplier; + product->row1_col1 = multiplicand->row1_col1 * multiplier; + product->row1_col2 = multiplicand->row1_col2 * multiplier; + product->row1_col3 = multiplicand->row1_col3 * multiplier; - product->r2c1 = multiplicand->r2c1 * multiplier; - product->r2c2 = multiplicand->r2c2 * multiplier; - product->r2c3 = multiplicand->r2c3 * multiplier; + product->row2_col1 = multiplicand->row2_col1 * multiplier; + product->row2_col2 = multiplicand->row2_col2 * multiplier; + product->row2_col3 = multiplicand->row2_col3 * multiplier; - product->r3c1 = multiplicand->r3c1 * multiplier; - product->r3c2 = multiplicand->r3c2 * multiplier; - product->r3c3 = multiplicand->r3c3 * multiplier; + product->row3_col1 = multiplicand->row3_col1 * multiplier; + product->row3_col2 = multiplicand->row3_col2 * multiplier; + product->row3_col3 = multiplicand->row3_col3 * multiplier; } inline void bgc_fp64_matrix3x3_multiply(BGC_FP64_Matrix3x3* product, const BGC_FP64_Matrix3x3* multiplicand, const double multiplier) { - product->r1c1 = multiplicand->r1c1 * multiplier; - product->r1c2 = multiplicand->r1c2 * multiplier; - product->r1c3 = multiplicand->r1c3 * multiplier; + product->row1_col1 = multiplicand->row1_col1 * multiplier; + product->row1_col2 = multiplicand->row1_col2 * multiplier; + product->row1_col3 = multiplicand->row1_col3 * multiplier; - product->r2c1 = multiplicand->r2c1 * multiplier; - product->r2c2 = multiplicand->r2c2 * multiplier; - product->r2c3 = multiplicand->r2c3 * multiplier; + product->row2_col1 = multiplicand->row2_col1 * multiplier; + product->row2_col2 = multiplicand->row2_col2 * multiplier; + product->row2_col3 = multiplicand->row2_col3 * multiplier; - product->r3c1 = multiplicand->r3c1 * multiplier; - product->r3c2 = multiplicand->r3c2 * multiplier; - product->r3c3 = multiplicand->r3c3 * multiplier; + product->row3_col1 = multiplicand->row3_col1 * multiplier; + product->row3_col2 = multiplicand->row3_col2 * multiplier; + product->row3_col3 = multiplicand->row3_col3 * multiplier; } // =================== Divide =================== // @@ -800,43 +800,43 @@ inline void bgc_fp32_matrix3x3_interpolate(BGC_FP32_Matrix3x3* interpolation, co { 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->row1_col1 = first->row1_col1 * counter_phase + second->row1_col1 * phase; + interpolation->row1_col2 = first->row1_col2 * counter_phase + second->row1_col2 * phase; + interpolation->row1_col3 = first->row1_col3 * counter_phase + second->row1_col3 * 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->row2_col1 = first->row2_col1 * counter_phase + second->row2_col1 * phase; + interpolation->row2_col2 = first->row2_col2 * counter_phase + second->row2_col2 * phase; + interpolation->row2_col3 = first->row2_col3 * counter_phase + second->row2_col3 * 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; + interpolation->row3_col1 = first->row3_col1 * counter_phase + second->row3_col1 * phase; + interpolation->row3_col2 = first->row3_col2 * counter_phase + second->row3_col2 * phase; + interpolation->row3_col3 = first->row3_col3 * counter_phase + second->row3_col3 * phase; } inline void bgc_fp64_matrix3x3_interpolate(BGC_FP64_Matrix3x3* interpolation, const BGC_FP64_Matrix3x3* first, const BGC_FP64_Matrix3x3* second, const double phase) { 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->row1_col1 = first->row1_col1 * counter_phase + second->row1_col1 * phase; + interpolation->row1_col2 = first->row1_col2 * counter_phase + second->row1_col2 * phase; + interpolation->row1_col3 = first->row1_col3 * counter_phase + second->row1_col3 * 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->row2_col1 = first->row2_col1 * counter_phase + second->row2_col1 * phase; + interpolation->row2_col2 = first->row2_col2 * counter_phase + second->row2_col2 * phase; + interpolation->row2_col3 = first->row2_col3 * counter_phase + second->row2_col3 * 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; + interpolation->row3_col1 = first->row3_col1 * counter_phase + second->row3_col1 * phase; + interpolation->row3_col2 = first->row3_col2 * counter_phase + second->row3_col2 * phase; + interpolation->row3_col3 = first->row3_col3 * counter_phase + second->row3_col3 * phase; } // ============ Left Vector Product ============= // inline void bgc_fp32_multiply_vector3_by_matrix3x3(BGC_FP32_Vector3* product, const BGC_FP32_Vector3* vector, const BGC_FP32_Matrix3x3* matrix) { - 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 x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3 + vector->x3 * matrix->r3c3; + const float x1 = vector->x1 * matrix->row1_col1 + vector->x2 * matrix->row2_col1 + vector->x3 * matrix->row3_col1; + const float x2 = vector->x1 * matrix->row1_col2 + vector->x2 * matrix->row2_col2 + vector->x3 * matrix->row3_col2; + const float x3 = vector->x1 * matrix->row1_col3 + vector->x2 * matrix->row2_col3 + vector->x3 * matrix->row3_col3; product->x1 = x1; product->x2 = x2; @@ -845,9 +845,9 @@ inline void bgc_fp32_multiply_vector3_by_matrix3x3(BGC_FP32_Vector3* product, co inline void bgc_fp64_multiply_vector3_by_matrix3x3(BGC_FP64_Vector3* product, const BGC_FP64_Vector3* vector, const BGC_FP64_Matrix3x3* matrix) { - 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 x3 = vector->x1 * matrix->r1c3 + vector->x2 * matrix->r2c3 + vector->x3 * matrix->r3c3; + const double x1 = vector->x1 * matrix->row1_col1 + vector->x2 * matrix->row2_col1 + vector->x3 * matrix->row3_col1; + const double x2 = vector->x1 * matrix->row1_col2 + vector->x2 * matrix->row2_col2 + vector->x3 * matrix->row3_col2; + const double x3 = vector->x1 * matrix->row1_col3 + vector->x2 * matrix->row2_col3 + vector->x3 * matrix->row3_col3; product->x1 = x1; product->x2 = x2; @@ -858,9 +858,9 @@ inline void bgc_fp64_multiply_vector3_by_matrix3x3(BGC_FP64_Vector3* product, co inline void bgc_fp32_multiply_matrix3x3_by_vector3(BGC_FP32_Vector3* product, const BGC_FP32_Matrix3x3* matrix, const BGC_FP32_Vector3* vector) { - 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 x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3; + const float x1 = matrix->row1_col1 * vector->x1 + matrix->row1_col2 * vector->x2 + matrix->row1_col3 * vector->x3; + const float x2 = matrix->row2_col1 * vector->x1 + matrix->row2_col2 * vector->x2 + matrix->row2_col3 * vector->x3; + const float x3 = matrix->row3_col1 * vector->x1 + matrix->row3_col2 * vector->x2 + matrix->row3_col3 * vector->x3; product->x1 = x1; product->x2 = x2; @@ -869,9 +869,9 @@ inline void bgc_fp32_multiply_matrix3x3_by_vector3(BGC_FP32_Vector3* product, co inline void bgc_fp64_multiply_matrix3x3_by_vector3(BGC_FP64_Vector3* product, const BGC_FP64_Matrix3x3* matrix, const BGC_FP64_Vector3* vector) { - 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 x3 = matrix->r3c1 * vector->x1 + matrix->r3c2 * vector->x2 + matrix->r3c3 * vector->x3; + const double x1 = matrix->row1_col1 * vector->x1 + matrix->row1_col2 * vector->x2 + matrix->row1_col3 * vector->x3; + const double x2 = matrix->row2_col1 * vector->x1 + matrix->row2_col2 * vector->x2 + matrix->row2_col3 * vector->x3; + const double x3 = matrix->row3_col1 * vector->x1 + matrix->row3_col2 * vector->x2 + matrix->row3_col3 * vector->x3; product->x1 = x1; product->x2 = x2; diff --git a/basic-geometry/quaternion.c b/basic-geometry/quaternion.c index bedd7bf..e7cc0eb 100644 --- a/basic-geometry/quaternion.c +++ b/basic-geometry/quaternion.c @@ -114,7 +114,7 @@ int bgc_fp32_quaternion_get_exponation(BGC_FP32_Quaternion* power, const BGC_FP3 return 0; } - if (square_vector <= BGC_FP32_SQUARE_EPSYLON) { + if (square_vector <= BGC_FP32_SQUARE_EPSILON) { if (base->s0 < 0.0f) { return 0; } @@ -155,7 +155,7 @@ int bgc_fp64_quaternion_get_exponation(BGC_FP64_Quaternion* power, const BGC_FP6 return 0; } - if (square_vector <= BGC_FP64_SQUARE_EPSYLON) { + if (square_vector <= BGC_FP64_SQUARE_EPSILON) { if (base->s0 < 0.0) { return 0; } diff --git a/basic-geometry/quaternion.h b/basic-geometry/quaternion.h index b6491d2..dfc6085 100644 --- a/basic-geometry/quaternion.h +++ b/basic-geometry/quaternion.h @@ -97,12 +97,12 @@ inline double bgc_fp64_quaternion_get_modulus(const BGC_FP64_Quaternion* quatern inline int bgc_fp32_quaternion_is_zero(const BGC_FP32_Quaternion* quaternion) { - return bgc_fp32_quaternion_get_square_modulus(quaternion) <= BGC_FP32_SQUARE_EPSYLON; + return bgc_fp32_quaternion_get_square_modulus(quaternion) <= BGC_FP32_SQUARE_EPSILON; } inline int bgc_fp64_quaternion_is_zero(const BGC_FP64_Quaternion* quaternion) { - return bgc_fp64_quaternion_get_square_modulus(quaternion) <= BGC_FP64_SQUARE_EPSYLON; + return bgc_fp64_quaternion_get_square_modulus(quaternion) <= BGC_FP64_SQUARE_EPSILON; } // ================== Is Unit =================== // @@ -295,7 +295,7 @@ inline int bgc_fp32_quaternion_get_ratio(BGC_FP32_Quaternion* quotient, const BG { const float square_modulus = bgc_fp32_quaternion_get_square_modulus(divisor); - if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) { return 0; } @@ -318,7 +318,7 @@ inline int bgc_fp64_quaternion_get_ratio(BGC_FP64_Quaternion* quotient, const BG { const double square_modulus = bgc_fp64_quaternion_get_square_modulus(divisor); - if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) { return 0; } @@ -477,7 +477,7 @@ inline int bgc_fp32_quaternion_get_inverse(BGC_FP32_Quaternion* inverse, const B { const float square_modulus = bgc_fp32_quaternion_get_square_modulus(quaternion); - if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) { return 0; } @@ -495,7 +495,7 @@ inline int bgc_fp64_quaternion_get_inverse(BGC_FP64_Quaternion* inverse, const B { const double square_modulus = bgc_fp64_quaternion_get_square_modulus(quaternion); - if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) { return 0; } @@ -529,7 +529,7 @@ inline int bgc_fp32_quaternion_normalize(BGC_FP32_Quaternion* quaternion) return 1; } - if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) { return 0; } @@ -551,7 +551,7 @@ inline int bgc_fp64_quaternion_normalize(BGC_FP64_Quaternion* quaternion) return 1; } - if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) { return 0; } @@ -574,7 +574,7 @@ inline int bgc_fp32_quaternion_get_normalized(BGC_FP32_Quaternion* normalized, c return 1; } - if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) { bgc_fp32_quaternion_reset(normalized); return 0; } @@ -592,7 +592,7 @@ inline int bgc_fp64_quaternion_get_normalized(BGC_FP64_Quaternion* normalized, c return 1; } - if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) { bgc_fp64_quaternion_reset(normalized); return 0; } @@ -618,7 +618,7 @@ inline int bgc_fp32_quaternion_get_rotation_matrix(BGC_FP32_Matrix3x3* rotation, const float square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3); - if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) + if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) { bgc_fp32_matrix3x3_make_identity(rotation); return 0; @@ -635,17 +635,17 @@ inline int bgc_fp32_quaternion_get_rotation_matrix(BGC_FP32_Matrix3x3* rotation, const float corrector2 = 2.0f * corrector1; - rotation->r1c1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3)); - rotation->r2c2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3)); - rotation->r3c3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2)); + rotation->row1_col1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3)); + rotation->row2_col2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3)); + rotation->row3_col3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2)); - rotation->r1c2 = corrector2 * (x1x2 - s0x3); - rotation->r2c3 = corrector2 * (x2x3 - s0x1); - rotation->r3c1 = corrector2 * (x1x3 - s0x2); + rotation->row1_col2 = corrector2 * (x1x2 - s0x3); + rotation->row2_col3 = corrector2 * (x2x3 - s0x1); + rotation->row3_col1 = corrector2 * (x1x3 - s0x2); - rotation->r2c1 = corrector2 * (x1x2 + s0x3); - rotation->r3c2 = corrector2 * (x2x3 + s0x1); - rotation->r1c3 = corrector2 * (x1x3 + s0x2); + rotation->row2_col1 = corrector2 * (x1x2 + s0x3); + rotation->row3_col2 = corrector2 * (x2x3 + s0x1); + rotation->row1_col3 = corrector2 * (x1x3 + s0x2); return 1; } @@ -659,7 +659,7 @@ inline int bgc_fp64_quaternion_get_rotation_matrix(BGC_FP64_Matrix3x3* rotation, const double square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3); - if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) + if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) { bgc_fp64_matrix3x3_make_identity(rotation); return 0; @@ -676,17 +676,17 @@ inline int bgc_fp64_quaternion_get_rotation_matrix(BGC_FP64_Matrix3x3* rotation, const double corrector2 = 2.0f * corrector1; - rotation->r1c1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3)); - rotation->r2c2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3)); - rotation->r3c3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2)); + rotation->row1_col1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3)); + rotation->row2_col2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3)); + rotation->row3_col3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2)); - rotation->r1c2 = corrector2 * (x1x2 - s0x3); - rotation->r2c3 = corrector2 * (x2x3 - s0x1); - rotation->r3c1 = corrector2 * (x1x3 - s0x2); + rotation->row1_col2 = corrector2 * (x1x2 - s0x3); + rotation->row2_col3 = corrector2 * (x2x3 - s0x1); + rotation->row3_col1 = corrector2 * (x1x3 - s0x2); - rotation->r2c1 = corrector2 * (x1x2 + s0x3); - rotation->r3c2 = corrector2 * (x2x3 + s0x1); - rotation->r1c3 = corrector2 * (x1x3 + s0x2); + rotation->row2_col1 = corrector2 * (x1x2 + s0x3); + rotation->row3_col2 = corrector2 * (x2x3 + s0x1); + rotation->row1_col3 = corrector2 * (x1x3 + s0x2); return 1; } @@ -702,7 +702,7 @@ inline int bgc_fp32_quaternion_get_reverse_matrix(BGC_FP32_Matrix3x3* reverse, c const float square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3); - if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) + if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) { bgc_fp32_matrix3x3_make_identity(reverse); return 0; @@ -719,17 +719,17 @@ inline int bgc_fp32_quaternion_get_reverse_matrix(BGC_FP32_Matrix3x3* reverse, c const float corrector2 = 2.0f * corrector1; - reverse->r1c1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3)); - reverse->r2c2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3)); - reverse->r3c3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2)); + reverse->row1_col1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3)); + reverse->row2_col2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3)); + reverse->row3_col3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2)); - reverse->r1c2 = corrector2 * (x1x2 + s0x3); - reverse->r2c3 = corrector2 * (x2x3 + s0x1); - reverse->r3c1 = corrector2 * (x1x3 + s0x2); + reverse->row1_col2 = corrector2 * (x1x2 + s0x3); + reverse->row2_col3 = corrector2 * (x2x3 + s0x1); + reverse->row3_col1 = corrector2 * (x1x3 + s0x2); - reverse->r2c1 = corrector2 * (x1x2 - s0x3); - reverse->r3c2 = corrector2 * (x2x3 - s0x1); - reverse->r1c3 = corrector2 * (x1x3 - s0x2); + reverse->row2_col1 = corrector2 * (x1x2 - s0x3); + reverse->row3_col2 = corrector2 * (x2x3 - s0x1); + reverse->row1_col3 = corrector2 * (x1x3 - s0x2); return 1; } @@ -743,7 +743,7 @@ inline int bgc_fp64_quaternion_get_reverse_matrix(BGC_FP64_Matrix3x3* reverse, c const double square_modulus = (s0s0 + x1x1) + (x2x2 + x3x3); - if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) + if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) { bgc_fp64_matrix3x3_make_identity(reverse); return 0; @@ -760,17 +760,17 @@ inline int bgc_fp64_quaternion_get_reverse_matrix(BGC_FP64_Matrix3x3* reverse, c const double corrector2 = 2.0f * corrector1; - reverse->r1c1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3)); - reverse->r2c2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3)); - reverse->r3c3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2)); + reverse->row1_col1 = corrector1 * ((s0s0 + x1x1) - (x2x2 + x3x3)); + reverse->row2_col2 = corrector1 * ((s0s0 + x2x2) - (x1x1 + x3x3)); + reverse->row3_col3 = corrector1 * ((s0s0 + x3x3) - (x1x1 + x2x2)); - reverse->r1c2 = corrector2 * (x1x2 + s0x3); - reverse->r2c3 = corrector2 * (x2x3 + s0x1); - reverse->r3c1 = corrector2 * (x1x3 + s0x2); + reverse->row1_col2 = corrector2 * (x1x2 + s0x3); + reverse->row2_col3 = corrector2 * (x2x3 + s0x1); + reverse->row3_col1 = corrector2 * (x1x3 + s0x2); - reverse->r2c1 = corrector2 * (x1x2 - s0x3); - reverse->r3c2 = corrector2 * (x2x3 - s0x1); - reverse->r1c3 = corrector2 * (x1x3 - s0x2); + reverse->row2_col1 = corrector2 * (x1x2 - s0x3); + reverse->row3_col2 = corrector2 * (x2x3 - s0x1); + reverse->row1_col3 = corrector2 * (x1x3 - s0x2); return 1; } @@ -810,11 +810,11 @@ inline int bgc_fp32_quaternion_are_close(const BGC_FP32_Quaternion* quaternion1, const float square_modulus2 = bgc_fp32_quaternion_get_square_modulus(quaternion2); const float square_distance = (ds0 * ds0 + dx1 * dx1) + (dx2 * dx2 + dx3 * dx3); - if (square_modulus1 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT) { - return square_distance <= BGC_FP32_SQUARE_EPSYLON; + if (square_modulus1 <= BGC_FP32_EPSILON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP32_EPSILON_EFFECTIVENESS_LIMIT) { + return square_distance <= BGC_FP32_SQUARE_EPSILON; } - return square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus2; + return square_distance <= BGC_FP32_SQUARE_EPSILON * square_modulus1 && square_distance <= BGC_FP32_SQUARE_EPSILON * square_modulus2; } inline int bgc_fp64_quaternion_are_close(const BGC_FP64_Quaternion* quaternion1, const BGC_FP64_Quaternion* quaternion2) @@ -828,11 +828,11 @@ inline int bgc_fp64_quaternion_are_close(const BGC_FP64_Quaternion* quaternion1, const double square_modulus2 = bgc_fp64_quaternion_get_square_modulus(quaternion2); const double square_distance = (ds0 * ds0 + dx1 * dx1) + (dx2 * dx2 + dx3 * dx3); - if (square_modulus1 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT) { - return square_distance <= BGC_FP64_SQUARE_EPSYLON; + if (square_modulus1 <= BGC_FP64_EPSILON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP64_EPSILON_EFFECTIVENESS_LIMIT) { + return square_distance <= BGC_FP64_SQUARE_EPSILON; } - return square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus2; + return square_distance <= BGC_FP64_SQUARE_EPSILON * square_modulus1 && square_distance <= BGC_FP64_SQUARE_EPSILON * square_modulus2; } #endif diff --git a/basic-geometry/slerp.c b/basic-geometry/slerp.c index 55274e9..9112549 100644 --- a/basic-geometry/slerp.c +++ b/basic-geometry/slerp.c @@ -21,7 +21,7 @@ void bgc_fp32_slerp_make(BGC_FP32_Slerp* slerp, const BGC_FP32_Versor* start, co return; } - if (square_vector <= BGC_FP32_SQUARE_EPSYLON) { + if (square_vector <= BGC_FP32_SQUARE_EPSILON) { slerp->s0_cos_weight = start->_s0; slerp->x1_cos_weight = start->_x1; slerp->x2_cos_weight = start->_x2; @@ -62,7 +62,7 @@ void bgc_fp64_slerp_make(BGC_FP64_Slerp* slerp, const BGC_FP64_Versor* start, co return; } - if (square_vector <= BGC_FP64_SQUARE_EPSYLON) { + if (square_vector <= BGC_FP64_SQUARE_EPSILON) { slerp->s0_cos_weight = start->_s0; slerp->x1_cos_weight = start->_x1; slerp->x2_cos_weight = start->_x2; diff --git a/basic-geometry/utilities.h b/basic-geometry/utilities.h index 4a23f33..9e0a3a9 100644 --- a/basic-geometry/utilities.h +++ b/basic-geometry/utilities.h @@ -1,10 +1,10 @@ #ifndef _BGC_UTILITIES_H_ #define _BGC_UTILITIES_H_ -#define BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT 1.0f +#define BGC_FP32_EPSILON_EFFECTIVENESS_LIMIT 1.0f -#define BGC_FP32_EPSYLON 4.76837E-7f -#define BGC_FP32_SQUARE_EPSYLON (BGC_FP32_EPSYLON * BGC_FP32_EPSYLON) +#define BGC_FP32_EPSILON 4.76837E-7f +#define BGC_FP32_SQUARE_EPSILON (BGC_FP32_EPSILON * BGC_FP32_EPSILON) #define BGC_FP32_ONE_THIRD 0.3333333333f #define BGC_FP32_ONE_SIXTH 0.1666666667f @@ -14,10 +14,10 @@ #define BGC_FP32_GOLDEN_RATIO_HIGH 1.618034f #define BGC_FP32_GOLDEN_RATIO_LOW 0.618034f -#define BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT 1.0 +#define BGC_FP64_EPSILON_EFFECTIVENESS_LIMIT 1.0 -#define BGC_FP64_EPSYLON 4.996003611E-14 -#define BGC_FP64_SQUARE_EPSYLON (BGC_FP64_EPSYLON * BGC_FP64_EPSYLON) +#define BGC_FP64_EPSILON 4.996003611E-14 +#define BGC_FP64_SQUARE_EPSILON (BGC_FP64_EPSILON * BGC_FP64_EPSILON) #define BGC_FP64_ONE_THIRD 0.3333333333333333333 #define BGC_FP64_ONE_SIXTH 0.1666666666666666667 @@ -53,34 +53,34 @@ inline int bgc_is_correct_axis(const int axis) inline int bgc_fp32_is_zero(const float value) { - return (-BGC_FP32_EPSYLON <= value) && (value <= BGC_FP32_EPSYLON); + return (-BGC_FP32_EPSILON <= value) && (value <= BGC_FP32_EPSILON); } inline int bgc_fp64_is_zero(const double value) { - return (-BGC_FP64_EPSYLON <= value) && (value <= BGC_FP64_EPSYLON); + return (-BGC_FP64_EPSILON <= value) && (value <= BGC_FP64_EPSILON); } inline int bgc_fp32_is_unit(const float value) { - return (1.0f - BGC_FP32_EPSYLON <= value) && (value <= 1.0f + BGC_FP32_EPSYLON); + return (1.0f - BGC_FP32_EPSILON <= value) && (value <= 1.0f + BGC_FP32_EPSILON); } inline int bgc_fp64_is_unit(const double value) { - return (1.0 - BGC_FP64_EPSYLON <= value) && (value <= 1.0 + BGC_FP64_EPSYLON); + return (1.0 - BGC_FP64_EPSILON <= value) && (value <= 1.0 + BGC_FP64_EPSILON); } inline int bgc_fp32_is_square_unit(const float square_value) { - return (1.0f - 2.0f * BGC_FP32_EPSYLON <= square_value) && (square_value <= 1.0f + 2.0f * BGC_FP32_EPSYLON); + return (1.0f - 2.0f * BGC_FP32_EPSILON <= square_value) && (square_value <= 1.0f + 2.0f * BGC_FP32_EPSILON); } inline int bgc_fp64_is_square_unit(const double square_value) { - return (1.0 - 2.0 * BGC_FP64_EPSYLON <= square_value) && (square_value <= 1.0 + 2.0 * BGC_FP64_EPSYLON); + return (1.0 - 2.0 * BGC_FP64_EPSILON <= square_value) && (square_value <= 1.0 + 2.0 * BGC_FP64_EPSILON); } // ================== Are Close ================= // @@ -92,11 +92,11 @@ inline int bgc_fp32_are_close(const float value1, const float value2) const float square_value2 = value2 * value2; const float square_difference = difference * difference; - if (square_value1 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT || square_value2 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT) { - return square_difference <= BGC_FP32_SQUARE_EPSYLON; + if (square_value1 <= BGC_FP32_EPSILON_EFFECTIVENESS_LIMIT || square_value2 <= BGC_FP32_EPSILON_EFFECTIVENESS_LIMIT) { + return square_difference <= BGC_FP32_SQUARE_EPSILON; } - return square_difference <= BGC_FP32_SQUARE_EPSYLON * square_value1 && square_difference <= BGC_FP32_SQUARE_EPSYLON * square_value2; + return square_difference <= BGC_FP32_SQUARE_EPSILON * square_value1 && square_difference <= BGC_FP32_SQUARE_EPSILON * square_value2; } inline int bgc_fp64_are_close(const double value1, const double value2) @@ -106,11 +106,11 @@ inline int bgc_fp64_are_close(const double value1, const double value2) const double square_value2 = value2 * value2; const double square_difference = difference * difference; - if (square_value1 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT || square_value2 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT) { - return square_difference <= BGC_FP64_SQUARE_EPSYLON; + if (square_value1 <= BGC_FP64_EPSILON_EFFECTIVENESS_LIMIT || square_value2 <= BGC_FP64_EPSILON_EFFECTIVENESS_LIMIT) { + return square_difference <= BGC_FP64_SQUARE_EPSILON; } - return square_difference <= BGC_FP64_SQUARE_EPSYLON * square_value1 && square_difference <= BGC_FP64_SQUARE_EPSYLON * square_value2; + return square_difference <= BGC_FP64_SQUARE_EPSILON * square_value1 && square_difference <= BGC_FP64_SQUARE_EPSILON * square_value2; } #endif diff --git a/basic-geometry/vector2.c b/basic-geometry/vector2.c index 06d18e3..bb854bb 100644 --- a/basic-geometry/vector2.c +++ b/basic-geometry/vector2.c @@ -97,14 +97,14 @@ float bgc_fp32_vector2_get_angle(const BGC_FP32_Vector2* vector1, const BGC_FP32 const float square_modulus1 = bgc_fp32_vector2_get_square_modulus(vector1); // square_modulus1 != square_modulus1 is check for NaN value at square_modulus1 - if (square_modulus1 <= BGC_FP32_SQUARE_EPSYLON || square_modulus1 != square_modulus1) { + if (square_modulus1 <= BGC_FP32_SQUARE_EPSILON || square_modulus1 != square_modulus1) { return 0.0f; } const float square_modulus2 = bgc_fp32_vector2_get_square_modulus(vector2); // square_modulus2 != square_modulus2 is check for NaN value at square_modulus2 - if (square_modulus2 <= BGC_FP32_SQUARE_EPSYLON || square_modulus2 != square_modulus2) { + if (square_modulus2 <= BGC_FP32_SQUARE_EPSILON || square_modulus2 != square_modulus2) { return 0.0f; } @@ -122,14 +122,14 @@ double bgc_fp64_vector2_get_angle(const BGC_FP64_Vector2* vector1, const BGC_FP6 const double square_modulus1 = bgc_fp64_vector2_get_square_modulus(vector1); // square_modulus1 != square_modulus1 is check for NaN value at square_modulus1 - if (square_modulus1 <= BGC_FP64_SQUARE_EPSYLON || square_modulus1 != square_modulus1) { + if (square_modulus1 <= BGC_FP64_SQUARE_EPSILON || square_modulus1 != square_modulus1) { return 0.0; } const double square_modulus2 = bgc_fp64_vector2_get_square_modulus(vector2); // square_modulus2 != square_modulus2 is check for NaN value at square_modulus2 - if (square_modulus2 <= BGC_FP64_SQUARE_EPSYLON || square_modulus2 != square_modulus2) { + if (square_modulus2 <= BGC_FP64_SQUARE_EPSILON || square_modulus2 != square_modulus2) { return 0.0; } diff --git a/basic-geometry/vector2.h b/basic-geometry/vector2.h index 9f12d25..7d7ad2f 100644 --- a/basic-geometry/vector2.h +++ b/basic-geometry/vector2.h @@ -70,12 +70,12 @@ inline double bgc_fp64_vector2_get_modulus(const BGC_FP64_Vector2* vector) inline int bgc_fp32_vector2_is_zero(const BGC_FP32_Vector2* vector) { - return bgc_fp32_vector2_get_square_modulus(vector) <= BGC_FP32_SQUARE_EPSYLON; + return bgc_fp32_vector2_get_square_modulus(vector) <= BGC_FP32_SQUARE_EPSILON; } inline int bgc_fp64_vector2_is_zero(const BGC_FP64_Vector2* vector) { - return bgc_fp64_vector2_get_square_modulus(vector) <= BGC_FP64_SQUARE_EPSYLON; + return bgc_fp64_vector2_get_square_modulus(vector) <= BGC_FP64_SQUARE_EPSILON; } inline int bgc_fp32_vector2_is_unit(const BGC_FP32_Vector2* vector) @@ -292,7 +292,7 @@ inline int bgc_fp32_vector2_normalize(BGC_FP32_Vector2* vector) return 1; } - if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) { return 0; } @@ -312,7 +312,7 @@ inline int bgc_fp64_vector2_normalize(BGC_FP64_Vector2* vector) return 1; } - if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) { return 0; } @@ -333,7 +333,7 @@ inline int bgc_fp32_vector2_get_normalized(BGC_FP32_Vector2* normalized, const B return 1; } - if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) { bgc_fp32_vector2_reset(normalized); return 0; } @@ -351,7 +351,7 @@ inline int bgc_fp64_vector2_get_normalized(BGC_FP64_Vector2* normalized, const B return 1; } - if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) { bgc_fp64_vector2_reset(normalized); return 0; } @@ -440,11 +440,11 @@ inline int bgc_fp32_vector2_are_close(const BGC_FP32_Vector2* vector1, const BGC const float square_modulus2 = bgc_fp32_vector2_get_square_modulus(vector2); const float square_distance = bgc_fp32_vector2_get_square_distance(vector1, vector2); - if (square_modulus1 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT) { - return square_distance <= BGC_FP32_SQUARE_EPSYLON; + if (square_modulus1 <= BGC_FP32_EPSILON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP32_EPSILON_EFFECTIVENESS_LIMIT) { + return square_distance <= BGC_FP32_SQUARE_EPSILON; } - return square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus2; + return square_distance <= BGC_FP32_SQUARE_EPSILON * square_modulus1 && square_distance <= BGC_FP32_SQUARE_EPSILON * square_modulus2; } inline int bgc_fp64_vector2_are_close(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2) @@ -453,11 +453,11 @@ inline int bgc_fp64_vector2_are_close(const BGC_FP64_Vector2* vector1, const BGC const double square_modulus2 = bgc_fp64_vector2_get_square_modulus(vector2); const double square_distance = bgc_fp64_vector2_get_square_distance(vector1, vector2); - if (square_modulus1 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT) { - return square_distance <= BGC_FP64_SQUARE_EPSYLON; + if (square_modulus1 <= BGC_FP64_EPSILON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP64_EPSILON_EFFECTIVENESS_LIMIT) { + return square_distance <= BGC_FP64_SQUARE_EPSILON; } - return square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus2; + return square_distance <= BGC_FP64_SQUARE_EPSILON * square_modulus1 && square_distance <= BGC_FP64_SQUARE_EPSILON * square_modulus2; } @@ -467,38 +467,38 @@ inline int bgc_fp32_vector2_are_parallel(const BGC_FP32_Vector2* vector1, const { const float square_modulus1 = bgc_fp32_vector2_get_square_modulus(vector1); - if (square_modulus1 <= BGC_FP32_SQUARE_EPSYLON) { + if (square_modulus1 <= BGC_FP32_SQUARE_EPSILON) { return 1; } const float square_modulus2 = bgc_fp32_vector2_get_square_modulus(vector2); - if (square_modulus2 <= BGC_FP32_SQUARE_EPSYLON) { + if (square_modulus2 <= BGC_FP32_SQUARE_EPSILON) { return 1; } const float cross_product = bgc_fp32_vector2_get_cross_product(vector1, vector2); - return cross_product * cross_product <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 * square_modulus2; + return cross_product * cross_product <= BGC_FP32_SQUARE_EPSILON * square_modulus1 * square_modulus2; } inline int bgc_fp64_vector2_are_parallel(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2) { const double square_modulus1 = bgc_fp64_vector2_get_square_modulus(vector1); - if (square_modulus1 <= BGC_FP64_SQUARE_EPSYLON) { + if (square_modulus1 <= BGC_FP64_SQUARE_EPSILON) { return 1; } const double square_modulus2 = bgc_fp64_vector2_get_square_modulus(vector2); - if (square_modulus2 <= BGC_FP64_SQUARE_EPSYLON) { + if (square_modulus2 <= BGC_FP64_SQUARE_EPSILON) { return 1; } const double cross_product = bgc_fp64_vector2_get_cross_product(vector1, vector2); - return cross_product * cross_product <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 * square_modulus2; + return cross_product * cross_product <= BGC_FP64_SQUARE_EPSILON * square_modulus1 * square_modulus2; } // ================= Orthogonal ================= // @@ -507,38 +507,38 @@ inline int bgc_fp32_vector2_are_orthogonal(const BGC_FP32_Vector2* vector1, cons { const float square_modulus1 = bgc_fp32_vector2_get_square_modulus(vector1); - if (square_modulus1 <= BGC_FP32_SQUARE_EPSYLON) { + if (square_modulus1 <= BGC_FP32_SQUARE_EPSILON) { return 1; } const float square_modulus2 = bgc_fp32_vector2_get_square_modulus(vector2); - if (square_modulus2 <= BGC_FP32_SQUARE_EPSYLON) { + if (square_modulus2 <= BGC_FP32_SQUARE_EPSILON) { return 1; } const float scalar_product = bgc_fp32_vector2_get_dot_product(vector1, vector2); - return scalar_product * scalar_product <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 * square_modulus2; + return scalar_product * scalar_product <= BGC_FP32_SQUARE_EPSILON * square_modulus1 * square_modulus2; } inline int bgc_fp64_vector2_are_orthogonal(const BGC_FP64_Vector2* vector1, const BGC_FP64_Vector2* vector2) { const double square_modulus1 = bgc_fp64_vector2_get_square_modulus(vector1); - if (square_modulus1 <= BGC_FP64_SQUARE_EPSYLON) { + if (square_modulus1 <= BGC_FP64_SQUARE_EPSILON) { return 1; } const double square_modulus2 = bgc_fp64_vector2_get_square_modulus(vector2); - if (square_modulus2 <= BGC_FP64_SQUARE_EPSYLON) { + if (square_modulus2 <= BGC_FP64_SQUARE_EPSILON) { return 1; } const double scalar_product = bgc_fp64_vector2_get_dot_product(vector1, vector2); - return scalar_product * scalar_product <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 * square_modulus2; + return scalar_product * scalar_product <= BGC_FP64_SQUARE_EPSILON * square_modulus1 * square_modulus2; } @@ -549,11 +549,11 @@ inline int bgc_fp32_vector2_get_attitude(const BGC_FP32_Vector2* vector1, const const float square_modulus1 = bgc_fp32_vector2_get_square_modulus(vector1); const float square_modulus2 = bgc_fp32_vector2_get_square_modulus(vector2); - if (square_modulus1 <= BGC_FP32_SQUARE_EPSYLON || square_modulus2 <= BGC_FP32_SQUARE_EPSYLON) { + if (square_modulus1 <= BGC_FP32_SQUARE_EPSILON || square_modulus2 <= BGC_FP32_SQUARE_EPSILON) { return BGC_ATTITUDE_ZERO; } - const float square_limit = BGC_FP32_SQUARE_EPSYLON * square_modulus1 * square_modulus2; + const float square_limit = BGC_FP32_SQUARE_EPSILON * square_modulus1 * square_modulus2; const float scalar_product = bgc_fp32_vector2_get_dot_product(vector1, vector2); @@ -575,11 +575,11 @@ inline int bgc_fp64_vector2_get_attitude(const BGC_FP64_Vector2* vector1, const const double square_modulus1 = bgc_fp64_vector2_get_square_modulus(vector1); const double square_modulus2 = bgc_fp64_vector2_get_square_modulus(vector2); - if (square_modulus1 <= BGC_FP64_SQUARE_EPSYLON || square_modulus2 <= BGC_FP64_SQUARE_EPSYLON) { + if (square_modulus1 <= BGC_FP64_SQUARE_EPSILON || square_modulus2 <= BGC_FP64_SQUARE_EPSILON) { return BGC_ATTITUDE_ZERO; } - const double square_limit = BGC_FP64_SQUARE_EPSYLON * square_modulus1 * square_modulus2; + const double square_limit = BGC_FP64_SQUARE_EPSILON * square_modulus1 * square_modulus2; const double scalar_product = bgc_fp64_vector2_get_dot_product(vector1, vector2); diff --git a/basic-geometry/vector3.c b/basic-geometry/vector3.c index 2740d11..fbf9615 100644 --- a/basic-geometry/vector3.c +++ b/basic-geometry/vector3.c @@ -103,14 +103,14 @@ float bgc_fp32_vector3_get_angle(const BGC_FP32_Vector3* vector1, const BGC_FP32 const float square_modulus1 = bgc_fp32_vector3_get_square_modulus(vector1); // square_modulus1 != square_modulus1 is check for NaN value at square_modulus1 - if (square_modulus1 <= BGC_FP32_SQUARE_EPSYLON || square_modulus1 != square_modulus1) { + if (square_modulus1 <= BGC_FP32_SQUARE_EPSILON || square_modulus1 != square_modulus1) { return 0.0f; } const float square_modulus2 = bgc_fp32_vector3_get_square_modulus(vector2); // square_modulus2 != square_modulus2 is check for NaN value at square_modulus2 - if (square_modulus2 <= BGC_FP32_SQUARE_EPSYLON || square_modulus2 != square_modulus2) { + if (square_modulus2 <= BGC_FP32_SQUARE_EPSILON || square_modulus2 != square_modulus2) { return 0.0f; } @@ -130,14 +130,14 @@ double bgc_fp64_vector3_get_angle(const BGC_FP64_Vector3* vector1, const BGC_FP6 const double square_modulus1 = bgc_fp64_vector3_get_square_modulus(vector1); // square_modulus1 != square_modulus1 is check for NaN value at square_modulus1 - if (square_modulus1 <= BGC_FP64_SQUARE_EPSYLON || square_modulus1 != square_modulus1) { + if (square_modulus1 <= BGC_FP64_SQUARE_EPSILON || square_modulus1 != square_modulus1) { return 0.0; } const double square_modulus2 = bgc_fp64_vector3_get_square_modulus(vector2); // square_modulus2 != square_modulus2 is check for NaN value at square_modulus2 - if (square_modulus2 <= BGC_FP64_SQUARE_EPSYLON || square_modulus2 != square_modulus2) { + if (square_modulus2 <= BGC_FP64_SQUARE_EPSILON || square_modulus2 != square_modulus2) { return 0.0; } diff --git a/basic-geometry/vector3.h b/basic-geometry/vector3.h index e5dbe6f..4888d56 100644 --- a/basic-geometry/vector3.h +++ b/basic-geometry/vector3.h @@ -76,12 +76,12 @@ inline double bgc_fp64_vector3_get_modulus(const BGC_FP64_Vector3* vector) inline int bgc_fp32_vector3_is_zero(const BGC_FP32_Vector3* vector) { - return bgc_fp32_vector3_get_square_modulus(vector) <= BGC_FP32_SQUARE_EPSYLON; + return bgc_fp32_vector3_get_square_modulus(vector) <= BGC_FP32_SQUARE_EPSILON; } inline int bgc_fp64_vector3_is_zero(const BGC_FP64_Vector3* vector) { - return bgc_fp64_vector3_get_square_modulus(vector) <= BGC_FP64_SQUARE_EPSYLON; + return bgc_fp64_vector3_get_square_modulus(vector) <= BGC_FP64_SQUARE_EPSILON; } inline int bgc_fp32_vector3_is_unit(const BGC_FP32_Vector3* vector) @@ -326,7 +326,7 @@ inline int bgc_fp32_vector3_normalize(BGC_FP32_Vector3* vector) return 1; } - if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) { return 0; } @@ -347,7 +347,7 @@ inline int bgc_fp64_vector3_normalize(BGC_FP64_Vector3* vector) return 1; } - if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) { return 0; } @@ -369,7 +369,7 @@ inline int bgc_fp32_vector3_get_normalized(BGC_FP32_Vector3* normalized, const B return 1; } - if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) { bgc_fp32_vector3_reset(normalized); return 0; } @@ -387,7 +387,7 @@ inline int bgc_fp64_vector3_get_normalized(BGC_FP64_Vector3* normalized, const B return 1; } - if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) { bgc_fp64_vector3_reset(normalized); return 0; } @@ -528,11 +528,11 @@ inline int bgc_fp32_vector3_are_close(const BGC_FP32_Vector3* vector1, const BGC const float square_modulus2 = bgc_fp32_vector3_get_square_modulus(vector2); const float square_distance = bgc_fp32_vector3_get_square_distance(vector1, vector2); - if (square_modulus1 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP32_EPSYLON_EFFECTIVENESS_LIMIT) { - return square_distance <= BGC_FP32_SQUARE_EPSYLON; + if (square_modulus1 <= BGC_FP32_EPSILON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP32_EPSILON_EFFECTIVENESS_LIMIT) { + return square_distance <= BGC_FP32_SQUARE_EPSILON; } - return square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP32_SQUARE_EPSYLON * square_modulus2; + return square_distance <= BGC_FP32_SQUARE_EPSILON * square_modulus1 && square_distance <= BGC_FP32_SQUARE_EPSILON * square_modulus2; } inline int bgc_fp64_vector3_are_close(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2) @@ -541,11 +541,11 @@ inline int bgc_fp64_vector3_are_close(const BGC_FP64_Vector3* vector1, const BGC const double square_modulus2 = bgc_fp64_vector3_get_square_modulus(vector2); const double square_distance = bgc_fp64_vector3_get_square_distance(vector1, vector2); - if (square_modulus1 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP64_EPSYLON_EFFECTIVENESS_LIMIT) { - return square_distance <= BGC_FP64_SQUARE_EPSYLON; + if (square_modulus1 <= BGC_FP64_EPSILON_EFFECTIVENESS_LIMIT || square_modulus2 <= BGC_FP64_EPSILON_EFFECTIVENESS_LIMIT) { + return square_distance <= BGC_FP64_SQUARE_EPSILON; } - return square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 && square_distance <= BGC_FP64_SQUARE_EPSYLON * square_modulus2; + return square_distance <= BGC_FP64_SQUARE_EPSILON * square_modulus1 && square_distance <= BGC_FP64_SQUARE_EPSILON * square_modulus2; } // ================== Parallel ================== // @@ -555,7 +555,7 @@ inline int bgc_fp32_vector3_are_parallel(const BGC_FP32_Vector3* vector1, const const float square_modulus1 = bgc_fp32_vector3_get_square_modulus(vector1); const float square_modulus2 = bgc_fp32_vector3_get_square_modulus(vector2); - if (square_modulus1 <= BGC_FP32_SQUARE_EPSYLON || square_modulus2 <= BGC_FP32_SQUARE_EPSYLON) { + if (square_modulus1 <= BGC_FP32_SQUARE_EPSILON || square_modulus2 <= BGC_FP32_SQUARE_EPSILON) { return 1; } @@ -563,7 +563,7 @@ inline int bgc_fp32_vector3_are_parallel(const BGC_FP32_Vector3* vector1, const bgc_fp32_vector3_get_cross_product(&product, vector1, vector2); - return bgc_fp32_vector3_get_square_modulus(&product) <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 * square_modulus2; + return bgc_fp32_vector3_get_square_modulus(&product) <= BGC_FP32_SQUARE_EPSILON * square_modulus1 * square_modulus2; } inline int bgc_fp64_vector3_are_parallel(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2) @@ -571,7 +571,7 @@ inline int bgc_fp64_vector3_are_parallel(const BGC_FP64_Vector3* vector1, const const double square_modulus1 = bgc_fp64_vector3_get_square_modulus(vector1); const double square_modulus2 = bgc_fp64_vector3_get_square_modulus(vector2); - if (square_modulus1 <= BGC_FP64_SQUARE_EPSYLON || square_modulus2 <= BGC_FP64_SQUARE_EPSYLON) { + if (square_modulus1 <= BGC_FP64_SQUARE_EPSILON || square_modulus2 <= BGC_FP64_SQUARE_EPSILON) { return 1; } @@ -579,7 +579,7 @@ inline int bgc_fp64_vector3_are_parallel(const BGC_FP64_Vector3* vector1, const bgc_fp64_vector3_get_cross_product(&product, vector1, vector2); - return bgc_fp64_vector3_get_square_modulus(&product) <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 * square_modulus2; + return bgc_fp64_vector3_get_square_modulus(&product) <= BGC_FP64_SQUARE_EPSILON * square_modulus1 * square_modulus2; } // ================= Orthogonal ================= // @@ -589,13 +589,13 @@ inline int bgc_fp32_vector3_are_orthogonal(const BGC_FP32_Vector3* vector1, cons const float square_modulus1 = bgc_fp32_vector3_get_square_modulus(vector1); const float square_modulus2 = bgc_fp32_vector3_get_square_modulus(vector2); - if (square_modulus1 <= BGC_FP32_SQUARE_EPSYLON || square_modulus2 <= BGC_FP32_SQUARE_EPSYLON) { + if (square_modulus1 <= BGC_FP32_SQUARE_EPSILON || square_modulus2 <= BGC_FP32_SQUARE_EPSILON) { return 1; } const float scalar_product = bgc_fp32_vector3_get_dot_product(vector1, vector2); - return scalar_product * scalar_product <= BGC_FP32_SQUARE_EPSYLON * square_modulus1 * square_modulus2; + return scalar_product * scalar_product <= BGC_FP32_SQUARE_EPSILON * square_modulus1 * square_modulus2; } inline int bgc_fp64_vector3_are_orthogonal(const BGC_FP64_Vector3* vector1, const BGC_FP64_Vector3* vector2) @@ -603,13 +603,13 @@ inline int bgc_fp64_vector3_are_orthogonal(const BGC_FP64_Vector3* vector1, cons const double square_modulus1 = bgc_fp64_vector3_get_square_modulus(vector1); const double square_modulus2 = bgc_fp64_vector3_get_square_modulus(vector2); - if (square_modulus1 <= BGC_FP64_SQUARE_EPSYLON || square_modulus2 <= BGC_FP64_SQUARE_EPSYLON) { + if (square_modulus1 <= BGC_FP64_SQUARE_EPSILON || square_modulus2 <= BGC_FP64_SQUARE_EPSILON) { return 1; } const double scalar_product = bgc_fp64_vector3_get_dot_product(vector1, vector2); - return scalar_product * scalar_product <= BGC_FP64_SQUARE_EPSYLON * square_modulus1 * square_modulus2; + return scalar_product * scalar_product <= BGC_FP64_SQUARE_EPSILON * square_modulus1 * square_modulus2; } // ================== Attitude ================== // @@ -619,11 +619,11 @@ inline int bgc_fp32_vector3_get_attitude(const BGC_FP32_Vector3* vector1, const const float square_modulus1 = bgc_fp32_vector3_get_square_modulus(vector1); const float square_modulus2 = bgc_fp32_vector3_get_square_modulus(vector2); - if (square_modulus1 <= BGC_FP32_SQUARE_EPSYLON || square_modulus2 <= BGC_FP32_SQUARE_EPSYLON) { + if (square_modulus1 <= BGC_FP32_SQUARE_EPSILON || square_modulus2 <= BGC_FP32_SQUARE_EPSILON) { return BGC_ATTITUDE_ZERO; } - const float square_limit = BGC_FP32_SQUARE_EPSYLON * square_modulus1 * square_modulus2; + const float square_limit = BGC_FP32_SQUARE_EPSILON * square_modulus1 * square_modulus2; const float scalar_product = bgc_fp32_vector3_get_dot_product(vector1, vector2); @@ -647,11 +647,11 @@ inline int bgc_fp64_vector3_get_attitude(const BGC_FP64_Vector3* vector1, const const double square_modulus1 = bgc_fp64_vector3_get_square_modulus(vector1); const double square_modulus2 = bgc_fp64_vector3_get_square_modulus(vector2); - if (square_modulus1 <= BGC_FP64_SQUARE_EPSYLON || square_modulus2 <= BGC_FP64_SQUARE_EPSYLON) { + if (square_modulus1 <= BGC_FP64_SQUARE_EPSILON || square_modulus2 <= BGC_FP64_SQUARE_EPSILON) { return BGC_ATTITUDE_ZERO; } - const double square_limit = BGC_FP64_SQUARE_EPSYLON * square_modulus1 * square_modulus2; + const double square_limit = BGC_FP64_SQUARE_EPSILON * square_modulus1 * square_modulus2; const double scalar_product = bgc_fp64_vector3_get_dot_product(vector1, vector2); diff --git a/basic-geometry/versor.c b/basic-geometry/versor.c index f08187b..b95d9ae 100644 --- a/basic-geometry/versor.c +++ b/basic-geometry/versor.c @@ -79,7 +79,7 @@ void _bgc_fp32_versor_normalize(BGC_FP32_Versor* versor) { const float square_modulus = (versor->_s0 * versor->_s0 + versor->_x1 * versor->_x1) + (versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3); - if (square_modulus <= BGC_FP32_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP32_SQUARE_EPSILON || isnan(square_modulus)) { versor->_s0 = 1.0f; versor->_x1 = 0.0f; versor->_x2 = 0.0f; @@ -99,7 +99,7 @@ void _bgc_fp64_versor_normalize(BGC_FP64_Versor* versor) { const double square_modulus = (versor->_s0 * versor->_s0 + versor->_x1 * versor->_x1) + (versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3); - if (square_modulus <= BGC_FP64_SQUARE_EPSYLON || isnan(square_modulus)) { + if (square_modulus <= BGC_FP64_SQUARE_EPSILON || isnan(square_modulus)) { versor->_s0 = 1.0; versor->_x1 = 0.0; versor->_x2 = 0.0; @@ -121,7 +121,7 @@ void bgc_fp32_versor_make_for_turn(BGC_FP32_Versor* versor, const float x1, cons { const float square_vector = x1 * x1 + x2 * x2 + x3 * x3; - if (square_vector <= BGC_FP32_SQUARE_EPSYLON) { + if (square_vector <= BGC_FP32_SQUARE_EPSILON) { bgc_fp32_versor_reset(versor); return; } @@ -144,7 +144,7 @@ void bgc_fp64_versor_make_for_turn(BGC_FP64_Versor* versor, const double x1, con { const double square_vector = x1 * x1 + x2 * x2 + x3 * x3; - if (square_vector <= BGC_FP64_SQUARE_EPSYLON) { + if (square_vector <= BGC_FP64_SQUARE_EPSILON) { bgc_fp64_versor_reset(versor); return; } @@ -175,7 +175,7 @@ static int _bgc_fp32_versor_make_direction_turn(BGC_FP32_Versor* versor, const B const float square_modulus = bgc_fp32_vector3_get_square_modulus(&orthogonal_axis); const float square_sine = square_modulus / square_modulus_product; - if (square_sine > BGC_FP32_SQUARE_EPSYLON) { + if (square_sine > BGC_FP32_SQUARE_EPSILON) { const float cosine = scalar_product / sqrtf(square_modulus_product); const float angle = 0.5f * atan2f(sqrtf(square_sine), cosine); @@ -203,7 +203,7 @@ static int _bgc_fp64_versor_make_direction_turn(BGC_FP64_Versor* versor, const B const double square_modulus = bgc_fp64_vector3_get_square_modulus(&orthogonal_axis); const double square_sine = square_modulus / square_modulus_product; - if (square_sine > BGC_FP64_SQUARE_EPSYLON) { + if (square_sine > BGC_FP64_SQUARE_EPSILON) { const double cosine = scalar_product / sqrt(square_modulus_product); const double angle = 0.5 * atan2(sqrt(square_sine), cosine); @@ -226,7 +226,7 @@ int bgc_fp32_versor_make_direction_difference(BGC_FP32_Versor* versor, const BGC const float start_square_modulus = bgc_fp32_vector3_get_square_modulus(start); const float end_square_modulus = bgc_fp32_vector3_get_square_modulus(end); - if (start_square_modulus <= BGC_FP32_SQUARE_EPSYLON || end_square_modulus <= BGC_FP32_SQUARE_EPSYLON) { + if (start_square_modulus <= BGC_FP32_SQUARE_EPSILON || end_square_modulus <= BGC_FP32_SQUARE_EPSILON) { bgc_fp32_versor_reset(versor); return BGC_ZERO_TURN; } @@ -239,7 +239,7 @@ int bgc_fp64_versor_make_direction_difference(BGC_FP64_Versor* versor, const BGC const double start_square_modulus = bgc_fp64_vector3_get_square_modulus(start); const double end_square_modulus = bgc_fp64_vector3_get_square_modulus(end); - if (start_square_modulus <= BGC_FP64_SQUARE_EPSYLON || end_square_modulus <= BGC_FP64_SQUARE_EPSYLON) { + if (start_square_modulus <= BGC_FP64_SQUARE_EPSILON || end_square_modulus <= BGC_FP64_SQUARE_EPSILON) { bgc_fp64_versor_reset(versor); return BGC_ZERO_TURN; } @@ -251,17 +251,17 @@ int bgc_fp64_versor_make_direction_difference(BGC_FP64_Versor* versor, const BGC 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_FP32_SQUARE_EPSYLON) { + if (primary_square_modulus <= BGC_FP32_SQUARE_EPSILON) { //TODO: add error code for: primary_vector is zero return BGC_FAILED; } - if (auxiliary_square_modulus <= BGC_FP32_SQUARE_EPSYLON) { + if (auxiliary_square_modulus <= BGC_FP32_SQUARE_EPSILON) { //TODO: add error code for: auxiliary_vector is zero return BGC_FAILED; } - if (orthogonal_square_modulus <= BGC_FP32_SQUARE_EPSYLON * primary_square_modulus * auxiliary_square_modulus) { + if (orthogonal_square_modulus <= BGC_FP32_SQUARE_EPSILON * primary_square_modulus * auxiliary_square_modulus) { //TODO: add error code for: primary_vector and auxiliary_vector are parallel return BGC_FAILED; } @@ -271,17 +271,17 @@ static int _bgc_fp32_versor_validate_basis(const float primary_square_modulus, c 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_FP64_SQUARE_EPSYLON) { + if (primary_square_modulus <= BGC_FP64_SQUARE_EPSILON) { //TODO: add error code for: primary_vector is zero return BGC_FAILED; } - if (auxiliary_square_modulus <= BGC_FP64_SQUARE_EPSYLON) { + if (auxiliary_square_modulus <= BGC_FP64_SQUARE_EPSILON) { //TODO: add error code for: auxiliary_vector is zero return BGC_FAILED; } - if (orthogonal_square_modulus <= BGC_FP64_SQUARE_EPSYLON * primary_square_modulus * auxiliary_square_modulus) { + if (orthogonal_square_modulus <= BGC_FP64_SQUARE_EPSILON * primary_square_modulus * auxiliary_square_modulus) { //TODO: add error code for: primary_vector and auxiliary_vector are parallel return BGC_FAILED; } @@ -437,7 +437,7 @@ void bgc_fp32_versor_get_exponation(BGC_FP32_Versor* power, const BGC_FP32_Verso { const float square_vector = base->_x1 * base->_x1 + base->_x2 * base->_x2 + base->_x3 * base->_x3; - if (square_vector <= BGC_FP32_SQUARE_EPSYLON || square_vector != square_vector) { + if (square_vector <= BGC_FP32_SQUARE_EPSILON || square_vector != square_vector) { bgc_fp32_versor_reset(power); return; } @@ -455,7 +455,7 @@ void bgc_fp64_versor_get_exponation(BGC_FP64_Versor* power, const BGC_FP64_Verso { const double square_vector = base->_x1 * base->_x1 + base->_x2 * base->_x2 + base->_x3 * base->_x3; - if (square_vector <= BGC_FP64_SQUARE_EPSYLON || square_vector != square_vector) { + if (square_vector <= BGC_FP64_SQUARE_EPSILON || square_vector != square_vector) { bgc_fp64_versor_reset(power); return; } @@ -481,7 +481,7 @@ void bgc_fp32_versor_spherically_interpolate(BGC_FP32_Versor* interpolation, con 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 - if (square_vector <= BGC_FP32_SQUARE_EPSYLON || isnan(square_vector)) { + if (square_vector <= BGC_FP32_SQUARE_EPSILON || isnan(square_vector)) { bgc_fp32_versor_copy(interpolation, end); return; } @@ -516,7 +516,7 @@ void bgc_fp64_versor_spherically_interpolate(BGC_FP64_Versor* interpolation, con 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 - if (square_vector <= BGC_FP64_SQUARE_EPSYLON || isnan(square_vector)) { + if (square_vector <= BGC_FP64_SQUARE_EPSILON || isnan(square_vector)) { bgc_fp64_versor_copy(interpolation, end); return; } @@ -547,7 +547,7 @@ void bgc_fp32_versor_get_rotation(BGC_FP32_Rotation3* rotation, const BGC_FP32_V { const float square_modulus = versor->_x1 * versor->_x1 + versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3; - if (square_modulus <= BGC_FP32_SQUARE_EPSYLON) { + if (square_modulus <= BGC_FP32_SQUARE_EPSILON) { bgc_fp32_rotation3_reset(rotation); return; } @@ -567,7 +567,7 @@ void bgc_fp64_versor_get_rotation(BGC_FP64_Rotation3* rotation, const BGC_FP64_V { const double square_modulus = versor->_x1 * versor->_x1 + versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3; - if (square_modulus <= BGC_FP64_SQUARE_EPSYLON) { + if (square_modulus <= BGC_FP64_SQUARE_EPSILON) { bgc_fp64_rotation3_reset(rotation); return; } diff --git a/basic-geometry/versor.h b/basic-geometry/versor.h index ee3b4de..f066a17 100644 --- a/basic-geometry/versor.h +++ b/basic-geometry/versor.h @@ -192,12 +192,12 @@ inline void bgc_fp64_versor_swap(BGC_FP64_Versor* versor1, BGC_FP64_Versor* vers 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_FP32_SQUARE_EPSYLON; + return versor->_x1 * versor->_x1 + versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3 <= BGC_FP32_SQUARE_EPSILON; } 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_FP64_SQUARE_EPSYLON; + return versor->_x1 * versor->_x1 + versor->_x2 * versor->_x2 + versor->_x3 * versor->_x3 <= BGC_FP64_SQUARE_EPSILON; } // ================== Convert =================== // @@ -460,17 +460,17 @@ inline void bgc_fp32_versor_get_rotation_matrix(BGC_FP32_Matrix3x3* matrix, cons const float x1x3 = versor->_x1 * versor->_x3; const float x2x3 = versor->_x2 * versor->_x3; - matrix->r1c1 = (s0s0 + x1x1) - (x2x2 + x3x3); - matrix->r2c2 = (s0s0 + x2x2) - (x1x1 + x3x3); - matrix->r3c3 = (s0s0 + x3x3) - (x1x1 + x2x2); + matrix->row1_col1 = (s0s0 + x1x1) - (x2x2 + x3x3); + matrix->row2_col2 = (s0s0 + x2x2) - (x1x1 + x3x3); + matrix->row3_col3 = (s0s0 + x3x3) - (x1x1 + x2x2); - matrix->r1c2 = 2.0f * (x1x2 - s0x3); - matrix->r2c3 = 2.0f * (x2x3 - s0x1); - matrix->r3c1 = 2.0f * (x1x3 - s0x2); + matrix->row1_col2 = 2.0f * (x1x2 - s0x3); + matrix->row2_col3 = 2.0f * (x2x3 - s0x1); + matrix->row3_col1 = 2.0f * (x1x3 - s0x2); - matrix->r2c1 = 2.0f * (x1x2 + s0x3); - matrix->r3c2 = 2.0f * (x2x3 + s0x1); - matrix->r1c3 = 2.0f * (x1x3 + s0x2); + matrix->row2_col1 = 2.0f * (x1x2 + s0x3); + matrix->row3_col2 = 2.0f * (x2x3 + s0x1); + matrix->row1_col3 = 2.0f * (x1x3 + s0x2); } inline void bgc_fp64_versor_get_rotation_matrix(BGC_FP64_Matrix3x3* matrix, const BGC_FP64_Versor* versor) @@ -487,17 +487,17 @@ inline void bgc_fp64_versor_get_rotation_matrix(BGC_FP64_Matrix3x3* matrix, cons const double x1x3 = versor->_x1 * versor->_x3; const double x2x3 = versor->_x2 * versor->_x3; - matrix->r1c1 = (s0s0 + x1x1) - (x2x2 + x3x3); - matrix->r2c2 = (s0s0 + x2x2) - (x1x1 + x3x3); - matrix->r3c3 = (s0s0 + x3x3) - (x1x1 + x2x2); + matrix->row1_col1 = (s0s0 + x1x1) - (x2x2 + x3x3); + matrix->row2_col2 = (s0s0 + x2x2) - (x1x1 + x3x3); + matrix->row3_col3 = (s0s0 + x3x3) - (x1x1 + x2x2); - matrix->r1c2 = 2.0 * (x1x2 - s0x3); - matrix->r2c3 = 2.0 * (x2x3 - s0x1); - matrix->r3c1 = 2.0 * (x1x3 - s0x2); + matrix->row1_col2 = 2.0 * (x1x2 - s0x3); + matrix->row2_col3 = 2.0 * (x2x3 - s0x1); + matrix->row3_col1 = 2.0 * (x1x3 - s0x2); - matrix->r2c1 = 2.0 * (x1x2 + s0x3); - matrix->r3c2 = 2.0 * (x2x3 + s0x1); - matrix->r1c3 = 2.0 * (x1x3 + s0x2); + matrix->row2_col1 = 2.0 * (x1x2 + s0x3); + matrix->row3_col2 = 2.0 * (x2x3 + s0x1); + matrix->row1_col3 = 2.0 * (x1x3 + s0x2); } // ============= Get Reverse Matrix ============= // @@ -516,17 +516,17 @@ inline void bgc_fp32_versor_get_reverse_matrix(BGC_FP32_Matrix3x3* matrix, const const float x1x3 = versor->_x1 * versor->_x3; const float x2x3 = versor->_x2 * versor->_x3; - matrix->r1c1 = (s0s0 + x1x1) - (x2x2 + x3x3); - matrix->r2c2 = (s0s0 + x2x2) - (x1x1 + x3x3); - matrix->r3c3 = (s0s0 + x3x3) - (x1x1 + x2x2); + matrix->row1_col1 = (s0s0 + x1x1) - (x2x2 + x3x3); + matrix->row2_col2 = (s0s0 + x2x2) - (x1x1 + x3x3); + matrix->row3_col3 = (s0s0 + x3x3) - (x1x1 + x2x2); - matrix->r1c2 = 2.0f * (x1x2 + s0x3); - matrix->r2c3 = 2.0f * (x2x3 + s0x1); - matrix->r3c1 = 2.0f * (x1x3 + s0x2); + matrix->row1_col2 = 2.0f * (x1x2 + s0x3); + matrix->row2_col3 = 2.0f * (x2x3 + s0x1); + matrix->row3_col1 = 2.0f * (x1x3 + s0x2); - matrix->r2c1 = 2.0f * (x1x2 - s0x3); - matrix->r3c2 = 2.0f * (x2x3 - s0x1); - matrix->r1c3 = 2.0f * (x1x3 - s0x2); + matrix->row2_col1 = 2.0f * (x1x2 - s0x3); + matrix->row3_col2 = 2.0f * (x2x3 - s0x1); + matrix->row1_col3 = 2.0f * (x1x3 - s0x2); } inline void bgc_fp64_versor_get_reverse_matrix(BGC_FP64_Matrix3x3* matrix, const BGC_FP64_Versor* versor) @@ -543,17 +543,17 @@ inline void bgc_fp64_versor_get_reverse_matrix(BGC_FP64_Matrix3x3* matrix, const const double x1x3 = versor->_x1 * versor->_x3; const double x2x3 = versor->_x2 * versor->_x3; - matrix->r1c1 = (s0s0 + x1x1) - (x2x2 + x3x3); - matrix->r2c2 = (s0s0 + x2x2) - (x1x1 + x3x3); - matrix->r3c3 = (s0s0 + x3x3) - (x1x1 + x2x2); + matrix->row1_col1 = (s0s0 + x1x1) - (x2x2 + x3x3); + matrix->row2_col2 = (s0s0 + x2x2) - (x1x1 + x3x3); + matrix->row3_col3 = (s0s0 + x3x3) - (x1x1 + x2x2); - matrix->r1c2 = 2.0 * (x1x2 + s0x3); - matrix->r2c3 = 2.0 * (x2x3 + s0x1); - matrix->r3c1 = 2.0 * (x1x3 + s0x2); + matrix->row1_col2 = 2.0 * (x1x2 + s0x3); + matrix->row2_col3 = 2.0 * (x2x3 + s0x1); + matrix->row3_col1 = 2.0 * (x1x3 + s0x2); - matrix->r2c1 = 2.0 * (x1x2 - s0x3); - matrix->r3c2 = 2.0 * (x2x3 - s0x1); - matrix->r1c3 = 2.0 * (x1x3 - s0x2); + matrix->row2_col1 = 2.0 * (x1x2 - s0x3); + matrix->row3_col2 = 2.0 * (x2x3 - s0x1); + matrix->row1_col3 = 2.0 * (x1x3 - s0x2); } // ============= Get Both Matrixes ============== // @@ -643,7 +643,7 @@ inline int bgc_fp32_versor_are_close(const BGC_FP32_Versor* versor1, const BGC_F const float dx2 = versor1->_x2 - versor2->_x2; const float dx3 = versor1->_x3 - versor2->_x3; - return (ds0 * ds0 + dx1 * dx1) + (dx2 * dx2 + dx3 * dx3) <= BGC_FP32_SQUARE_EPSYLON; + return (ds0 * ds0 + dx1 * dx1) + (dx2 * dx2 + dx3 * dx3) <= BGC_FP32_SQUARE_EPSILON; } inline int bgc_fp64_versor_are_close(const BGC_FP64_Versor* versor1, const BGC_FP64_Versor* versor2) @@ -653,7 +653,7 @@ inline int bgc_fp64_versor_are_close(const BGC_FP64_Versor* versor1, const BGC_F const double dx2 = versor1->_x2 - versor2->_x2; const double dx3 = versor1->_x3 - versor2->_x3; - return (ds0 * ds0 + dx1 * dx1) + (dx2 * dx2 + dx3 * dx3) <= BGC_FP64_SQUARE_EPSYLON; + return (ds0 * ds0 + dx1 * dx1) + (dx2 * dx2 + dx3 * dx3) <= BGC_FP64_SQUARE_EPSILON; } #endif From 3f96b661a94eacbba7266c308a94ecb1dcbcff16 Mon Sep 17 00:00:00 2001 From: Andrey Pokidov Date: Tue, 3 Feb 2026 03:33:53 +0700 Subject: [PATCH 4/9] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B4=D1=83=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B?= =?UTF-8?q?=D1=85=20=D1=87=D0=B8=D1=81=D0=B5=D0=BB,=20=D0=B4=D1=83=D0=B0?= =?UTF-8?q?=D0=BB=D1=8C=D0=BD=D1=8B=D1=85=20=D0=B2=D0=B5=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=20(3D)=20=D0=B8=20=D0=B4=D1=83=D0=B0=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=8B=D1=85=20=D0=B2=D0=B5=D1=80=D1=81=D0=BE=D1=80?= =?UTF-8?q?=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- basic-geometry/basic-geometry.vcxproj | 8 + basic-geometry/basic-geometry.vcxproj.filters | 24 +++ basic-geometry/dual-number.c | 13 ++ basic-geometry/dual-number.h | 70 +++++++++ basic-geometry/dual-vector3.c | 22 +++ basic-geometry/dual-vector3.h | 146 +++++++++++++++++ basic-geometry/dual-versor.c | 10 ++ basic-geometry/dual-versor.h | 147 ++++++++++++++++++ 8 files changed, 440 insertions(+) create mode 100644 basic-geometry/dual-number.c create mode 100644 basic-geometry/dual-number.h create mode 100644 basic-geometry/dual-vector3.c create mode 100644 basic-geometry/dual-vector3.h create mode 100644 basic-geometry/dual-versor.c create mode 100644 basic-geometry/dual-versor.h diff --git a/basic-geometry/basic-geometry.vcxproj b/basic-geometry/basic-geometry.vcxproj index 2b985f5..bd39f43 100644 --- a/basic-geometry/basic-geometry.vcxproj +++ b/basic-geometry/basic-geometry.vcxproj @@ -25,6 +25,10 @@ + + + + @@ -47,6 +51,10 @@ + + + + diff --git a/basic-geometry/basic-geometry.vcxproj.filters b/basic-geometry/basic-geometry.vcxproj.filters index 5200901..4f47928 100644 --- a/basic-geometry/basic-geometry.vcxproj.filters +++ b/basic-geometry/basic-geometry.vcxproj.filters @@ -84,6 +84,18 @@ Файлы заголовков + + Файлы заголовков + + + Файлы заголовков + + + Файлы заголовков + + + Файлы заголовков + @@ -137,5 +149,17 @@ Исходные файлы + + Исходные файлы + + + Исходные файлы + + + Исходные файлы + + + Исходные файлы + \ No newline at end of file diff --git a/basic-geometry/dual-number.c b/basic-geometry/dual-number.c new file mode 100644 index 0000000..a8da6d7 --- /dev/null +++ b/basic-geometry/dual-number.c @@ -0,0 +1,13 @@ +#include "dual-number.h" + +inline void bgc_fp32_dual_number_reset(BGC_FP32_DualNumber* number); +inline void bgc_fp64_dual_number_reset(BGC_FP64_DualNumber* number); + +inline void bgc_fp32_dual_number_make(BGC_FP32_DualNumber* number, const float real, const float dual); +inline void bgc_fp64_dual_number_make(BGC_FP64_DualNumber* number, const double real, const double dual); + +inline void bgc_fp32_dual_number_copy(BGC_FP32_DualNumber* destination, const BGC_FP32_DualNumber* source); +inline void bgc_fp64_dual_number_copy(BGC_FP64_DualNumber* destination, const BGC_FP64_DualNumber* source); + +inline void bgc_fp32_dual_number_swap(BGC_FP32_DualNumber* first, BGC_FP32_DualNumber* second); +inline void bgc_fp64_dual_number_swap(BGC_FP64_DualNumber* first, BGC_FP64_DualNumber* second); diff --git a/basic-geometry/dual-number.h b/basic-geometry/dual-number.h new file mode 100644 index 0000000..3a1eaf5 --- /dev/null +++ b/basic-geometry/dual-number.h @@ -0,0 +1,70 @@ +#ifndef _BGC_DUAL_NUMBER_H_ +#define _BGC_DUAL_NUMBER_H_ + +// =================== Types ==================== // + +typedef struct { + float real, dual; +} BGC_FP32_DualNumber; + +typedef struct { + double real, dual; +} BGC_FP64_DualNumber; + +// =================== Reset ==================== // + +inline void bgc_fp32_dual_number_reset(BGC_FP32_DualNumber* number) +{ + number->real = 0.0f; + number->dual = 0.0f; +} + +inline void bgc_fp64_dual_number_reset(BGC_FP64_DualNumber* number) +{ + number->real = 0.0; + number->dual = 0.0; +} + +// ==================== Make ==================== // + +inline void bgc_fp32_dual_number_make(BGC_FP32_DualNumber* number, const float real, const float dual) +{ + number->real = real; + number->dual = dual; +} + +inline void bgc_fp64_dual_number_make(BGC_FP64_DualNumber* number, const double real, const double dual) +{ + number->real = real; + number->dual = dual; +} + +// ==================== Copy ==================== // + +inline void bgc_fp32_dual_number_copy(BGC_FP32_DualNumber* destination, const BGC_FP32_DualNumber* source) +{ + destination->real = source->real; + destination->dual = source->dual; +} + +inline void bgc_fp64_dual_number_copy(BGC_FP64_DualNumber* destination, const BGC_FP64_DualNumber* source) +{ + destination->real = source->real; + destination->dual = source->dual; +} + +// ==================== Swap ==================== // + +inline void bgc_fp32_dual_number_swap(BGC_FP32_DualNumber* first, BGC_FP32_DualNumber* second) +{ + first->real = second->real; + first->dual = second->dual; +} + +inline void bgc_fp64_dual_number_swap(BGC_FP64_DualNumber* first, BGC_FP64_DualNumber* second) +{ + first->real = second->real; + first->dual = second->dual; +} + +#endif diff --git a/basic-geometry/dual-vector3.c b/basic-geometry/dual-vector3.c new file mode 100644 index 0000000..b222db1 --- /dev/null +++ b/basic-geometry/dual-vector3.c @@ -0,0 +1,22 @@ +#include "./dual-vector3.h" + +inline void bgc_fp32_dual_vector3_reset(BGC_FP32_DualVector3* vector); +inline void bgc_fp64_dual_vector3_reset(BGC_FP64_DualVector3* vector); + +inline void bgc_fp32_dual_vector3_make(BGC_FP32_DualVector3* vector, const BGC_FP32_Vector3* real, const BGC_FP32_Vector3* dual); +inline void bgc_fp64_dual_vector3_make(BGC_FP64_DualVector3* vector, const BGC_FP64_Vector3* real, const BGC_FP64_Vector3* dual); + +inline void bgc_fp32_dual_vector3_set_real_values(BGC_FP32_DualVector3* vector, const float x1, const float x2, const float x3); +inline void bgc_fp64_dual_vector3_set_real_values(BGC_FP64_DualVector3* vector, const double x1, const double x2, const double x3); + +inline void bgc_fp32_dual_vector3_set_dual_values(BGC_FP32_DualVector3* vector, const float x1, const float x2, const float x3); +inline void bgc_fp64_dual_vector3_set_dual_values(BGC_FP64_DualVector3* vector, const double x1, const double x2, const double x3); + +inline void bgc_fp32_dual_vector3_add(BGC_FP32_DualVector3* sum, const BGC_FP32_DualVector3* first, const BGC_FP32_DualVector3* second); +inline void bgc_fp64_dual_vector3_add(BGC_FP64_DualVector3* sum, const BGC_FP64_DualVector3* first, const BGC_FP64_DualVector3* second); + +inline void bgc_fp32_dual_vector3_add_scaled(BGC_FP32_DualVector3* sum, const BGC_FP32_DualVector3* base_vector, const BGC_FP32_DualVector3* scalable_vector, const float scale); +inline void bgc_fp64_dual_vector3_add_scaled(BGC_FP64_DualVector3* sum, const BGC_FP64_DualVector3* base_vector, const BGC_FP64_DualVector3* scalable_vector, const double scale); + +inline void bgc_fp32_dual_vector3_subtract(BGC_FP32_DualVector3* difference, const BGC_FP32_DualVector3* minuend, const BGC_FP32_DualVector3* subtrahend); +inline void bgc_fp64_dual_vector3_subtract(BGC_FP64_DualVector3* difference, const BGC_FP64_DualVector3* minuend, const BGC_FP64_DualVector3* subtrahend); diff --git a/basic-geometry/dual-vector3.h b/basic-geometry/dual-vector3.h new file mode 100644 index 0000000..b0df5b8 --- /dev/null +++ b/basic-geometry/dual-vector3.h @@ -0,0 +1,146 @@ +#ifndef _BGC_DUAL_VECTOR3_H_INCLUDE_ +#define _BGC_DUAL_VECTOR3_H_INCLUDE_ + +#include "./vector3.h" + +// =================== Types ==================== // + +typedef struct { + BGC_FP32_Vector3 real, dual; +} BGC_FP32_DualVector3; + +typedef struct { + BGC_FP64_Vector3 real, dual; +} BGC_FP64_DualVector3; + +// =================== Reset ==================== // + +inline void bgc_fp32_dual_vector3_reset(BGC_FP32_DualVector3* vector) +{ + bgc_fp32_vector3_reset(&vector->real); + bgc_fp32_vector3_reset(&vector->dual); +} + +inline void bgc_fp64_dual_vector3_reset(BGC_FP64_DualVector3* vector) +{ + bgc_fp64_vector3_reset(&vector->real); + bgc_fp64_vector3_reset(&vector->dual); +} + +// ==================== Make ==================== // + +inline void bgc_fp32_dual_vector3_make(BGC_FP32_DualVector3* vector, const BGC_FP32_Vector3* real, const BGC_FP32_Vector3* dual) +{ + bgc_fp32_vector3_copy(&vector->real, real); + bgc_fp32_vector3_copy(&vector->dual, dual); +} + +inline void bgc_fp64_dual_vector3_make(BGC_FP64_DualVector3* vector, const BGC_FP64_Vector3* real, const BGC_FP64_Vector3* dual) +{ + bgc_fp64_vector3_copy(&vector->real, real); + bgc_fp64_vector3_copy(&vector->dual, dual); +} + +// ================== Set Real ================== // + +inline void bgc_fp32_dual_vector3_set_real_values(BGC_FP32_DualVector3* vector, const float x1, const float x2, const float x3) +{ + vector->real.x1 = x1; + vector->real.x2 = x2; + vector->real.x3 = x3; +} + +inline void bgc_fp64_dual_vector3_set_real_values(BGC_FP64_DualVector3* vector, const double x1, const double x2, const double x3) +{ + vector->real.x1 = x1; + vector->real.x2 = x2; + vector->real.x3 = x3; +} + +// ================== Set Dual ================== // + +inline void bgc_fp32_dual_vector3_set_dual_values(BGC_FP32_DualVector3* vector, const float x1, const float x2, const float x3) +{ + vector->dual.x1 = x1; + vector->dual.x2 = x2; + vector->dual.x3 = x3; +} + +inline void bgc_fp64_dual_vector3_set_dual_values(BGC_FP64_DualVector3* vector, const double x1, const double x2, const double x3) +{ + vector->dual.x1 = x1; + vector->dual.x2 = x2; + vector->dual.x3 = x3; +} + +// ==================== Add ===================== // + +inline void bgc_fp32_dual_vector3_add(BGC_FP32_DualVector3* sum, const BGC_FP32_DualVector3* first, const BGC_FP32_DualVector3* second) +{ + bgc_fp32_vector3_add(&sum->real, &first->real, &second->real); + bgc_fp32_vector3_add(&sum->dual, &first->dual, &second->dual); +} + +inline void bgc_fp64_dual_vector3_add(BGC_FP64_DualVector3* sum, const BGC_FP64_DualVector3* first, const BGC_FP64_DualVector3* second) +{ + bgc_fp64_vector3_add(&sum->real, &first->real, &second->real); + bgc_fp64_vector3_add(&sum->dual, &first->dual, &second->dual); +} + +// ================= Add Scaled ================= // + +inline void bgc_fp32_dual_vector3_add_scaled(BGC_FP32_DualVector3* sum, const BGC_FP32_DualVector3* base_vector, const BGC_FP32_DualVector3* scalable_vector, const float scale) +{ + bgc_fp32_vector3_add_scaled(&sum->real, &base_vector->real, &scalable_vector->real, scale); + bgc_fp32_vector3_add_scaled(&sum->dual, &base_vector->dual, &scalable_vector->dual, scale); +} + +inline void bgc_fp64_dual_vector3_add_scaled(BGC_FP64_DualVector3* sum, const BGC_FP64_DualVector3* base_vector, const BGC_FP64_DualVector3* scalable_vector, const double scale) +{ + bgc_fp64_vector3_add_scaled(&sum->real, &base_vector->real, &scalable_vector->real, scale); + bgc_fp64_vector3_add_scaled(&sum->dual, &base_vector->dual, &scalable_vector->dual, scale); +} + +// ================== Subtract ================== // + +inline void bgc_fp32_dual_vector3_subtract(BGC_FP32_DualVector3* difference, const BGC_FP32_DualVector3* minuend, const BGC_FP32_DualVector3* subtrahend) +{ + bgc_fp32_vector3_subtract(&difference->real, &minuend->real, &subtrahend->real); + bgc_fp32_vector3_subtract(&difference->dual, &minuend->dual, &subtrahend->dual); +} + +inline void bgc_fp64_dual_vector3_subtract(BGC_FP64_DualVector3* difference, const BGC_FP64_DualVector3* minuend, const BGC_FP64_DualVector3* subtrahend) +{ + bgc_fp64_vector3_subtract(&difference->real, &minuend->real, &subtrahend->real); + bgc_fp64_vector3_subtract(&difference->dual, &minuend->dual, &subtrahend->dual); +} + +// ================== Average2 ================== // + +inline void bgc_fp32_dual_vector3_get_mean2(BGC_FP32_DualVector3* mean, const BGC_FP32_DualVector3* vector1, const BGC_FP32_DualVector3* vector2) +{ + bgc_fp32_vector3_get_mean2(&mean->real, &vector1->real, &vector2->real); + bgc_fp32_vector3_get_mean2(&mean->dual, &vector1->dual, &vector2->dual); +} + +inline void bgc_fp64_dual_vector3_get_mean2(BGC_FP64_DualVector3* mean, const BGC_FP64_DualVector3* vector1, const BGC_FP64_DualVector3* vector2) +{ + bgc_fp64_vector3_get_mean2(&mean->real, &vector1->real, &vector2->real); + bgc_fp64_vector3_get_mean2(&mean->dual, &vector1->dual, &vector2->dual); +} + +// ================== Average3 ================== // + +inline void bgc_fp32_dual_vector3_get_mean3(BGC_FP32_DualVector3* mean, const BGC_FP32_DualVector3* vector1, const BGC_FP32_DualVector3* vector2, const BGC_FP32_DualVector3* vector3) +{ + bgc_fp32_vector3_get_mean2(&mean->real, &vector1->real, &vector2->real, &vector3->real); + bgc_fp32_vector3_get_mean2(&mean->dual, &vector1->dual, &vector2->dual, &vector3->dual); +} + +inline void bgc_fp64_dual_vector3_get_mean3(BGC_FP64_DualVector3* mean, const BGC_FP64_DualVector3* vector1, const BGC_FP64_DualVector3* vector2, const BGC_FP64_DualVector3* vector3) +{ + bgc_fp64_vector3_get_mean2(&mean->real, &vector1->real, &vector2->real, &vector3->real); + bgc_fp64_vector3_get_mean2(&mean->dual, &vector1->dual, &vector2->dual, &vector3->dual); +} + +#endif diff --git a/basic-geometry/dual-versor.c b/basic-geometry/dual-versor.c new file mode 100644 index 0000000..e5ed49d --- /dev/null +++ b/basic-geometry/dual-versor.c @@ -0,0 +1,10 @@ +#include "dual-versor.h" + +extern inline void bgc_fp32_dual_versor_reset(BGC_FP32_DualVersor* number); +extern inline void bgc_fp64_dual_versor_reset(BGC_FP64_DualVersor* number); + +extern inline void bgc_fp32_dual_versor_copy(BGC_FP32_DualVersor* destination, const BGC_FP32_DualVersor* source); +extern inline void bgc_fp64_dual_versor_copy(BGC_FP64_DualVersor* destination, const BGC_FP64_DualVersor* source); + +extern inline void bgc_fp32_dual_versor_swap(BGC_FP32_DualVersor* first, BGC_FP32_DualVersor* second); +extern inline void bgc_fp64_dual_versor_swap(BGC_FP64_DualVersor* first, BGC_FP64_DualVersor* second); diff --git a/basic-geometry/dual-versor.h b/basic-geometry/dual-versor.h new file mode 100644 index 0000000..b1b6e81 --- /dev/null +++ b/basic-geometry/dual-versor.h @@ -0,0 +1,147 @@ +#ifndef _BGC_DUAL_VERSOR_H_ +#define _BGC_DUAL_VERSOR_H_ + +// =================== Types ==================== // + +typedef struct { + struct { + float s0, x1, x2, x3; + } _real, _dual; +} BGC_FP32_DualVersor; + +typedef struct { + struct { + double s0, x1, x2, x3; + } _real, _dual; +} BGC_FP64_DualVersor; + +// =================== Reset ==================== // + +inline void bgc_fp32_dual_versor_reset(BGC_FP32_DualVersor* number) +{ + number->_real.s0 = 1.0f; + number->_real.x1 = 0.0f; + number->_real.x2 = 0.0f; + number->_real.x3 = 0.0f; + + number->_dual.s0 = 0.0f; + number->_dual.x1 = 0.0f; + number->_dual.x2 = 0.0f; + number->_dual.x3 = 0.0f; +} + +inline void bgc_fp64_dual_versor_reset(BGC_FP64_DualVersor* number) +{ + number->_real.s0 = 1.0f; + number->_real.x1 = 0.0f; + number->_real.x2 = 0.0f; + number->_real.x3 = 0.0f; + + number->_dual.s0 = 0.0f; + number->_dual.x1 = 0.0f; + number->_dual.x2 = 0.0f; + number->_dual.x3 = 0.0f; +} + +// ==================== Copy ==================== // + +inline void bgc_fp32_dual_versor_copy(BGC_FP32_DualVersor* destination, const BGC_FP32_DualVersor* source) +{ + destination->_real.s0 = source->_real.s0; + destination->_real.x1 = source->_real.x1; + destination->_real.x2 = source->_real.x2; + destination->_real.x3 = source->_real.x3; + + destination->_dual.s0 = source->_dual.s0; + destination->_dual.x1 = source->_dual.x1; + destination->_dual.x2 = source->_dual.x2; + destination->_dual.x3 = source->_dual.x3; +} + +inline void bgc_fp64_dual_versor_copy(BGC_FP64_DualVersor* destination, const BGC_FP64_DualVersor* source) +{ + destination->_real.s0 = source->_real.s0; + destination->_real.x1 = source->_real.x1; + destination->_real.x2 = source->_real.x2; + destination->_real.x3 = source->_real.x3; + + destination->_dual.s0 = source->_dual.s0; + destination->_dual.x1 = source->_dual.x1; + destination->_dual.x2 = source->_dual.x2; + destination->_dual.x3 = source->_dual.x3; +} + +// ==================== Swap ==================== // + +inline void bgc_fp32_dual_versor_swap(BGC_FP32_DualVersor* first, BGC_FP32_DualVersor* second) +{ + // Real + float s0 = second->_real.s0; + float x1 = second->_real.x1; + float x2 = second->_real.x2; + float x3 = second->_real.x3; + + second->_real.s0 = first->_real.s0; + second->_real.x1 = first->_real.x1; + second->_real.x2 = first->_real.x2; + second->_real.x3 = first->_real.x3; + + first->_real.s0 = s0; + first->_real.x1 = x1; + first->_real.x2 = x2; + first->_real.x3 = x3; + + // Dual + s0 = second->_dual.s0; + x1 = second->_dual.x1; + x2 = second->_dual.x2; + x3 = second->_dual.x3; + + second->_dual.s0 = first->_dual.s0; + second->_dual.x1 = first->_dual.x1; + second->_dual.x2 = first->_dual.x2; + second->_dual.x3 = first->_dual.x3; + + first->_dual.s0 = s0; + first->_dual.x1 = x1; + first->_dual.x2 = x2; + first->_dual.x3 = x3; +} + +inline void bgc_fp64_dual_versor_swap(BGC_FP64_DualVersor* first, BGC_FP64_DualVersor* second) +{ + // Real + double s0 = second->_real.s0; + double x1 = second->_real.x1; + double x2 = second->_real.x2; + double x3 = second->_real.x3; + + second->_real.s0 = first->_real.s0; + second->_real.x1 = first->_real.x1; + second->_real.x2 = first->_real.x2; + second->_real.x3 = first->_real.x3; + + first->_real.s0 = s0; + first->_real.x1 = x1; + first->_real.x2 = x2; + first->_real.x3 = x3; + + // Dual + s0 = second->_dual.s0; + x1 = second->_dual.x1; + x2 = second->_dual.x2; + x3 = second->_dual.x3; + + second->_dual.s0 = first->_dual.s0; + second->_dual.x1 = first->_dual.x1; + second->_dual.x2 = first->_dual.x2; + second->_dual.x3 = first->_dual.x3; + + first->_dual.s0 = s0; + first->_dual.x1 = x1; + first->_dual.x2 = x2; + first->_dual.x3 = x3; +} + + +#endif From b87518cd3f181ee86cb978af13c6f3f8502ab135 Mon Sep 17 00:00:00 2001 From: Andrey Pokidov Date: Tue, 3 Feb 2026 19:56:56 +0700 Subject: [PATCH 5/9] =?UTF-8?q?=D0=A0=D0=B0=D0=B7=D0=B2=D0=B8=D1=82=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B4=D1=83=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B=D0=B9=20?= =?UTF-8?q?=D1=87=D0=B8=D1=81=D0=B5=D0=BB,=20=D0=B2=D0=B5=D0=BA=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BE=D0=B2=20=D0=B8=20=D0=BA=D0=B2=D0=B0=D1=82?= =?UTF-8?q?=D0=B5=D1=80=D0=BD=D0=B8=D0=BE=D0=BD=D0=BE=D0=B2,=20=D0=B0=20?= =?UTF-8?q?=D1=82=D0=B0=D0=BA=D0=B6=D0=B5=20=D0=B3=D0=BE=D0=BC=D0=BE=D0=B3?= =?UTF-8?q?=D0=B5=D0=BD=D0=BD=D1=8B=D1=85=20=D0=B2=D0=B5=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=20=D0=B8=20=D0=BC=D0=B0=D1=82=D1=80=D0=B8?= =?UTF-8?q?=D1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- basic-geometry/basic-geometry.cbp | 16 + basic-geometry/cotes-number.h | 32 +- basic-geometry/dual-number.c | 21 + basic-geometry/dual-number.h | 98 ++++ basic-geometry/dual-quaternion.c | 10 + basic-geometry/dual-quaternion.h | 58 +++ basic-geometry/dual-vector3.c | 40 +- basic-geometry/dual-vector3.h | 62 ++- basic-geometry/dual-versor.c | 10 - basic-geometry/dual-versor.h | 147 ------ basic-geometry/hg-matrix3x3.c | 7 + basic-geometry/hg-matrix3x3.h | 123 +++++ basic-geometry/hg-vector3.h | 86 +++- basic-geometry/matrices.h | 388 +++++++-------- basic-geometry/matrix2x2.h | 396 +++++++-------- basic-geometry/matrix2x3.h | 404 ++++++++-------- basic-geometry/matrix3x2.h | 404 ++++++++-------- basic-geometry/matrix3x3.c | 72 +-- basic-geometry/matrix3x3.h | 780 +++++++++++++++--------------- basic-geometry/quaternion.h | 72 +-- basic-geometry/versor.h | 72 +-- 21 files changed, 1787 insertions(+), 1511 deletions(-) create mode 100644 basic-geometry/dual-quaternion.c create mode 100644 basic-geometry/dual-quaternion.h delete mode 100644 basic-geometry/dual-versor.c delete mode 100644 basic-geometry/dual-versor.h create mode 100644 basic-geometry/hg-matrix3x3.c create mode 100644 basic-geometry/hg-matrix3x3.h diff --git a/basic-geometry/basic-geometry.cbp b/basic-geometry/basic-geometry.cbp index ef4457c..7008f8e 100644 --- a/basic-geometry/basic-geometry.cbp +++ b/basic-geometry/basic-geometry.cbp @@ -64,6 +64,22 @@ \ No newline at end of file diff --git a/basic-geometry/dual-quaternion.c b/basic-geometry/dual-quaternion.c index a0a1d22..8cfeede 100644 --- a/basic-geometry/dual-quaternion.c +++ b/basic-geometry/dual-quaternion.c @@ -8,3 +8,15 @@ extern inline void bgc_fp64_dual_quaternion_copy(BGC_FP64_DualQuaternion* destin extern inline void bgc_fp32_dual_quaternion_swap(BGC_FP32_DualQuaternion* first, BGC_FP32_DualQuaternion* second); extern inline void bgc_fp64_dual_quaternion_swap(BGC_FP64_DualQuaternion* first, BGC_FP64_DualQuaternion* second); + +extern inline void bgc_fp32_dual_quaternion_convert_to_fp64(BGC_FP64_DualQuaternion* destination, const BGC_FP32_DualQuaternion* source); +extern inline void bgc_fp64_dual_quaternion_convert_to_fp32(BGC_FP32_DualQuaternion* destination, const BGC_FP64_DualQuaternion* source); + +extern inline void bgc_fp32_dual_quaternion_add(BGC_FP32_DualQuaternion* sum, const BGC_FP32_DualQuaternion* first, const BGC_FP32_DualQuaternion* second); +extern inline void bgc_fp64_dual_quaternion_add(BGC_FP64_DualQuaternion* sum, const BGC_FP64_DualQuaternion* first, const BGC_FP64_DualQuaternion* second); + +extern inline void bgc_fp32_dual_quaternion_add(BGC_FP32_DualQuaternion* sum, const BGC_FP32_DualQuaternion* base_quaternion, const BGC_FP32_DualQuaternion* scalable_quaternion, const float scale); +extern inline void bgc_fp64_dual_quaternion_add(BGC_FP64_DualQuaternion* sum, const BGC_FP64_DualQuaternion* base_quaternion, const BGC_FP64_DualQuaternion* scalable_quaternion, const double scale); + +extern inline void bgc_fp32_dual_quaternion_subtract(BGC_FP32_DualQuaternion* difference, const BGC_FP32_DualQuaternion* minuend, const BGC_FP32_DualQuaternion* subtrahend); +extern inline void bgc_fp64_dual_quaternion_subtract(BGC_FP64_DualQuaternion* difference, const BGC_FP64_DualQuaternion* minuend, const BGC_FP64_DualQuaternion* subtrahend); diff --git a/basic-geometry/dual-quaternion.h b/basic-geometry/dual-quaternion.h index d7961a9..12b3343 100644 --- a/basic-geometry/dual-quaternion.h +++ b/basic-geometry/dual-quaternion.h @@ -55,4 +55,60 @@ inline void bgc_fp64_dual_quaternion_swap(BGC_FP64_DualQuaternion* first, BGC_FP bgc_fp64_quaternion_swap(&first->dual, &second->dual); } +// ================== Convert =================== // + +inline void bgc_fp32_dual_quaternion_convert_to_fp64(BGC_FP64_DualQuaternion* destination, const BGC_FP32_DualQuaternion* source) +{ + bgc_fp32_quaternion_convert_to_fp64(&destination->real, &source->real); + bgc_fp32_quaternion_convert_to_fp64(&destination->dual, &source->dual); +} + +inline void bgc_fp64_dual_quaternion_convert_to_fp32(BGC_FP32_DualQuaternion* destination, const BGC_FP64_DualQuaternion* source) +{ + bgc_fp64_quaternion_convert_to_fp32(&destination->real, &source->real); + bgc_fp64_quaternion_convert_to_fp32(&destination->dual, &source->dual); +} + +// ==================== Add ===================== // + +inline void bgc_fp32_dual_quaternion_add(BGC_FP32_DualQuaternion* sum, const BGC_FP32_DualQuaternion* first, const BGC_FP32_DualQuaternion* second) +{ + bgc_fp32_quaternion_add(&sum->real, &first->real, &second->real); + bgc_fp32_quaternion_add(&sum->dual, &first->dual, &second->dual); +} + +inline void bgc_fp64_dual_quaternion_add(BGC_FP64_DualQuaternion* sum, const BGC_FP64_DualQuaternion* first, const BGC_FP64_DualQuaternion* second) +{ + bgc_fp64_quaternion_add(&sum->real, &first->real, &second->real); + bgc_fp64_quaternion_add(&sum->dual, &first->dual, &second->dual); +} + +// ================= Add Scaled ================= // + +inline void bgc_fp32_dual_quaternion_add(BGC_FP32_DualQuaternion* sum, const BGC_FP32_DualQuaternion* base_quaternion, const BGC_FP32_DualQuaternion* scalable_quaternion, const float scale) +{ + bgc_fp32_quaternion_add_scaled(&sum->real, &base_quaternion->real, &scalable_quaternion->real, scale); + bgc_fp32_quaternion_add_scaled(&sum->dual, &base_quaternion->dual, &scalable_quaternion->dual, scale); +} + +inline void bgc_fp64_dual_quaternion_add(BGC_FP64_DualQuaternion* sum, const BGC_FP64_DualQuaternion* base_quaternion, const BGC_FP64_DualQuaternion* scalable_quaternion, const double scale) +{ + bgc_fp64_quaternion_add_scaled(&sum->real, &base_quaternion->real, &scalable_quaternion->real, scale); + bgc_fp64_quaternion_add_scaled(&sum->dual, &base_quaternion->dual, &scalable_quaternion->dual, scale); +} + +// ================== Subtract ================== // + +inline void bgc_fp32_dual_quaternion_subtract(BGC_FP32_DualQuaternion* difference, const BGC_FP32_DualQuaternion* minuend, const BGC_FP32_DualQuaternion* subtrahend) +{ + bgc_fp32_quaternion_subtract(&difference->real, &minuend->real, &subtrahend->real); + bgc_fp32_quaternion_subtract(&difference->dual, &minuend->dual, &subtrahend->dual); +} + +inline void bgc_fp64_dual_quaternion_subtract(BGC_FP64_DualQuaternion* difference, const BGC_FP64_DualQuaternion* minuend, const BGC_FP64_DualQuaternion* subtrahend) +{ + bgc_fp64_quaternion_subtract(&difference->real, &minuend->real, &subtrahend->real); + bgc_fp64_quaternion_subtract(&difference->dual, &minuend->dual, &subtrahend->dual); +} + #endif From b470a3194b6c12126bc2a76afa1b75d282e54d66 Mon Sep 17 00:00:00 2001 From: Andrey Pokidov Date: Wed, 4 Feb 2026 21:02:15 +0700 Subject: [PATCH 7/9] =?UTF-8?q?=D0=9E=D1=82=D0=BA=D0=B0=D0=B7=20=D0=BE?= =?UTF-8?q?=D1=82=20=D1=82=D0=B5=D1=80=D0=BC=D0=B8=D0=BD=D0=BE=D0=B2=20Ver?= =?UTF-8?q?sor=20=D0=B8=20Cotes=20Number=20=D0=B2=20=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D1=8C=D0=B7=D1=83=20Turn3=20=D0=B8=20Turn2,=20=D0=B8=D1=81?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BA=D0=B2=D0=B0=D1=82=D0=B5=D1=80=D0=BD=D0=B8=D0=BE?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=20=D0=B2=D0=BD=D1=83=D1=82=D1=80=D0=B8=20Tur?= =?UTF-8?q?n3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- basic-geometry-dev/affine3.c | 2 +- basic-geometry-dev/main.c | 157 +++---- basic-geometry-test/helpers.h | 8 +- basic-geometry/basic-geometry.cbp | 20 +- basic-geometry/basic-geometry.h | 13 +- basic-geometry/cotes-number.c | 91 ----- basic-geometry/cotes-number.h | 343 ---------------- basic-geometry/dual-quaternion.c | 4 +- basic-geometry/dual-quaternion.h | 4 +- basic-geometry/matrix2x2.c | 4 +- basic-geometry/matrix2x2.h | 4 +- basic-geometry/position2.c | 4 +- basic-geometry/position2.h | 90 ++-- basic-geometry/position3.c | 4 +- basic-geometry/position3.h | 90 ++-- basic-geometry/quaternion.c | 3 + basic-geometry/quaternion.h | 26 ++ basic-geometry/rotation3.c | 14 - basic-geometry/rotation3.h | 93 ----- basic-geometry/slerp.c | 72 ++-- basic-geometry/slerp.h | 42 +- basic-geometry/turn2.c | 91 +++++ basic-geometry/turn2.h | 343 ++++++++++++++++ basic-geometry/turn3.c | 593 +++++++++++++++++++++++++++ basic-geometry/turn3.h | 502 +++++++++++++++++++++++ basic-geometry/versor.c | 584 -------------------------- basic-geometry/versor.h | 659 ------------------------------ 27 files changed, 1815 insertions(+), 2045 deletions(-) delete mode 100644 basic-geometry/cotes-number.c delete mode 100644 basic-geometry/cotes-number.h delete mode 100644 basic-geometry/rotation3.c delete mode 100644 basic-geometry/rotation3.h create mode 100644 basic-geometry/turn2.c create mode 100644 basic-geometry/turn2.h create mode 100644 basic-geometry/turn3.c create mode 100644 basic-geometry/turn3.h delete mode 100644 basic-geometry/versor.c delete mode 100644 basic-geometry/versor.h diff --git a/basic-geometry-dev/affine3.c b/basic-geometry-dev/affine3.c index bf737f8..a607e30 100644 --- a/basic-geometry-dev/affine3.c +++ b/basic-geometry-dev/affine3.c @@ -40,7 +40,7 @@ BGC_FP32_Affine3* _create_bgc_affine3_random_list(int affine_amount) BGC_FP32_Position3 position; for (int i = 0; i < affine_amount; i++) { - bgc_fp32_versor_make( + bgc_fp32_turn3_set_raw_values( &position.turn, get_random_value_fp32(), get_random_value_fp32(), diff --git a/basic-geometry-dev/main.c b/basic-geometry-dev/main.c index 186e044..bef60f1 100644 --- a/basic-geometry-dev/main.c +++ b/basic-geometry-dev/main.c @@ -10,7 +10,7 @@ #endif // _WINDOWS_ typedef struct { - BGC_FP32_Versor versor1, versor2, result; + BGC_FP32_Turn3 versor1, versor2, result; } structure_fp32_t; structure_fp32_t* allocate_structures(const unsigned int amount) @@ -29,7 +29,7 @@ structure_fp32_t* make_structures(const unsigned int amount) const float multiplier = 2.0f / RAND_MAX; for (unsigned int i = 0; i < amount; i++) { - bgc_fp32_versor_make( + bgc_fp32_turn3_set_raw_values( &list[i].versor1, rand() * multiplier - 1.0f, rand() * multiplier - 1.0f, @@ -37,7 +37,7 @@ structure_fp32_t* make_structures(const unsigned int amount) rand() * multiplier - 1.0f ); - bgc_fp32_versor_make( + bgc_fp32_turn3_set_raw_values( &list[i].versor2, rand() * multiplier - 1.0f, rand() * multiplier - 1.0f, @@ -45,20 +45,20 @@ structure_fp32_t* make_structures(const unsigned int amount) rand() * multiplier - 1.0f ); - bgc_fp32_versor_reset(&list[i].result); + bgc_fp32_turn3_reset(&list[i].result); } return list; } -void print_versor_fp32(const BGC_FP32_Versor* versor) +void print_quaternion_fp32(const BGC_FP32_Quaternion* quaternion) { - printf("Versor (s0 = %0.12f, x1 = %0.12f, x2 = %0.12f, x3 = %0.12f)\n", versor->_s0, versor->_x1, versor->_x2, versor->_x3); + printf("Quaternion FP32(s0 = %0.12f, x1 = %0.12f, x2 = %0.12f, x3 = %0.12f)\n", quaternion->s0, quaternion->x1, quaternion->x2, quaternion->x3); } -void print_versor_fp64(const BGC_FP64_Versor* versor) +void print_quaternion_fp64(const BGC_FP64_Quaternion* quaternion) { - printf("Versor (s0 = %0.20f, x1 = %0.20f, x2 = %0.20f, x3 = %0.20f)\n", versor->_s0, versor->_x1, versor->_x2, versor->_x3); + printf("Quaternion FP64(s0 = %0.12f, x1 = %0.12f, x2 = %0.12f, x3 = %0.12f)\n", quaternion->s0, quaternion->x1, quaternion->x2, quaternion->x3); } void print_vector_fp32(const BGC_FP32_Vector3* vector) @@ -75,11 +75,11 @@ void list_work(const uint_fast32_t amount, structure_fp32_t* list) { for (uint_fast32_t j = 0; j < 1000; j++) { for (uint_fast32_t i = 0; i < amount; i++) { - bgc_fp32_versor_combine(&list[i].versor1, &list[i].versor1, &list[i].result); + bgc_fp32_turn3_combine(&list[i].result, &list[i].versor1, &list[i].versor2); } } } -/* + int main() { const unsigned int amount = 1000000; @@ -113,15 +113,15 @@ int main() printf("Time: %lf\n", (end.tv_sec - start.tv_sec) * 1000.0 + (end.tv_nsec - start.tv_nsec) * 0.000001); #endif // _WIN64 - print_versor_fp32(&list[10].versor1); - print_versor_fp32(&list[10].versor2); - print_versor_fp32(&list[10].result); + print_quaternion_fp32(&list[10].versor1._versor); + print_quaternion_fp32(&list[10].versor2._versor); + print_quaternion_fp32(&list[10].result._versor); free(list); return 0; } -*/ + /* int main() { @@ -140,10 +140,10 @@ int main() { */ /* int main() { - BGC_FP32_Versor start = { 1.0f, 0.0f, 0.0f, 0.0f }; - BGC_FP32_Versor end = { 0.0f, 1.0f, 0.0f, 0.0f }; - BGC_FP32_Versor result; - bgc_fp32_versor_spherical_interpolation(&start, &end, 0.5f, &result); + BGC_FP32_Turn3 start = { 1.0f, 0.0f, 0.0f, 0.0f }; + BGC_FP32_Turn3 end = { 0.0f, 1.0f, 0.0f, 0.0f }; + BGC_FP32_Turn3 result; + bgc_fp32_turn3_spherical_interpolation(&start, &end, 0.5f, &result); printf("Result: %0.12f, %0.12f, %0.12f, %0.12f\n", result.s0, result.x1, result.x2, result.x3); return 0; } @@ -154,7 +154,7 @@ void test_basis_difference_fp32() BGC_FP32_Vector3 initial_primary, initial_auxiliary; BGC_FP32_Vector3 final_primary, final_auxiliary; - BGC_FP32_Versor turn; + BGC_FP32_Turn3 turn; // No turn bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f); @@ -163,10 +163,10 @@ void test_basis_difference_fp32() bgc_fp32_vector3_make(&final_primary, 1.0f, 0.0f, 0.0f); bgc_fp32_vector3_make(&final_auxiliary, 0.0f, 1.0f, 0.0f); - bgc_fp32_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + bgc_fp32_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); printf("\nNo turn:\n"); - print_versor_fp32(&turn); + print_quaternion_fp32(&turn._versor); // Turn around (1, 1, 0) axis on 180 degrees bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f); @@ -175,10 +175,10 @@ void test_basis_difference_fp32() bgc_fp32_vector3_make(&final_primary, 0.0f, 1.0f, 0.0f); bgc_fp32_vector3_make(&final_auxiliary, 1.0f, 0.0f, 0.0f); - bgc_fp32_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + bgc_fp32_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); printf("\nTurn around (1, 1, 0) axis on 180 degrees:\n"); - print_versor_fp32(&turn); + print_quaternion_fp32(&turn._versor); // 180 degree turn bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f); @@ -187,10 +187,10 @@ void test_basis_difference_fp32() bgc_fp32_vector3_make(&final_primary, -1.0f, 0.0f, 0.0f); bgc_fp32_vector3_make(&final_auxiliary, 0.0f, 1.0f, 0.0f); - bgc_fp32_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + bgc_fp32_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); printf("\n180 degree turn around (0, 1, 0):\n"); - print_versor_fp32(&turn); + print_quaternion_fp32(&turn._versor); // 90 degree turn around x3 axis bgc_fp32_vector3_make(&initial_primary, 2.0f, 0.0f, 0.0f); @@ -199,10 +199,10 @@ void test_basis_difference_fp32() bgc_fp32_vector3_make(&final_primary, 0.0f, 10.0f, 0.0f); bgc_fp32_vector3_make(&final_auxiliary,-1.0f, 0.0f, 0.0f); - bgc_fp32_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + bgc_fp32_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); printf("\n90 degree turn around (0, 0, 1):\n"); - print_versor_fp32(&turn); + print_quaternion_fp32(&turn._versor); // Unorthogonal pairs turn at 90 degrees around x3 axis bgc_fp32_vector3_make(&initial_primary, 2.0f, 0.0f, 0.0f); @@ -211,10 +211,10 @@ void test_basis_difference_fp32() bgc_fp32_vector3_make(&final_primary, 0.0f, 10.0f, 0.0f); bgc_fp32_vector3_make(&final_auxiliary, -1.0f, 5.0f, 0.0f); - bgc_fp32_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + bgc_fp32_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); printf("\nUnorthogonal pairs turn at 90 degrees around (0, 0, 1):\n"); - print_versor_fp32(&turn); + print_quaternion_fp32(&turn._versor); // Zero vectors bgc_fp32_vector3_make(&initial_primary, 0.0f, 0.0f, 0.0f); @@ -224,11 +224,11 @@ void test_basis_difference_fp32() int code; - code = bgc_fp32_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + code = bgc_fp32_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); if (code >= 0) { printf("\nZero vectors: this cannot be!\n"); - print_versor_fp32(&turn); + print_quaternion_fp32(&turn._versor); } else { printf("\nZero vector validation works fine\n"); @@ -240,11 +240,11 @@ void test_basis_difference_fp32() bgc_fp32_vector3_make(&final_primary, 1.0f, 0.0f, 0.0f); bgc_fp32_vector3_make(&final_auxiliary, 0.0f, 1.0f, 0.0f); - code = bgc_fp32_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + code = bgc_fp32_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); if (code >= 0) { printf("\nParallel vectors: this cannot be!\n"); - print_versor_fp32(&turn); + print_quaternion_fp32(&turn._versor); } else { printf("\nParallelism validation works fine\n"); @@ -257,10 +257,10 @@ void test_basis_difference_fp32() bgc_fp32_vector3_make(&final_primary, 0.999848f, 0.017452f, 0.0f); bgc_fp32_vector3_make(&final_auxiliary, -0.017452f, 0.999848f, 0.0f); - bgc_fp32_versor_make_basis_difference(&turn , &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + bgc_fp32_turn3_make_basis_difference(&turn , &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); printf("\nSmall angle turn (about 1 degree):\n"); - print_versor_fp32(&turn); + print_quaternion_fp32(&turn._versor); // About 179 degrees turn bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f); @@ -269,10 +269,10 @@ void test_basis_difference_fp32() bgc_fp32_vector3_make(&final_primary, -0.999848f, -0.017452f, 0.0f); bgc_fp32_vector3_make(&final_auxiliary, 0.017452f, -0.999848f, 0.0f); - bgc_fp32_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + bgc_fp32_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); printf("\nAbout 179 degrees turn:\n"); - print_versor_fp32(&turn); + print_quaternion_fp32(&turn._versor); // 120 degrees around (-1, -1, 1) bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f); @@ -281,10 +281,10 @@ void test_basis_difference_fp32() bgc_fp32_vector3_make(&final_primary, 0.0f, 1.0f, 0.0f); bgc_fp32_vector3_make(&final_auxiliary, 0.0f, 0.0f, -1.0f); - bgc_fp32_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + bgc_fp32_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); printf("\n120 degees turn:\n"); - print_versor_fp32(&turn); + print_quaternion_fp32(&turn._versor); // About 1 degree turn difference between initial_primary and initial_auxiliary directions @@ -293,10 +293,10 @@ void test_basis_difference_fp32() bgc_fp32_vector3_make(&final_primary, 0.0f, 1.0f, 0.0f); bgc_fp32_vector3_make(&final_auxiliary, -1.0f, 0.0f, 0.0f); - bgc_fp32_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + bgc_fp32_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); printf("\nAbout 1 degree turn difference between initial_primary and initial_auxiliary directions:\n"); - print_versor_fp32(&turn); + print_quaternion_fp32(&turn._versor); // About 0.01 degree turn difference between initial_primary and initial_auxiliary directions bgc_fp32_vector3_make(&initial_primary, 1.0f, 0.0f, 0.0f); @@ -304,10 +304,10 @@ void test_basis_difference_fp32() bgc_fp32_vector3_make(&final_primary, 0.0f, -1.0f, 0.0f); bgc_fp32_vector3_make(&final_auxiliary, 1.0f, 0.0f, 0.0f); - bgc_fp32_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + bgc_fp32_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); printf("\nAbout 0.01 degree turn difference between initial_primary and initial_auxiliary directions:\n"); - print_versor_fp32(&turn); + print_quaternion_fp32(&turn._versor); } void test_basis_difference_fp64() @@ -315,7 +315,7 @@ void test_basis_difference_fp64() BGC_FP64_Vector3 initial_primary, initial_auxiliary; BGC_FP64_Vector3 final_primary, final_auxiliary; - BGC_FP64_Versor turn; + BGC_FP64_Turn3 turn; // No turn bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0); @@ -323,10 +323,10 @@ void test_basis_difference_fp64() bgc_fp64_vector3_make(&final_primary, 1.0, 0.0, 0.0); bgc_fp64_vector3_make(&final_auxiliary, 0.0, 1.0, 0.0); - bgc_fp64_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); printf("\nNo turn:\n"); - print_versor_fp64(&turn); + print_quaternion_fp64(&turn._versor); // Turn around (1, 1, 0) axis on 180 degrees bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0); @@ -334,10 +334,10 @@ void test_basis_difference_fp64() bgc_fp64_vector3_make(&final_primary, 0.0, 1.0, 0.0); bgc_fp64_vector3_make(&final_auxiliary, 1.0, 0.0, 0.0); - bgc_fp64_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); printf("\nTurn around (1, 1, 0) axis on 180 degrees:\n"); - print_versor_fp64(&turn); + print_quaternion_fp64(&turn._versor); // 180 degree turn bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0); @@ -346,10 +346,10 @@ void test_basis_difference_fp64() bgc_fp64_vector3_make(&initial_auxiliary, -1.0, 0.0, 0.0); bgc_fp64_vector3_make(&final_auxiliary, 0.0, 1.0, 0.0); - bgc_fp64_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); printf("\n180 degree turn around (0, 1, 0):\n"); - print_versor_fp64(&turn); + print_quaternion_fp64(&turn._versor); // 90 degree turn around x3 axis bgc_fp64_vector3_make(&initial_primary, 2.0, 0.0, 0.0); @@ -358,10 +358,10 @@ void test_basis_difference_fp64() bgc_fp64_vector3_make(&final_primary, 0.0, 10.0, 0.0); bgc_fp64_vector3_make(&final_auxiliary, -1.0, 0.0, 0.0); - bgc_fp64_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); printf("\n90 degree turn around (0, 0, 1):\n"); - print_versor_fp64(&turn); + print_quaternion_fp64(&turn._versor); // Unorthogonal pairs turn at 90 degrees around x3 axis bgc_fp64_vector3_make(&initial_primary, 2.0, 0.0, 0.0); @@ -370,10 +370,10 @@ void test_basis_difference_fp64() bgc_fp64_vector3_make(&final_primary, 0.0, 10.0, 0.0); bgc_fp64_vector3_make(&final_auxiliary, -1.0, 5.0, 0.0); - bgc_fp64_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); printf("\nUnorthogonal pairs turn at 90 degrees around (0, 0, 1):\n"); - print_versor_fp64(&turn); + print_quaternion_fp64(&turn._versor); // Zero vectors bgc_fp64_vector3_make(&initial_primary, 0.0, 0.0, 0.0); @@ -383,11 +383,11 @@ void test_basis_difference_fp64() int code; - code = bgc_fp64_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + code = bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); if (code >= 0) { printf("\nZero vectors: this cannot be!\n"); - print_versor_fp64(&turn); + print_quaternion_fp64(&turn._versor); } else { printf("\nZero vector validation works fine\n"); @@ -399,11 +399,11 @@ void test_basis_difference_fp64() bgc_fp64_vector3_make(&final_primary, 1.0, 0.0, 0.0); bgc_fp64_vector3_make(&final_auxiliary, 0.0, 1.0, 0.0); - code = bgc_fp64_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + code = bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); if (code >= 0) { printf("\nParallel vectors: this cannot be!\n"); - print_versor_fp64(&turn); + print_quaternion_fp64(&turn._versor); } else { printf("\nParallelism validation works fine\n"); @@ -416,10 +416,10 @@ void test_basis_difference_fp64() bgc_fp64_vector3_make(&final_primary, 0.999848, 0.017452, 0.0); bgc_fp64_vector3_make(&final_auxiliary, -0.017452, 0.999848, 0.0); - bgc_fp64_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); printf("\nSmall angle turn (about 1 degree):\n"); - print_versor_fp64(&turn); + print_quaternion_fp64(&turn._versor); // About 179 degrees turn bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0); @@ -428,10 +428,10 @@ void test_basis_difference_fp64() bgc_fp64_vector3_make(&final_primary, -0.999848, -0.017452, 0.0); bgc_fp64_vector3_make(&final_auxiliary, 0.017452, -0.999848, 0.0); - bgc_fp64_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); printf("\nAbout 179 degrees turn:\n"); - print_versor_fp64(&turn); + print_quaternion_fp64(&turn._versor); // 120 degrees around (-1, -1, 1) bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0); @@ -440,10 +440,10 @@ void test_basis_difference_fp64() bgc_fp64_vector3_make(&final_primary, 0.0, 1.0, 0.0); bgc_fp64_vector3_make(&final_auxiliary, 0.0, 0.0, -1.0); - bgc_fp64_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); printf("\n120 degees turn:\n"); - print_versor_fp64(&turn); + print_quaternion_fp64(&turn._versor); // About 1 degree turn difference between initial_primary and initial_auxiliary directions @@ -452,10 +452,10 @@ void test_basis_difference_fp64() bgc_fp64_vector3_make(&final_primary, 0.0, 1.0, 0.0); bgc_fp64_vector3_make(&final_auxiliary, -1.0, 0.0, 0.0); - bgc_fp64_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); printf("\nAbout 1 degree turn difference between initial_primary and initial_auxiliary directions:\n"); - print_versor_fp64(&turn); + print_quaternion_fp64(&turn._versor); // About 0.001 degree turn difference between initial_primary and initial_auxiliary directions bgc_fp64_vector3_make(&initial_primary, 1.0, 0.0, 0.0); @@ -463,30 +463,30 @@ void test_basis_difference_fp64() bgc_fp64_vector3_make(&final_primary, 0.0, -1.0, 0.0); bgc_fp64_vector3_make(&final_auxiliary, 1.0, 0.0, 0.0); - bgc_fp64_versor_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); + bgc_fp64_turn3_make_basis_difference(&turn, &initial_primary, &initial_auxiliary, &final_primary, &final_auxiliary); printf("\nAbout 0.01 degree turn difference between initial_primary and initial_auxiliary directions:\n"); - print_versor_fp64(&turn); + print_quaternion_fp64(&turn._versor); } - +/* #include "affine3.h" int main() { - //BGC_FP32_Versor start = { 1.0f, 0.0f, 0.0f, 0.0f }; - //BGC_FP32_Versor end = { 0.0f, 1.0f, 0.0f, 0.0f }; - - BGC_FP32_Versor start = { 1.0f, 0.0f, 0.0f, 0.0f }; - BGC_FP32_Versor end = { 0.9999f, 0.01414f, 0.0f, 0.0f }; + //BGC_FP32_Turn3 start = { 1.0f, 0.0f, 0.0f, 0.0f }; + //BGC_FP32_Turn3 end = { 0.0f, 1.0f, 0.0f, 0.0f }; + + BGC_FP32_Turn3 start = { 1.0f, 0.0f, 0.0f, 0.0f }; + BGC_FP32_Turn3 end = { 0.9999f, 0.01414f, 0.0f, 0.0f }; BGC_FP32_Slerp slerp; - BGC_FP32_Versor result; + BGC_FP32_Turn3 result; bgc_fp32_slerp_make_full(&slerp, &start, &end); bgc_fp32_slerp_get_phase_versor(&result, &slerp, 0.5f); - //print_versor_fp32(&result); - + //print_quaternion_fp32(&result); + test_basis_difference_fp64(); - + //printf("Affine3 performance test: %f\n", test_bgc_affine3_performance(10000000, 10)); //printf("sizeof(BGC_FP32_Affine3) = %zu\n", sizeof(BGC_FP32_Affine3)); @@ -495,3 +495,4 @@ int main() return 0; } +*/ diff --git a/basic-geometry-test/helpers.h b/basic-geometry-test/helpers.h index 10bd548..2044198 100644 --- a/basic-geometry-test/helpers.h +++ b/basic-geometry-test/helpers.h @@ -25,19 +25,19 @@ typedef struct { // =================== Versor =================== // typedef struct { - BGC_FP32_Versor first, second; + BGC_FP32_Turn3 first, second; } TestVersorPairFP32; typedef struct { - BGC_FP64_Versor first, second; + BGC_FP64_Turn3 first, second; } TestVersorPairFP64; typedef struct { - BGC_FP32_Versor first, second, result; + BGC_FP32_Turn3 first, second, result; } TestVersorTripletFP32; typedef struct { - BGC_FP64_Versor first, second, result; + BGC_FP64_Turn3 first, second, result; } TestVersorTripletFP64; // ================= Functions ================== // diff --git a/basic-geometry/basic-geometry.cbp b/basic-geometry/basic-geometry.cbp index 7008f8e..4d62d04 100644 --- a/basic-geometry/basic-geometry.cbp +++ b/basic-geometry/basic-geometry.cbp @@ -60,10 +60,6 @@