mirror of
https://github.com/BlackMATov/vmath.hpp.git
synced 2025-12-13 20:17:58 +07:00
relational operators instead relational functions, add relational operators for matrix
This commit is contained in:
146
README.md
146
README.md
@@ -57,7 +57,9 @@ Most functions and types are based on the HLSL ([High-Level Shading Language for
|
||||
- [Vector Types](#Vector-Types)
|
||||
- [Matrix Types](#Matrix-Types)
|
||||
- [Vector Operators](#Vector-Operators)
|
||||
- [Vector Relational Operators](#Vector-Relational-Operators)
|
||||
- [Matrix Operators](#Matrix-Operators)
|
||||
- [Matrix Relational Operators](#Matrix-Relational-Operators)
|
||||
- [Angle and Trigonometry Functions](#Angle-and-Trigonometry-Functions)
|
||||
- [Exponential Functions](#Exponential-Functions)
|
||||
- [Common Functions](#Common-Functions)
|
||||
@@ -552,6 +554,54 @@ template < typename T, size_t Size >
|
||||
constexpr bool operator<(const vec<T, Size>& xs, const vec<T, Size>& ys);
|
||||
```
|
||||
|
||||
### Vector Relational Operators
|
||||
|
||||
```cpp
|
||||
// operator<
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> operator<(const vec<T, Size>& xs, T y);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> operator<(T x, const vec<T, Size>& ys);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> operator<(const vec<T, Size>& xs, const vec<T, Size>& ys);
|
||||
|
||||
// operator<=
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> operator<=(const vec<T, Size>& xs, T y);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> operator<=(T x, const vec<T, Size>& ys);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> operator<=(const vec<T, Size>& xs, const vec<T, Size>& ys);
|
||||
|
||||
// operator>
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> operator>(const vec<T, Size>& xs, T y);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> operator>(T x, const vec<T, Size>& ys);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> operator>(const vec<T, Size>& xs, const vec<T, Size>& ys);
|
||||
|
||||
// operator>=
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> operator>=(const vec<T, Size>& xs, T y);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> operator>=(T x, const vec<T, Size>& ys);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> operator>=(const vec<T, Size>& xs, const vec<T, Size>& ys);
|
||||
```
|
||||
|
||||
### Matrix Operators
|
||||
|
||||
```cpp
|
||||
@@ -739,6 +789,54 @@ template < typename T, size_t Size >
|
||||
constexpr bool operator<(const mat<T, Size>& xs, const mat<T, Size>& ys);
|
||||
```
|
||||
|
||||
### Matrix Relational Operators
|
||||
|
||||
```cpp
|
||||
// operator<
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr mat<bool, Size> operator<(const mat<T, Size>& xs, T y);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr mat<bool, Size> operator<(T x, const mat<T, Size>& ys);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr mat<bool, Size> operator<(const mat<T, Size>& xs, const mat<T, Size>& ys);
|
||||
|
||||
// operator<=
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr mat<bool, Size> operator<=(const mat<T, Size>& xs, T y);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr mat<bool, Size> operator<=(T x, const mat<T, Size>& ys);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr mat<bool, Size> operator<=(const mat<T, Size>& xs, const mat<T, Size>& ys);
|
||||
|
||||
// operator>
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr mat<bool, Size> operator>(const mat<T, Size>& xs, T y);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr mat<bool, Size> operator>(T x, const mat<T, Size>& ys);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr mat<bool, Size> operator>(const mat<T, Size>& xs, const mat<T, Size>& ys);
|
||||
|
||||
// operator>=
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr mat<bool, Size> operator>=(const mat<T, Size>& xs, T y);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr mat<bool, Size> operator>=(T x, const mat<T, Size>& ys);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr mat<bool, Size> operator>=(const mat<T, Size>& xs, const mat<T, Size>& ys);
|
||||
```
|
||||
|
||||
### Angle and Trigonometry Functions
|
||||
|
||||
#### Scalar
|
||||
@@ -1156,18 +1254,6 @@ vec<T, Size> refract(const vec<T, Size>& i, const vec<T, Size>& n, T eta);
|
||||
#### Scalar
|
||||
|
||||
```cpp
|
||||
template < arithmetic T >
|
||||
constexpr bool less(T x, T y) noexcept;
|
||||
|
||||
template < arithmetic T >
|
||||
constexpr bool less_equal(T x, T y) noexcept;
|
||||
|
||||
template < arithmetic T >
|
||||
constexpr bool greater(T x, T y) noexcept;
|
||||
|
||||
template < arithmetic T >
|
||||
constexpr bool greater_equal(T x, T y) noexcept;
|
||||
|
||||
template < arithmetic T >
|
||||
constexpr bool equal_to(T x, T y) noexcept;
|
||||
|
||||
@@ -1190,42 +1276,6 @@ constexpr bool all(T x) noexcept;
|
||||
#### Vector
|
||||
|
||||
```cpp
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> less(const vec<T, Size>& xs, T y);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> less(T x, const vec<T, Size>& ys);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> less(const vec<T, Size>& xs, const vec<T, Size>& ys);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> less_equal(const vec<T, Size>& xs, T y);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> less_equal(T x, const vec<T, Size>& ys);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> less_equal(const vec<T, Size>& xs, const vec<T, Size>& ys);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> greater(const vec<T, Size>& xs, T y);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> greater(T x, const vec<T, Size>& ys);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> greater(const vec<T, Size>& xs, const vec<T, Size>& ys);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> greater_equal(const vec<T, Size>& xs, T y);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> greater_equal(T x, const vec<T, Size>& ys);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> greater_equal(const vec<T, Size>& xs, const vec<T, Size>& ys);
|
||||
|
||||
template < typename T, size_t Size >
|
||||
constexpr vec<bool, Size> equal_to(const vec<T, Size>& xs, T y);
|
||||
|
||||
|
||||
@@ -404,30 +404,6 @@ namespace vmath_hpp
|
||||
|
||||
namespace vmath_hpp
|
||||
{
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_arithmetic_v<T>, bool>
|
||||
constexpr less(T x, T y) noexcept {
|
||||
return x < y;
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_arithmetic_v<T>, bool>
|
||||
constexpr less_equal(T x, T y) noexcept {
|
||||
return x <= y;
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_arithmetic_v<T>, bool>
|
||||
constexpr greater(T x, T y) noexcept {
|
||||
return x > y;
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_arithmetic_v<T>, bool>
|
||||
constexpr greater_equal(T x, T y) noexcept {
|
||||
return x >= y;
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_arithmetic_v<T>, bool>
|
||||
constexpr equal_to(T x, T y) noexcept {
|
||||
|
||||
@@ -467,20 +467,80 @@ namespace vmath_hpp
|
||||
[[nodiscard]] constexpr bool operator!=(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
return !(xs == ys);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Relational Operators
|
||||
//
|
||||
|
||||
namespace vmath_hpp
|
||||
{
|
||||
// operator<
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr bool operator<(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
for ( std::size_t i = 0; i < Size; ++i ) {
|
||||
if ( xs[i] < ys[i] ) {
|
||||
return true;
|
||||
}
|
||||
if ( ys[i] < xs[i] ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
[[nodiscard]] constexpr mat<bool, Size> operator<(const mat<T, Size>& xs, T y) {
|
||||
return map_join([y](const vec<T, Size>& x){ return x < y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<bool, Size> operator<(T x, const mat<T, Size>& ys) {
|
||||
return map_join([x](const vec<T, Size>& y){ return x < y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<bool, Size> operator<(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
return map_join([](const vec<T, Size>& x, const vec<T, Size>& y){ return x < y; }, xs, ys);
|
||||
}
|
||||
|
||||
// operator<=
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<bool, Size> operator<=(const mat<T, Size>& xs, T y) {
|
||||
return map_join([y](const vec<T, Size>& x){ return x <= y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<bool, Size> operator<=(T x, const mat<T, Size>& ys) {
|
||||
return map_join([x](const vec<T, Size>& y){ return x <= y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<bool, Size> operator<=(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
return map_join([](const vec<T, Size>& x, const vec<T, Size>& y){ return x <= y; }, xs, ys);
|
||||
}
|
||||
|
||||
// operator>
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<bool, Size> operator>(const mat<T, Size>& xs, T y) {
|
||||
return map_join([y](const vec<T, Size>& x){ return x > y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<bool, Size> operator>(T x, const mat<T, Size>& ys) {
|
||||
return map_join([x](const vec<T, Size>& y){ return x > y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<bool, Size> operator>(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
return map_join([](const vec<T, Size>& x, const vec<T, Size>& y){ return x > y; }, xs, ys);
|
||||
}
|
||||
|
||||
// operator>=
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<bool, Size> operator>=(const mat<T, Size>& xs, T y) {
|
||||
return map_join([y](const vec<T, Size>& x){ return x >= y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<bool, Size> operator>=(T x, const mat<T, Size>& ys) {
|
||||
return map_join([x](const vec<T, Size>& y){ return x >= y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr mat<bool, Size> operator>=(const mat<T, Size>& xs, const mat<T, Size>& ys) {
|
||||
return map_join([](const vec<T, Size>& x, const vec<T, Size>& y){ return x >= y; }, xs, ys);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -436,20 +436,80 @@ namespace vmath_hpp
|
||||
[[nodiscard]] constexpr bool operator!=(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
return !(xs == ys);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Relational Operators
|
||||
//
|
||||
|
||||
namespace vmath_hpp
|
||||
{
|
||||
// operator<
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr bool operator<(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
for ( std::size_t i = 0; i < Size; ++i ) {
|
||||
if ( xs[i] < ys[i] ) {
|
||||
return true;
|
||||
}
|
||||
if ( ys[i] < xs[i] ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
[[nodiscard]] constexpr vec<bool, Size> operator<(const vec<T, Size>& xs, T y) {
|
||||
return map_join([y](T x){ return x < y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> operator<(T x, const vec<T, Size>& ys) {
|
||||
return map_join([x](T y){ return x < y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> operator<(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
return map_join([](T x, T y){ return x < y; }, xs, ys);
|
||||
}
|
||||
|
||||
// operator<=
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> operator<=(const vec<T, Size>& xs, T y) {
|
||||
return map_join([y](T x){ return x <= y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> operator<=(T x, const vec<T, Size>& ys) {
|
||||
return map_join([x](T y){ return x <= y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> operator<=(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
return map_join([](T x, T y){ return x <= y; }, xs, ys);
|
||||
}
|
||||
|
||||
// operator>
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> operator>(const vec<T, Size>& xs, T y) {
|
||||
return map_join([y](T x){ return x > y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> operator>(T x, const vec<T, Size>& ys) {
|
||||
return map_join([x](T y){ return x > y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> operator>(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
return map_join([](T x, T y){ return x > y; }, xs, ys);
|
||||
}
|
||||
|
||||
// operator>=
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> operator>=(const vec<T, Size>& xs, T y) {
|
||||
return map_join([y](T x){ return x >= y; }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> operator>=(T x, const vec<T, Size>& ys) {
|
||||
return map_join([x](T y){ return x >= y; }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> operator>=(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
return map_join([](T x, T y){ return x >= y; }, xs, ys);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -843,74 +903,6 @@ namespace vmath_hpp
|
||||
|
||||
namespace vmath_hpp
|
||||
{
|
||||
// less
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> less(const vec<T, Size>& xs, T y) {
|
||||
return map_join([y](T x){ return less(x, y); }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> less(T x, const vec<T, Size>& ys) {
|
||||
return map_join([x](T y){ return less(x, y); }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> less(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
return map_join([](T x, T y){ return less(x, y); }, xs, ys);
|
||||
}
|
||||
|
||||
// less_equal
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> less_equal(const vec<T, Size>& xs, T y) {
|
||||
return map_join([y](T x){ return less_equal(x, y); }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> less_equal(T x, const vec<T, Size>& ys) {
|
||||
return map_join([x](T y){ return less_equal(x, y); }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> less_equal(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
return map_join([](T x, T y){ return less_equal(x, y); }, xs, ys);
|
||||
}
|
||||
|
||||
// greater
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> greater(const vec<T, Size>& xs, T y) {
|
||||
return map_join([y](T x){ return greater(x, y); }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> greater(T x, const vec<T, Size>& ys) {
|
||||
return map_join([x](T y){ return greater(x, y); }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> greater(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
return map_join([](T x, T y){ return greater(x, y); }, xs, ys);
|
||||
}
|
||||
|
||||
// greater_equal
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> greater_equal(const vec<T, Size>& xs, T y) {
|
||||
return map_join([y](T x){ return greater_equal(x, y); }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> greater_equal(T x, const vec<T, Size>& ys) {
|
||||
return map_join([x](T y){ return greater_equal(x, y); }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<bool, Size> greater_equal(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
return map_join([](T x, T y){ return greater_equal(x, y); }, xs, ys);
|
||||
}
|
||||
|
||||
// equal_to
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
#include "vmath_tests.hpp"
|
||||
#include "doctest/doctest.hpp"
|
||||
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <unordered_set>
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -64,19 +62,6 @@ TEST_CASE("vmath/ext") {
|
||||
|
||||
REQUIRE(std::hash<int2x2>{}({1,2,3,4}) == std::hash<int2x2>{}({1,2,3,4}));
|
||||
REQUIRE_FALSE(std::hash<int2x2>{}({1,2,3,4}) == std::hash<int2x2>{}({1,2,4,3}));
|
||||
{
|
||||
std::set<int2> s;
|
||||
s.insert(int2(1,2));
|
||||
REQUIRE(s.count(int2(1,2)) > 0);
|
||||
REQUIRE_FALSE(s.count(int2(1,1)) > 0);
|
||||
}
|
||||
{
|
||||
std::map<int2, int> s;
|
||||
s.emplace(int2(1,2),3);
|
||||
s.emplace(int2(2,3),5);
|
||||
REQUIRE(s[int2(1,2)] == 3);
|
||||
REQUIRE(s[int2(2,3)] == 5);
|
||||
}
|
||||
{
|
||||
std::unordered_set<int2> s;
|
||||
s.insert(int2(1,2));
|
||||
|
||||
@@ -143,16 +143,6 @@ TEST_CASE("vmath/fun") {
|
||||
}
|
||||
|
||||
SUBCASE("Scalar Relational Functions") {
|
||||
STATIC_REQUIRE(less(0, 1));
|
||||
STATIC_REQUIRE(less_equal(0, 1));
|
||||
STATIC_REQUIRE_FALSE(less(1, 1));
|
||||
STATIC_REQUIRE(less_equal(1, 1));
|
||||
|
||||
STATIC_REQUIRE(greater(1, 0));
|
||||
STATIC_REQUIRE(greater_equal(1, 0));
|
||||
STATIC_REQUIRE_FALSE(greater(1, 1));
|
||||
STATIC_REQUIRE(greater_equal(1, 1));
|
||||
|
||||
STATIC_REQUIRE(equal_to(1, 1));
|
||||
STATIC_REQUIRE_FALSE(equal_to(0, 1));
|
||||
STATIC_REQUIRE_FALSE(equal_to(0, 1, 0));
|
||||
|
||||
@@ -163,6 +163,24 @@ TEST_CASE("vmath/mat_fun") {
|
||||
}
|
||||
}
|
||||
|
||||
SUBCASE("relational operators") {
|
||||
STATIC_REQUIRE((int2x2(1,1,1,1) < int2x2(0,1,2,3)) == bool2x2(false, false, true, true));
|
||||
STATIC_REQUIRE((int2x2(0,1,2,3) < 1) == bool2x2(true, false, false, false));
|
||||
STATIC_REQUIRE((1 < int2x2(0,1,2,3)) == bool2x2(false, false, true, true));
|
||||
|
||||
STATIC_REQUIRE((int2x2(1,1,1,1) <= int2x2(0,1,2,3)) == bool2x2(false, true, true, true));
|
||||
STATIC_REQUIRE((int2x2(0,1,2,3) <= 1) == bool2x2(true, true, false, false));
|
||||
STATIC_REQUIRE((1 <= int2x2(0,1,2,3)) == bool2x2(false, true, true, true));
|
||||
|
||||
STATIC_REQUIRE((int2x2(1,1,1,1) > int2x2(0,1,2,3)) == bool2x2(true, false, false, false));
|
||||
STATIC_REQUIRE((int2x2(0,1,2,3) > 1) == bool2x2(false, false, true, true));
|
||||
STATIC_REQUIRE((1 > int2x2(0,1,2,3)) == bool2x2(true, false, false, false));
|
||||
|
||||
STATIC_REQUIRE((int2x2(1,1,1,1) >= int2x2(0,1,2,3)) == bool2x2(true, true, false, false));
|
||||
STATIC_REQUIRE((int2x2(0,1,2,3) >= 1) == bool2x2(false, true, true, true));
|
||||
STATIC_REQUIRE((1 >= int2x2(0,1,2,3)) == bool2x2(true, true, false, false));
|
||||
}
|
||||
|
||||
SUBCASE("transpose") {
|
||||
STATIC_REQUIRE(transpose(int2x2(
|
||||
1, 2,
|
||||
|
||||
@@ -270,14 +270,4 @@ TEST_CASE("vmath/mat") {
|
||||
STATIC_REQUIRE(int2x2(1,2,3,4) != int2x2(2,2,3,4));
|
||||
STATIC_REQUIRE(int2x2(1,2,3,4) != int2x2(1,3,3,4));
|
||||
}
|
||||
|
||||
SUBCASE("operator<") {
|
||||
STATIC_REQUIRE_FALSE(int2x2(1,2,3,4) < int2x2(1,2,3,4));
|
||||
|
||||
STATIC_REQUIRE(int2x2(1,1,3,4) < int2x2(1,2,3,4));
|
||||
STATIC_REQUIRE_FALSE(int2x2(1,2,3,4) < int2x2(1,1,3,4));
|
||||
|
||||
STATIC_REQUIRE(int2x2(0,3,3,4) < int2x2(1,2,3,4));
|
||||
STATIC_REQUIRE_FALSE(int2x2(1,2,3,4) < int2x2(0,3,3,4));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,6 +129,24 @@ TEST_CASE("vmath/vec_fun") {
|
||||
}
|
||||
}
|
||||
|
||||
SUBCASE("Relational Operators") {
|
||||
STATIC_REQUIRE((int3(1,1,1) < int3(0,1,2)) == bool3(false, false, true));
|
||||
STATIC_REQUIRE((int3(0,1,2) < 1) == bool3(true, false, false));
|
||||
STATIC_REQUIRE((1 < int3(0,1,2)) == bool3(false, false, true));
|
||||
|
||||
STATIC_REQUIRE((int3(1,1,1) <= int3(0,1,2)) == bool3(false, true, true));
|
||||
STATIC_REQUIRE((int3(0,1,2) <= 1) == bool3(true, true, false));
|
||||
STATIC_REQUIRE((1 <= int3(0,1,2)) == bool3(false, true, true));
|
||||
|
||||
STATIC_REQUIRE((int3(1,1,1) > int3(0,1,2)) == bool3(true, false, false));
|
||||
STATIC_REQUIRE((int3(0,1,2) > 1) == bool3(false, false, true));
|
||||
STATIC_REQUIRE((1 > int3(0,1,2)) == bool3(true, false, false));
|
||||
|
||||
STATIC_REQUIRE((int3(1,1,1) >= int3(0,1,2)) == bool3(true, true, false));
|
||||
STATIC_REQUIRE((int3(0,1,2) >= 1) == bool3(false, true, true));
|
||||
STATIC_REQUIRE((1 >= int3(0,1,2)) == bool3(true, true, false));
|
||||
}
|
||||
|
||||
SUBCASE("Angle and Trigonometry Functions") {
|
||||
STATIC_REQUIRE(radians(degrees(float2(12.13f))) == approx2(12.13f));
|
||||
STATIC_REQUIRE(degrees(radians(float2(12.13f))) == approx2(12.13f));
|
||||
@@ -251,22 +269,6 @@ TEST_CASE("vmath/vec_fun") {
|
||||
}
|
||||
|
||||
SUBCASE("Vector Relational Functions") {
|
||||
STATIC_REQUIRE(less(int3(1,1,1), int3(0,1,2)) == bool3(false, false, true));
|
||||
STATIC_REQUIRE(less(int3(0,1,2),1) == bool3(true, false, false));
|
||||
STATIC_REQUIRE(less(1,int3(0,1,2)) == bool3(false, false, true));
|
||||
|
||||
STATIC_REQUIRE(less_equal(int3(1,1,1), int3(0,1,2)) == bool3(false, true, true));
|
||||
STATIC_REQUIRE(less_equal(int3(0,1,2),1) == bool3(true, true, false));
|
||||
STATIC_REQUIRE(less_equal(1,int3(0,1,2)) == bool3(false, true, true));
|
||||
|
||||
STATIC_REQUIRE(greater(int3(1,1,1), int3(0,1,2)) == bool3(true, false, false));
|
||||
STATIC_REQUIRE(greater(int3(0,1,2),1) == bool3(false, false, true));
|
||||
STATIC_REQUIRE(greater(1,int3(0,1,2)) == bool3(true, false, false));
|
||||
|
||||
STATIC_REQUIRE(greater_equal(int3(1,1,1), int3(0,1,2)) == bool3(true, true, false));
|
||||
STATIC_REQUIRE(greater_equal(int3(0,1,2),1) == bool3(false, true, true));
|
||||
STATIC_REQUIRE(greater_equal(1,int3(0,1,2)) == bool3(true, true, false));
|
||||
|
||||
STATIC_REQUIRE(equal_to(int3(1,1,1), int3(0,1,2)) == bool3(false, true, false));
|
||||
STATIC_REQUIRE(equal_to(int3(0,1,2),1) == bool3(false, true, false));
|
||||
STATIC_REQUIRE(equal_to(1,int3(0,1,2)) == bool3(false, true, false));
|
||||
|
||||
@@ -267,14 +267,4 @@ TEST_CASE("vmath/vec") {
|
||||
STATIC_REQUIRE(int2(1,2) != int2(2,2));
|
||||
STATIC_REQUIRE(int2(1,2) != int2(1,3));
|
||||
}
|
||||
|
||||
SUBCASE("operator<") {
|
||||
STATIC_REQUIRE_FALSE(int2(1,2) < int2(1,2));
|
||||
|
||||
STATIC_REQUIRE(int2(1,1) < int2(1,2));
|
||||
STATIC_REQUIRE_FALSE(int2(1,2) < int2(1,1));
|
||||
|
||||
STATIC_REQUIRE(int2(0,3) < int2(1,2));
|
||||
STATIC_REQUIRE_FALSE(int2(1,2) < int2(0,3));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user