mirror of
https://github.com/BlackMATov/vmath.hpp.git
synced 2025-12-16 22:19:51 +07:00
min(scalar, vector), max(scalar, vector) funcs
This commit is contained in:
@@ -866,7 +866,7 @@ namespace vmath_hpp
|
||||
/// REFERENCE:
|
||||
/// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/
|
||||
|
||||
auto xyzw = T(0.5) * sqrt(max(zero4<T>, {
|
||||
auto xyzw = T(0.5) * sqrt(max(T(0), vec{
|
||||
T(1) + m[0][0] - m[1][1] - m[2][2],
|
||||
T(1) - m[0][0] + m[1][1] - m[2][2],
|
||||
T(1) - m[0][0] - m[1][1] + m[2][2],
|
||||
|
||||
@@ -590,6 +590,11 @@ namespace vmath_hpp
|
||||
return map_join([y](T x) { return min(x, y); }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> min(T x, const vec<T, Size>& ys) {
|
||||
return map_join([x](T y) { return min(x, y); }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> min(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
return map_join([](T x, T y) { return min(x, y); }, xs, ys);
|
||||
@@ -605,6 +610,11 @@ namespace vmath_hpp
|
||||
return map_join([y](T x) { return max(x, y); }, xs);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> max(T x, const vec<T, Size>& ys) {
|
||||
return map_join([x](T y) { return max(x, y); }, ys);
|
||||
}
|
||||
|
||||
template < typename T, std::size_t Size >
|
||||
[[nodiscard]] constexpr vec<T, Size> max(const vec<T, Size>& xs, const vec<T, Size>& ys) {
|
||||
return map_join([](T x, T y) { return max(x, y); }, xs, ys);
|
||||
|
||||
Reference in New Issue
Block a user