diff --git a/src/versor.c b/src/versor.c index 896e259..2874d2a 100644 --- a/src/versor.c +++ b/src/versor.c @@ -7,7 +7,7 @@ const BgFP32Versor BG_FP32_IDLE_VERSOR = { 1.0f, 0.0f, 0.0f, 0.0f }; const BgFP64Versor BG_FP64_IDLE_VERSOR = { 1.0, 0.0, 0.0, 0.0 }; -void __bg_fp32_versor_normalize(const float square_module, __BgFP32VersorDarkTwin* twin) +void __bg_fp32_versor_normalize(const float square_module, __BgFP32DarkTwinVersor* twin) { if (square_module <= BG_FP32_SQUARE_EPSYLON || (twin->x1 * twin->x1 + twin->x2 * twin->x2 + twin->x3 * twin->x3) <= BG_FP32_SQUARE_EPSYLON * square_module) { twin->s0 = 1.0f; @@ -25,7 +25,7 @@ void __bg_fp32_versor_normalize(const float square_module, __BgFP32VersorDarkTwi twin->x3 /= module; } -void __bg_fp64_versor_normalize(const double square_module, __BgFP64VersorDarkTwin* twin) +void __bg_fp64_versor_normalize(const double square_module, __BgFP64DarkTwinVersor* twin) { if (square_module <= BG_FP64_SQUARE_EPSYLON || (twin->x1 * twin->x1 + twin->x2 * twin->x2 + twin->x3 * twin->x3) <= BG_FP64_SQUARE_EPSYLON * square_module) { twin->s0 = 1.0; diff --git a/src/versor.h b/src/versor.h index 312c8f9..bdc5769 100644 --- a/src/versor.h +++ b/src/versor.h @@ -3,6 +3,8 @@ #include +#include + #include "basis.h" #include "vector3.h" #include "rotation3.h" @@ -22,11 +24,11 @@ typedef struct { typedef struct { float s0, x1, x2, x3; -} __BgFP32VersorDarkTwin; +} __BgFP32DarkTwinVersor; typedef struct { double s0, x1, x2, x3; -} __BgFP64VersorDarkTwin; +} __BgFP64DarkTwinVersor; // ================= Constants ================== // @@ -37,7 +39,7 @@ extern const BgFP64Versor BG_FP64_IDLE_VERSOR; static inline void bg_fp32_versor_reset(BgFP32Versor* versor) { - __BgFP32VersorDarkTwin* twin = (__BgFP32VersorDarkTwin*)versor; + __BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)versor; twin->s0 = 1.0f; twin->x1 = 0.0f; @@ -47,7 +49,7 @@ static inline void bg_fp32_versor_reset(BgFP32Versor* versor) static inline void bg_fp64_versor_reset(BgFP64Versor* versor) { - __BgFP64VersorDarkTwin* twin = (__BgFP64VersorDarkTwin*)versor; + __BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)versor; twin->s0 = 1.0; twin->x1 = 0.0; @@ -57,13 +59,13 @@ static inline void bg_fp64_versor_reset(BgFP64Versor* versor) // ==================== Set ===================== // -void __bg_fp32_versor_normalize(const float square_module, __BgFP32VersorDarkTwin* twin); +void __bg_fp32_versor_normalize(const float square_module, __BgFP32DarkTwinVersor* twin); -void __bg_fp64_versor_normalize(const double square_module, __BgFP64VersorDarkTwin* twin); +void __bg_fp64_versor_normalize(const double square_module, __BgFP64DarkTwinVersor* twin); static inline void bg_fp32_versor_set_values(const float s0, const float x1, const float x2, const float x3, BgFP32Versor* versor) { - __BgFP32VersorDarkTwin* twin = (__BgFP32VersorDarkTwin*)versor; + __BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)versor; twin->s0 = s0; twin->x1 = x1; @@ -73,13 +75,13 @@ static inline void bg_fp32_versor_set_values(const float s0, const float x1, con const float square_module = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3); if (square_module < 1.0f - BG_FP32_TWO_EPSYLON || 1.0f + BG_FP32_TWO_EPSYLON < square_module) { - __bg_fp32_versor_normalize(square_module, (__BgFP32VersorDarkTwin*)versor); + __bg_fp32_versor_normalize(square_module, (__BgFP32DarkTwinVersor*)versor); } } static inline void bg_fp64_versor_set_values(const double s0, const double x1, const double x2, const double x3, BgFP64Versor* versor) { - __BgFP64VersorDarkTwin* twin = (__BgFP64VersorDarkTwin*)versor; + __BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)versor; twin->s0 = s0; twin->x1 = x1; @@ -97,7 +99,7 @@ static inline void bg_fp64_versor_set_values(const double s0, const double x1, c static inline void bg_fp32_versor_copy(const BgFP32Versor* from, BgFP32Versor* to) { - __BgFP32VersorDarkTwin* twin = (__BgFP32VersorDarkTwin*)to; + __BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)to; twin->s0 = from->s0; twin->x1 = from->x1; @@ -107,7 +109,7 @@ static inline void bg_fp32_versor_copy(const BgFP32Versor* from, BgFP32Versor* t static inline void bg_fp64_versor_copy(const BgFP64Versor* from, BgFP64Versor* to) { - __BgFP64VersorDarkTwin* twin = (__BgFP64VersorDarkTwin*)to; + __BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)to; twin->s0 = from->s0; twin->x1 = from->x1; @@ -185,7 +187,7 @@ static inline void bg_fp64_versor_set_from_fp32(const BgFP32Versor* versor, BgFP static inline void bg_fp32_versor_invert(BgFP32Versor* versor) { - __BgFP32VersorDarkTwin* twin = (__BgFP32VersorDarkTwin*)versor; + __BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)versor; twin->x1 = -versor->x1; twin->x2 = -versor->x2; twin->x3 = -versor->x3; @@ -193,7 +195,7 @@ static inline void bg_fp32_versor_invert(BgFP32Versor* versor) static inline void bg_fp64_versor_invert(BgFP64Versor* versor) { - __BgFP64VersorDarkTwin* twin = (__BgFP64VersorDarkTwin*)versor; + __BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)versor; twin->x1 = -versor->x1; twin->x2 = -versor->x2; twin->x3 = -versor->x3; @@ -203,7 +205,7 @@ static inline void bg_fp64_versor_invert(BgFP64Versor* versor) static inline void bg_fp32_versor_set_inverted(const BgFP32Versor* versor, BgFP32Versor* to) { - __BgFP32VersorDarkTwin* twin = (__BgFP32VersorDarkTwin*)to; + __BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)to; twin->s0 = versor->s0; twin->x1 = -versor->x1; twin->x2 = -versor->x2; @@ -212,7 +214,7 @@ static inline void bg_fp32_versor_set_inverted(const BgFP32Versor* versor, BgFP3 static inline void bg_fp64_versor_set_inverted(const BgFP64Versor* versor, BgFP64Versor* to) { - __BgFP64VersorDarkTwin* twin = (__BgFP64VersorDarkTwin*)to; + __BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)to; twin->s0 = versor->s0; twin->x1 = -versor->x1; twin->x2 = -versor->x2; @@ -254,7 +256,7 @@ static inline void bg_fp32_versor_combine(const BgFP32Versor* second, const BgFP const float square_module = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3); - __BgFP32VersorDarkTwin* twin = (__BgFP32VersorDarkTwin*)result; + __BgFP32DarkTwinVersor* twin = (__BgFP32DarkTwinVersor*)result; twin->s0 = s0; twin->x1 = x1; @@ -275,7 +277,7 @@ static inline void bg_fp64_versor_combine(const BgFP64Versor* second, const BgFP const double square_module = (s0 * s0 + x1 * x1) + (x2 * x2 + x3 * x3); - __BgFP64VersorDarkTwin* twin = (__BgFP64VersorDarkTwin*)result; + __BgFP64DarkTwinVersor* twin = (__BgFP64DarkTwinVersor*)result; twin->s0 = s0; twin->x1 = x1; diff --git a/test/fp32_vector2_test.c b/test/fp32_vector2_test.c index 5f67a94..c5bbc81 100644 --- a/test/fp32_vector2_test.c +++ b/test/fp32_vector2_test.c @@ -1,4 +1,4 @@ -#include "sp_vector2_test.h" +#include "fp32_vector2_test.h" const int TEST_BG_FP32_VECTOR2_AMOUNT_1 = 5; @@ -22,7 +22,7 @@ const BgFP32Vector2 TEST_BG_FP32_VECTOR2_COMMON_2[] = { const float BG_FP32_VECTOR2_SQUARE_MODULE_1[] = { 25.0f, 25.0f, 500000000.0f, 100.01f, 15266.150221f }; -int test_sp_vector2_square_module() +int test_bg_fp32_vector2_square_module() { print_test_name("BgFP32Vector2 square module"); @@ -31,7 +31,7 @@ int test_sp_vector2_square_module() for (int i = 0; i < TEST_BG_FP32_VECTOR2_AMOUNT_1; i++) { square_module = bg_fp32_vector2_get_square_module(&TEST_BG_FP32_VECTOR2_COMMON_1[i]); - if (!test_sp_are_equal(square_module, BG_FP32_VECTOR2_SQUARE_MODULE_1[i], TEST_BG_FP32_TWO_EPSYLON)) { + if (!test_bg_fp32_are_equal(square_module, BG_FP32_VECTOR2_SQUARE_MODULE_1[i], TEST_BG_FP32_TWO_EPSYLON)) { print_test_failed(); return TEST_RESULT_FAILED; } @@ -45,16 +45,16 @@ int test_sp_vector2_square_module() const float BG_FP32_VECTOR2_MODULE_1[] = { 5.0f, 5.0f, 22360.68f, 10.0005f, 123.55626338f }; -int test_sp_vector2_module() +int test_bg_fp32_vector2_module() { print_test_name("BgFP32Vector2 module"); float square_module; for (int i = 0; i < TEST_BG_FP32_VECTOR2_AMOUNT_1; i++) { - square_module = sp_vector2_get_module(&TEST_BG_FP32_VECTOR2_COMMON_1[i]); + square_module = bg_fp32_vector2_get_module(&TEST_BG_FP32_VECTOR2_COMMON_1[i]); - if (!test_sp_are_equal(square_module, BG_FP32_VECTOR2_MODULE_1[i], TEST_BG_FP32_EPSYLON)) { + if (!test_bg_fp32_are_equal(square_module, BG_FP32_VECTOR2_MODULE_1[i], TEST_BG_FP32_EPSYLON)) { print_test_failed(); return TEST_RESULT_FAILED; } @@ -74,17 +74,17 @@ const BgFP32Vector2 TEST_BG_FP32_VECTOR2_COMMON_1_2_SUM[] = { { -122.0f, -19.6217f } }; -int test_sp_vector2_add() +int test_bg_fp32_vector2_add() { print_test_name("BgFP32Vector2 add"); BgFP32Vector2 vector; for (int i = 0; i < TEST_BG_FP32_VECTOR2_AMOUNT_1; i++) { - sp_vector2_add(&TEST_BG_FP32_VECTOR2_COMMON_1[i], &TEST_BG_FP32_VECTOR2_COMMON_2[i], &vector); + bg_fp32_vector2_add(&TEST_BG_FP32_VECTOR2_COMMON_1[i], &TEST_BG_FP32_VECTOR2_COMMON_2[i], &vector); - if (!test_sp_are_equal(vector.x1, TEST_BG_FP32_VECTOR2_COMMON_1_2_SUM[i].x1, TEST_BG_FP32_EPSYLON) || - !test_sp_are_equal(vector.x2, TEST_BG_FP32_VECTOR2_COMMON_1_2_SUM[i].x2, TEST_BG_FP32_EPSYLON)) { + if (!test_bg_fp32_are_equal(vector.x1, TEST_BG_FP32_VECTOR2_COMMON_1_2_SUM[i].x1, TEST_BG_FP32_EPSYLON) || + !test_bg_fp32_are_equal(vector.x2, TEST_BG_FP32_VECTOR2_COMMON_1_2_SUM[i].x2, TEST_BG_FP32_EPSYLON)) { print_test_failed(); return TEST_RESULT_FAILED; } @@ -104,17 +104,17 @@ const BgFP32Vector2 TEST_BG_FP32_VECTOR2_COMMON_1_2_DIFF[] = { { -125.0f, 27.0783f } }; -int test_sp_vector2_subtract() +int test_bg_fp32_vector2_subtract() { print_test_name("BgFP32Vector2 subtract"); BgFP32Vector2 vector; for (int i = 0; i < TEST_BG_FP32_VECTOR2_AMOUNT_1; i++) { - sp_vector2_subtract(&TEST_BG_FP32_VECTOR2_COMMON_1[i], &TEST_BG_FP32_VECTOR2_COMMON_2[i], &vector); + bg_fp32_vector2_subtract(&TEST_BG_FP32_VECTOR2_COMMON_1[i], &TEST_BG_FP32_VECTOR2_COMMON_2[i], &vector); - if (!test_sp_are_equal(vector.x1, TEST_BG_FP32_VECTOR2_COMMON_1_2_DIFF[i].x1, TEST_BG_FP32_EPSYLON) || - !test_sp_are_equal(vector.x2, TEST_BG_FP32_VECTOR2_COMMON_1_2_DIFF[i].x2, TEST_BG_FP32_EPSYLON)) { + if (!test_bg_fp32_are_equal(vector.x1, TEST_BG_FP32_VECTOR2_COMMON_1_2_DIFF[i].x1, TEST_BG_FP32_EPSYLON) || + !test_bg_fp32_are_equal(vector.x2, TEST_BG_FP32_VECTOR2_COMMON_1_2_DIFF[i].x2, TEST_BG_FP32_EPSYLON)) { print_test_failed(); return TEST_RESULT_FAILED; } @@ -126,23 +126,23 @@ int test_sp_vector2_subtract() // ==================== 1234 ==================== // -int test_sp_vector2() +int test_bg_fp32_vector2() { print_test_section("BgFP32Vector2"); - if (test_sp_vector2_square_module() != TEST_RESULT_SUCCES) { + if (test_bg_fp32_vector2_square_module() != TEST_RESULT_SUCCES) { return TEST_RESULT_FAILED; } - if (test_sp_vector2_module() != TEST_RESULT_SUCCES) { + if (test_bg_fp32_vector2_module() != TEST_RESULT_SUCCES) { return TEST_RESULT_FAILED; } - if (test_sp_vector2_add() != TEST_RESULT_SUCCES) { + if (test_bg_fp32_vector2_add() != TEST_RESULT_SUCCES) { return TEST_RESULT_FAILED; } - if (test_sp_vector2_subtract() != TEST_RESULT_SUCCES) { + if (test_bg_fp32_vector2_subtract() != TEST_RESULT_SUCCES) { return TEST_RESULT_FAILED; } diff --git a/test/geometry-test.vcxproj b/test/geometry-test.vcxproj index 466a968..0ca598a 100644 --- a/test/geometry-test.vcxproj +++ b/test/geometry-test.vcxproj @@ -148,13 +148,13 @@ + - + - diff --git a/test/geometry-test.vcxproj.filters b/test/geometry-test.vcxproj.filters index d7e4b49..df06490 100644 --- a/test/geometry-test.vcxproj.filters +++ b/test/geometry-test.vcxproj.filters @@ -21,7 +21,7 @@ Исходные файлы - + Исходные файлы @@ -29,7 +29,7 @@ Исходные файлы - + Исходные файлы