This commit is contained in:
Saikari
2025-12-21 22:22:18 +03:00
parent 1499ac3213
commit 4a8e7e85ce
3 changed files with 14 additions and 4 deletions

View File

@@ -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
##############################################################################

View File

@@ -233,10 +233,10 @@ namespace omath
return Angle<float, 0.f, 180.f, AngleFlags::Clamped>::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<Type>(0.0001)) const noexcept
{
if (const auto angle = angle_between(other))
return angle->as_degrees() == static_cast<Type>(90);
return std::abs(angle->as_degrees() - static_cast<Type>(90)) <= epsilon;
return false;
}

View File

@@ -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());
}