Blobalizer
Loading...
Searching...
No Matches
Utils.h
Go to the documentation of this file.
1#pragma once
2
9template <size_t size, class T>
10Magnum::Math::Vector<size, T> cwiseMin(const Magnum::Math::Vector<size, T>& a, const Magnum::Math::Vector<size, T>& b) {
11 Magnum::Math::Vector<size, T> result;
12 for (size_t i = 0; i < size; i++) {
13 result[i] = std::min(a[i], b[i]);
14 }
15 return result;
16}
17
23template <size_t size, class T>
24void cwiseMinInplace(Magnum::Math::Vector<size, T>& a, const Magnum::Math::Vector<size, T>& b) {
25 for (size_t i = 0; i < size; i++) {
26 a[i] = std::min(a[i], b[i]);
27 }
28}
29
36template <size_t size, class T>
37Magnum::Math::Vector<size, T> cwiseMax(const Magnum::Math::Vector<size, T>& a, const Magnum::Math::Vector<size, T>& b) {
38 Magnum::Math::Vector<size, T> result;
39 for (size_t i = 0; i < size; i++) {
40 result[i] = std::max(a[i], b[i]);
41 }
42 return result;
43}
44
50template <size_t size, class T>
51void cwiseMaxInplace(Magnum::Math::Vector<size, T>& a, const Magnum::Math::Vector<size, T>& b) {
52 for (size_t i = 0; i < size; i++) {
53 a[i] = std::max(a[i], b[i]);
54 }
55}
Magnum::Math::Vector< size, T > cwiseMax(const Magnum::Math::Vector< size, T > &a, const Magnum::Math::Vector< size, T > &b)
Calculate the component-wise maximum of the given vectors.
Definition Utils.h:37
void cwiseMinInplace(Magnum::Math::Vector< size, T > &a, const Magnum::Math::Vector< size, T > &b)
Calculate the component-wise minimum of the given vectors and stores it into the first given vector.
Definition Utils.h:24
void cwiseMaxInplace(Magnum::Math::Vector< size, T > &a, const Magnum::Math::Vector< size, T > &b)
Calculate the component-wise maximum of the given vectors and stores it into the first given vector.
Definition Utils.h:51
Magnum::Math::Vector< size, T > cwiseMin(const Magnum::Math::Vector< size, T > &a, const Magnum::Math::Vector< size, T > &b)
Calculate the component-wise minimum of the given vectors.
Definition Utils.h:10