qua: isnan, isinf, isfinite

This commit is contained in:
BlackMATov
2021-01-26 01:54:20 +07:00
parent 1acbb0dffb
commit 341e3dd0a3
2 changed files with 28 additions and 0 deletions

View File

@@ -145,5 +145,27 @@ namespace vmath_hpp
}
}
//
// Common Functions
//
namespace vmath_hpp
{
template < typename T >
[[nodiscard]] vec<bool, 4> isnan(const qua<T>& xs) {
return isnan(vec{xs});
}
template < typename T >
[[nodiscard]] vec<bool, 4> isinf(const qua<T>& xs) {
return isinf(vec{xs});
}
template < typename T >
[[nodiscard]] vec<bool, 4> isfinite(const qua<T>& xs) {
return isfinite(vec{xs});
}
}
}
}

View File

@@ -63,4 +63,10 @@ TEST_CASE("vmath/qua_fun") {
STATIC_REQUIRE(float3{1,2,3} * fqua{} == uapprox3(1.f,2.f,3.f));
STATIC_REQUIRE(float3{1,0,0} * fqua{0,0,0.7071067812f,0.7071067812f} == uapprox3(0.f,1.f,0.f));
}
SUBCASE("Common Functions") {
REQUIRE_FALSE(any(isnan(fqua(1,1,1,1))));
REQUIRE_FALSE(any(isinf(fqua(1,1,1,1))));
REQUIRE(all(isfinite(fqua(1,1,1,1))));
}
}