fennec
Loading...
Searching...
No Matches
relational.h
Go to the documentation of this file.
1// =====================================================================================================================
2// fennec, a free and open source game engine
3// Copyright © 2025 Medusa Slockbower
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see <https://www.gnu.org/licenses/>.
17// =====================================================================================================================
18
30
31#ifndef FENNEC_MATH_RELATIONAL_H
32#define FENNEC_MATH_RELATIONAL_H
33
113
114#include <fennec/lang/types.h>
115
116namespace fennec
117{
118
125template<typename genType, typename genBType = bool_t, size_t...i>
126constexpr vector<genBType, i...> lessThan(const vector<genType, i...>& x, const vector<genType, i...>& y) {
127 return vector<genBType, i...>(x[i] < y[i]...);
128}
129
130
137template<typename genType, typename genBType = bool_t, size_t...i>
138constexpr vector<genBType, i...> lessThanEqual(const vector<genType, i...>& x, const vector<genType, i...>& y) {
139 return vector<genBType, i...>(x[i] <= y[i]...);
140}
141
142
149template<typename genType, typename genBType = bool_t, size_t...i>
150constexpr vector<genBType, i...> greaterThan(const vector<genType, i...>& x, const vector<genType, i...>& y) {
151 return vector<genBType, i...>(x[i] > y[i]...);
152}
153
154
161template<typename genType, typename genBType = bool_t, size_t...i>
162constexpr vector<genBType, i...> greaterThanEqual(const vector<genType, i...>& x, const vector<genType, i...>& y) {
163 return vector<genBType, i...>(x[i] >= y[i]...);
164}
165
166
173template<typename genType, typename genBType = bool_t, size_t...i>
174constexpr vector<genBType, i...> equal(const vector<genType, i...>& x, const vector<genType, i...>& y) {
175 return vector<genBType, i...>(x[i] == y[i]...);
176}
177
178
185template<typename genType, typename genBType = bool_t, size_t...i>
186constexpr vector<genBType, i...> notEqual(const vector<genType, i...>& x, const vector<genType, i...>& y) {
187 return vector<genBType, i...>(x[i] != y[i]...);
188}
189
190
196template<typename genBType = bool_t, size_t...i>
197constexpr genBType any(const vector<genBType, i...>& x) {
198 return (x[i] || ...);
199}
200
206template<typename genBType = bool_t, size_t...i>
207constexpr genBType all(const vector<genBType, i...>& x) {
208 return (x[i] && ...);
209}
210
218template<typename genBType = bool_t, size_t...i>
219constexpr vector<genBType, i...> operator not(const vector<genBType, i...>& x) {
220 return vector<genBType, i...>((!x[i]) ...);
221}
222
223}
224
225
226
227#endif // FENNEC_MATH_RELATIONAL_H
constexpr genType y()
Definition constants.h:672
constexpr genBType any(const vector< genBType, i... > &x)
Returns if any component of is .
Definition relational.h:197
constexpr vector< genBType, i... > greaterThan(const vector< genType, i... > &x, const vector< genType, i... > &y)
Returns the component-wise compare of x > y.
Definition relational.h:150
constexpr vector< genBType, i... > notEqual(const vector< genType, i... > &x, const vector< genType, i... > &y)
Returns the component-wise compare of x != y.
Definition relational.h:186
constexpr genBType all(const vector< genBType, i... > &x)
Returns if all components of are .
Definition relational.h:207
constexpr vector< genBType, i... > lessThan(const vector< genType, i... > &x, const vector< genType, i... > &y)
Returns the component-wise compare of x < y.
Definition relational.h:126
constexpr vector< genBType, i... > greaterThanEqual(const vector< genType, i... > &x, const vector< genType, i... > &y)
Returns the component-wise compare of x >= y.
Definition relational.h:162
constexpr vector< genBType, i... > lessThanEqual(const vector< genType, i... > &x, const vector< genType, i... > &y)
Returns the component-wise compare of x <= y.
Definition relational.h:138
constexpr vector< genBType, i... > equal(const vector< genType, i... > &x, const vector< genType, i... > &y)
Returns the component-wise compare of x == y.
Definition relational.h:174
Math Vector Type.
Definition vector.h:183
Types
bool bool_t
A conditional type.
Definition types.h:214