mirror of
https://github.com/BlackMATov/vmath.hpp.git
synced 2025-12-14 12:28:58 +07:00
qua: approx, equal_to, not_equal_to
This commit is contained in:
@@ -193,3 +193,36 @@ namespace vmath_hpp
|
||||
return qua(normalize(vec{xs}));
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Relational Functions
|
||||
//
|
||||
|
||||
namespace vmath_hpp
|
||||
{
|
||||
// approx
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] constexpr vec<bool, 4> approx(const qua<T>& xs, const qua<T>& ys) {
|
||||
return approx(vec{xs}, vec{ys});
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] constexpr vec<bool, 4> approx(const qua<T>& xs, const qua<T>& ys, T epsilon) {
|
||||
return approx(vec{xs}, vec{ys}, epsilon);
|
||||
}
|
||||
|
||||
// equal_to
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] constexpr vec<bool, 4> equal_to(const qua<T>& xs, const qua<T>& ys) {
|
||||
return equal_to(vec{xs}, vec{ys});
|
||||
}
|
||||
|
||||
// not_equal_to
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] constexpr vec<bool, 4> not_equal_to(const qua<T>& xs, const qua<T>& ys) {
|
||||
return not_equal_to(vec{xs}, vec{ys});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,4 +81,14 @@ TEST_CASE("vmath/qua_fun") {
|
||||
|
||||
REQUIRE(normalize(fqua(0.5f,0.f,0.f,0.f)).v == uapprox3(1.f,0.f,0.f));
|
||||
}
|
||||
|
||||
SUBCASE("Relational Functions") {
|
||||
STATIC_REQUIRE(approx(qua(1,1,1,1), qua(0,1,2,3)) == bool4(false, true, false, false));
|
||||
STATIC_REQUIRE(approx(qua(1,1,1,1), qua(0,1,2,3), 0) == bool4(false, true, false, false));
|
||||
STATIC_REQUIRE(approx(qua(1,1,1,1), qua(0,1,2,3), 1) == bool4(true, true, true, false));
|
||||
STATIC_REQUIRE(approx(qua(1,1,1,1), qua(0,1,2,3), 2) == bool4(true, true, true, true));
|
||||
|
||||
STATIC_REQUIRE(equal_to(qua(1,1,1,1), qua(0,1,2,3)) == bool4(false, true, false, false));
|
||||
STATIC_REQUIRE(not_equal_to(qua(1,1,1,1), qua(0,1,2,3)) == bool4(true, false, true, true));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user