neoGFX
Cross-platform C++ app/game engine
numerical.hpp
Go to the documentation of this file.
1 // numerical.hpp
2 /*
3  neogfx C++ GUI Library
4  Copyright (c) 2015 Leigh Johnston. All Rights Reserved.
5 
6  This program is free software: you can redistribute it and / or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 #include <neogfx/neogfx.hpp>
23 #include <type_traits>
24 #include <stdexcept>
25 #include <array>
26 #include <algorithm>
27 #include <ostream>
28 #include <optional>
29 #include <boost/math/constants/constants.hpp>
30 #include <neolib/vecarray.hpp>
31 #include <neogfx/core/swizzle.hpp>
33 
34 namespace neogfx
35 {
36  namespace math
37  {
38  using namespace boost::math::constants;
39 
40  typedef double scalar;
41  typedef double angle;
42 
43  namespace constants
44  {
45  template <typename T>
46  constexpr T zero = static_cast<T>(0.0);
47  template <typename T>
48  constexpr T one = static_cast<T>(1.0);
49  template <typename T>
50  constexpr T two = static_cast<T>(2.0);
51  }
52 
53  template <typename T, typename SFINAE = std::enable_if_t<std::is_scalar_v<T>, sfinae>>
54  inline T lerp(T aX1, T aX2, double aAmount)
55  {
56  double x1 = aX1;
57  double x2 = aX2;
58  return static_cast<T>((x2 - x1) * aAmount + x1);
59  }
60 
61  inline angle to_rad(angle aDegrees)
62  {
63  return aDegrees / 180.0 * pi<angle>();
64  }
65 
66  inline angle to_deg(angle aRadians)
67  {
68  return aRadians * 180.0 / pi<angle>();
69  }
70 
71  struct column_vector {};
72  struct row_vector {};
73 
74  template <typename T, uint32_t Size, typename Type = column_vector, bool IsScalar = std::is_scalar<T>::value>
75  class basic_vector;
76 
77  /* todo: specializations that use SIMD intrinsics. */
78  template <typename T, uint32_t _Size, typename Type>
79  class basic_vector<T, _Size, Type, true> : public swizzle_array<basic_vector<T, _Size, Type, true>, T, _Size>
80  {
83  public:
84  typedef self_type abstract_type; // todo: abstract base; std::array?
85  public:
86  enum : uint32_t { Size = _Size };
87  typedef Type type;
88  public:
89  typedef T value_type;
91  typedef uint32_t size_type;
92  typedef std::array<value_type, Size> array_type;
93  typedef typename array_type::const_iterator const_iterator;
94  typedef typename array_type::iterator iterator;
95  public:
96  template <uint32_t Size2> struct rebind { typedef basic_vector<T, Size2, Type> type; };
97  public:
98  basic_vector() : base_type{} {}
99  template <typename SFINAE = int>
100  explicit basic_vector(value_type x, typename std::enable_if_t<Size == 1, SFINAE> = 0) : base_type{ {x} } {}
101  template <typename SFINAE = int>
102  explicit basic_vector(value_type x, value_type y, typename std::enable_if_t<Size == 2, SFINAE> = 0) : base_type{ {x, y} } {}
103  template <typename SFINAE = int>
104  explicit basic_vector(value_type x, value_type y, value_type z, typename std::enable_if_t<Size == 3, SFINAE> = 0) : base_type{ {x, y, z} } {}
105  template <typename SFINAE = int>
106  explicit basic_vector(value_type x, value_type y, value_type z, value_type w, typename std::enable_if_t<Size == 4, SFINAE> = 0) : base_type{ { x, y, z, w } } {}
107  template <typename... Arguments>
108  explicit basic_vector(const value_type& value, Arguments&&... aArguments) : base_type{ {value, std::forward<Arguments>(aArguments)...} } {}
109  template <typename... Arguments>
110  explicit basic_vector(value_type&& value, Arguments&&... aArguments) : base_type{ {std::move(value), std::forward<Arguments>(aArguments)...} } {}
111  explicit basic_vector(const array_type& v) : base_type{ v } {}
112  template <typename V, typename A, uint32_t S, uint32_t... Indexes>
113  basic_vector(const swizzle<V, A, S, Indexes...>& aSwizzle) : self_type{ ~aSwizzle } {}
114  basic_vector(const self_type& other) : base_type{ other.v } {}
115  basic_vector(self_type&& other) : base_type{ std::move(other.v) } {}
116  template <typename T2>
117  basic_vector(const basic_vector<T2, Size, Type>& other) { std::transform(other.begin(), other.end(), v.begin(), [](T2 source) { return static_cast<value_type>(source); }); }
118  template <typename T2, uint32_t Size2, typename SFINAE = int>
119  basic_vector(const basic_vector<T2, Size2, Type>& other, typename std::enable_if_t<Size2 < Size, SFINAE> = 0) : base_type{} { std::transform(other.begin(), other.end(), v.begin(), [](T2 source) { return static_cast<value_type>(source); }); }
120  self_type& operator=(const self_type& other) { v = other.v; return *this; }
121  self_type& operator=(self_type&& other) { v = std::move(other.v); return *this; }
122  self_type& operator=(std::initializer_list<value_type> values) { if (values.size() > Size) throw std::out_of_range("neogfx::basic_vector: initializer list too big"); std::copy(values.begin(), values.end(), v.begin()); std::uninitialized_fill(v.begin() + (values.end() - values.begin()), v.end(), value_type{}); return *this; }
123  public:
124  static uint32_t size() { return Size; }
125  value_type operator[](uint32_t aIndex) const { return v[aIndex]; }
126  value_type& operator[](uint32_t aIndex) { return v[aIndex]; }
127  const_iterator begin() const { return v.begin(); }
128  const_iterator end() const { return v.end(); }
129  iterator begin() { return v.begin(); }
130  iterator end() { return v.end(); }
131  operator const array_type&() const { return v; }
132  public:
133  template <typename T2>
135  {
136  return basic_vector<T2, Size, Type>{ *this };
137  }
138  public:
139  bool operator==(const self_type& right) const { return v == right.v; }
140  bool operator!=(const self_type& right) const { return v != right.v; }
141  self_type& operator+=(value_type value) { for (uint32_t index = 0; index < Size; ++index) v[index] += value; return *this; }
142  self_type& operator-=(value_type value) { for (uint32_t index = 0; index < Size; ++index) v[index] -= value; return *this; }
143  self_type& operator*=(value_type value) { for (uint32_t index = 0; index < Size; ++index) v[index] *= value; return *this; }
144  self_type& operator/=(value_type value) { for (uint32_t index = 0; index < Size; ++index) v[index] /= value; return *this; }
145  self_type& operator+=(const self_type& right) { for (uint32_t index = 0; index < Size; ++index) v[index] += right.v[index]; return *this; }
146  self_type& operator-=(const self_type& right) { for (uint32_t index = 0; index < Size; ++index) v[index] -= right.v[index]; return *this; }
147  self_type& operator*=(const self_type& right) { for (uint32_t index = 0; index < Size; ++index) v[index] *= right.v[index]; return *this; }
148  self_type& operator/=(const self_type& right) { for (uint32_t index = 0; index < Size; ++index) v[index] /= right.v[index]; return *this; }
149  self_type operator-() const { self_type result; for (uint32_t index = 0; index < Size; ++index) result.v[index] = -v[index]; return result; }
150  self_type scale(const self_type& right) const { self_type result; for (uint32_t index = 0; index < Size; ++index) result[index] = v[index] * right[index]; return result; }
151  value_type magnitude() const { value_type ss = constants::zero<value_type>; for (uint32_t index = 0; index < Size; ++index) ss += (v[index] * v[index]); return std::sqrt(ss); }
152  self_type normalized() const { self_type result; value_type im = constants::one<value_type> / magnitude(); for (uint32_t index = 0; index < Size; ++index) result.v[index] = v[index] * im; return result; }
153  self_type min(const self_type& right) const { self_type result; for (uint32_t index = 0; index < Size; ++index) result[index] = std::min(v[index], right.v[index]); return result; }
154  self_type max(const self_type& right) const { self_type result; for (uint32_t index = 0; index < Size; ++index) result[index] = std::max(v[index], right.v[index]); return result; }
155  value_type min() const { value_type result = v[0]; for (uint32_t index = 1; index < Size; ++index) result = std::min(v[index], result); return result; }
156  self_type ceil() const { self_type result; for (uint32_t index = 0; index < Size; ++index) result[index] = std::ceil(v[index]); return result; }
157  self_type floor() const { self_type result; for (uint32_t index = 0; index < Size; ++index) result[index] = std::floor(v[index]); return result; }
158  self_type round() const { self_type result; for (uint32_t index = 0; index < Size; ++index) result[index] = std::round(v[index]); return result; }
159  value_type distance(const self_type& right) const { value_type total = 0; for (uint32_t index = 0; index < Size; ++index) total += ((v[index] - right.v[index]) * (v[index] - right.v[index])); return std::sqrt(total); }
160  value_type dot(const self_type& right) const
161  {
162  value_type result = constants::zero<value_type>;
163  for (uint32_t index = 0; index < Size; ++index)
164  result += (v[index] * right[index]);
165  return result;
166  }
167  template <typename SFINAE = self_type>
168  std::enable_if_t<Size == 3, SFINAE> cross(const self_type& right) const
169  {
170  return self_type{
171  base_type::y * right.base_type::z - base_type::z * right.base_type::y,
172  base_type::z * right.base_type::x - base_type::x * right.base_type::z,
173  base_type::x * right.base_type::y - base_type::y * right.base_type::x };
174  }
175  self_type hadamard_product(const self_type& right) const
176  {
177  self_type result = *this;
178  result *= right;
179  return result;
180  }
181  public:
182  using base_type::v;
183  };
184 
185  template <typename T, uint32_t _Size, typename Type>
186  class basic_vector<T, _Size, Type, false>
187  {
189  public:
190  typedef self_type abstract_type; // todo: abstract base; std::array?
191  public:
192  enum : uint32_t { Size = _Size };
193  typedef Type type;
194  public:
195  typedef T value_type;
197  typedef uint32_t size_type;
198  typedef std::array<value_type, Size> array_type;
199  typedef typename array_type::const_iterator const_iterator;
200  typedef typename array_type::iterator iterator;
201  public:
202  template <uint32_t Size2> struct rebind { typedef basic_vector<T, Size2, Type> type; };
203  public:
204  basic_vector() : v{} {}
205  template <typename SFINAE = int>
206  explicit basic_vector(value_type x, typename std::enable_if_t<Size == 1, SFINAE> = 0) : v{ { x } } {}
207  template <typename SFINAE = int>
208  explicit basic_vector(value_type x, value_type y, typename std::enable_if_t<Size == 2, SFINAE> = 0) : v{ { x, y } } {}
209  template <typename SFINAE = int>
210  explicit basic_vector(value_type x, value_type y, value_type z, typename std::enable_if_t<Size == 3, SFINAE> = 0) : v{ { x, y, z } } {}
211  template <typename SFINAE = int>
212  explicit basic_vector(value_type x, value_type y, value_type z, value_type w, typename std::enable_if_t<Size == 4, SFINAE> = 0) : v{ { x, y, z, w } } {}
213  template <typename... Arguments>
214  explicit basic_vector(const value_type& value, Arguments&&... aArguments) : v{ {value, std::forward<Arguments>(aArguments)...} } {}
215  template <typename... Arguments>
216  explicit basic_vector(value_type&& value, Arguments&&... aArguments) : v{ {std::move(value), std::forward<Arguments>(aArguments)...} } {}
217  explicit basic_vector(const array_type& v) : v{ v } {}
218  basic_vector(const self_type& other) : v{ other.v } {}
219  basic_vector(self_type&& other) : v{ std::move(other.v) } {}
220  template <typename T2>
221  basic_vector(const basic_vector<T2, Size, Type>& other) { std::transform(other.begin(), other.end(), v.begin(), [](T2 source) { return static_cast<value_type>(source); }); }
222  template <typename T2, uint32_t Size2, typename SFINAE = int>
223  basic_vector(const basic_vector<T2, Size2, Type>& other, typename std::enable_if_t<Size2 < Size, SFINAE> = 0) : v{} { std::transform(other.begin(), other.end(), v.begin(), [](T2 source) { return static_cast<value_type>(source); }); }
224  self_type& operator=(const self_type& other) { v = other.v; return *this; }
225  self_type& operator=(self_type&& other) { v = std::move(other.v); return *this; }
226  self_type& operator=(std::initializer_list<value_type> values) { if (values.size() > Size) throw std::out_of_range("neogfx::basic_vector: initializer list too big"); std::copy(values.begin(), values.end(), v.begin()); std::uninitialized_fill(v.begin() + (values.end() - values.begin()), v.end(), value_type{}); return *this; }
227  public:
228  static uint32_t size() { return Size; }
229  const value_type& operator[](uint32_t aIndex) const { return v[aIndex]; }
230  value_type& operator[](uint32_t aIndex) { return v[aIndex]; }
231  const_iterator begin() const { return v.begin(); }
232  const_iterator end() const { return v.end(); }
233  iterator begin() { return v.begin(); }
234  iterator end() { return v.end(); }
235  operator const array_type&() const { return v; }
236  public:
237  template <typename T2>
239  {
240  return basic_vector<T2, Size, Type>{ *this };
241  }
242  public:
243  bool operator==(const basic_vector& right) const { return v == right.v; }
244  bool operator!=(const basic_vector& right) const { return v != right.v; }
245  self_type& operator+=(value_type value) { for (uint32_t index = 0; index < Size; ++index) v[index] += value; return *this; }
246  self_type& operator-=(value_type value) { for (uint32_t index = 0; index < Size; ++index) v[index] -= value; return *this; }
247  self_type& operator*=(value_type value) { for (uint32_t index = 0; index < Size; ++index) v[index] *= value; return *this; }
248  self_type& operator/=(value_type value) { for (uint32_t index = 0; index < Size; ++index) v[index] /= value; return *this; }
249  self_type& operator+=(const self_type& right) { for (uint32_t index = 0; index < Size; ++index) v[index] += right.v[index]; return *this; }
250  self_type& operator-=(const self_type& right) { for (uint32_t index = 0; index < Size; ++index) v[index] -= right.v[index]; return *this; }
251  self_type& operator*=(const self_type& right) { for (uint32_t index = 0; index < Size; ++index) v[index] *= right.v[index]; return *this; }
252  self_type& operator/=(const self_type& right) { for (uint32_t index = 0; index < Size; ++index) v[index] /= right.v[index]; return *this; }
253  self_type operator-() const { self_type result; for (uint32_t index = 0; index < Size; ++index) result.v[index] = -v[index]; return result; }
254  self_type scale(const self_type& right) const { self_type result; for (uint32_t index = 0; index < Size; ++index) result[index] = v[index] * right[index]; return result; }
255  value_type magnitude() const { value_type ss = constants::zero<value_type>; for (uint32_t index = 0; index < Size; ++index) ss += (v[index] * v[index]); return std::sqrt(ss); }
256  self_type normalized() const { self_type result; value_type im = constants::one<value_type> / magnitude(); for (uint32_t index = 0; index < Size; ++index) result.v[index] = v[index] * im; return result; }
257  self_type min(const self_type& right) const { self_type result; for (uint32_t index = 0; index < Size; ++index) result[index] = std::min(v[index], right.v[index]); return result; }
258  self_type max(const self_type& right) const { self_type result; for (uint32_t index = 0; index < Size; ++index) result[index] = std::max(v[index], right.v[index]); return result; }
259  self_type ceil() const { self_type result; for (uint32_t index = 0; index < Size; ++index) result[index] = std::ceil(v[index]); return result; }
260  self_type floor() const { self_type result; for (uint32_t index = 0; index < Size; ++index) result[index] = std::floor(v[index]); return result; }
261  self_type round() const { self_type result; for (uint32_t index = 0; index < Size; ++index) result[index] = std::round(v[index]); return result; }
262  value_type distance(const self_type& right) const { value_type total = constants::zero<value_type>; for (uint32_t index = 0; index < Size; ++index) total += ((v[index] - right.v[index]) * (v[index] - right.v[index])); return std::sqrt(total); }
263  value_type dot(const self_type& right) const
264  {
265  value_type result = constants::zero<value_type>;
266  for (uint32_t index = 0; index < Size; ++index)
267  result += ((*this)[index] * right[index]);
268  return result;
269  }
270  std::enable_if_t<Size == 3, self_type> cross(const self_type& right) const
271  {
272  auto const& x = v[0];
273  auto const& y = v[1];
274  auto const& z = v[2];
275  auto const& xx = right.v[0];
276  auto const& yy = right.v[1];
277  auto const& zz = right.v[2];
278  return self_type{ y * zz - z * yy, z * xx - x * zz, x * yy - y * xx };
279  }
280  self_type hadamard_product(const self_type& right) const
281  {
282  self_type result = *this;
283  result *= right;
284  return result;
285  }
286  public:
287  array_type v;
288  };
289 
290  template <typename T, uint32_t Size, typename Type>
291  inline bool operator<(const basic_vector<T, Size, Type>& aLhs, const basic_vector<T, Size, Type>& aRhs)
292  {
293  return aLhs.v < aRhs.v;
294  }
295 
296  template <typename T, uint32_t Size, typename Type>
297  inline bool operator<=(const basic_vector<T, Size, Type>& aLhs, const basic_vector<T, Size, Type>& aRhs)
298  {
299  return aLhs.v <= aRhs.v;
300  }
301 
302  template <typename T, uint32_t Size, typename Type>
304  {
305  return aLhs.v > aRhs.v;
306  }
307 
308  template <typename T, uint32_t Size, typename Type>
310  {
311  return aLhs.v >= aRhs.v;
312  }
313 
314  template <typename T, uint32_t Size, typename Type>
316  {
317  return aLhs.v == aRhs.v;
318  }
319 
320  template <typename T, uint32_t Size, typename Type>
322  {
323  return aLhs.v != aRhs.v;
324  }
325 
330 
331  typedef vector1 vec1;
332  typedef vector2 vec2;
333  typedef vector3 vec3;
334  typedef vector4 vec4;
335 
336  typedef vec1 col_vec1;
337  typedef vec2 col_vec2;
338  typedef vec3 col_vec3;
339  typedef vec4 col_vec4;
340 
345 
346  typedef std::optional<vector1> optional_vector1;
347  typedef std::optional<vector2> optional_vector2;
348  typedef std::optional<vector3> optional_vector3;
349  typedef std::optional<vector4> optional_vector4;
350 
351  typedef std::optional<vec1> optional_vec1;
352  typedef std::optional<vec2> optional_vec2;
353  typedef std::optional<vec3> optional_vec3;
354  typedef std::optional<vec4> optional_vec4;
355 
356  typedef std::optional<col_vec1> optional_col_vec1;
357  typedef std::optional<col_vec2> optional_col_vec2;
358  typedef std::optional<col_vec3> optional_col_vec3;
359  typedef std::optional<col_vec4> optional_col_vec4;
360 
361  typedef std::optional<row_vec1> optional_row_vec1;
362  typedef std::optional<row_vec2> optional_row_vec2;
363  typedef std::optional<row_vec3> optional_row_vec3;
364  typedef std::optional<row_vec4> optional_row_vec4;
365 
366  typedef std::vector<vec2> vec2_list;
367  typedef std::vector<vec3> vec3_list;
368 
369  typedef std::optional<vec2_list> optional_vec2_list;
370  typedef std::optional<vec3_list> optional_vec3_list;
371 
372  typedef vec2_list vertices_2d;
373  typedef vec3_list vertices;
374 
375  typedef optional_vec2_list optional_vertices_2d_t;
376  typedef optional_vec3_list optional_vertices_t;
377 
382 
383  typedef vector1f vec1f;
384  typedef vector2f vec2f;
385  typedef vector3f vec3f;
386  typedef vector4f vec4f;
387 
392 
393  typedef vector1i32 vec1i32;
394  typedef vector2i32 vec2i32;
395  typedef vector3i32 vec3i32;
396  typedef vector4i32 vec4i32;
397 
402 
403  typedef vector1u32 vec1u32;
404  typedef vector2u32 vec2u32;
405  typedef vector3u32 vec3u32;
406  typedef vector4u32 vec4u32;
407 
408  template <std::size_t VertexCount>
410 
411  template <std::size_t VertexCount>
413 
414  typedef std::array<vec3, 3> triangle;
415  typedef std::array<vec3, 4> quad;
416 
417  typedef std::array<vec2, 3> triangle_2d;
418  typedef std::array<vec2, 4> quad_2d;
419 
420  template <typename T, uint32_t D, typename Type, bool IsScalar>
422  {
424  result += right;
425  return result;
426  }
427 
428  template <typename T, uint32_t D, typename Type, bool IsScalar>
430  {
432  result -= right;
433  return result;
434  }
435 
436  template <typename T, uint32_t D, typename Type, bool IsScalar>
438  {
440  for (uint32_t i = 0; i < D; ++i)
441  result[i] += right;
442  return result;
443  }
444 
445  template <typename T, uint32_t D, typename Type, bool IsScalar>
447  {
448  basic_vector<T, D, Type, IsScalar> result = right;
449  for (uint32_t i = 0; i < D; ++i)
450  result[i] += left;
451  return result;
452  }
453 
454  template <typename T, uint32_t D, typename Type, bool IsScalar>
456  {
458  for (uint32_t i = 0; i < D; ++i)
459  result[i] -= right;
460  return result;
461  }
462 
463  template <typename T, uint32_t D, typename Type, bool IsScalar>
465  {
467  for (uint32_t i = 0; i < D; ++i)
468  result[i] = left - right[i];
469  return result;
470  }
471 
472  template <typename T, uint32_t D, typename Type, bool IsScalar>
474  {
476  for (uint32_t i = 0; i < D; ++i)
477  result[i] *= right;
478  return result;
479  }
480 
481  template <typename T, uint32_t D, typename Type, bool IsScalar>
483  {
484  basic_vector<T, D, Type, IsScalar> result = right;
485  for (uint32_t i = 0; i < D; ++i)
486  result[i] *= left;
487  return result;
488  }
489 
490  template <typename T, uint32_t D, typename Type, bool IsScalar>
492  {
494  for (uint32_t i = 0; i < D; ++i)
495  result[i] /= right;
496  return result;
497  }
498 
499  template <typename T, uint32_t D, typename Type, bool IsScalar>
501  {
503  for (uint32_t i = 0; i < D; ++i)
504  result[i] = left / right[i];
505  return result;
506  }
507 
508  template <typename T, uint32_t D, typename Type, bool IsScalar>
510  {
512  for (uint32_t i = 0; i < D; ++i)
513  result[i] = std::fmod(left[i], right);
514  return result;
515  }
516 
517  template <typename T, uint32_t D, bool IsScalar>
519  {
520  T result = {};
521  for (uint32_t index = 0; index < D; ++index)
522  result += (left[index] * right[index]);
523  return result;
524  }
525 
526  template <typename T, typename Type, bool IsScalar>
528  {
529  return basic_vector<T, 3, Type, IsScalar>{ left[0] + right[0], left[1] + right[1], left[2] + right[2] };
530  }
531 
532  template <typename T, typename Type, bool IsScalar>
534  {
535  return basic_vector<T, 3, Type, IsScalar>{ left[0] - right[0], left[1] - right[1], left[2] - right[2] };
536  }
537 
538  template <typename T, typename Type, bool IsScalar>
540  {
541  return basic_vector<T, 3, Type, IsScalar>{ left[0] + right, left[1] + right, left[2] + right };
542  }
543 
544  template <typename T, typename Type, bool IsScalar>
546  {
547  return basic_vector<T, 3, Type, IsScalar>{ left + right[0], left + right[1], left + right[2] };
548  }
549 
550  template <typename T, typename Type, bool IsScalar>
552  {
553  return basic_vector<T, 3, Type, IsScalar>{ left[0] - right, left[1] - right, left[2] - right };
554  }
555 
556  template <typename T, typename Type, bool IsScalar>
558  {
559  return basic_vector<T, 3, Type, IsScalar>{ left - right[0], left - right[1], left - right[2] };
560  }
561 
562  template <typename T, typename Type, bool IsScalar>
564  {
565  return basic_vector<T, 3, Type, IsScalar>{ left[0] * right, left[1] * right, left[2] * right };
566  }
567 
568  template <typename T, typename Type, bool IsScalar>
570  {
571  return basic_vector<T, 3, Type, IsScalar>{ left * right[0], left * right[1], left * right[2] };
572  }
573 
574  template <typename T, typename Type, bool IsScalar>
576  {
577  return basic_vector<T, 3, Type, IsScalar>{ left[0] / right, left[1] / right, left[2] / right };
578  }
579 
580  template <typename T, typename Type, bool IsScalar>
582  {
583  return basic_vector<T, 3, Type, IsScalar>{ std::fmod(left[0], right), std::fmod(left[1], right), std::fmod(left[2], right) };
584  }
585 
586  template <typename T, bool IsScalar>
588  {
589  return left[0] * right[0] + left[1] * right[1] + left[2] * right[2];
590  }
591 
592  template <typename T, typename Type, bool IsScalar>
594  {
595  return (left + right) / constants::two<T>;
596  }
597 
598  template <typename T, uint32_t Size, typename Type, bool IsScalar>
600  {
602  for (uint32_t i = 0; i < Size; ++i)
603  {
604  double x1 = aV1[i];
605  double x2 = aV2[i];
606  result[i] = static_cast<T>((x2 - x1) * aAmount + x1);
607  }
608  return result;
609  }
610 
611  /* todo: specializations that use SIMD intrinsics. */
612  template <typename T, uint32_t Rows, uint32_t Columns>
614  {
616  public:
617  typedef self_type abstract_type; // todo: abstract base
618  public:
619  typedef T value_type;
622  typedef std::array<column_type, Columns> array_type;
623  public:
624  template <typename T2>
626  public:
627  basic_matrix() : m{ {} } {}
628  basic_matrix(std::initializer_list<std::initializer_list<value_type>> aColumns) { std::copy(aColumns.begin(), aColumns.end(), m.begin()); }
629  basic_matrix(const self_type& other) : m{ other.m } {}
630  basic_matrix(self_type&& other) : m{ std::move(other.m) } {}
631  template <typename T2>
633  {
634  for (uint32_t column = 0; column < Columns; ++column)
635  for (uint32_t row = 0; row < Rows; ++row)
636  (*this)[column][row] = static_cast<value_type>(other[column][row]);
637  }
638  self_type& operator=(const self_type& other) { m = other.m; return *this; }
639  self_type& operator=(self_type&& other) { m = std::move(other.m); return *this; }
640  public:
641  template <typename T2>
643  {
644  return basic_matrix<T2, Rows, Columns>{ *this };
645  }
646  public:
647  std::pair<uint32_t, uint32_t> size() const { return std::make_pair(Rows, Columns); }
648  const column_type& operator[](uint32_t aColumn) const { return m[aColumn]; }
649  column_type& operator[](uint32_t aColumn) { return m[aColumn]; }
650  const value_type* data() const { return &m[0].v[0]; }
651  public:
652  bool operator==(const self_type& right) const { return m == right.m; }
653  bool operator!=(const self_type& right) const { return m != right.m; }
654  self_type& operator+=(const self_type& right) { for (uint32_t column = 0; column < Columns; ++column) m[column] += right.m[column]; return *this; }
655  self_type& operator-=(const self_type& right) { for (uint32_t column = 0; column < Columns; ++column) m[column] -= right.m[column]; return *this; }
656  self_type& operator*=(const self_type& right)
657  {
658  self_type result;
659  for (uint32_t column = 0; column < Columns; ++column)
660  for (uint32_t row = 0; row < Rows; ++row)
661  for (uint32_t index = 0; index < Columns; ++index)
662  result[column][row] += (m[index][row] * right[column][index]);
663  *this = result;
664  return *this;
665  }
666  self_type operator-() const
667  {
668  self_type result = *this;
669  for (uint32_t column = 0; column < Columns; ++column)
670  for (uint32_t row = 0; row < Rows; ++row)
671  result[column][row] = -result[column][row];
672  return result;
673  }
674  self_type round_to(value_type aEpsilon) const
675  {
676  self_type result;
677  for (uint32_t column = 0; column < Columns; ++column)
678  for (uint32_t row = 0; row < Rows; ++row)
679  {
680  std::modf((*this)[column][row] / aEpsilon + 0.5, &result[column][row]);
681  result[column][row] *= aEpsilon;
682  }
683  return result;
684  }
686  {
688  for (uint32_t column = 0; column < Columns; ++column)
689  for (uint32_t row = 0; row < Rows; ++row)
690  result[row][column] = m[column][row];
691  return result;
692  }
693  template <typename SFINAE = self_type>
694  static const std::enable_if_t<Rows == Columns, SFINAE>& identity()
695  {
696  auto make_identity = []()
697  {
698  self_type result;
699  for (uint32_t diag = 0; diag < Rows; ++diag)
700  result[diag][diag] = static_cast<value_type>(1.0);
701  return result;
702  };
703  static self_type const sIdentity = make_identity();
704  return sIdentity;
705  }
706  bool is_identity() const
707  {
708  return this == &identity();
709  }
710  private:
711  array_type m;
712  };
713 
730 
731  typedef matrix11 matrix1;
732  typedef matrix22 matrix2;
733  typedef matrix33 matrix3;
734  typedef matrix44 matrix4;
735 
736  typedef matrix11 mat11;
737  typedef matrix22 mat22;
738  typedef matrix21 mat21;
739  typedef matrix12 mat12;
740  typedef matrix33 mat33;
741  typedef matrix31 mat31;
742  typedef matrix32 mat32;
743  typedef matrix13 mat13;
744  typedef matrix23 mat23;
745  typedef matrix44 mat44;
746  typedef matrix41 mat41;
747  typedef matrix42 mat42;
748  typedef matrix43 mat43;
749  typedef matrix14 mat14;
750  typedef matrix24 mat24;
751  typedef matrix34 mat34;
752 
753  typedef mat11 mat1;
754  typedef mat22 mat2;
755  typedef mat33 mat3;
756  typedef mat44 mat4;
757 
758  typedef std::optional<matrix11> optional_matrix11;
759  typedef std::optional<matrix22> optional_matrix22;
760  typedef std::optional<matrix21> optional_matrix21;
761  typedef std::optional<matrix12> optional_matrix12;
762  typedef std::optional<matrix33> optional_matrix33;
763  typedef std::optional<matrix31> optional_matrix31;
764  typedef std::optional<matrix32> optional_matrix32;
765  typedef std::optional<matrix13> optional_matrix13;
766  typedef std::optional<matrix23> optional_matrix23;
767  typedef std::optional<matrix44> optional_matrix44;
768  typedef std::optional<matrix41> optional_matrix41;
769  typedef std::optional<matrix42> optional_matrix42;
770  typedef std::optional<matrix43> optional_matrix43;
771  typedef std::optional<matrix14> optional_matrix14;
772  typedef std::optional<matrix24> optional_matrix24;
773  typedef std::optional<matrix34> optional_matrix34;
774 
775  typedef std::optional<matrix11> optional_matrix1;
776  typedef std::optional<matrix22> optional_matrix2;
777  typedef std::optional<matrix33> optional_matrix3;
778  typedef std::optional<matrix44> optional_matrix4;
779 
780  typedef std::optional<mat11> optional_mat11;
781  typedef std::optional<mat22> optional_mat22;
782  typedef std::optional<mat21> optional_mat21;
783  typedef std::optional<mat12> optional_mat12;
784  typedef std::optional<mat33> optional_mat33;
785  typedef std::optional<mat31> optional_mat31;
786  typedef std::optional<mat32> optional_mat32;
787  typedef std::optional<mat13> optional_mat13;
788  typedef std::optional<mat23> optional_mat23;
789  typedef std::optional<mat44> optional_mat44;
790  typedef std::optional<mat41> optional_mat41;
791  typedef std::optional<mat42> optional_mat42;
792  typedef std::optional<mat43> optional_mat43;
793  typedef std::optional<mat14> optional_mat14;
794  typedef std::optional<mat24> optional_mat24;
795  typedef std::optional<mat34> optional_mat34;
796 
797  typedef std::optional<mat11> optional_mat1;
798  typedef std::optional<mat22> optional_mat2;
799  typedef std::optional<mat33> optional_mat3;
800  typedef std::optional<mat44> optional_mat4;
801 
818 
819  typedef matrix11f mat11f;
820  typedef matrix22f mat22f;
821  typedef matrix21f mat21f;
822  typedef matrix12f mat12f;
823  typedef matrix33f mat33f;
824  typedef matrix31f mat31f;
825  typedef matrix32f mat32f;
826  typedef matrix13f mat13f;
827  typedef matrix23f mat23f;
828  typedef matrix44f mat44f;
829  typedef matrix41f mat41f;
830  typedef matrix42f mat42f;
831  typedef matrix43f mat43f;
832  typedef matrix14f mat14f;
833  typedef matrix24f mat24f;
834  typedef matrix34f mat34f;
835 
836  typedef matrix11f mat1f;
837  typedef matrix22f mat2f;
838  typedef matrix33f mat3f;
839  typedef matrix44f mat4f;
840 
841  typedef std::optional<matrix11f> optional_matrix11f;
842  typedef std::optional<matrix22f> optional_matrix22f;
843  typedef std::optional<matrix21f> optional_matrix21f;
844  typedef std::optional<matrix12f> optional_matrix12f;
845  typedef std::optional<matrix33f> optional_matrix33f;
846  typedef std::optional<matrix31f> optional_matrix31f;
847  typedef std::optional<matrix32f> optional_matrix32f;
848  typedef std::optional<matrix13f> optional_matrix13f;
849  typedef std::optional<matrix23f> optional_matrix23f;
850  typedef std::optional<matrix44f> optional_matrix44f;
851  typedef std::optional<matrix41f> optional_matrix41f;
852  typedef std::optional<matrix42f> optional_matrix42f;
853  typedef std::optional<matrix43f> optional_matrix43f;
854  typedef std::optional<matrix14f> optional_matrix14f;
855  typedef std::optional<matrix24f> optional_matrix24f;
856  typedef std::optional<matrix34f> optional_matrix34f;
857 
858  typedef std::optional<matrix11f> optional_matrix1f;
859  typedef std::optional<matrix22f> optional_matrix2f;
860  typedef std::optional<matrix33f> optional_matrix3f;
861  typedef std::optional<matrix44f> optional_matrix4f;
862 
863  typedef std::optional<mat11f> optional_mat11f;
864  typedef std::optional<mat22f> optional_mat22f;
865  typedef std::optional<mat21f> optional_mat21f;
866  typedef std::optional<mat12f> optional_mat12f;
867  typedef std::optional<mat33f> optional_mat33f;
868  typedef std::optional<mat31f> optional_mat31f;
869  typedef std::optional<mat32f> optional_mat32f;
870  typedef std::optional<mat13f> optional_mat13f;
871  typedef std::optional<mat23f> optional_mat23f;
872  typedef std::optional<mat44f> optional_mat44f;
873  typedef std::optional<mat41f> optional_mat41f;
874  typedef std::optional<mat42f> optional_mat42f;
875  typedef std::optional<mat43f> optional_mat43f;
876  typedef std::optional<mat14f> optional_mat14f;
877  typedef std::optional<mat24f> optional_mat24f;
878  typedef std::optional<mat34f> optional_mat34f;
879 
880  typedef std::optional<mat11f> optional_mat1f;
881  typedef std::optional<mat22f> optional_mat2f;
882  typedef std::optional<mat33f> optional_mat3f;
883  typedef std::optional<mat44f> optional_mat4f;
884 
885  template <typename T, uint32_t Rows, uint32_t Columns>
887  {
888  basic_matrix<T, Rows, Columns> result = left;
889  result += right;
890  return result;
891  }
892 
893  template <typename T, uint32_t Rows, uint32_t Columns>
895  {
896  basic_matrix<T, Rows, Columns> result = left;
897  result -= right;
898  return result;
899  }
900 
901  template <typename T, uint32_t Rows, uint32_t Columns>
903  {
904  basic_matrix<T, Rows, Columns> result = left;
905  result *= right;
906  return result;
907  }
908 
909  template <typename T, uint32_t Rows, uint32_t Columns>
911  {
912  basic_matrix<T, Rows, Columns> result = left;
913  result /= right;
914  return result;
915  }
916 
917  template <typename T, uint32_t Rows, uint32_t Columns>
919  {
920  basic_matrix<T, Rows, Columns> result = right;
921  result += left;
922  return result;
923  }
924 
925  template <typename T, uint32_t Rows, uint32_t Columns>
927  {
928  return -right + left;
929  }
930 
931  template <typename T, uint32_t Rows, uint32_t Columns>
933  {
934  basic_matrix<T, Rows, Columns> result = right;
935  result *= left;
936  return result;
937  }
938 
939  template <typename T, uint32_t Rows, uint32_t Columns>
941  {
942  basic_matrix<T, Rows, Columns> result = left;
943  result += right;
944  return result;
945  }
946 
947  template <typename T, uint32_t Rows, uint32_t Columns>
949  {
950  basic_matrix<T, Rows, Columns> result = left;
951  result -= right;
952  return result;
953  }
954 
955  template <typename T, uint32_t D1, uint32_t D2>
957  {
958  if (&left == &left.identity())
959  return right;
960  if (&right == &right.identity())
961  return left;
963  for (uint32_t column = 0; column < D1; ++column)
964  for (uint32_t row = 0; row < D1; ++row)
965  for (uint32_t index = 0; index < D2; ++index)
966  result[column][row] += (left[index][row] * right[column][index]);
967  return result;
968  }
969 
970  template <typename T, uint32_t D, bool IsScalar>
972  {
974  for (uint32_t row = 0; row < D; ++row)
975  for (uint32_t index = 0; index < D; ++index)
976  result[row] += (left[index][row] * right[index]);
977  return result;
978  }
979 
980  template <typename T, uint32_t D, bool IsScalar>
982  {
984  for (uint32_t column = 0; column < D; ++column)
985  for (uint32_t index = 0; index < D; ++index)
986  result[column] += (left[index] * right[column][index]);
987  return result;
988  }
989 
990  template <typename T, uint32_t D, bool IsScalar>
992  {
993  basic_matrix<T, D, D> result;
994  for (uint32_t column = 0; column < D; ++column)
995  for (uint32_t row = 0; row < D; ++row)
996  result[column][row] = (left[row] * right[column]);
997  return result;
998  }
999 
1000  template <typename T, uint32_t D>
1002  {
1003  auto result = matrix;
1004  for (uint32_t row = 0; row < D - 1; ++row)
1005  result[D - 1][row] = 0.0;
1006  return result;
1007  }
1008 
1009  template <typename Elem, typename Traits, typename T, uint32_t Size, typename Type, bool IsScalar>
1010  inline std::basic_ostream<Elem, Traits>& operator<<(std::basic_ostream<Elem, Traits>& aStream, const basic_vector<T, Size, Type, IsScalar>& aVector)
1011  {
1012  aStream << "[";
1013  for (uint32_t i = 0; i < Size; ++i)
1014  {
1015  if (i != 0)
1016  aStream << ", ";
1017  aStream << aVector[i];
1018  }
1019  aStream << "]";
1020  return aStream;
1021  }
1022 
1023  template <typename Elem, typename Traits, typename T, uint32_t Rows, uint32_t Columns>
1024  inline std::basic_ostream<Elem, Traits>& operator<<(std::basic_ostream<Elem, Traits>& aStream, const basic_matrix<T, Rows, Columns>& aMatrix)
1025  {
1026  aStream << "[";
1027  for (uint32_t row = 0; row < Rows; ++row)
1028  {
1029  if (row != 0)
1030  aStream << ", ";
1031  aStream << "[";
1032  for (uint32_t column = 0; column < Columns; ++column)
1033  {
1034  if (column != 0)
1035  aStream << ", ";
1036  aStream << aMatrix[column][row];
1037  }
1038  aStream << "]";
1039  }
1040  aStream << "]";
1041  return aStream;
1042  }
1043 
1044  template <typename Elem, typename Traits, typename T, uint32_t Rows, uint32_t Columns>
1045  inline std::basic_ostream<Elem, Traits>& operator<<(std::basic_ostream<Elem, Traits>& aStream, const std::optional<basic_matrix<T, Rows, Columns>>& aMatrix)
1046  {
1047  if (aMatrix != std::nullopt)
1048  aStream << *aMatrix;
1049  else
1050  aStream << "[null]";
1051  return aStream;
1052  }
1053 
1054  struct aabb
1055  {
1056  vec3 min;
1057  vec3 max;
1058  aabb() : min{}, max{} {}
1059  aabb(const vec3& aMin, const vec3& aMax) : min{ aMin }, max{ aMax } {}
1060  };
1061 
1062  inline bool operator==(const aabb& left, const aabb& right)
1063  {
1064  return left.min == right.min && left.max == right.max;
1065  }
1066 
1067  inline bool operator!=(const aabb& left, const aabb& right)
1068  {
1069  return !(left == right);
1070  }
1071 
1072  inline bool operator<(const aabb& left, const aabb& right)
1073  {
1074  return std::tie(left.min.z, left.min.y, left.min.x, left.max.z, left.max.y, left.max.x) <
1075  std::tie(right.min.z, right.min.y, right.min.x, right.max.z, right.max.y, right.max.x);
1076  }
1077 
1078  typedef std::optional<aabb> optional_aabb;
1079 
1080  inline aabb aabb_union(const aabb& left, const aabb& right)
1081  {
1082  return aabb{ left.min.min(right.min), left.max.max(right.max) };
1083  }
1084 
1085  inline scalar aabb_volume(const aabb& a)
1086  {
1087  auto extents = a.max - a.min;
1088  return extents.x * extents.y * (extents.z != 0.0 ? extents.z : 1.0);
1089  }
1090 
1091  inline bool aabb_contains(const aabb& outer, const aabb& inner)
1092  {
1093  return inner.min >= outer.min && inner.max <= outer.max;
1094  }
1095 
1096  inline bool aabb_contains(const aabb& outer, const vec3& point)
1097  {
1098  return point >= outer.min && point <= outer.max;
1099  }
1100 
1101  inline bool aabb_intersects(const aabb& first, const aabb& second)
1102  {
1103  if (first.max.x < second.min.x)
1104  return false;
1105  if (first.min.x > second.max.x)
1106  return false;
1107  if (first.max.y < second.min.y)
1108  return false;
1109  if (first.min.y > second.max.y)
1110  return false;
1111  if (first.max.z < second.min.z)
1112  return false;
1113  if (first.min.z > second.max.z)
1114  return false;
1115  return true;
1116  }
1117 
1118  struct aabb_2d
1119  {
1120  vec2 min;
1121  vec2 max;
1122  aabb_2d() : min{}, max{} {}
1123  aabb_2d(const vec2& aMin, const vec2& aMax) : min{ aMin }, max{ aMax } {}
1124  aabb_2d(const aabb& aAabb) : min{ aAabb.min.xy }, max{ aAabb.max.xy } {}
1125  };
1126 
1127  inline aabb_2d to_aabb_2d(const vertices& vertices)
1128  {
1129  aabb_2d result = !vertices.empty() ? aabb_2d{ vertices[0].xy, vertices[0].xy } : aabb_2d{};
1130  for (auto const& v : vertices)
1131  {
1132  result.min = result.min.min(v.xy);
1133  result.max = result.max.max(v.xy);
1134  }
1135  return result;
1136  }
1137 
1138  inline bool operator==(const aabb_2d& left, const aabb_2d& right)
1139  {
1140  return left.min == right.min && left.max == right.max;
1141  }
1142 
1143  inline bool operator!=(const aabb_2d& left, const aabb_2d& right)
1144  {
1145  return !(left == right);
1146  }
1147 
1148  inline bool operator<(const aabb_2d& left, const aabb_2d& right)
1149  {
1150  return std::tie(left.min.y, left.min.x, left.max.y, left.max.x) <
1151  std::tie(right.min.y, right.min.x, right.max.y, right.max.x);
1152  }
1153 
1154  typedef std::optional<aabb_2d> optional_aabb_2d;
1155 
1156  inline aabb_2d aabb_union(const aabb_2d& left, const aabb_2d& right)
1157  {
1158  return aabb_2d{ left.min.min(right.min), left.max.max(right.max) };
1159  }
1160 
1161  inline scalar aabb_volume(const aabb_2d& a)
1162  {
1163  auto extents = a.max - a.min;
1164  return extents.x * extents.y;
1165  }
1166 
1167  inline bool aabb_contains(const aabb_2d& outer, const aabb_2d& inner)
1168  {
1169  return inner.min >= outer.min && inner.max <= outer.max;
1170  }
1171 
1172  inline bool aabb_contains(const aabb_2d& outer, const vec2& point)
1173  {
1174  return point >= outer.min && point <= outer.max;
1175  }
1176 
1177  inline bool aabb_intersects(const aabb_2d& first, const aabb_2d& second)
1178  {
1179  if (first.max.x < second.min.x)
1180  return false;
1181  if (first.min.x > second.max.x)
1182  return false;
1183  if (first.max.y < second.min.y)
1184  return false;
1185  if (first.min.y > second.max.y)
1186  return false;
1187  return true;
1188  }
1189 
1190  // 3D helpers
1191 
1192  template <typename T, bool IsScalar>
1194  {
1195  return (left * basic_vector<T, 4, column_vector, IsScalar>{ right.x, right.y, right.z, 1.0 }).xyz;
1196  }
1197 
1198  template <typename T, bool IsScalar>
1199  inline std::vector<basic_vector<T, 3, column_vector, IsScalar>> operator*(const basic_matrix<T, 4, 4>& left, const std::vector<basic_vector<T, 3, column_vector, IsScalar>>& right)
1200  {
1201  std::vector<basic_vector<T, 3, column_vector, IsScalar>> result;
1202  result.reserve(right.size());
1203  for (auto const& v : right)
1204  result.push_back(left * v);
1205  return result;
1206  }
1207 
1208  inline mat33 rotation_matrix(const vec3& axis, scalar angle, scalar epsilon = 0.00001)
1209  {
1210  if (std::abs(angle) <= epsilon)
1211  return mat33::identity();
1212  else if (std::abs(angle - boost::math::constants::pi<scalar>()) <= epsilon)
1213  return -mat33::identity();
1214  scalar const s = std::sin(angle);
1215  scalar const c = std::cos(angle);
1216  scalar const a = 1.0 - c;
1217  scalar const ax = a * axis.x;
1218  scalar const ay = a * axis.y;
1219  scalar const az = a * axis.z;
1220  return mat33{
1221  { ax * axis.x + c, ax * axis.y + axis.z * s, ax * axis.z - axis.y * s },
1222  { ay * axis.x - axis.z * s, ay * axis.y + c, ay * axis.z + axis.x * s },
1223  { az * axis.x + axis.y * s, az * axis.y - axis.x * s, az * axis.z + c } }.round_to(epsilon);
1224  }
1225 
1226  inline mat33 rotation_matrix(const vec3& vectorA, const vec3& vectorB, scalar epsilon = 0.00001)
1227  {
1228  auto const nva = vectorA.normalized();
1229  auto const nvb = vectorB.normalized();
1230  return rotation_matrix(nva.cross(nvb).normalized(), std::acos(nva.dot(nvb)), epsilon);
1231  }
1232 
1233  inline mat33 rotation_matrix(const vec3& angles)
1234  {
1235  scalar ax = angles.x;
1236  scalar ay = angles.y;
1237  scalar az = angles.z;
1238  if (ax != 0.0 || ay != 0.0)
1239  {
1240  mat33 rx = { { 1.0, 0.0, 0.0 },{ 0.0, std::cos(ax), std::sin(ax) },{ 0.0, -std::sin(ax), std::cos(ax) } };
1241  mat33 ry = { { std::cos(ay), 0.0, -std::sin(ay) },{ 0.0, 1.0, 0.0 },{ std::sin(ay), 0.0, std::cos(ay) } };
1242  mat33 rz = { { std::cos(az), std::sin(az), 0.0 },{ -std::sin(az), std::cos(az), 0.0 },{ 0.0, 0.0, 1.0 } };
1243  return rz * ry * rx;
1244  }
1245  else
1246  {
1247  return mat33{ { std::cos(az), std::sin(az), 0.0 },{ -std::sin(az), std::cos(az), 0.0 },{ 0.0, 0.0, 1.0 } };
1248  }
1249  }
1250 
1251  inline mat44 affine_rotation_matrix(const vec3& angles)
1252  {
1253  scalar ax = angles.x;
1254  scalar ay = angles.y;
1255  scalar az = angles.z;
1256  if (ax != 0.0 || ay != 0.0)
1257  {
1258  mat44 rx = { { 1.0, 0.0, 0.0, 0.0 },{ 0.0, std::cos(ax), std::sin(ax), 0.0 },{ 0.0, -std::sin(ax), std::cos(ax), 0.0 },{0.0, 0.0, 0.0, 1.0} };
1259  mat44 ry = { { std::cos(ay), 0.0, -std::sin(ay), 0.0 },{ 0.0, 1.0, 0.0, 0.0 },{ std::sin(ay), 0.0, std::cos(ay), 0.0 },{0.0, 0.0, 0.0, 1.0} };
1260  mat44 rz = { { std::cos(az), std::sin(az), 0.0, 0.0 },{ -std::sin(az), std::cos(az), 0.0, 0.0 },{ 0.0, 0.0, 1.0, 0.0 },{0.0, 0.0, 0.0, 1.0} };
1261  return rz * ry * rx;
1262  }
1263  else
1264  {
1265  return mat44{ { std::cos(az), std::sin(az), 0.0, 0.0 },{ -std::sin(az), std::cos(az), 0.0, 0.0 },{ 0.0, 0.0, 1.0, 0.0 },{0.0, 0.0, 0.0, 1.0} };
1266  }
1267  }
1268  }
1269 
1270  using namespace math;
1271 }
basic_matrix< double, 2, 2 > matrix22
Definition: numerical.hpp:715
vector2i32 vec2i32
Definition: numerical.hpp:394
std::optional< matrix23f > optional_matrix23f
Definition: numerical.hpp:849
basic_vector< uint32_t, 4 > vector4u32
Definition: numerical.hpp:401
const value_type & operator[](uint32_t aIndex) const
Definition: numerical.hpp:229
value_type dot(const self_type &right) const
Definition: numerical.hpp:160
self_type & operator*=(const self_type &right)
Definition: numerical.hpp:147
self_type & operator=(const self_type &other)
Definition: numerical.hpp:120
aabb_2d to_aabb_2d(const vertices &vertices)
Definition: numerical.hpp:1127
T lerp(T aX1, T aX2, double aAmount)
Definition: numerical.hpp:54
self_type & operator-=(const self_type &right)
Definition: numerical.hpp:146
basic_vector< float, 3 > vector3f
Definition: numerical.hpp:380
basic_matrix< double, 1, 2 > matrix12
Definition: numerical.hpp:717
std::optional< matrix42 > optional_matrix42
Definition: numerical.hpp:769
std::optional< col_vec3 > optional_col_vec3
Definition: numerical.hpp:358
mat33 rotation_matrix(const vec3 &axis, scalar angle, scalar epsilon=0.00001)
Definition: numerical.hpp:1208
std::optional< mat22 > optional_mat22
Definition: numerical.hpp:781
std::optional< vector2 > optional_vector2
Definition: numerical.hpp:347
basic_vector(const value_type &value, Arguments &&... aArguments)
Definition: numerical.hpp:214
matrix33 matrix3
Definition: numerical.hpp:733
bool operator>(const basic_vector< T, Size, Type > &aLhs, const basic_vector< T, Size, Type > &aRhs)
Definition: numerical.hpp:303
std::optional< matrix12 > optional_matrix12
Definition: numerical.hpp:761
basic_matrix< double, 1, 3 > matrix13
Definition: numerical.hpp:721
std::optional< matrix43f > optional_matrix43f
Definition: numerical.hpp:853
bool operator!=(const basic_vector &right) const
Definition: numerical.hpp:244
std::optional< matrix33 > optional_matrix33
Definition: numerical.hpp:762
bool operator>=(const basic_vector< T, Size, Type > &aLhs, const basic_vector< T, Size, Type > &aRhs)
Definition: numerical.hpp:309
std::enable_if_t< Size==3, self_type > cross(const self_type &right) const
Definition: numerical.hpp:270
basic_vector< float, 4 > vector4f
Definition: numerical.hpp:381
value_type distance(const self_type &right) const
Definition: numerical.hpp:262
self_type max(const self_type &right) const
Definition: numerical.hpp:154
matrix12 mat12
Definition: numerical.hpp:739
basic_matrix< double, 4, 3 > matrix43
Definition: numerical.hpp:726
std::optional< mat23f > optional_mat23f
Definition: numerical.hpp:871
matrix42f mat42f
Definition: numerical.hpp:830
basic_matrix< float, 4, 4 > matrix44f
Definition: numerical.hpp:811
basic_vector< double, 1 > vector1
Definition: numerical.hpp:326
std::optional< mat34 > optional_mat34
Definition: numerical.hpp:795
self_type & operator*=(const self_type &right)
Definition: numerical.hpp:656
basic_matrix(std::initializer_list< std::initializer_list< value_type >> aColumns)
Definition: numerical.hpp:628
optional_vec2_list optional_vertices_2d_t
Definition: numerical.hpp:375
basic_vector< int32_t, 2 > vector2i32
Definition: numerical.hpp:389
matrix44f mat4f
Definition: numerical.hpp:839
matrix14f mat14f
Definition: numerical.hpp:832
vector4 vec4
Definition: numerical.hpp:334
std::optional< mat41 > optional_mat41
Definition: numerical.hpp:790
std::optional< matrix33 > optional_matrix3
Definition: numerical.hpp:777
std::optional< mat14 > optional_mat14
Definition: numerical.hpp:793
basic_matrix< float, 1, 3 > matrix13f
Definition: numerical.hpp:809
value_type dot(const self_type &right) const
Definition: numerical.hpp:263
basic_matrix< double, 2, 1 > matrix21
Definition: numerical.hpp:716
basic_matrix< float, 3, 1 > matrix31f
Definition: numerical.hpp:807
matrix24 mat24
Definition: numerical.hpp:750
self_type & operator+=(const self_type &right)
Definition: numerical.hpp:145
angle to_rad(angle aDegrees)
Definition: numerical.hpp:61
vector4u32 vec4u32
Definition: numerical.hpp:406
matrix34f mat34f
Definition: numerical.hpp:834
matrix43 mat43
Definition: numerical.hpp:748
matrix21f mat21f
Definition: numerical.hpp:821
std::optional< mat32 > optional_mat32
Definition: numerical.hpp:786
vector4f vec4f
Definition: numerical.hpp:386
std::optional< matrix13f > optional_matrix13f
Definition: numerical.hpp:848
basic_vector< float, 2 > vector2f
Definition: numerical.hpp:379
std::optional< mat21f > optional_mat21f
Definition: numerical.hpp:865
basic_matrix< double, 4, 1 > matrix41
Definition: numerical.hpp:724
self_type & operator-=(const self_type &right)
Definition: numerical.hpp:655
matrix44f mat44f
Definition: numerical.hpp:828
std::array< value_type, Size > array_type
Definition: numerical.hpp:92
matrix11 mat11
Definition: numerical.hpp:736
self_type & operator=(const self_type &other)
Definition: numerical.hpp:224
basic_vector< int32_t, 3 > vector3i32
Definition: numerical.hpp:390
matrix13f mat13f
Definition: numerical.hpp:826
std::optional< col_vec2 > optional_col_vec2
Definition: numerical.hpp:357
value_type distance(const self_type &right) const
Definition: numerical.hpp:159
std::optional< vec2 > optional_vec2
Definition: numerical.hpp:352
std::optional< mat11f > optional_mat1f
Definition: numerical.hpp:880
basic_matrix< float, 1, 4 > matrix14f
Definition: numerical.hpp:815
bool aabb_intersects(const aabb &first, const aabb &second)
Definition: numerical.hpp:1101
matrix32 mat32
Definition: numerical.hpp:742
basic_vector(value_type x, value_type y, value_type z, typename std::enable_if_t< Size==3, SFINAE >=0)
Definition: numerical.hpp:210
std::optional< mat22f > optional_mat22f
Definition: numerical.hpp:864
std::optional< vec2_list > optional_vec2_list
Definition: numerical.hpp:369
std::optional< mat43f > optional_mat43f
Definition: numerical.hpp:875
aabb_2d(const vec2 &aMin, const vec2 &aMax)
Definition: numerical.hpp:1123
vector1f vec1f
Definition: numerical.hpp:383
std::optional< matrix13 > optional_matrix13
Definition: numerical.hpp:765
optional_vec3_list optional_vertices_t
Definition: numerical.hpp:376
std::optional< matrix44 > optional_matrix44
Definition: numerical.hpp:767
basic_vector< T, D, Type, IsScalar > operator-(const basic_vector< T, D, Type, IsScalar > &left, const basic_vector< T, D, Type, IsScalar > &right)
Definition: numerical.hpp:429
matrix24f mat24f
Definition: numerical.hpp:833
matrix23 mat23
Definition: numerical.hpp:744
basic_matrix< float, 2, 3 > matrix23f
Definition: numerical.hpp:810
std::optional< mat11f > optional_mat11f
Definition: numerical.hpp:863
basic_vector< T2, Size, Type > as() const
Definition: numerical.hpp:238
matrix41 mat41
Definition: numerical.hpp:746
vector2 vec2
Definition: numerical.hpp:332
std::optional< mat41f > optional_mat41f
Definition: numerical.hpp:873
basic_matrix< double, 1, 1 > matrix11
Definition: numerical.hpp:714
basic_vector< double, 2, row_vector > row_vec2
Definition: numerical.hpp:342
std::optional< matrix14f > optional_matrix14f
Definition: numerical.hpp:854
basic_matrix< float, 4, 1 > matrix41f
Definition: numerical.hpp:812
mat44 affine_rotation_matrix(const vec3 &angles)
Definition: numerical.hpp:1251
std::optional< matrix11 > optional_matrix1
Definition: numerical.hpp:775
basic_matrix< double, 3, 1 > matrix31
Definition: numerical.hpp:719
std::optional< mat33f > optional_mat3f
Definition: numerical.hpp:882
bool operator==(const basic_vector &right) const
Definition: numerical.hpp:243
self_type max(const self_type &right) const
Definition: numerical.hpp:258
std::optional< vec1 > optional_vec1
Definition: numerical.hpp:351
std::optional< mat24 > optional_mat24
Definition: numerical.hpp:794
basic_matrix< double, 2, 4 > matrix24
Definition: numerical.hpp:728
std::optional< vec3_list > optional_vec3_list
Definition: numerical.hpp:370
const value_type * data() const
Definition: numerical.hpp:650
matrix33f mat33f
Definition: numerical.hpp:823
std::optional< matrix34f > optional_matrix34f
Definition: numerical.hpp:856
std::optional< row_vec3 > optional_row_vec3
Definition: numerical.hpp:363
std::optional< mat13 > optional_mat13
Definition: numerical.hpp:787
vector3 vec3
Definition: numerical.hpp:333
std::array< vec2, 4 > quad_2d
Definition: numerical.hpp:418
std::optional< matrix43 > optional_matrix43
Definition: numerical.hpp:770
std::optional< matrix44f > optional_matrix4f
Definition: numerical.hpp:861
basic_matrix< float, 2, 2 > matrix22f
Definition: numerical.hpp:803
std::optional< mat11 > optional_mat11
Definition: numerical.hpp:780
std::optional< matrix24 > optional_matrix24
Definition: numerical.hpp:772
basic_vector< value_type, Size, Type > vector_type
Definition: numerical.hpp:90
angle to_deg(angle aRadians)
Definition: numerical.hpp:66
basic_matrix< double, 3, 3 > matrix33
Definition: numerical.hpp:718
matrix22f mat22f
Definition: numerical.hpp:820
std::optional< mat13f > optional_mat13f
Definition: numerical.hpp:870
std::optional< mat44f > optional_mat4f
Definition: numerical.hpp:883
basic_matrix< T2, Rows, Columns > type
Definition: numerical.hpp:625
bool operator<(const basic_vector< T, Size, Type > &aLhs, const basic_vector< T, Size, Type > &aRhs)
Definition: numerical.hpp:291
aabb_2d(const aabb &aAabb)
Definition: numerical.hpp:1124
matrix11f mat11f
Definition: numerical.hpp:819
basic_matrix< float, 4, 2 > matrix42f
Definition: numerical.hpp:813
basic_vector< float, 1 > vector1f
Definition: numerical.hpp:378
self_type & operator/=(const self_type &right)
Definition: numerical.hpp:148
basic_matrix< T, Columns, Rows > transposed() const
Definition: numerical.hpp:685
matrix31f mat31f
Definition: numerical.hpp:824
basic_vector< uint32_t, 3 > vector3u32
Definition: numerical.hpp:400
self_type & operator*=(const self_type &right)
Definition: numerical.hpp:251
const column_type & operator[](uint32_t aColumn) const
Definition: numerical.hpp:648
matrix22f mat2f
Definition: numerical.hpp:837
vec2_list vertices_2d
Definition: numerical.hpp:372
basic_vector(const basic_vector< T2, Size, Type > &other)
Definition: numerical.hpp:117
std::optional< matrix31f > optional_matrix31f
Definition: numerical.hpp:846
std::optional< mat22 > optional_mat2
Definition: numerical.hpp:798
std::array< vec3, 3 > triangle
Definition: numerical.hpp:414
std::optional< matrix11f > optional_matrix1f
Definition: numerical.hpp:858
basic_matrix< double, 4, 2 > matrix42
Definition: numerical.hpp:725
basic_vector< T, 3, Type, IsScalar > midpoint(const basic_vector< T, 3, Type, IsScalar > &left, const basic_vector< T, 3, Type, IsScalar > &right)
Definition: numerical.hpp:593
std::optional< mat31f > optional_mat31f
Definition: numerical.hpp:868
self_type hadamard_product(const self_type &right) const
Definition: numerical.hpp:175
scalar aabb_volume(const aabb &a)
Definition: numerical.hpp:1085
self_type operator-() const
Definition: numerical.hpp:666
matrix42 mat42
Definition: numerical.hpp:747
std::optional< matrix42f > optional_matrix42f
Definition: numerical.hpp:852
self_type hadamard_product(const self_type &right) const
Definition: numerical.hpp:280
std::optional< matrix32 > optional_matrix32
Definition: numerical.hpp:764
basic_matrix(const basic_matrix< T2, Rows, Columns > &other)
Definition: numerical.hpp:632
basic_vector< T, D, Type, IsScalar > operator%(const basic_vector< T, D, Type, IsScalar > &left, const T &right)
Definition: numerical.hpp:509
matrix31 mat31
Definition: numerical.hpp:741
vector3f vec3f
Definition: numerical.hpp:385
basic_matrix< double, 3, 2 > matrix32
Definition: numerical.hpp:720
vector1 vec1
Definition: numerical.hpp:331
std::optional< vector1 > optional_vector1
Definition: numerical.hpp:346
std::optional< vec4 > optional_vec4
Definition: numerical.hpp:354
basic_vector(const basic_vector< T2, Size2, Type > &other, typename std::enable_if_t< Size2< Size, SFINAE >=0)
Definition: numerical.hpp:119
std::optional< matrix11f > optional_matrix11f
Definition: numerical.hpp:841
std::optional< mat42 > optional_mat42
Definition: numerical.hpp:791
matrix43f mat43f
Definition: numerical.hpp:831
basic_matrix(const self_type &other)
Definition: numerical.hpp:629
basic_vector(value_type x, typename std::enable_if_t< Size==1, SFINAE >=0)
Definition: numerical.hpp:100
matrix12f mat12f
Definition: numerical.hpp:822
std::optional< row_vec1 > optional_row_vec1
Definition: numerical.hpp:361
vector4i32 vec4i32
Definition: numerical.hpp:396
matrix21 mat21
Definition: numerical.hpp:738
matrix41f mat41f
Definition: numerical.hpp:829
matrix22 mat22
Definition: numerical.hpp:737
self_type & operator+=(const self_type &right)
Definition: numerical.hpp:249
std::optional< mat33f > optional_mat33f
Definition: numerical.hpp:867
matrix33 mat33
Definition: numerical.hpp:740
basic_matrix< float, 2, 1 > matrix21f
Definition: numerical.hpp:804
basic_vector(value_type x, typename std::enable_if_t< Size==1, SFINAE >=0)
Definition: numerical.hpp:206
std::optional< mat31 > optional_mat31
Definition: numerical.hpp:785
std::optional< matrix34 > optional_matrix34
Definition: numerical.hpp:773
std::optional< matrix31 > optional_matrix31
Definition: numerical.hpp:763
bool operator==(const self_type &right) const
Definition: numerical.hpp:139
basic_matrix(self_type &&other)
Definition: numerical.hpp:630
matrix14 mat14
Definition: numerical.hpp:749
basic_matrix< float, 4, 3 > matrix43f
Definition: numerical.hpp:814
self_type round_to(value_type aEpsilon) const
Definition: numerical.hpp:674
std::optional< mat43 > optional_mat43
Definition: numerical.hpp:792
basic_matrix< T, D, D > without_translation(const basic_matrix< T, D, D > &matrix)
Definition: numerical.hpp:1001
std::array< vec3, 4 > quad
Definition: numerical.hpp:415
vector3i32 vec3i32
Definition: numerical.hpp:395
matrix13 mat13
Definition: numerical.hpp:743
basic_vector(const basic_vector< T2, Size, Type > &other)
Definition: numerical.hpp:221
std::optional< matrix44f > optional_matrix44f
Definition: numerical.hpp:850
matrix11 matrix1
Definition: numerical.hpp:731
bool operator!=(const self_type &right) const
Definition: numerical.hpp:140
std::optional< vector4 > optional_vector4
Definition: numerical.hpp:349
basic_vector< T, D, Type, IsScalar > operator*(const basic_vector< T, D, Type, IsScalar > &left, const T &right)
Definition: numerical.hpp:473
value_type operator[](uint32_t aIndex) const
Definition: numerical.hpp:125
matrix32f mat32f
Definition: numerical.hpp:825
aabb(const vec3 &aMin, const vec3 &aMax)
Definition: numerical.hpp:1059
basic_vector< T, Columns, row_vector > row_type
Definition: numerical.hpp:620
std::optional< matrix21f > optional_matrix21f
Definition: numerical.hpp:843
std::optional< matrix32f > optional_matrix32f
Definition: numerical.hpp:847
std::optional< mat34f > optional_mat34f
Definition: numerical.hpp:878
std::optional< vector3 > optional_vector3
Definition: numerical.hpp:348
basic_vector< double, 4 > vector4
Definition: numerical.hpp:329
self_type & operator-=(const self_type &right)
Definition: numerical.hpp:250
self_type min(const self_type &right) const
Definition: numerical.hpp:257
std::optional< mat12f > optional_mat12f
Definition: numerical.hpp:866
matrix23f mat23f
Definition: numerical.hpp:827
std::optional< mat21 > optional_mat21
Definition: numerical.hpp:782
basic_vector(value_type x, value_type y, typename std::enable_if_t< Size==2, SFINAE >=0)
Definition: numerical.hpp:208
self_type min(const self_type &right) const
Definition: numerical.hpp:153
basic_vector< uint32_t, 2 > vector2u32
Definition: numerical.hpp:399
double angle
Definition: numerical.hpp:41
std::optional< mat23 > optional_mat23
Definition: numerical.hpp:788
matrix34 mat34
Definition: numerical.hpp:751
basic_vector(value_type &&value, Arguments &&... aArguments)
Definition: numerical.hpp:110
std::optional< matrix33f > optional_matrix33f
Definition: numerical.hpp:845
std::pair< uint32_t, uint32_t > size() const
Definition: numerical.hpp:647
vector3u32 vec3u32
Definition: numerical.hpp:405
std::optional< col_vec4 > optional_col_vec4
Definition: numerical.hpp:359
basic_vector(value_type x, value_type y, value_type z, typename std::enable_if_t< Size==3, SFINAE >=0)
Definition: numerical.hpp:104
std::optional< matrix41 > optional_matrix41
Definition: numerical.hpp:768
basic_matrix< float, 3, 4 > matrix34f
Definition: numerical.hpp:817
std::optional< matrix44 > optional_matrix4
Definition: numerical.hpp:778
std::optional< mat11 > optional_mat1
Definition: numerical.hpp:797
basic_vector< uint32_t, 1 > vector1u32
Definition: numerical.hpp:398
std::optional< mat24f > optional_mat24f
Definition: numerical.hpp:877
std::optional< matrix24f > optional_matrix24f
Definition: numerical.hpp:855
std::optional< matrix21 > optional_matrix21
Definition: numerical.hpp:760
std::optional< mat44 > optional_mat4
Definition: numerical.hpp:800
std::optional< matrix12f > optional_matrix12f
Definition: numerical.hpp:844
std::optional< aabb > optional_aabb
Definition: numerical.hpp:1078
basic_matrix< double, 4, 4 > matrix44
Definition: numerical.hpp:723
basic_matrix< T2, Rows, Columns > as() const
Definition: numerical.hpp:642
std::optional< col_vec1 > optional_col_vec1
Definition: numerical.hpp:356
basic_vector< double, 3, row_vector > row_vec3
Definition: numerical.hpp:343
basic_matrix< float, 2, 4 > matrix24f
Definition: numerical.hpp:816
matrix22 matrix2
Definition: numerical.hpp:732
self_type & operator=(std::initializer_list< value_type > values)
Definition: numerical.hpp:122
std::optional< matrix11 > optional_matrix11
Definition: numerical.hpp:758
std::optional< matrix33f > optional_matrix3f
Definition: numerical.hpp:860
self_type & operator/=(const self_type &right)
Definition: numerical.hpp:252
basic_vector(value_type x, value_type y, typename std::enable_if_t< Size==2, SFINAE >=0)
Definition: numerical.hpp:102
std::optional< matrix22f > optional_matrix22f
Definition: numerical.hpp:842
basic_vector(value_type &&value, Arguments &&... aArguments)
Definition: numerical.hpp:216
basic_vector< value_type, Size, Type > vector_type
Definition: numerical.hpp:196
basic_matrix< float, 1, 1 > matrix11f
Definition: numerical.hpp:802
bool operator!=(const self_type &right) const
Definition: numerical.hpp:653
basic_vector< T, D, Type, IsScalar > operator+(const basic_vector< T, D, Type, IsScalar > &left, const basic_vector< T, D, Type, IsScalar > &right)
Definition: numerical.hpp:421
matrix11f mat1f
Definition: numerical.hpp:836
basic_matrix< float, 1, 2 > matrix12f
Definition: numerical.hpp:805
basic_matrix< double, 1, 4 > matrix14
Definition: numerical.hpp:727
std::enable_if_t< Size==3, SFINAE > cross(const self_type &right) const
Definition: numerical.hpp:168
vector1i32 vec1i32
Definition: numerical.hpp:393
bool operator!=(const basic_vector< T, Size, Type > &aLhs, const basic_vector< T, Size, Type > &aRhs)
Definition: numerical.hpp:321
self_type & operator=(const self_type &other)
Definition: numerical.hpp:638
vector1u32 vec1u32
Definition: numerical.hpp:403
self_type scale(const self_type &right) const
Definition: numerical.hpp:150
std::optional< matrix22 > optional_matrix22
Definition: numerical.hpp:759
matrix44 mat44
Definition: numerical.hpp:745
std::optional< mat44f > optional_mat44f
Definition: numerical.hpp:872
vector2f vec2f
Definition: numerical.hpp:384
std::optional< aabb_2d > optional_aabb_2d
Definition: numerical.hpp:1154
self_type & operator=(std::initializer_list< value_type > values)
Definition: numerical.hpp:226
basic_matrix< double, 2, 3 > matrix23
Definition: numerical.hpp:722
std::optional< matrix41f > optional_matrix41f
Definition: numerical.hpp:851
basic_vector(const basic_vector< T2, Size2, Type > &other, typename std::enable_if_t< Size2< Size, SFINAE >=0)
Definition: numerical.hpp:223
std::optional< mat14f > optional_mat14f
Definition: numerical.hpp:876
double scalar
Definition: numerical.hpp:40
std::optional< mat44 > optional_mat44
Definition: numerical.hpp:789
std::array< column_type, Columns > array_type
Definition: numerical.hpp:622
static const std::enable_if_t< Rows==Columns, SFINAE > & identity()
Definition: numerical.hpp:694
std::optional< vec3 > optional_vec3
Definition: numerical.hpp:353
self_type & operator=(self_type &&other)
Definition: numerical.hpp:121
basic_vector(const swizzle< V, A, S, Indexes... > &aSwizzle)
Definition: numerical.hpp:113
std::optional< row_vec4 > optional_row_vec4
Definition: numerical.hpp:364
basic_vector< double, 3 > vector3
Definition: numerical.hpp:328
std::optional< matrix22 > optional_matrix2
Definition: numerical.hpp:776
basic_vector(value_type x, value_type y, value_type z, value_type w, typename std::enable_if_t< Size==4, SFINAE >=0)
Definition: numerical.hpp:212
self_type scale(const self_type &right) const
Definition: numerical.hpp:254
basic_vector< T2, Size, Type > as() const
Definition: numerical.hpp:134
std::array< vec2, 3 > triangle_2d
Definition: numerical.hpp:417
bool aabb_contains(const aabb &outer, const aabb &inner)
Definition: numerical.hpp:1091
std::optional< mat33 > optional_mat33
Definition: numerical.hpp:784
basic_matrix< float, 3, 3 > matrix33f
Definition: numerical.hpp:806
column_type & operator[](uint32_t aColumn)
Definition: numerical.hpp:649
basic_vector< double, 1, row_vector > row_vec1
Definition: numerical.hpp:341
bool operator==(const self_type &right) const
Definition: numerical.hpp:652
std::optional< row_vec2 > optional_row_vec2
Definition: numerical.hpp:362
bool operator==(const basic_vector< T, Size, Type > &aLhs, const basic_vector< T, Size, Type > &aRhs)
Definition: numerical.hpp:315
std::optional< matrix23 > optional_matrix23
Definition: numerical.hpp:766
std::optional< mat12 > optional_mat12
Definition: numerical.hpp:783
std::optional< mat42f > optional_mat42f
Definition: numerical.hpp:874
basic_vector< T, Rows, column_vector > column_type
Definition: numerical.hpp:621
vector2u32 vec2u32
Definition: numerical.hpp:404
basic_matrix< float, 3, 2 > matrix32f
Definition: numerical.hpp:808
std::vector< vec3 > vec3_list
Definition: numerical.hpp:367
std::optional< matrix22f > optional_matrix2f
Definition: numerical.hpp:859
basic_vector(const value_type &value, Arguments &&... aArguments)
Definition: numerical.hpp:108
basic_vector(value_type x, value_type y, value_type z, value_type w, typename std::enable_if_t< Size==4, SFINAE >=0)
Definition: numerical.hpp:106
matrix33f mat3f
Definition: numerical.hpp:838
std::optional< mat33 > optional_mat3
Definition: numerical.hpp:799
basic_matrix< double, 3, 4 > matrix34
Definition: numerical.hpp:729
basic_vector< int32_t, 1 > vector1i32
Definition: numerical.hpp:388
basic_vector< double, 2 > vector2
Definition: numerical.hpp:327
aabb aabb_union(const aabb &left, const aabb &right)
Definition: numerical.hpp:1080
basic_vector< double, 4, row_vector > row_vec4
Definition: numerical.hpp:344
vec3_list vertices
Definition: numerical.hpp:373
std::vector< vec2 > vec2_list
Definition: numerical.hpp:366
self_type & operator+=(const self_type &right)
Definition: numerical.hpp:654
basic_vector< int32_t, 4 > vector4i32
Definition: numerical.hpp:391
std::optional< mat22f > optional_mat2f
Definition: numerical.hpp:881
std::optional< mat32f > optional_mat32f
Definition: numerical.hpp:869
basic_vector< T, D, Type, IsScalar > operator/(const basic_vector< T, D, Type, IsScalar > &left, const T &right)
Definition: numerical.hpp:491
std::optional< matrix14 > optional_matrix14
Definition: numerical.hpp:771
matrix44 matrix4
Definition: numerical.hpp:734
pair< std::decay_t< T1 >, std::decay_t< T2 > > make_pair(T1 &&aFirst, T2 &&aSecond)
Definition: pair.hpp:85
self_type & operator=(self_type &&other)
Definition: numerical.hpp:639