diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 0c2aadf..95c34f2 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -506,6 +506,14 @@ jobs: cmake-build/build/${{ matrix.preset }}/**/*.log ${{ env.VCPKG_ROOT }}/buildtrees/**/*.log + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Run WASM Unit Tests + run: node out/Release/unit_tests.js + ############################################################################## # 8) Windows MSYS2 MinGW – GCC / Ninja ############################################################################## diff --git a/include/omath/linear_algebra/vector3.hpp b/include/omath/linear_algebra/vector3.hpp index 1aaec5a..ab481f2 100644 --- a/include/omath/linear_algebra/vector3.hpp +++ b/include/omath/linear_algebra/vector3.hpp @@ -233,10 +233,10 @@ namespace omath return Angle::from_radians(std::acos(dot(other) / bottom)); } - [[nodiscard]] bool is_perpendicular(const Vector3& other) const noexcept + [[nodiscard]] bool is_perpendicular(const Vector3& other, Type epsilon = static_cast(0.0001)) const noexcept { if (const auto angle = angle_between(other)) - return angle->as_degrees() == static_cast(90); + return std::abs(angle->as_degrees() - static_cast(90)) <= epsilon; return false; } diff --git a/tests/general/unit_test_vector3.cpp b/tests/general/unit_test_vector3.cpp index f5cc9fb..2be59df 100644 --- a/tests/general/unit_test_vector3.cpp +++ b/tests/general/unit_test_vector3.cpp @@ -390,8 +390,10 @@ TEST_F(UnitTestVector3, AsTuple) // Test AsTuple method TEST_F(UnitTestVector3, AngleBeatween) { - EXPECT_EQ(Vector3(0.0f, 0.0f, 1.0f).angle_between({1, 0 ,0}).value().as_degrees(), 90.0f); - EXPECT_EQ(Vector3(0.0f, 0.0f, 1.0f).angle_between({0.0f, 0.0f, 1.0f}).value().as_degrees(), 0.0f); + EXPECT_NEAR(Vector3(0.0f, 0.0f, 1.0f).angle_between({1, 0, 0}).value().as_degrees(), + 90.0f, 0.001f); + EXPECT_NEAR(Vector3(0.0f, 0.0f, 1.0f).angle_between({0.0f, 0.0f, 1.0f}).value().as_degrees(), + 0.0f, 0.001f); EXPECT_FALSE(Vector3(0.0f, 0.0f, 0.0f).angle_between({0.0f, 0.0f, 1.0f}).has_value()); }