mirror of
https://github.com/BlackMATov/vmath.hpp.git
synced 2025-12-16 22:19:51 +07:00
rename approximately to approx
This commit is contained in:
28
README.md
28
README.md
@@ -1261,10 +1261,10 @@ template < arithmetic T >
|
|||||||
constexpr bool all(T x) noexcept;
|
constexpr bool all(T x) noexcept;
|
||||||
|
|
||||||
template < arithmetic T >
|
template < arithmetic T >
|
||||||
constexpr bool approximately(T x, T y) noexcept;
|
constexpr bool approx(T x, T y) noexcept;
|
||||||
|
|
||||||
template < arithmetic T >
|
template < arithmetic T >
|
||||||
constexpr bool approximately(T x, T y, T epsilon) noexcept;
|
constexpr bool approx(T x, T y, T epsilon) noexcept;
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Vector
|
#### Vector
|
||||||
@@ -1277,22 +1277,22 @@ template < typename T, size_t Size >
|
|||||||
constexpr bool all(const vec<T, Size>& xs);
|
constexpr bool all(const vec<T, Size>& xs);
|
||||||
|
|
||||||
template < typename T, size_t Size >
|
template < typename T, size_t Size >
|
||||||
constexpr vec<bool, Size> approximately(const vec<T, Size>& xs, T y);
|
constexpr vec<bool, Size> approx(const vec<T, Size>& xs, T y);
|
||||||
|
|
||||||
template < typename T, size_t Size >
|
template < typename T, size_t Size >
|
||||||
constexpr vec<bool, Size> approximately(T x, const vec<T, Size>& ys);
|
constexpr vec<bool, Size> approx(T x, const vec<T, Size>& ys);
|
||||||
|
|
||||||
template < typename T, size_t Size >
|
template < typename T, size_t Size >
|
||||||
constexpr vec<bool, Size> approximately(const vec<T, Size>& xs, const vec<T, Size>& ys);
|
constexpr vec<bool, Size> approx(const vec<T, Size>& xs, const vec<T, Size>& ys);
|
||||||
|
|
||||||
template < typename T, size_t Size >
|
template < typename T, size_t Size >
|
||||||
constexpr vec<bool, Size> approximately(const vec<T, Size>& xs, T y, T epsilon);
|
constexpr vec<bool, Size> approx(const vec<T, Size>& xs, T y, T epsilon);
|
||||||
|
|
||||||
template < typename T, size_t Size >
|
template < typename T, size_t Size >
|
||||||
constexpr vec<bool, Size> approximately(T x, const vec<T, Size>& ys, T epsilon);
|
constexpr vec<bool, Size> approx(T x, const vec<T, Size>& ys, T epsilon);
|
||||||
|
|
||||||
template < typename T, size_t Size >
|
template < typename T, size_t Size >
|
||||||
constexpr vec<bool, Size> approximately(const vec<T, Size>& xs, const vec<T, Size>& ys, T epsilon);
|
constexpr vec<bool, Size> approx(const vec<T, Size>& xs, const vec<T, Size>& ys, T epsilon);
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Matrix
|
#### Matrix
|
||||||
@@ -1305,22 +1305,22 @@ template < typename T, size_t Size >
|
|||||||
constexpr bool all(const mat<T, Size>& xs);
|
constexpr bool all(const mat<T, Size>& xs);
|
||||||
|
|
||||||
template < typename T, size_t Size >
|
template < typename T, size_t Size >
|
||||||
constexpr mat<bool, Size> approximately(const mat<T, Size>& xs, T y);
|
constexpr mat<bool, Size> approx(const mat<T, Size>& xs, T y);
|
||||||
|
|
||||||
template < typename T, size_t Size >
|
template < typename T, size_t Size >
|
||||||
constexpr mat<bool, Size> approximately(T x, const mat<T, Size>& ys);
|
constexpr mat<bool, Size> approx(T x, const mat<T, Size>& ys);
|
||||||
|
|
||||||
template < typename T, size_t Size >
|
template < typename T, size_t Size >
|
||||||
constexpr mat<bool, Size> approximately(const mat<T, Size>& xs, const mat<T, Size>& ys);
|
constexpr mat<bool, Size> approx(const mat<T, Size>& xs, const mat<T, Size>& ys);
|
||||||
|
|
||||||
template < typename T, size_t Size >
|
template < typename T, size_t Size >
|
||||||
constexpr mat<bool, Size> approximately(const mat<T, Size>& xs, T y, T epsilon);
|
constexpr mat<bool, Size> approx(const mat<T, Size>& xs, T y, T epsilon);
|
||||||
|
|
||||||
template < typename T, size_t Size >
|
template < typename T, size_t Size >
|
||||||
constexpr mat<bool, Size> approximately(T x, const mat<T, Size>& ys, T epsilon);
|
constexpr mat<bool, Size> approx(T x, const mat<T, Size>& ys, T epsilon);
|
||||||
|
|
||||||
template < typename T, size_t Size >
|
template < typename T, size_t Size >
|
||||||
constexpr mat<bool, Size> approximately(const mat<T, Size>& xs, const mat<T, Size>& ys, T epsilon);
|
constexpr mat<bool, Size> approx(const mat<T, Size>& xs, const mat<T, Size>& ys, T epsilon);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Matrix Functions
|
### Matrix Functions
|
||||||
|
|||||||
@@ -418,7 +418,7 @@ namespace vmath_hpp
|
|||||||
|
|
||||||
template < typename T >
|
template < typename T >
|
||||||
[[nodiscard]] std::enable_if_t<std::is_arithmetic_v<T>, bool>
|
[[nodiscard]] std::enable_if_t<std::is_arithmetic_v<T>, bool>
|
||||||
constexpr approximately(T x, T y) noexcept {
|
constexpr approx(T x, T y) noexcept {
|
||||||
if constexpr ( std::is_floating_point_v<T> ) {
|
if constexpr ( std::is_floating_point_v<T> ) {
|
||||||
// http://www.realtimecollisiondetection.net/pubs/Tolerances
|
// http://www.realtimecollisiondetection.net/pubs/Tolerances
|
||||||
const T epsilon = std::numeric_limits<T>::epsilon();
|
const T epsilon = std::numeric_limits<T>::epsilon();
|
||||||
@@ -430,7 +430,7 @@ namespace vmath_hpp
|
|||||||
|
|
||||||
template < typename T >
|
template < typename T >
|
||||||
[[nodiscard]] std::enable_if_t<std::is_arithmetic_v<T>, bool>
|
[[nodiscard]] std::enable_if_t<std::is_arithmetic_v<T>, bool>
|
||||||
constexpr approximately(T x, T y, T epsilon) noexcept {
|
constexpr approx(T x, T y, T epsilon) noexcept {
|
||||||
if constexpr ( std::is_floating_point_v<T> ) {
|
if constexpr ( std::is_floating_point_v<T> ) {
|
||||||
// http://www.realtimecollisiondetection.net/pubs/Tolerances
|
// http://www.realtimecollisiondetection.net/pubs/Tolerances
|
||||||
return abs(x - y) <= epsilon * max(T(1), abs(x), abs(y));
|
return abs(x - y) <= epsilon * max(T(1), abs(x), abs(y));
|
||||||
|
|||||||
@@ -561,33 +561,33 @@ namespace vmath_hpp
|
|||||||
}
|
}
|
||||||
|
|
||||||
template < typename T, std::size_t Size >
|
template < typename T, std::size_t Size >
|
||||||
[[nodiscard]] constexpr mat<bool, Size> approximately(const mat<T, Size>& xs, T y) {
|
[[nodiscard]] constexpr mat<bool, Size> approx(const mat<T, Size>& xs, T y) {
|
||||||
return map_join([y](const vec<T, Size>& x){ return approximately(x, y); }, xs);
|
return map_join([y](const vec<T, Size>& x){ return approx(x, y); }, xs);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename T, std::size_t Size >
|
template < typename T, std::size_t Size >
|
||||||
[[nodiscard]] constexpr mat<bool, Size> approximately(T x, const mat<T, Size>& ys) {
|
[[nodiscard]] constexpr mat<bool, Size> approx(T x, const mat<T, Size>& ys) {
|
||||||
return map_join([x](const vec<T, Size>& y){ return approximately(x, y); }, ys);
|
return map_join([x](const vec<T, Size>& y){ return approx(x, y); }, ys);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename T, std::size_t Size >
|
template < typename T, std::size_t Size >
|
||||||
[[nodiscard]] constexpr mat<bool, Size> approximately(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
[[nodiscard]] constexpr mat<bool, Size> approx(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||||
return map_join([](const vec<T, Size>& x, const vec<T, Size>& y){ return approximately(x, y); }, xs, ys);
|
return map_join([](const vec<T, Size>& x, const vec<T, Size>& y){ return approx(x, y); }, xs, ys);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename T, std::size_t Size >
|
template < typename T, std::size_t Size >
|
||||||
[[nodiscard]] constexpr mat<bool, Size> approximately(const mat<T, Size>& xs, T y, T epsilon) {
|
[[nodiscard]] constexpr mat<bool, Size> approx(const mat<T, Size>& xs, T y, T epsilon) {
|
||||||
return map_join([y, epsilon](const vec<T, Size>& x){ return approximately(x, y, epsilon); }, xs);
|
return map_join([y, epsilon](const vec<T, Size>& x){ return approx(x, y, epsilon); }, xs);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename T, std::size_t Size >
|
template < typename T, std::size_t Size >
|
||||||
[[nodiscard]] constexpr mat<bool, Size> approximately(T x, const mat<T, Size>& ys, T epsilon) {
|
[[nodiscard]] constexpr mat<bool, Size> approx(T x, const mat<T, Size>& ys, T epsilon) {
|
||||||
return map_join([x, epsilon](const vec<T, Size>& y){ return approximately(x, y, epsilon); }, ys);
|
return map_join([x, epsilon](const vec<T, Size>& y){ return approx(x, y, epsilon); }, ys);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename T, std::size_t Size >
|
template < typename T, std::size_t Size >
|
||||||
[[nodiscard]] constexpr mat<bool, Size> approximately(const mat<T, Size>& xs, const mat<T, Size>& ys, T epsilon) {
|
[[nodiscard]] constexpr mat<bool, Size> approx(const mat<T, Size>& xs, const mat<T, Size>& ys, T epsilon) {
|
||||||
return map_join([epsilon](const vec<T, Size>& x, const vec<T, Size>& y){ return approximately(x, y, epsilon); }, xs, ys);
|
return map_join([epsilon](const vec<T, Size>& x, const vec<T, Size>& y){ return approx(x, y, epsilon); }, xs, ys);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -914,32 +914,32 @@ namespace vmath_hpp
|
|||||||
}
|
}
|
||||||
|
|
||||||
template < typename T, std::size_t Size >
|
template < typename T, std::size_t Size >
|
||||||
[[nodiscard]] constexpr vec<bool, Size> approximately(const vec<T, Size>& xs, T y) {
|
[[nodiscard]] constexpr vec<bool, Size> approx(const vec<T, Size>& xs, T y) {
|
||||||
return map_join([y](T x){ return approximately(x, y); }, xs);
|
return map_join([y](T x){ return approx(x, y); }, xs);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename T, std::size_t Size >
|
template < typename T, std::size_t Size >
|
||||||
[[nodiscard]] constexpr vec<bool, Size> approximately(T x, const vec<T, Size>& ys) {
|
[[nodiscard]] constexpr vec<bool, Size> approx(T x, const vec<T, Size>& ys) {
|
||||||
return map_join([x](T y){ return approximately(x, y); }, ys);
|
return map_join([x](T y){ return approx(x, y); }, ys);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename T, std::size_t Size >
|
template < typename T, std::size_t Size >
|
||||||
[[nodiscard]] constexpr vec<bool, Size> approximately(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
[[nodiscard]] constexpr vec<bool, Size> approx(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||||
return map_join([](T x, T y){ return approximately(x, y); }, xs, ys);
|
return map_join([](T x, T y){ return approx(x, y); }, xs, ys);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename T, std::size_t Size >
|
template < typename T, std::size_t Size >
|
||||||
[[nodiscard]] constexpr vec<bool, Size> approximately(const vec<T, Size>& xs, T y, T epsilon) {
|
[[nodiscard]] constexpr vec<bool, Size> approx(const vec<T, Size>& xs, T y, T epsilon) {
|
||||||
return map_join([y, epsilon](T x){ return approximately(x, y, epsilon); }, xs);
|
return map_join([y, epsilon](T x){ return approx(x, y, epsilon); }, xs);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename T, std::size_t Size >
|
template < typename T, std::size_t Size >
|
||||||
[[nodiscard]] constexpr vec<bool, Size> approximately(T x, const vec<T, Size>& ys, T epsilon) {
|
[[nodiscard]] constexpr vec<bool, Size> approx(T x, const vec<T, Size>& ys, T epsilon) {
|
||||||
return map_join([x, epsilon](T y){ return approximately(x, y, epsilon); }, ys);
|
return map_join([x, epsilon](T y){ return approx(x, y, epsilon); }, ys);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename T, std::size_t Size >
|
template < typename T, std::size_t Size >
|
||||||
[[nodiscard]] constexpr vec<bool, Size> approximately(const vec<T, Size>& xs, const vec<T, Size>& ys, T epsilon) {
|
[[nodiscard]] constexpr vec<bool, Size> approx(const vec<T, Size>& xs, const vec<T, Size>& ys, T epsilon) {
|
||||||
return map_join([epsilon](T x, T y){ return approximately(x, y, epsilon); }, xs, ys);
|
return map_join([epsilon](T x, T y){ return approx(x, y, epsilon); }, xs, ys);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,14 +153,14 @@ TEST_CASE("vmath/fun") {
|
|||||||
STATIC_REQUIRE(all(true));
|
STATIC_REQUIRE(all(true));
|
||||||
STATIC_REQUIRE(all(1));
|
STATIC_REQUIRE(all(1));
|
||||||
|
|
||||||
STATIC_REQUIRE(approximately(1, 1));
|
STATIC_REQUIRE(approx(1, 1));
|
||||||
STATIC_REQUIRE_FALSE(approximately(0, 1));
|
STATIC_REQUIRE_FALSE(approx(0, 1));
|
||||||
STATIC_REQUIRE_FALSE(approximately(0, 1, 0));
|
STATIC_REQUIRE_FALSE(approx(0, 1, 0));
|
||||||
STATIC_REQUIRE(approximately(0, 1, 1));
|
STATIC_REQUIRE(approx(0, 1, 1));
|
||||||
|
|
||||||
STATIC_REQUIRE(approximately(1.f, 1.f + std::numeric_limits<float>::epsilon() * 0.5f));
|
STATIC_REQUIRE(approx(1.f, 1.f + std::numeric_limits<float>::epsilon() * 0.5f));
|
||||||
STATIC_REQUIRE_FALSE(approximately(1.f, 1.f + std::numeric_limits<float>::epsilon() * 1.5f));
|
STATIC_REQUIRE_FALSE(approx(1.f, 1.f + std::numeric_limits<float>::epsilon() * 1.5f));
|
||||||
STATIC_REQUIRE(approximately(100.f, 100.f + std::numeric_limits<float>::epsilon() * 90.f));
|
STATIC_REQUIRE(approx(100.f, 100.f + std::numeric_limits<float>::epsilon() * 90.f));
|
||||||
STATIC_REQUIRE_FALSE(approximately(100.f, 100.f + std::numeric_limits<float>::epsilon() * 110.f));
|
STATIC_REQUIRE_FALSE(approx(100.f, 100.f + std::numeric_limits<float>::epsilon() * 110.f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,21 +202,21 @@ TEST_CASE("vmath/mat_fun") {
|
|||||||
STATIC_REQUIRE_FALSE(all(int2x2(0, 1, 0, 1)));
|
STATIC_REQUIRE_FALSE(all(int2x2(0, 1, 0, 1)));
|
||||||
STATIC_REQUIRE(all(int2x2(1, 1, 1, 1)));
|
STATIC_REQUIRE(all(int2x2(1, 1, 1, 1)));
|
||||||
|
|
||||||
STATIC_REQUIRE(approximately(int2x2(1,1,1,1), int2x2(0,1,2,3)) == bool2x2(false, true, false, false));
|
STATIC_REQUIRE(approx(int2x2(1,1,1,1), int2x2(0,1,2,3)) == bool2x2(false, true, false, false));
|
||||||
STATIC_REQUIRE(approximately(int2x2(0,1,2,3),1) == bool2x2(false, true, false, false));
|
STATIC_REQUIRE(approx(int2x2(0,1,2,3),1) == bool2x2(false, true, false, false));
|
||||||
STATIC_REQUIRE(approximately(1,int2x2(0,1,2,3)) == bool2x2(false, true, false, false));
|
STATIC_REQUIRE(approx(1,int2x2(0,1,2,3)) == bool2x2(false, true, false, false));
|
||||||
|
|
||||||
STATIC_REQUIRE(approximately(int2x2(1,1,1,1), int2x2(0,1,2,3), 0) == bool2x2(false, true, false, false));
|
STATIC_REQUIRE(approx(int2x2(1,1,1,1), int2x2(0,1,2,3), 0) == bool2x2(false, true, false, false));
|
||||||
STATIC_REQUIRE(approximately(int2x2(0,1,2,3), 1, 0) == bool2x2(false, true, false, false));
|
STATIC_REQUIRE(approx(int2x2(0,1,2,3), 1, 0) == bool2x2(false, true, false, false));
|
||||||
STATIC_REQUIRE(approximately(1, int2x2(0,1,2,3), 0) == bool2x2(false, true, false, false));
|
STATIC_REQUIRE(approx(1, int2x2(0,1,2,3), 0) == bool2x2(false, true, false, false));
|
||||||
|
|
||||||
STATIC_REQUIRE(approximately(int2x2(1,1,1,1), int2x2(0,1,2,3), 1) == bool2x2(true, true, true, false));
|
STATIC_REQUIRE(approx(int2x2(1,1,1,1), int2x2(0,1,2,3), 1) == bool2x2(true, true, true, false));
|
||||||
STATIC_REQUIRE(approximately(int2x2(0,1,2,3), 1, 1) == bool2x2(true, true, true, false));
|
STATIC_REQUIRE(approx(int2x2(0,1,2,3), 1, 1) == bool2x2(true, true, true, false));
|
||||||
STATIC_REQUIRE(approximately(1, int2x2(0,1,2,3), 1) == bool2x2(true, true, true, false));
|
STATIC_REQUIRE(approx(1, int2x2(0,1,2,3), 1) == bool2x2(true, true, true, false));
|
||||||
|
|
||||||
STATIC_REQUIRE(approximately(int2x2(1,1,1,1), int2x2(0,1,2,3), 2) == bool2x2(true, true, true, true));
|
STATIC_REQUIRE(approx(int2x2(1,1,1,1), int2x2(0,1,2,3), 2) == bool2x2(true, true, true, true));
|
||||||
STATIC_REQUIRE(approximately(int2x2(0,1,2,3), 1, 2) == bool2x2(true, true, true, true));
|
STATIC_REQUIRE(approx(int2x2(0,1,2,3), 1, 2) == bool2x2(true, true, true, true));
|
||||||
STATIC_REQUIRE(approximately(1, int2x2(0,1,2,3), 2) == bool2x2(true, true, true, true));
|
STATIC_REQUIRE(approx(1, int2x2(0,1,2,3), 2) == bool2x2(true, true, true, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBCASE("transpose") {
|
SUBCASE("transpose") {
|
||||||
@@ -280,7 +280,7 @@ TEST_CASE("vmath/mat_fun") {
|
|||||||
{
|
{
|
||||||
constexpr float4x4 m1 = translate(float3(1.f, 2.f, 3.f));
|
constexpr float4x4 m1 = translate(float3(1.f, 2.f, 3.f));
|
||||||
constexpr float4x4 rm1 = inverse(m1);
|
constexpr float4x4 rm1 = inverse(m1);
|
||||||
STATIC_REQUIRE(all(approximately(
|
STATIC_REQUIRE(all(approx(
|
||||||
unit4_z<float> * m1 * rm1,
|
unit4_z<float> * m1 * rm1,
|
||||||
unit4_z<float>,
|
unit4_z<float>,
|
||||||
uapprox_epsilon_v<float>)));
|
uapprox_epsilon_v<float>)));
|
||||||
@@ -290,7 +290,7 @@ TEST_CASE("vmath/mat_fun") {
|
|||||||
const float3 axis2 = normalize(float3(1.f, 2.f, 3.f));
|
const float3 axis2 = normalize(float3(1.f, 2.f, 3.f));
|
||||||
const float4x4 m2 = rotate(0.5f,axis2);
|
const float4x4 m2 = rotate(0.5f,axis2);
|
||||||
const float4x4 rm2 = inverse(m2);
|
const float4x4 rm2 = inverse(m2);
|
||||||
REQUIRE(all(approximately(
|
REQUIRE(all(approx(
|
||||||
unit4_z<float> * m2 * rm2,
|
unit4_z<float> * m2 * rm2,
|
||||||
unit4_z<float>,
|
unit4_z<float>,
|
||||||
uapprox_epsilon_v<float>)));
|
uapprox_epsilon_v<float>)));
|
||||||
@@ -300,7 +300,7 @@ TEST_CASE("vmath/mat_fun") {
|
|||||||
const float3 axis3 = normalize(float3(1.f, 2.f, 3.f));
|
const float3 axis3 = normalize(float3(1.f, 2.f, 3.f));
|
||||||
const float3x3 m3 = float3x3(rotate(0.5f,axis3));
|
const float3x3 m3 = float3x3(rotate(0.5f,axis3));
|
||||||
const float3x3 rm3 = inverse(m3);
|
const float3x3 rm3 = inverse(m3);
|
||||||
REQUIRE(all(approximately(
|
REQUIRE(all(approx(
|
||||||
unit3_z<float> * m3 * rm3,
|
unit3_z<float> * m3 * rm3,
|
||||||
unit3_z<float>,
|
unit3_z<float>,
|
||||||
uapprox_epsilon_v<float>)));
|
uapprox_epsilon_v<float>)));
|
||||||
@@ -310,7 +310,7 @@ TEST_CASE("vmath/mat_fun") {
|
|||||||
const float3 axis4 = normalize(float3(0.f, 0.f, 3.f));
|
const float3 axis4 = normalize(float3(0.f, 0.f, 3.f));
|
||||||
const float2x2 m4 = float2x2(rotate(0.5f,axis4));
|
const float2x2 m4 = float2x2(rotate(0.5f,axis4));
|
||||||
const float2x2 rm4 = inverse(m4);
|
const float2x2 rm4 = inverse(m4);
|
||||||
REQUIRE(all(approximately(
|
REQUIRE(all(approx(
|
||||||
unit2_y<float> * m4 * rm4,
|
unit2_y<float> * m4 * rm4,
|
||||||
unit2_y<float>,
|
unit2_y<float>,
|
||||||
uapprox_epsilon_v<float>)));
|
uapprox_epsilon_v<float>)));
|
||||||
|
|||||||
@@ -73,21 +73,21 @@ namespace vmath_tests
|
|||||||
|
|
||||||
template < typename T >
|
template < typename T >
|
||||||
constexpr bool operator==(const T& l, const uapprox<T>& r) {
|
constexpr bool operator==(const T& l, const uapprox<T>& r) {
|
||||||
return approximately(l, r.value, uapprox_epsilon_v<T>);
|
return approx(l, r.value, uapprox_epsilon_v<T>);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename T >
|
template < typename T >
|
||||||
constexpr bool operator==(const vec<T, 2>& l, const uapprox2<T>& r) {
|
constexpr bool operator==(const vec<T, 2>& l, const uapprox2<T>& r) {
|
||||||
return all(approximately(l, r.value, uapprox_epsilon_v<T>));
|
return all(approx(l, r.value, uapprox_epsilon_v<T>));
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename T >
|
template < typename T >
|
||||||
constexpr bool operator==(const vec<T, 3>& l, const uapprox3<T>& r) {
|
constexpr bool operator==(const vec<T, 3>& l, const uapprox3<T>& r) {
|
||||||
return all(approximately(l, r.value, uapprox_epsilon_v<T>));
|
return all(approx(l, r.value, uapprox_epsilon_v<T>));
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename T >
|
template < typename T >
|
||||||
constexpr bool operator==(const vec<T, 4>& l, const uapprox4<T>& r) {
|
constexpr bool operator==(const vec<T, 4>& l, const uapprox4<T>& r) {
|
||||||
return all(approximately(l, r.value, uapprox_epsilon_v<T>));
|
return all(approx(l, r.value, uapprox_epsilon_v<T>));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -289,20 +289,20 @@ TEST_CASE("vmath/vec_fun") {
|
|||||||
STATIC_REQUIRE_FALSE(all(int2(0, 1)));
|
STATIC_REQUIRE_FALSE(all(int2(0, 1)));
|
||||||
STATIC_REQUIRE(all(int2(1, 1)));
|
STATIC_REQUIRE(all(int2(1, 1)));
|
||||||
|
|
||||||
STATIC_REQUIRE(approximately(int3(1,1,1), int3(0,1,2)) == bool3(false, true, false));
|
STATIC_REQUIRE(approx(int3(1,1,1), int3(0,1,2)) == bool3(false, true, false));
|
||||||
STATIC_REQUIRE(approximately(int3(0,1,2),1) == bool3(false, true, false));
|
STATIC_REQUIRE(approx(int3(0,1,2),1) == bool3(false, true, false));
|
||||||
STATIC_REQUIRE(approximately(1,int3(0,1,2)) == bool3(false, true, false));
|
STATIC_REQUIRE(approx(1,int3(0,1,2)) == bool3(false, true, false));
|
||||||
|
|
||||||
STATIC_REQUIRE(approximately(int4(1,1,1,1), int4(0,1,2,3), 0) == bool4(false, true, false, false));
|
STATIC_REQUIRE(approx(int4(1,1,1,1), int4(0,1,2,3), 0) == bool4(false, true, false, false));
|
||||||
STATIC_REQUIRE(approximately(int4(0,1,2,3), 1, 0) == bool4(false, true, false, false));
|
STATIC_REQUIRE(approx(int4(0,1,2,3), 1, 0) == bool4(false, true, false, false));
|
||||||
STATIC_REQUIRE(approximately(1, int4(0,1,2,3), 0) == bool4(false, true, false, false));
|
STATIC_REQUIRE(approx(1, int4(0,1,2,3), 0) == bool4(false, true, false, false));
|
||||||
|
|
||||||
STATIC_REQUIRE(approximately(int4(1,1,1,1), int4(0,1,2,3), 1) == bool4(true, true, true, false));
|
STATIC_REQUIRE(approx(int4(1,1,1,1), int4(0,1,2,3), 1) == bool4(true, true, true, false));
|
||||||
STATIC_REQUIRE(approximately(int4(0,1,2,3), 1, 1) == bool4(true, true, true, false));
|
STATIC_REQUIRE(approx(int4(0,1,2,3), 1, 1) == bool4(true, true, true, false));
|
||||||
STATIC_REQUIRE(approximately(1, int4(0,1,2,3), 1) == bool4(true, true, true, false));
|
STATIC_REQUIRE(approx(1, int4(0,1,2,3), 1) == bool4(true, true, true, false));
|
||||||
|
|
||||||
STATIC_REQUIRE(approximately(int4(1,1,1,1), int4(0,1,2,3), 2) == bool4(true, true, true, true));
|
STATIC_REQUIRE(approx(int4(1,1,1,1), int4(0,1,2,3), 2) == bool4(true, true, true, true));
|
||||||
STATIC_REQUIRE(approximately(int4(0,1,2,3), 1, 2) == bool4(true, true, true, true));
|
STATIC_REQUIRE(approx(int4(0,1,2,3), 1, 2) == bool4(true, true, true, true));
|
||||||
STATIC_REQUIRE(approximately(1, int4(0,1,2,3), 2) == bool4(true, true, true, true));
|
STATIC_REQUIRE(approx(1, int4(0,1,2,3), 2) == bool4(true, true, true, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user