Itasca C++ Interface
vect.h
Go to the documentation of this file.
1 #pragma once
7 #include "basestring.h"
8 #include "to.h"
9 #include <cmath>
10 #include <array>
11 
12 #ifdef _LINUX
13 namespace std {
14  template <class T> T abs(const T &t) {
15  if (t<0) return -t;
16  return t;
17  }
18  template <class T> T max0(const T &t1,const T &t2) {
19  if (t2>t1) return t2;
20  return t1;
21  }
22  template <class T> T min0(const T &t1,const T &t2) {
23  if (t2<t1) return t1;
24  return t1;
25  }
26 } // namespace std
27 #endif
28 
31 PUSHWARNING
32 VSWARNING(26594)
33 VSWARNING(4702) // Unreachable code warnings in release (?)
34 template <class T> class Vector2 {
35  public:
36  using CompType = T;
37  static constexpr uint32 vdim = 2;
38 
39  // Creators
41 #ifdef _DEBUG
42  constexpr Vector2() : a_({initVal<T>(),initVal<T>()}) { }
43 #else
44  Vector2() { }
45 #endif
47  constexpr Vector2(const Vector2<T> &v) : a_(v.a_) { }
49  constexpr Vector2(const T &x,const T &y) : a_({x,y}) { }
51  explicit constexpr Vector2(const T &t) : a_({t,t}) { }
52  constexpr const Vector2<T> &operator=(const Vector2<T> &in) { a_ = in.a_; return *this; }
54  static Vector2<T> nothing() { Vector2<T> v(limits<T>::max(),-limits<T>::max()); return v; }
55 
56  // Accessorse
58  constexpr const T &x() const { return a_[0]; }
60  constexpr const T &y() const { return a_[1]; }
62  constexpr const T &dof(unsigned u) const { return a_[u]; }
64  T &rx() { return a_[0]; }
66  T &ry() { return a_[1]; }
68  T &rdof(unsigned u) { return a_[u]; }
70  constexpr const T &operator[](unsigned u) const { return dof(u); }
71  T & operator[](unsigned u) { return rdof(u); }
72  template <std::size_t N> constexpr decltype(auto) get() const {
73  static_assert(N<2,"Index out of range");
74  return a_[N];
75  }
76 
77  // Various norms
79  constexpr T fsum() const { return (std::abs(x())+std::abs(y())); }
81  constexpr T sum() const { return x() + y(); }
83  constexpr T mag2() const { return (x()*x()+y()*y()); }
85  constexpr T mag() const { return to<T>(std::sqrt(to<double>(mag2()))); }
87  constexpr T area() const { return (x()*y()); }
89  constexpr T volume() const { return area(); }
91  constexpr T spread() const { return (y() -x()); }
93  constexpr Vector2<T> unit() const { Vector2<T> v(*this); T m(v.mag()); if (m) v/=m; return v; }
95  constexpr Vector2<T> abs() const { Vector2<T> v(std::abs(x()),std::abs(y())); return v; }
97  constexpr void fill(const T &d) { rx()=d; ry()=d; }
99  constexpr T maxComp() const { return std::max(x(),y()); }
101  constexpr T minComp() const { return std::min(x(),y()); }
103  constexpr unsigned maxCompIndex() const { return x() > y() ? 0 : 1; }
105  constexpr unsigned minCompIndex() const { return x() < y() ? 0 : 1; }
107  constexpr const Vector2<T> &safeDivE(const Vector2<T> &v) { rx()=::safeDiv(x(),v.x()); ry() = ::safeDiv(y(),v.y()); return *this; }
109  constexpr const Vector2<T> safeDiv(const Vector2<T> &v) { Vector2<T> ret(::safeDiv(x(),v.x()),::safeDiv(y(),v.y())); return ret; }
110 
112  constexpr bool operator==(const Vector2<T> &v) const { return ((x()==v.x())&&(y()==v.y())); }
114  constexpr bool operator!=(const Vector2<T> &v) const { return ((x()!=v.x())||(y()!=v.y())); }
116  constexpr bool operator<(const Vector2<T> &v) const { if (x()!=v.x()) return x()<v.x(); return y()<v.y(); }
118  constexpr bool operator>(const Vector2<T> &v) const { if (x()!=v.x()) return x()>v.x(); return y()>v.y(); }
119 
120  // In-place operators
122  constexpr const Vector2<T> &operator+=(const Vector2<T> &v) { rx()+=v.x(); ry()+=v.y(); return *this; }
123  constexpr const Vector2<T> &operator-=(const Vector2<T> &v) { rx()-=v.x(); ry()-=v.y(); return *this; }
124  constexpr const Vector2<T> &operator*=(const Vector2<T> &v) { rx()*=v.x(); ry()*=v.y(); return *this; }
125  constexpr const Vector2<T> &operator*=(const T &t) { rx()*=t; ry()*=t; return *this; }
126  constexpr const Vector2<T> &operator/=(const Vector2<T> &v) { rx()/=v.x(); ry()/=v.y(); return *this; }
127  constexpr const Vector2<T> &operator/=(const T &t) { rx()/=t; ry()/=t; return *this; }
128 
129  // Binary operators - require temp (ugh)
131  constexpr Vector2<T> operator+(const Vector2<T> &v) const { Vector2<T> out(x()+v.x(),y()+v.y()); return out; }
132  constexpr Vector2<T> operator-(const Vector2<T> &v) const { Vector2<T> out(x()-v.x(),y()-v.y()); return out; }
133  constexpr Vector2<T> operator*(const Vector2<T> &v) const { Vector2<T> out(x()*v.x(),y()*v.y()); return out; }
134  constexpr Vector2<T> operator*(const T &t) const { Vector2<T> out(x()*t,y()*t); return out; }
135  constexpr Vector2<T> operator/(const Vector2<T> &v) const { Vector2<T> out(x()/v.x(),y()/v.y()); return out; }
136  constexpr Vector2<T> operator/(const T &t) const { Vector2<T> out(x()/t,y()/t); return out; }
137  // Cross Product (see DAVect)
139  constexpr T operator|(const Vector2<T> &v) const { return (x()*v.x()+y()*v.y()); }
140 
141  // Support for use of a Vect2 as a range (min,max)
143  constexpr const Vector2<T> &expandToInclude(const T &t) { rx() = std::min(x(),t); ry() = std::max(y(),t); return *this; }
145  constexpr const Vector2<T> &expandToInclude(const Vector2<T> &v) { rx() = std::min(x(),v.minComp()); ry() = std::max(y(),v.maxComp()); return *this; }
147  constexpr Vector2<T> expandedToInclude(const T &t) const { Vector2<T> ret(*this); ret.expandToInclude(t); return ret; }
149  constexpr Vector2<T> expandedToInclude(const Vector2<T> &v) const { Vector2<T> ret(*this); ret.expandToInclude(v); return ret; }
151  constexpr bool contains(const T &t) const { if (t<x()) return false; if (t>y()) return false; return true; }
152 
153 private:
154  std::array<T,2> a_;
155 };
156 POPWARNING
157 
160 PUSHWARNING
161 VSWARNING(26495) // Uninitialize in VS code analysis - on purpose
162 VSWARNING(4702) // Weird unreachable code warnings in release
163 template <class T> class Vector3 {
164  public:
165  using CompType = T;
166  static constexpr uint32 vdim = 3;
167  // Creators
169 #ifdef _DEBUG
170  constexpr Vector3() : a_({initVal<T>(),initVal<T>(),initVal<T>()}) { }
171 #else
172  Vector3() { }
173 #endif
175  constexpr Vector3(const Vector3<T> &v) : a_(v.a_) { }
177  constexpr Vector3(const T &x,const T &y,const T &z=0) : a_({x,y,z}) { }
179  explicit constexpr Vector3(const T &t) : a_({t,t,t}) { }
180  constexpr const Vector3<T> &operator=(const Vector3<T> &in) { a_ = in.a_; return *this; }
181 
182  // Accessors
184  constexpr const T &x() const { return a_[0]; }
186  constexpr const T &y() const { return a_[1]; }
188  constexpr const T &z() const { return a_[2]; }
190  constexpr const T &dof(unsigned u) const { return a_[u]; }
192  T &rx() { return a_[0]; }
194  T &ry() { return a_[1]; }
196  T &rz() { return a_[2]; }
198  T &rdof(unsigned u) { return a_[u]; }
200  constexpr const T &operator[](unsigned u) const { return dof(u); }
202  T &operator[](unsigned u) { return rdof(u); }
203  template <std::size_t N> constexpr T get() const {
204  static_assert(N<3,"Index out of range");
205  return a_[N];
206  }
207 
208  // Various norms
210  constexpr T fsum() const { return (std::abs(x())+std::abs(y())+std::abs(z())); }
212  constexpr T sum() const { return x()+y()+z(); }
214  constexpr T mag2() const { return (x()*x()+y()*y()+z()*z()); }
216  constexpr T mag() const { return to<T>(std::sqrt(to<double>(mag2()))); }
218  constexpr T volume() const { return (x()*y()*z()); }
220  Vector3<T> unit() const { Vector3<T> v(*this); T m(v.mag()); if (m) v/=m; return v; }
222  constexpr Vector3<T> abs() const { Vector3<T> v(std::abs(x()),std::abs(y()),std::abs(z())); return v; }
224  void fill(const T &d) { rx()=d; ry()=d; rz()=d; }
226  constexpr T maxComp() const { return std::max(x(),std::max(y(),z())); }
228  constexpr T minComp() const { return std::min(x(),std::min(y(),z())); }
230  constexpr unsigned maxCompIndex() const { return x() > y() ? (x() > z() ? 0 : 2) : (y() > z() ? 1 : 2); }
232  constexpr unsigned minCompIndex() const { return x() < y() ? (x() < z() ? 0 : 2) : (y() < z() ? 1 : 2); }
234  constexpr const Vector3<T> &safeDivE(const Vector3<T> &v) { rx()=::safeDiv(x(),v.x()); ry() = ::safeDiv(y(),v.y()); rz() = ::safeDiv(z(),v.z()); return *this; }
236  constexpr const Vector3<T> safeDiv(const Vector3<T> &v) { Vector3<T> ret(::safeDiv(x(),v.x()),::safeDiv(y(),v.y()),::safeDiv(z(),v.z())); return ret; }
237 
239  constexpr bool operator==(const Vector3<T> &v) const { return ((x()==v.x())&&(y()==v.y())&&(z()==v.z())); }
241  constexpr bool operator!=(const Vector3<T> &v) const { return ((x()!=v.x())||(y()!=v.y())||(z()!=v.z())); }
243  constexpr bool operator<(const Vector3<T> &v) const { if (x()!=v.x()) return x()<v.x(); if (y()!=v.y()) return y()<v.y(); return z()<v.z(); }
245  constexpr bool operator>(const Vector3<T> &v) const { if (x()!=v.x()) return x()>v.x(); if (y()!=v.y()) return y()>v.y(); return z()>v.z(); }
246 
247  // In-place operators
249  constexpr const Vector3<T> &operator+=(const Vector3<T> &v) { rx()+=v.x(); ry()+=v.y(); rz()+=v.z(); return *this; }
250  constexpr const Vector3<T> &operator-=(const Vector3<T> &v) { rx()-=v.x(); ry()-=v.y(); rz()-=v.z(); return *this; }
251  constexpr const Vector3<T> &operator*=(const Vector3<T> &v) { rx()*=v.x(); ry()*=v.y(); rz()*=v.z(); return *this; }
252  constexpr const Vector3<T> &operator*=(const T &t) { rx()*=t; ry()*=t; rz()*=t; return *this; }
253  constexpr const Vector3<T> &operator/=(const Vector3<T> &v) { rx()/=v.x(); ry()/=v.y(); rz()/=v.z(); return *this; }
254  constexpr const Vector3<T> &operator/=(const T &t) { rx()/=t; ry()/=t; rz()/=t; return *this; }
255 
256  // Binary operators - require temp (ugh)
258  constexpr Vector3<T> operator+(const Vector3<T> &v) const { Vector3<T> out(x()+v.x(),y()+v.y(),z()+v.z()); return out; }
259  constexpr Vector3<T> operator-(const Vector3<T> &v) const { Vector3<T> out(x()-v.x(),y()-v.y(),z()-v.z()); return out; }
260  constexpr Vector3<T> operator*(const Vector3<T> &v) const { Vector3<T> out(x()*v.x(),y()*v.y(),z()*v.z()); return out; }
261  constexpr Vector3<T> operator*(const T &t) const { Vector3<T> out(x()*t,y()*t,z()*t); return out; }
262  constexpr Vector3<T> operator/(const Vector3<T> &v) const { Vector3<T> out(x()/v.x(),y()/v.y(),z()/v.z()); return out; }
263  constexpr Vector3<T> operator/(const T &t) const { Vector3<T> out(x()/t,y()/t,z()/t); return out; }
265  constexpr Vector3<T> operator&(const Vector3<T> &v) const {
266  Vector3<T> out((y()*v.z())-(z()*v.y()),(z()*v.x())-(x()*v.z()),(x()*v.y())-(y()*v.x()));
267  return out;
268  }
270  constexpr T operator|(const Vector3<T> &v) const { return (x()*v.x()+y()*v.y()+z()*v.z()); }
271 
272 private:
273  std::array<T,3> a_;
274 };
275 POPWARNING
276 
277 // Naming convention for most commonly used types.
278 typedef Vector2<double> DVect2;
279 typedef Vector2<float> FVect2;
280 typedef Vector2<int32> IVect2;
281 typedef Vector2<uint32> UVect2;
282 typedef Vector2<int64> I64Vect2;
283 typedef Vector2<uint64> U64Vect2;
284 
285 typedef Vector3<double> DVect3;
286 typedef Vector3<float> FVect3;
287 typedef Vector3<int32> IVect3;
288 typedef Vector3<uint32> UVect3;
289 typedef Vector3<int64> I64Vect3;
290 typedef Vector3<uint64> U64Vect3;
291 
292 // Conversion routines.
295 template <class T> inline constexpr DVect2 toDVect2(const Vector2<T> &v) { DVect2 dv2(to<double>(v.x()),to<double>(v.y())); return dv2; }
298 template <class T> inline constexpr FVect2 toFVect2(const Vector2<T> &v) { FVect2 fv2(to<float>(v.x()),to<float>(v.y())); return fv2; }
301 template <class T> inline constexpr IVect2 toIVect2(const Vector2<T> &v) { IVect2 iv2(to<int32>(v.x()),to<int32>(v.y())); return iv2; }
302 template <class T> inline constexpr I64Vect2 toI64Vect2(const Vector2<T> &v) { I64Vect2 iv2(to<int64>(v.x()),to<int64>(v.y())); return iv2; }
305 template <class T> inline constexpr UVect2 toUVect2(const Vector2<T> &v) { UVect2 uv2(to<uint32>(v.x()),to<uint32>(v.y())); return uv2; }
306 template <class T> inline constexpr U64Vect2 toU64Vect2(const Vector2<T> &v) { U64Vect2 uv2(to<uint64>(v.x()),to<uint64>(v.y())); return uv2; }
307 
310 template <class T> inline constexpr DVect3 toDVect3(const Vector3<T> &v) {
311  DVect3 dv3(to<double>(v.x()),to<double>(v.y()),to<double>(v.z()));
312  return dv3;
313 }
316 template <class T> inline constexpr FVect3 toFVect3(const Vector3<T> &v) {
317  FVect3 fv3(to<float>(v.x()),to<float>(v.y()),to<float>(v.z()));
318  return fv3;
319 }
322 template <class T> inline constexpr IVect3 toIVect3(const Vector3<T> &v) {
323  IVect3 iv3(to<int32>(v.x()),to<int32>(v.y()),to<int32>(v.z()));
324  return iv3;
325 }
326 template <class T> inline I64Vect3 toI64Vect3(const Vector3<T> &v) {
327  I64Vect3 iv3(to<int64>(v.x()),to<int64>(v.y()),to<int64>(v.z()));
328  return iv3;
329 }
332 template <class T> inline constexpr U64Vect3 toU64Vect3(const Vector3<T> &v) {
333  U64Vect3 uv3(to<uint64>(v.x()),to<uint64>(v.y()),to<uint64>(v.z()));
334  return uv3;
335 }
336 
337 
339 template <class T> inline constexpr const Vector2<T> &toVect2(const Vector2<T> &v) { return v; }
340 template <class T> inline constexpr Vector2<T> toVect2(const Vector3<T> &v) { return Vector2<T>(v.x(),v.y()); }
341 template <class T> inline constexpr Vector3<T> toVect3(const Vector2<T> &v,const T &t=0) { return Vector3<T>(v.x(),v.y(),t); }
342 template <class T> inline constexpr const Vector3<T> &toVect3(const Vector3<T> &v) { return v; }
343 
344 
347 template <class T> inline constexpr Vector2<T> vmax(const Vector2<T> &v1,const Vector2<T> &v2) {
348  Vector2<T> out(std::max<T>(v1.x(),v2.x()),std::max<T>(v1.y(),v2.y()));
349  return out;
350 }
353 template <class T> inline constexpr Vector2<T> vmin(const Vector2<T> &v1,const Vector2<T> &v2) {
354  Vector2<T> out(std::min<T>(v1.x(),v2.x()),std::min<T>(v1.y(),v2.y()));
355  return out;
356 }
357 
360 template <class T> inline constexpr Vector2<T> vsign(const Vector2<T> &v1,const Vector2<T> &v2) {
361  Vector2<T> out(v2.x() < 0 ? -qAbs(v1.x()) : qAbs(v1.x()) ,v2.y() < 0 ? -qAbs(v1.y()) : qAbs(v1.y()));
362  return out;
363 }
364 
367 template <class T> inline constexpr Vector3<T> vmax(const Vector3<T> &v1,const Vector3<T> &v2) {
368  Vector3<T> out(std::max<T>(v1.x(),v2.x()),std::max<T>(v1.y(),v2.y()),std::max<T>(v1.z(),v2.z()));
369  return out;
370 }
373 template <class T> inline constexpr Vector3<T> vmin(const Vector3<T> &v1,const Vector3<T> &v2) {
374  Vector3<T> out(std::min<T>(v1.x(),v2.x()),std::min<T>(v1.y(),v2.y()),std::min<T>(v1.z(),v2.z()));
375  return out;
376 }
377 
380 template <class T> inline constexpr Vector3<T> vsign(const Vector3<T> &v1,const Vector3<T> &v2) {
381  Vector3<T> out(v2.x() < 0 ? -qAbs(v1.x()) : qAbs(v1.x()), v2.y() < 0 ? -qAbs(v1.y()) : qAbs(v1.y()), v2.z() < 0 ? -qAbs(v1.z()) : qAbs(v1.z()));
382  return out;
383 }
384 
387 template <class T> inline Vector2<T> vceil(const Vector2<T> &v) {
388  Vector2<T> out(ceil(v.x()),ceil(v.y()));
389  return out;
390 }
391 
394 template <class T> inline Vector3<T> vceil(const Vector3<T> &v) {
395  Vector3<T> out(ceil(v.x()),ceil(v.y()),ceil(v.z()));
396  return out;
397 }
398 
401 template <class T> inline Vector2<T> vfloor(const Vector2<T> &v) {
402  Vector2<T> out(floor(v.x()),floor(v.y()));
403  return out;
404 }
405 
408 template <class T> inline Vector3<T> vfloor(const Vector3<T> &v) {
409  Vector3<T> out(floor(v.x()),floor(v.y()),floor(v.z()));
410  return out;
411 }
412 
415 template <class T> IVect2 vround(const Vector2<T> &v) {
416  IVect2 out(qRound(v.x()),qRound(v.y()));
417  return out;
418 }
419 
422 template <class T> IVect3 constexpr vround(const Vector3<T> &v) {
423  IVect3 out(qRound(v.x()),qRound(v.y()),qRound(v.z()));
424  return out;
425 }
426 template <class T> I64Vect3 constexpr v64round(const Vector3<T> &v) {
427  I64Vect3 out(std::llround(v.x()),std::llround(v.y()),std::llround(v.z()));
428  return out;
429 }
430 
431 namespace std {
433  template <class T> constexpr Vector2<T> max(const Vector2<T> &v1,const Vector2<T> &v2) { return vmax(v1,v2); }
435  template <class T> constexpr Vector2<T> min(const Vector2<T> &v1,const Vector2<T> &v2) { return vmin(v1,v2); }
437  template <class T> constexpr Vector3<T> max(const Vector3<T> &v1,const Vector3<T> &v2) { return vmax(v1,v2); }
439  template <class T> constexpr Vector3<T> min(const Vector3<T> &v1,const Vector3<T> &v2) { return vmin(v1,v2); }
440 
442  template <class T> struct tuple_size<Vector2<T>> : std::integral_constant<std::size_t, 2> {};
443  template <class T> struct tuple_size<Vector3<T>> : std::integral_constant<std::size_t, 3> {};
444  template <std::size_t N,class T> struct tuple_element<N, Vector2<T>> { using type = T; };
445  template <std::size_t N,class T> struct tuple_element<N, Vector3<T>> { using type = T; };
446 }
447 
448 namespace base {
449  // ts (tostring) support for vectors
450  // fs (fromstring) support not implemented yet.
451  namespace basehelper {
452  template <typename T>
453  string tsVect(const Vector2<T> &t, int width, char notation, int precision, char fill) {
454  if (abs(width) > 5) width = width < 0 ? -abs(abs(width) - 3) : abs(abs(width) - 3); // Subtraci (,)
455  else width = 0;
456  int w2 = std::abs(width)/2;
457  int w1 = std::abs(width) - w2;
458  if (width<0) { w1 *= -1; w2 *= -1; }
459  return "("+ts(t.x(), w1, notation, precision, fill)+","
460  +ts(t.y(), w2, notation, precision, fill)+")";
461  }
462  template <typename T>
463  string tsVect(const Vector3<T> &t, int width, char notation, int precision, char fill) {
464  if (abs(width) > 7) width = width < 0 ? -abs(abs(width) - 4) : abs(abs(width) - 4);// Subtraci (,,)
465  else width = 0;
466  int w3 = std::abs(width)/3;
467  int w2 = (std::abs(width)-w3)/2;
468  int w1 = std::abs(width) - w2 - w3;
469  if (width<0) { w1 *= -1; w2 *= -1; w3 *= -1; }
470  return "("+ts(t.x(), w1, notation, precision, fill)+","
471  +ts(t.y(), w2, notation, precision, fill)+","
472  +ts(t.z(), w3, notation, precision, fill)+")";
473  }
474  }
475 
476  template <>
477  inline string ts(const DVect2 &t, int width, char notation, int precision, char fill) {
478  return basehelper::tsVect(t, width, notation, precision, fill);
479  }
480 
481  template <>
482  inline string ts(const DVect3 &t, int width, char notation, int precision, char fill) {
483  return basehelper::tsVect(t, width, notation, precision, fill);
484  }
485 
486  template <>
487  inline string ts(const IVect2 &t, int width, char notation, int precision, char fill) {
488  return basehelper::tsVect(t, width, notation, precision, fill);
489  }
490 
491  template <>
492  inline string ts(const IVect3 &t, int width, char notation, int precision, char fill) {
493  return basehelper::tsVect(t, width, notation, precision, fill);
494  }
495 
496  template <>
497  inline string ts(const I64Vect2 &t, int width, char notation, int precision, char fill) {
498  return basehelper::tsVect(t, width, notation, precision, fill);
499  }
500 
501  template <>
502  inline string ts(const I64Vect3 &t, int width, char notation, int precision, char fill) {
503  return basehelper::tsVect(t, width, notation, precision, fill);
504  }
505 }
506 
507 // This allows you to send Vector2<T> to a fmt::format
508 // Each component is formatted as using fmt::format double format specification.
509 // This means if W is the given width the actual width will be 2*W+3
510 template <class T>
511 struct fmt::formatter<Vector2<T>> : public fmt::formatter<double> {
512  template <typename ParseContext>
513  constexpr auto parse(ParseContext &ctx) { return fmt::formatter<double>::parse(ctx); }
514 
515  // I'm sure there is a better way to do this
516  template <typename FormatContext>
517  auto format(Vector2<T> const &val, FormatContext &ctx) {
518  format_to(ctx.out(),"(");
519  fmt::formatter<double>::format(val.x(),ctx);
520  format_to(ctx.out(),",");
521  fmt::formatter<double>::format(val.y(),ctx);
522  return format_to(ctx.out(),")");
523  }
524 };
525 
526 // This allows you to send Vector3<T> to a fmt::format
527 // Each component is formatted as using fmt::format double format specification.
528 // This means if W is the given width the actual width will be 3*W+4
529 template <class T>
530 struct fmt::formatter<Vector3<T>> : public fmt::formatter<double> {
531  template <typename ParseContext>
532  constexpr auto parse(ParseContext &ctx) { return fmt::formatter<double>::parse(ctx); }
533 
534  // I'm sure there is a better way to do this
535  template <typename FormatContext>
536  auto format(Vector3<T> const &val, FormatContext &ctx) {
537  format_to(ctx.out(),"(");
538  fmt::formatter<double>::format(val.x(),ctx);
539  format_to(ctx.out(),",");
540  fmt::formatter<double>::format(val.y(),ctx);
541  format_to(ctx.out(),",");
542  fmt::formatter<double>::format(val.z(),ctx);
543  return format_to(ctx.out(),")");
544  }
545 };
547 // EoF
548 
QString helper functions, plus some additions.
debug checked shorthand for std::numeric_limits<T>::
Definition: limit.h:25
Vector3< T > vceil(const Vector3< T > &v)
Definition: vect.h:394
constexpr U64Vect3 toU64Vect3(const Vector3< T > &v)
Definition: vect.h:332
AVector3< T > vsign(const AVector3< T > &v1, const AVector3< T > &v2)
Definition: avect.h:289
constexpr FVect3 toFVect3(const Vector3< T > &v)
Definition: vect.h:316
constexpr Vector3< T > vmax(const Vector3< T > &v1, const Vector3< T > &v2)
Definition: vect.h:367
IVect2 toIVect2(const QPoint &p)
Convert a QPoint to an IVect2.
Definition: basetoqt.h:263
UVect2 toUVect2(const QPoint &p)
Convert a QPoint to a UVect2.
Definition: basetoqt.h:274
AVector3< T > vceil(const AVector3< T > &v)
Definition: avect.h:296
Vector2< T > operator&(const Vector2< T > &v, const AVector2< T > &av)
Definition: avect.h:140
Vector3< T > vfloor(const Vector3< T > &v)
Definition: vect.h:408
constexpr Vector2< T > operator*(const Matrix< T, 2, 2 > &m, const Vector2< T > &v)
Definition: matrix.h:987
FVect2 toFVect2(const QPoint &p)
Convert a QPoint to an FVect2.
Definition: basetoqt.h:258
PUSHWARNING VSWARNING(4702) template< class T > class Vector2
2D vector utility class.
Definition: vect.h:33
constexpr Vector3< T > vmin(const Vector3< T > &v1, const Vector3< T > &v2)
Definition: vect.h:373
constexpr DVect3 toDVect3(const Vector3< T > &v)
Definition: vect.h:310
constexpr IVect3 toIVect3(const Vector3< T > &v)
Definition: vect.h:322
constexpr const T safeDiv(const T num, const T denom)
This function provids "safe" division operation, checks explicitly for zero.
Definition: to.h:117
Vector2< T > toVect2(const AVector2< T > &)
Definition: avect.h:247
AVector3< T > vmax(const AVector3< T > &v1, const AVector3< T > &v2)
Definition: avect.h:275
constexpr Vector3< T > vsign(const Vector3< T > &v1, const Vector3< T > &v2)
Definition: vect.h:380
Vector3< T > toVect3(const AVector2< T > &v)
Definition: avect.h:250
constexpr IVect3 vround(const Vector3< T > &v)
Definition: vect.h:422
AVector3< T > vmin(const AVector3< T > &v1, const AVector3< T > &v2)
Definition: avect.h:282
T operator|(const Vector2< T > &, const AVector2< T > &)
Definition: avect.h:161
DVect2 toDVect2(const QPoint &p)
Convert a QPoint to a DVect2.
Definition: basetoqt.h:248
A overflow checked shorthand for static_cast<T>().
constexpr Vector2< T > max(const Vector2< T > &v1, const Vector2< T > &v2)
Template specialization for max, min.
Definition: vect.h:433
constexpr Vector2< T > min(const Vector2< T > &v1, const Vector2< T > &v2)
Template specialization for max, min.
Definition: vect.h:435