geolib2
math_types.h
Go to the documentation of this file.
1 #ifndef GEOLIB_MATH_TYPES_H_
2 #define GEOLIB_MATH_TYPES_H_
3 
4 #include <iostream>
5 #include <cmath>
6 
7 namespace geo {
8 
9 typedef double real;
10 
11 // Forward declare
12 template<typename T>
13 class Vec3T;
14 
15 template<typename T>
16 class Mat3T;
17 
18 template<typename T>
20 
21 // --------------------------------------------------------------------------------
22 
23 template<typename T>
24 class Vec2T
25 {
26 
27 public:
28  Vec2T() : x(), y() {}
29  Vec2T(const Vec2T& v) = default;
30  Vec2T(T x_, T y_) : x(x_), y(y_) {}
31  Vec2T(T value) : x(value), y(value) {}
32  Vec2T(const T* values) { memcpy(m, values, 2 * sizeof(T)); }
33 
34  Vec2T &operator=(const Vec2T &v) {
35  if (this != &v) {
36  x = v.x;
37  y = v.y;
38  }
39  return *this;
40  }
41 
42  ~Vec2T() {}
43 
44  T& operator[](const uint i) { return m[i]; }
45 
46  const T& operator[](const uint i) const { return m[i]; }
47 
48  bool operator==(const Vec2T& v) const {
49  return (x == v.x && y == v.y);
50  }
51 
52  bool operator!=(const Vec2T& v) const {
53  return !(*this == v);
54  }
55 
57  T dot(const Vec2T& v) const { return x * v.x + y * v.y; }
58 
60  T cross(const Vec2T& v) const { return x * v.y - y * v.x; }
61 
63  Vec2T operator+(const Vec2T& v) const { return Vec2T(x + v.x, y + v.y); }
64 
66  Vec2T operator-(const Vec2T& v) const { return Vec2T(x - v.x, y - v.y); }
67 
69  Vec2T operator*(T s) const { return Vec2T(x * s, y * s); }
70 
72  Vec2T operator/(T s) const { return Vec2T(x / s, y / s); }
73 
75  friend Vec2T operator*(T s, const Vec2T& v) { return Vec2T(v.x * s, v.y * s); }
76 
78  T length() const { return sqrt(x * x + y * y); }
79 
81  T length2() const { return x * x + y * y; }
82 
84  Vec2T normalized() const { T len = length(); return Vec2T(x / len, y / len); }
85 
87  void normalize() { T l = length(); x /= l; y /= l; }
88 
89  friend Vec2T operator-(const Vec2T& v) { return Vec2T(-v.x, -v.y); }
90 
91  Vec2T &operator+=(const Vec2T& v) { x += v.x; y += v.y; return *this; }
92  Vec2T &operator-=(const Vec2T& v) { x -= v.x; y -= v.y; return *this; }
93  Vec2T &operator*=(const Vec2T& v) { x *= v.x; y *= v.y; return *this; }
94  Vec2T &operator/=(const Vec2T& v) { x /= v.x; y /= v.y; return *this; }
95 
96  Vec2T &operator*=(T s) { x *= s; y *= s; return *this; }
97  Vec2T &operator/=(T s) { x /= s; y /= s; return *this; }
98 
104  return Vec3T<T>(x, y, 0);
105  }
106 
107  // serialize vector to stream
108  friend std::ostream& operator<< (std::ostream& out, const Vec2T& v) {
109  out << "[ " << v.x << " " << v.y << " ]";
110  return out;
111  }
112 
113  union {
114  struct { T x, y; };
115  T m[2];
116  };
117 };
118 
119 // --------------------------------------------------------------------------------
120 
121 template<typename T>
122 class Vec3T
123 {
124 
125 public:
126  Vec3T() : x(), y(), z() {}
127  Vec3T(const Vec3T& v) = default;
128  Vec3T(T x_, T y_, T z_) : x(x_), y(y_), z(z_) {}
129  Vec3T(T value) : x(value), y(value), z(value) {}
130  Vec3T(const T* values) { memcpy(m, values, 3 * sizeof(T)); }
131 
132  Vec3T &operator=(const Vec3T &v) {
133  if (this != &v) {
134  x = v.x;
135  y = v.y;
136  z = v.z;
137  }
138  return *this;
139  }
140 
141  ~Vec3T() {}
142 
143  T& operator[](const uint i) { return m[i]; }
144 
145  const T& operator[](const uint i) const { return m[i]; }
146 
147  bool operator==(const Vec3T& v) const {
148  return (x == v.x && y == v.y && z == v.z);
149  }
150 
151  bool operator!=(const Vec3T& v) const {
152  return !(*this == v);
153  }
154 
156  T dot(const Vec3T& v) const { return x * v.x + y * v.y + z * v.z; }
157 
159  Vec3T cross(const Vec3T& v) const { return Vec3T(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x ); }
160 
162  Vec3T operator+(const Vec3T& v) const { return Vec3T(x + v.x, y + v.y, z + v.z); }
163 
165  Vec3T operator-(const Vec3T& v) const { return Vec3T(x - v.x, y - v.y, z - v.z); }
166 
168  Vec3T operator*(T s) const { return Vec3T(x * s, y * s, z * s); }
169 
171  Vec3T operator/(T s) const { return Vec3T(x / s, y / s, z / s); }
172 
174  friend Vec3T operator*(T s, const Vec3T& v) { return Vec3T(v.x * s, v.y * s, v.z * s); }
175 
177  T length() const { return sqrt(x * x + y * y + z * z); }
178 
180  T length2() const { return x * x + y * y + z * z; }
181 
183  Vec3T normalized() const { T len = length(); return Vec3T(x / len, y / len, z / len); }
184 
186  void normalize() { T l = length(); x /= l; y /= l; z /= l; }
187 
188  friend Vec3T operator-(const Vec3T& v) { return Vec3T(-v.x, -v.y, -v.z); }
189 
190  Vec3T &operator+=(const Vec3T& v) { x += v.x; y += v.y; z += v.z; return *this; }
191  Vec3T &operator-=(const Vec3T& v) { x -= v.x; y -= v.y; z -= v.z; return *this; }
192  Vec3T &operator*=(const Vec3T& v) { x *= v.x; y *= v.y; z *= v.z; return *this; }
193  Vec3T &operator/=(const Vec3T& v) { x /= v.x; y /= v.y; z /= v.z; return *this; }
194 
195  Vec3T &operator*=(T s) { x *= s; y *= s; z *= s; return *this; }
196  Vec3T &operator/=(T s) { x /= s; y /= s; z /= s; return *this; }
197 
198  T getX() const { return x; }
199  T getY() const { return y; }
200  T getZ() const { return z; }
201 
207  return Vec2T<T>(x, y);
208  }
209 
210  // serialize vector to stream
211  friend std::ostream& operator<< (std::ostream& out, const Vec3T& v) {
212  out << "[ " << v.x << " " << v.y << " " << v.z << " ]";
213  return out;
214  }
215 
216  union {
217  struct { T x, y, z; };
218  T m[3];
219  };
220 };
221 
222 // --------------------------------------------------------------------------------
223 
224 template<typename T>
225 class Mat2T
226 {
227 
228 public:
229  Mat2T() : xx(), xy(), yx(), yy() {}
230  Mat2T(const Mat2T& v) = default;
231  Mat2T(T xx_, T xy_, T yx_, T yy_) : xx(xx_), xy(xy_), yx(yx_), yy(yy_) {}
232  Mat2T(T value) : xx(value), xy(value), yx(value), yy(value) {}
233 
234  Mat2T &operator=(const Mat2T &v) {
235  if (this != &v) {
236  xx = v.xx;
237  xy = v.xy;
238  yx = v.yx;
239  yy = v.yy;
240  }
241  return *this;
242  }
243 
244  ~Mat2T() {}
245 
246  T& operator[](const uint i) { return m[i]; }
247 
248  const T& operator[](const uint i) const { return m[i]; }
249 
250  bool operator==(const Mat2T& m) const {
251  return (xx == m.xx && xy == m.xy &&
252  yx == m.yx && yy == m.yy );
253  }
254 
255  bool operator!=(const Mat2T& m) const {
256  return !(*this == m);
257  }
258 
260  Mat2T operator+(const Mat2T& m) const { return Mat2T(xx + m.xx, xy + m.xy, yx + m.yx, yy + m.yy); }
261 
263  Mat2T operator-(const Mat2T& m) const { return Mat2T(xx - m.xx, xy - m.xy, yx - m.yx, yy - m.yy); }
264 
265  Vec2T<T> operator*(const Vec2T<T>& v) const { return Vec2T<T>(xx * v.x + xy * v.y, yx * v.x + yy * v.y); }
266 
268  Mat2T operator*(const Mat2T& m) const { return Mat2T(xx * m.xx + xy * m.yx, xx * m.xy + xy * m.yy,
269  yx * m.xx + yy * m.yx, yx * m.xy + yy * m.yy); }
270 
271  Mat2T transpose() const {
272  return Mat2T(xx, yx,
273  xy, yy);
274  }
275 
276  T& operator()(int i, int j) {
277  return m[i * 2 + j];
278  }
279 
280  const T& operator()(int i, int j) const {
281  return m[i * 2 + j];
282  }
283 
285  Mat2T operator*(T s) const { return Mat2T(xx * s, xy * s, yx * s, yy * s); }
286 
288  Mat2T operator/(T s) const { return Mat2T(xx / s, xy / s, yx / s, yy / s); }
289 
291  friend Mat2T operator*(T s, const Mat2T& m) { return Mat2T(m.xx * s, m.xy * s, m.yx * s, m.yy * s); }
292 
293  static Mat2T identity() { return Mat2T(1, 0, 0, 1); }
294 
300  return Mat3T<T>(xx, xy, 0,
301  yx, yy, 0,
302  0, 0, 1);
303  }
304 
305  // serialize matrix to stream
306  friend std::ostream& operator<< (std::ostream& out, const Mat2T& m) {
307  out << "[ " << m[0] << " " << m[1] << " ; "
308  << m[2] << " " << m[3] << " " << " ]";
309  return out;
310  }
311 
312  union {
313  struct { T xx, xy, yx, yy; };
314  T m[4];
315  };
316 
317 };
318 
319 // --------------------------------------------------------------------------------
320 
321 template<typename T>
323 {
324 
325 public:
326 
327  QuaternionT() : x(), y(), z(), w() {}
328  QuaternionT(const QuaternionT& q) = default;
329  QuaternionT(T x_, T y_, T z_, T w_) : x(x_), y(y_), z(z_), w(w_) {}
330 
332  if (this != &q) {
333  x = q.x;
334  y = q.y;
335  z = q.z;
336  w = q.w;
337  }
338  return *this;
339  }
340 
342 
343  T& operator[](const uint i) { return m[i]; }
344 
345  const T& operator[](const uint i) const { return m[i]; }
346 
347  bool operator==(const QuaternionT& q) const {
348  return (x == q.x && y == q.y && z == q.z && w == q.w);
349  }
350 
351  bool operator!=(const QuaternionT& q) const {
352  return !(*this == q);
353  }
354 
356  T dot(const QuaternionT& q) const { return x * q.x + y * q.y + z * q.z + w * q.w; }
357 
359  QuaternionT operator+(const QuaternionT& q) const { return QuaternionT(x + q.x, y + q.y, z + q.z, w + q.w); }
360 
362  QuaternionT operator-(const QuaternionT& q) const { return QuaternionT(x - q.x, y - q.y, z - q.z, w - q.w); }
363 
364  T getX() const { return x; }
365  T getY() const { return y; }
366  T getZ() const { return z; }
367  T getW() const { return w; }
368 
369  friend QuaternionT operator*(T s, const QuaternionT& q) { return QuaternionT(q.x * s, q.y * s, q.z * s, q.w * s); }
370 
371  QuaternionT operator*(T s) const { return QuaternionT(x * s, y * s, z * s, w * s); }
372 
374  T length() const { return sqrt(x * x + y * y + z * z + w * w); }
375 
377  T length2() const { return x * x + y * y + z * z + w * w; }
378 
380  QuaternionT normalized() const { T len = length(); return QuaternionT(x / len, y / len, z / len, w / len); }
381 
383  void normalize() { T l = length(); x /= l; y /= l; z /= l; w /= l; }
384 
386  out << "[ " << q.x << " " << q.y << " " << q.z << " " << q.w << " ]";
387  return out;
388  }
389 
390  union {
391  struct { T x, y, z, w; };
392  T m[4];
393  };
394 };
395 
396 // --------------------------------------------------------------------------------
397 
398 template<typename T>
399 class Mat3T
400 {
401 
402 public:
403  Mat3T() {}
404  Mat3T(const Mat3T& v) = default;
405 
406  Mat3T(T xx_, T xy_, T xz_, T yx_, T yy_, T yz_, T zx_, T zy_, T zz_)
407  : xx(xx_), xy(xy_), xz(xz_), yx(yx_), yy(yy_), yz(yz_), zx(zx_), zy(zy_), zz(zz_) {}
408 
409  Mat3T(T value) : xx(value), xy(value), xz(value), yx(value), yy(value), yz(value), zx(value), zy(value), zz(value) {}
410 
411  Mat3T(const T* values) { memcpy(m, values, 9 * sizeof(T)); }
412 
414  : xx(x.x), xy(y.x), xz(z.x), yx(x.y), yy(y.y), yz(z.y), zx(x.z), zy(y.z), zz(z.z) {}
415 
416  Mat3T &operator=(const Mat3T &m) {
417  if (this != &m) {
418  xx = m.xx; xy = m.xy; xz = m.xz;
419  yx = m.yx; yy = m.yy; yz = m.yz;
420  zx = m.zx; zy = m.zy; zz = m.zz;
421  }
422  return *this;
423  }
424 
425  ~Mat3T() {}
426 
427  T& operator[](const uint i) { return m[i]; }
428 
429  const T& operator[](const uint i) const { return m[i]; }
430 
431  bool operator==(const Mat3T& m) const {
432  return (xx == m.xx && xy == m.xy && xz == m.xz &&
433  yx == m.yx && yy == m.yy && yz == m.yz &&
434  zx == m.zx && zy == m.zy && zz == m.zz);
435  }
436 
437  bool operator!=(const Mat3T& m) const {
438  return !(*this == m);
439  }
440 
442  Mat3T operator+(const Mat3T& m) const { return Mat3T(xx + m.xx, xy + m.xy, xz + m.xz,
443  yx + m.yx, yy + m.yy, yz + m.yz,
444  zx + m.zx, zy + m.zy, zz + m.zz); }
445 
447  Mat3T operator-(const Mat3T& m) const { return Mat3T(xx - m.xx, xy - m.xy, xz - m.xz,
448  yx - m.yx, yy - m.yy, yz - m.yz,
449  zx - m.zx, zy - m.zy, zz - m.zz); }
450 
451  Vec3T<T> operator*(const Vec3T<T>& v) const {
452  return Vec3T<T>(xx * v.x + xy * v.y + xz * v.z,
453  yx * v.x + yy * v.y + yz * v.z,
454  zx * v.x + zy * v.y + zz * v.z); }
455 
456 
457  Mat3T operator*(const Mat3T& m) const {
458  return Mat3T(xx * m.xx + xy * m.yx + xz * m.zx, xx * m.xy + xy * m.yy + xz * m.zy, xx * m.xz + xy * m.yz + xz * m.zz,
459  yx * m.xx + yy * m.yx + yz * m.zx, yx * m.xy + yy * m.yy + yz * m.zy, yx * m.xz + yy * m.yz + yz * m.zz,
460  zx * m.xx + zy * m.yx + zz * m.zx, zx * m.xy + zy * m.yy + zz * m.zy, zx * m.xz + zy * m.yz + zz * m.zz); }
461 
463  Mat3T operator*(T s) const { return Mat3T(xx * s, xy * s, xz * s,
464  yx * s, yy * s, yz * s,
465  zx * s, zy * s, zz * s); }
466 
468  Mat3T operator/(T s) const { return Mat3T(xx / s, xy / s, xz / s,
469  yx / s, yy / s, yz / s,
470  zx / s, zy / s, zz / s); }
471 
472  T& operator()(int i, int j) {
473  return m[i * 3 + j];
474  }
475 
476  const T& operator()(int i, int j) const {
477  return m[i * 3 + j];
478  }
479 
481  friend Mat3T operator*(T s, const Mat3T& m) { return Mat3T(m.xx * s, m.xy * s, m.xz * s,
482  m.yx * s, m.yy * s, m.yz * s,
483  m.zx * s, m.zy * s, m.zz * s); }
484 
485  Mat3T transpose() const {
486  return Mat3T(xx, yx, zx,
487  xy, yy, zy,
488  xz, yz, zz);
489  }
490 
491  Vec3T<T> getRow(int i) const {
492  return Vec3T<T>(m[i*3], m[i*3+1], m[i*3+2]);
493  }
494 
495  Vec3T<T> getColumn(int i) const {
496  return Vec3T<T>(m[i], m[3+i], m[6+i]);
497  }
498 
499  void setRPY(T roll, T pitch, T yaw) {
500  T ci = cos(roll);
501  T cj = cos(pitch);
502  T ch = cos(yaw);
503  T si = sin(roll);
504  T sj = sin(pitch);
505  T sh = sin(yaw);
506  T cc = ci * ch;
507  T cs = ci * sh;
508  T sc = si * ch;
509  T ss = si * sh;
510 
511  m[0] = cj * ch; m[1] = sj * sc - cs; m[2] = sj * cc + ss;
512  m[3] = cj * sh; m[4] = sj * ss + cc, m[5] = sj * cs - sc;
513  m[6] = -sj; m[7] = cj * si; m[8] = cj * ci ;
514  }
515 
516  static Mat3T identity() {
517  return Mat3T(1, 0, 0, 0, 1, 0, 0, 0, 1);
518  }
519 
520  void getRotation(QuaternionT<T>& q) const {
521  T trace = xx + yy + zz;
522 
523  if (trace > 0) {
524  T s = sqrt(trace + 1);
525  q.m[3] = (s / 2);
526  s = 0.5 / s;
527 
528  q.m[0]=((zy - yz) * s);
529  q.m[1]=((xz - zx) * s);
530  q.m[2]=((yx - xy) * s);
531  } else {
532  int i = xx < yy ? (yy < zz ? 2 : 1) : (xx < zz ? 2 : 0);
533  int j = (i + 1) % 3;
534  int k = (i + 2) % 3;
535 
536  T s = sqrt(m[i*4] - m[j*4] - m[k*4] + 1);
537  q.m[i] = s / 2;
538  s = 0.5 / s;
539 
540  q.m[3] = (m[k*3+j] - m[j*3+k]) * s;
541  q.m[j] = (m[j*3+i] + m[i*3+j]) * s;
542  q.m[k] = (m[k*3+i] + m[i*3+k]) * s;
543  }
544  }
545 
546  void setRotation(const QuaternionT<T>& q) {
547  T d = q.length2();
548  T s = 2 / d;
549  T xs = q.x * s, ys = q.y * s, zs = q.z * s;
550  T wx = q.w * xs, wy = q.w * ys, wz = q.w * zs;
551  T xx = q.x * xs, xy = q.x * ys, xz = q.x * zs;
552  T yy = q.y * ys, yz = q.y * zs, zz = q.z * zs;
553 
554  m[0] = 1 - (yy + zz); m[1] = xy - wz; m[2] = xz + wy;
555  m[3] = xy + wz; m[4] = 1 - (xx + zz); m[5] = yz - wx;
556  m[6] = xz - wy; m[7] = yz + wx; m[8] = 1 - (xx + yy);
557  }
558 
564  return Mat2T<T>(xx, xy, yx, yy);
565  }
566 
567  // Serialize matrix to stream
568  friend std::ostream& operator<< (std::ostream& out, const Mat3T& m) {
569  out << "[ " << m[0] << " " << m[1] << " " << m[2] << " ; "
570  << m[3] << " " << m[4] << " " << m[5] << " ; "
571  << m[6] << " " << m[7] << " " << m[8] << " ]";
572  return out;
573  }
574 
575  union {
576  struct { T xx, xy, xz, yx, yy, yz, zx, zy, zz; };
577  T m[9];
578  };
579 
580  void normalize() {
581  T len_x = getColumn(0).length();
582  T len_y = getColumn(1).length();
583  T len_z = getColumn(2).length();
584  xx /= len_x; xy /= len_y; xz /= len_z; yx /= len_x; yy /= len_y; yz /= len_z; zx /= len_x; zy /= len_y; zz /= len_z;
585  }
586 
588  Vec3T<T> x = getColumn(0);
589  Vec3T<T> y = getColumn(1);
590  Vec3T<T> z = getColumn(2);
591  return Mat3T<T>(x.normalized(), y.normalized(), z.normalized());
592  }
593 };
594 
595 // --------------------------------------------------------------------------------
596 
597 template<typename T>
598 class Transform2T {
599 
600 public:
601 
603  Transform2T(const Transform2T& tr) = default;
604 
605  Transform2T(T x, T y, T yaw = 0) : t(x, y) {
606  setRotation(yaw);
607  }
608 
609  Transform2T(const Mat2T<T>& r, const Vec2T<T>& v) : R(r), t(v) {
610  }
611 
613 
615  if (this != &tr) {
616  R = tr.R;
617  t = tr.t;
618  }
619  return *this;
620  }
621 
622  inline Vec2T<T> operator*(const Vec2T<T>& v) const {
623  return R * v + t;
624  }
625 
626  inline Transform2T operator*(const Transform2T& tr) const {
627  return Transform2T(R * tr.R, R * tr.t + t);
628  }
629 
630  inline Transform2T inverseTimes(const Transform2T& tr) const {
631  // TODO: more efficient
632  return inverse() * tr;
633  }
634 
635  inline const Vec2T<T>& getOrigin() const {
636  return t;
637  }
638 
639  inline const Mat2T<T>& getBasis() const {
640  return R;
641  }
642 
643  void setOrigin(const Vec2T<T>& v) { t = v; }
644  void setBasis(const Mat2T<T>& r) { R = r; }
645 
646  inline Transform2T inverse() const {
647  Mat2T<T> inv = R.transpose();
648  return Transform2T(inv, inv * -t);
649  }
650 
651  void setRotation(T yaw) {
652  T c = cos(yaw);
653  T s = sin(yaw);
654 
655  R.xx = c; R.xy = -s;
656  R.yx = s; R.yy = c;
657  }
658 
659  T rotation() const {
660  return atan2(R.yx , R.xx);
661  }
662 
664 
670  return Transform3T<T>(R.projectTo3d(), t.projectTo3d());
671  }
672 
674  out << "t: " << t.t << "\tR: " << t.R;
675  return out;
676  }
677 
680 
681 };
682 
683 // --------------------------------------------------------------------------------
684 
685 template<typename T>
686 class Transform3T {
687 
688 public:
689 
691  Transform3T(const Transform3T& tr) = default;
692 
693  Transform3T(T x, T y, T z, T roll = 0, T pitch = 0, T yaw = 0) : t(x, y, z) {
694  setRPY(roll, pitch, yaw);
695  }
696 
697  Transform3T(const Mat3T<T>& r, const Vec3T<T>& v) : R(r), t(v) {}
698 
700 
702  if (this != &tr) {
703  R = tr.R;
704  t = tr.t;
705  }
706  return *this;
707  }
708 
709  inline bool operator==(const Transform3T& tr) const{
710  return (R == tr.R && t == tr.t);
711  }
712 
713  inline bool operator!=(const Transform3T& tr) const{
714  return !(*this == tr);
715  }
716 
717  inline Vec3T<T> operator*(const Vec3T<T>& v) const {
718  return R * v + t;
719  }
720 
721  inline Transform3T operator*(const Transform3T& tr) const {
722  return Transform3T(R * tr.R, R * tr.t + t);
723  }
724 
725  inline Transform3T inverseTimes(const Transform3T& tr) const {
726  // TODO: more efficient
727  return inverse() * tr;
728  }
729 
730  inline const Vec3T<T>& getOrigin() const {
731  return t;
732  }
733 
735  QuaternionT<T> q;
736  R.getRotation(q);
737  return q;
738  }
739 
740  inline const Mat3T<T>& getBasis() const {
741  return R;
742  }
743 
744  void setOrigin(const Vec3T<T>& v) { t = v; }
745  void setBasis(const Mat3T<T>& r) { R = r; }
746 
747  inline Transform3T inverse() const {
748  Mat3T<T> inv = R.transpose();
749  return Transform3T(inv, inv * -t);
750  }
751 
752  void setRPY(double roll, double pitch, double yaw) {
753  R.setRPY(roll, pitch, yaw);
754  }
755 
756  void getRPY(double& roll, double& pitch, double& yaw) const {
757  double epsilon = 1e-12;
758  pitch = atan2(-R.zx, sqrt(R.zy*R.zy + R.zz*R.zz));
759  if (std::fabs(pitch - M_PI/2) < epsilon) // detect singularity
760  {
761  // At singularity roll is set to zero, yaw is equal to sum of both
762  yaw = atan2(-R.xy, R.yy);
763  roll = 0;
764  }
765  else
766  {
767  roll = atan2(R.zy, R.zz);
768  yaw = atan2(R.yx, R.xx);
769  }
770  }
771 
772  double getYaw() const {
773  double roll, pitch, yaw;
774  getRPY(roll, pitch, yaw);
775  return yaw;
776  }
777 
778  static Transform3T identity() { return Transform3T(Mat3T<T>::identity(), Vec3T<T>(0, 0, 0)); }
779 
785  return Transform2T<T>(R.projectTo2d(), t.projectTo2d());
786  }
787 
789  out << "t: " << t.t << "\tR: " << t.R;
790  return out;
791  }
792 
795 
796 };
797 
798 // --------------------------------------------------------------------------------
799 
805 
811 
817 
823 
829 
835 
836 }
837 
838 #endif
geo::QuaternionT::length2
T length2() const
Returns the squared length of the vector.
Definition: math_types.h:377
geo::Mat2T::operator()
T & operator()(int i, int j)
Definition: math_types.h:276
geo::Mat3T::identity
static Mat3T identity()
Definition: math_types.h:516
geo::Vec2T::operator*
friend Vec2T operator*(T s, const Vec2T &v)
multiplies vector with a scalar
Definition: math_types.h:75
geo::Vec3T::normalize
void normalize()
Normalizes the vector.
Definition: math_types.h:186
geo::Mat3i
Mat3T< int > Mat3i
Definition: math_types.h:821
geo::Transform3T::operator<<
friend std::ostream & operator<<(std::ostream &out, const Transform3T &t)
Definition: math_types.h:788
geo::Vec3T::Vec3T
Vec3T(T x_, T y_, T z_)
Definition: math_types.h:128
geo::QuaternionT::QuaternionT
QuaternionT(T x_, T y_, T z_, T w_)
Definition: math_types.h:329
geo::Mat3T::projectTo2d
Mat2T< T > projectTo2d() const
Drops the rotation of the 3rd coordinate.
Definition: math_types.h:563
geo::Mat3T::setRotation
void setRotation(const QuaternionT< T > &q)
Definition: math_types.h:546
geo::Transform3T::getQuaternion
QuaternionT< T > getQuaternion() const
Definition: math_types.h:734
geo::Transform2T::rotation
T rotation() const
Definition: math_types.h:659
geo::Mat3T::~Mat3T
~Mat3T()
Definition: math_types.h:425
geo::Mat3
Mat3T< real > Mat3
Definition: math_types.h:818
geo::Mat2d
Mat2T< double > Mat2d
Definition: math_types.h:814
geo::Mat3T::operator()
T & operator()(int i, int j)
Definition: math_types.h:472
geo::real
double real
Definition: math_types.h:9
geo::Mat2T::identity
static Mat2T identity()
Definition: math_types.h:293
geo::QuaternionT
Definition: math_types.h:322
geo::Vec2T::operator-
friend Vec2T operator-(const Vec2T &v)
Definition: math_types.h:89
geo::Mat3T::transpose
Mat3T transpose() const
Definition: math_types.h:485
geo::Transform3T::getBasis
const Mat3T< T > & getBasis() const
Definition: math_types.h:740
geo::Vec2T::operator+=
Vec2T & operator+=(const Vec2T &v)
Definition: math_types.h:91
geo::QuaternionT::operator<<
friend std::ostream & operator<<(std::ostream &out, const QuaternionT &q)
Definition: math_types.h:385
geo::Mat3T::operator()
const T & operator()(int i, int j) const
Definition: math_types.h:476
geo::Vec3T::~Vec3T
~Vec3T()
Definition: math_types.h:141
geo::Mat2T::Mat2T
Mat2T(T value)
Definition: math_types.h:232
std::fabs
T fabs(T... args)
geo::QuaternionT::operator[]
T & operator[](const uint i)
Definition: math_types.h:343
geo::Transform3T::setOrigin
void setOrigin(const Vec3T< T > &v)
Definition: math_types.h:744
geo::Mat3T::getRotation
void getRotation(QuaternionT< T > &q) const
Definition: math_types.h:520
geo::Transform3T::getRPY
void getRPY(double &roll, double &pitch, double &yaw) const
Definition: math_types.h:756
geo::Mat3T::operator!=
bool operator!=(const Mat3T &m) const
Definition: math_types.h:437
geo
Definition: Box.h:6
geo::QuaternionT::~QuaternionT
~QuaternionT()
Definition: math_types.h:341
geo::Mat2i
Mat2T< int > Mat2i
Definition: math_types.h:815
geo::Vec3T::operator+=
Vec3T & operator+=(const Vec3T &v)
Definition: math_types.h:190
geo::Vec3T::operator-
friend Vec3T operator-(const Vec3T &v)
Definition: math_types.h:188
geo::Vec2T::y
T y
Definition: math_types.h:114
geo::Vec2T::operator==
bool operator==(const Vec2T &v) const
Definition: math_types.h:48
geo::Mat3T::Mat3T
Mat3T(T xx_, T xy_, T xz_, T yx_, T yy_, T yz_, T zx_, T zy_, T zz_)
Definition: math_types.h:406
geo::Vec2T::operator/=
Vec2T & operator/=(T s)
Definition: math_types.h:97
geo::Transform3T::identity
static Transform3T identity()
Definition: math_types.h:778
geo::Vec2T::operator*=
Vec2T & operator*=(T s)
Definition: math_types.h:96
geo::Vec3T::operator!=
bool operator!=(const Vec3T &v) const
Definition: math_types.h:151
geo::Vec2T::normalize
void normalize()
Normalizes the vector.
Definition: math_types.h:87
geo::Transform3T::setBasis
void setBasis(const Mat3T< T > &r)
Definition: math_types.h:745
geo::Transform3T::getOrigin
const Vec3T< T > & getOrigin() const
Definition: math_types.h:730
geo::Transform2T::R
Mat2T< T > R
Definition: math_types.h:678
geo::Mat2f
Mat2T< float > Mat2f
Definition: math_types.h:813
geo::Mat3T::xz
T xz
Definition: math_types.h:576
geo::Vec2T::dot
T dot(const Vec2T &v) const
returns dot product
Definition: math_types.h:57
geo::Vec2T::operator!=
bool operator!=(const Vec2T &v) const
Definition: math_types.h:52
geo::Vec2T::~Vec2T
~Vec2T()
Definition: math_types.h:42
geo::Transform2i
Transform2T< int > Transform2i
Definition: math_types.h:827
geo::Vec3T
Definition: math_types.h:13
geo::QuaternionT::operator==
bool operator==(const QuaternionT &q) const
Definition: math_types.h:347
geo::Vec3T::Vec3T
Vec3T(const T *values)
Definition: math_types.h:130
geo::Mat3T::normalized
Mat3T normalized()
Definition: math_types.h:587
geo::Mat2T::~Mat2T
~Mat2T()
Definition: math_types.h:244
geo::Vec3T::m
T m[3]
Definition: math_types.h:218
geo::Vec2T::x
T x
Definition: math_types.h:114
geo::Mat3T::operator-
Mat3T operator-(const Mat3T &m) const
returns this minus m
Definition: math_types.h:447
geo::Transform2T::setRotation
void setRotation(T yaw)
Definition: math_types.h:651
geo::Transform2T::~Transform2T
~Transform2T()
Definition: math_types.h:612
geo::Vec3T::operator-
Vec3T operator-(const Vec3T &v) const
returns this minus v
Definition: math_types.h:165
geo::Transform3T::operator*
Vec3T< T > operator*(const Vec3T< T > &v) const
Definition: math_types.h:717
geo::Mat2T::Mat2T
Mat2T(T xx_, T xy_, T yx_, T yy_)
Definition: math_types.h:231
geo::Transform2u
Transform2T< unsigned int > Transform2u
Definition: math_types.h:828
geo::Vec3T::operator==
bool operator==(const Vec3T &v) const
Definition: math_types.h:147
geo::Vec2T::operator/=
Vec2T & operator/=(const Vec2T &v)
Definition: math_types.h:94
geo::Transform3T
Definition: math_types.h:19
geo::Transform3T::Transform3T
Transform3T(const Mat3T< T > &r, const Vec3T< T > &v)
Definition: math_types.h:697
geo::Vec3T::operator*
friend Vec3T operator*(T s, const Vec3T &v)
multiplies vector with a scalar
Definition: math_types.h:174
geo::Vec3T::operator+
Vec3T operator+(const Vec3T &v) const
returns addition with v
Definition: math_types.h:162
geo::Mat2T::operator[]
const T & operator[](const uint i) const
Definition: math_types.h:248
geo::Vec3T::operator*
Vec3T operator*(T s) const
multiplies vector with a scalar
Definition: math_types.h:168
geo::Transform2T::operator*
Vec2T< T > operator*(const Vec2T< T > &v) const
Definition: math_types.h:622
geo::QuaternionT::m
T m[4]
Definition: math_types.h:392
geo::Vec2f
Vec2T< float > Vec2f
Definition: math_types.h:801
iostream
geo::Vec3T::operator[]
T & operator[](const uint i)
Definition: math_types.h:143
cmath
geo::Vec3T::operator/=
Vec3T & operator/=(const Vec3T &v)
Definition: math_types.h:193
geo::Mat2T::operator-
Mat2T operator-(const Mat2T &m) const
returns this minus m
Definition: math_types.h:263
geo::Vec2T::operator*=
Vec2T & operator*=(const Vec2T &v)
Definition: math_types.h:93
geo::Transform2T::t
Vec2T< T > t
Definition: math_types.h:679
geo::QuaternionT::w
T w
Definition: math_types.h:391
geo::Mat2T::yy
T yy
Definition: math_types.h:313
geo::Mat3T::getRow
Vec3T< T > getRow(int i) const
Definition: math_types.h:491
geo::Vec2T::Vec2T
Vec2T(T value)
Definition: math_types.h:31
geo::Mat3T::Mat3T
Mat3T(Vec3T< T > x, Vec3T< T > y, Vec3T< T > z)
Definition: math_types.h:413
geo::Vec3T::operator[]
const T & operator[](const uint i) const
Definition: math_types.h:145
geo::Vec2T::projectTo3d
Vec3T< T > projectTo3d() const
Expand vector with a zero 3rd coordinate.
Definition: math_types.h:103
geo::Mat2T::operator<<
friend std::ostream & operator<<(std::ostream &out, const Mat2T &m)
Definition: math_types.h:306
geo::Vec2T::operator+
Vec2T operator+(const Vec2T &v) const
returns addition of this and v
Definition: math_types.h:63
geo::Transform2T::Transform2T
Transform2T()
Definition: math_types.h:602
geo::Vec2T::operator[]
const T & operator[](const uint i) const
Definition: math_types.h:46
geo::Vec3T::y
T y
Definition: math_types.h:217
geo::Mat2T::operator+
Mat2T operator+(const Mat2T &m) const
returns addition with v
Definition: math_types.h:260
geo::Mat3T::operator*
Mat3T operator*(T s) const
multiplies vector with a scalar
Definition: math_types.h:463
geo::Mat3T::m
T m[9]
Definition: math_types.h:577
geo::Transform3T::operator==
bool operator==(const Transform3T &tr) const
Definition: math_types.h:709
geo::Transform3T::inverse
Transform3T inverse() const
Definition: math_types.h:747
geo::Transform2T::setBasis
void setBasis(const Mat2T< T > &r)
Definition: math_types.h:644
geo::Mat2T::operator*
Mat2T operator*(const Mat2T &m) const
return this multiplied by m
Definition: math_types.h:268
geo::Mat2T
Definition: math_types.h:225
geo::Vec3T::operator<<
friend std::ostream & operator<<(std::ostream &out, const Vec3T &v)
Definition: math_types.h:211
geo::QuaternionT::operator-
QuaternionT operator-(const QuaternionT &q) const
returns this minus q
Definition: math_types.h:362
geo::Vec3d
Vec3T< double > Vec3d
Definition: math_types.h:808
geo::Transform3T::inverseTimes
Transform3T inverseTimes(const Transform3T &tr) const
Definition: math_types.h:725
geo::Mat2T::Mat2T
Mat2T()
Definition: math_types.h:229
geo::Vec3T::getY
T getY() const
Definition: math_types.h:199
geo::Mat3T::Mat3T
Mat3T(T value)
Definition: math_types.h:409
geo::Vec2T::cross
T cross(const Vec2T &v) const
returns cross product
Definition: math_types.h:60
geo::Vec2T::Vec2T
Vec2T(T x_, T y_)
Definition: math_types.h:30
geo::Transform2T::operator=
Transform2T & operator=(const Transform2T &tr)
Definition: math_types.h:614
geo::QuaternionT::y
T y
Definition: math_types.h:391
std::ostream
geo::Vec2T::operator[]
T & operator[](const uint i)
Definition: math_types.h:44
geo::Vec2i
Vec2T< int > Vec2i
Definition: math_types.h:803
geo::Mat3T::operator[]
const T & operator[](const uint i) const
Definition: math_types.h:429
geo::Vec3i
Vec3T< int > Vec3i
Definition: math_types.h:809
geo::Mat3T::operator*
Vec3T< T > operator*(const Vec3T< T > &v) const
Definition: math_types.h:451
geo::Transform3T::operator=
Transform3T & operator=(const Transform3T &tr)
Definition: math_types.h:701
geo::Transform2T::Transform2T
Transform2T(const Mat2T< T > &r, const Vec2T< T > &v)
Definition: math_types.h:609
geo::QuaternionT::normalize
void normalize()
Normalizes the quaternion.
Definition: math_types.h:383
geo::Transform2T
Definition: math_types.h:598
geo::Mat3T::zx
T zx
Definition: math_types.h:576
geo::QuaternionT::x
T x
Definition: math_types.h:391
geo::Transform2T::inverseTimes
Transform2T inverseTimes(const Transform2T &tr) const
Definition: math_types.h:630
geo::Mat2T::operator/
Mat2T operator/(T s) const
divides matrix by scalar
Definition: math_types.h:288
geo::Transform2f
Transform2T< float > Transform2f
Definition: math_types.h:825
geo::Mat3T::zz
T zz
Definition: math_types.h:576
geo::Mat2T::operator[]
T & operator[](const uint i)
Definition: math_types.h:246
geo::Transform2
Transform2T< real > Transform2
Definition: math_types.h:824
geo::Mat3T::yy
T yy
Definition: math_types.h:576
geo::Vec2T::length
T length() const
Returns the length of the vector.
Definition: math_types.h:78
geo::Transform3T::t
Vec3T< T > t
Definition: math_types.h:794
geo::Vec3T::length2
T length2() const
Returns the squared length of the vector.
Definition: math_types.h:180
geo::Vec2T::m
T m[2]
Definition: math_types.h:115
geo::QuaternionT::getZ
T getZ() const
Definition: math_types.h:366
geo::Vec3u
Vec3T< unsigned int > Vec3u
Definition: math_types.h:810
geo::Transform2T::operator<<
friend std::ostream & operator<<(std::ostream &out, const Transform2T &t)
Definition: math_types.h:673
geo::Vec3T::cross
Vec3T cross(const Vec3T &v) const
returns cross product
Definition: math_types.h:159
geo::Transform2T::identity
static Transform2T identity()
Definition: math_types.h:663
geo::Mat3T::xx
T xx
Definition: math_types.h:576
geo::Vec3T::Vec3T
Vec3T()
Definition: math_types.h:126
geo::Vec3T::operator/=
Vec3T & operator/=(T s)
Definition: math_types.h:196
geo::Transform2T::Transform2T
Transform2T(T x, T y, T yaw=0)
Definition: math_types.h:605
geo::Mat2T::operator()
const T & operator()(int i, int j) const
Definition: math_types.h:280
geo::QuaternionT::operator=
QuaternionT & operator=(const QuaternionT &q)
Definition: math_types.h:331
geo::Transform3T::~Transform3T
~Transform3T()
Definition: math_types.h:699
geo::Vec3T::Vec3T
Vec3T(T value)
Definition: math_types.h:129
geo::Vec2
Vec2T< real > Vec2
Definition: math_types.h:800
geo::Vec3
Vec3T< real > Vec3
Definition: math_types.h:806
geo::Mat2T::transpose
Mat2T transpose() const
Definition: math_types.h:271
geo::Mat3f
Mat3T< float > Mat3f
Definition: math_types.h:819
geo::Transform2T::getBasis
const Mat2T< T > & getBasis() const
Definition: math_types.h:639
geo::Vec2T::operator-
Vec2T operator-(const Vec2T &v) const
returns this minus v
Definition: math_types.h:66
geo::Transform3T::getYaw
double getYaw() const
Definition: math_types.h:772
geo::Transform3
Transform3T< real > Transform3
Definition: math_types.h:830
geo::Mat3T::operator[]
T & operator[](const uint i)
Definition: math_types.h:427
geo::Mat3T::Mat3T
Mat3T(const T *values)
Definition: math_types.h:411
geo::Vec3T::operator=
Vec3T & operator=(const Vec3T &v)
Definition: math_types.h:132
geo::Mat3T::zy
T zy
Definition: math_types.h:576
geo::Mat2T::xx
T xx
Definition: math_types.h:313
geo::Transform2T::getOrigin
const Vec2T< T > & getOrigin() const
Definition: math_types.h:635
geo::Mat2T::operator*
Mat2T operator*(T s) const
multiplies vector with a scalar
Definition: math_types.h:285
geo::QuaternionT::normalized
QuaternionT normalized() const
Returns the normalized version of the vector.
Definition: math_types.h:380
geo::Mat3T::operator/
Mat3T operator/(T s) const
divides matrix by scalar
Definition: math_types.h:468
geo::Mat3T
Definition: math_types.h:16
geo::Mat2T::projectTo3d
Mat3T< T > projectTo3d() const
Expand rotation matrix into 3D, with zero rotation around the 3rd axis.
Definition: math_types.h:299
geo::Vec3T::operator*=
Vec3T & operator*=(T s)
Definition: math_types.h:195
geo::Vec2T::operator*
Vec2T operator*(T s) const
multiplies vector with a scalar
Definition: math_types.h:69
geo::Vec2T::operator=
Vec2T & operator=(const Vec2T &v)
Definition: math_types.h:34
geo::Mat2T::operator==
bool operator==(const Mat2T &m) const
Definition: math_types.h:250
geo::Vec2T::length2
T length2() const
Returns the squared length of the vector.
Definition: math_types.h:81
geo::Transform3T::projectTo2d
Transform2T< T > projectTo2d() const
Drops displacement and rotation fo the 3rd coordinate.
Definition: math_types.h:784
geo::Vec2u
Vec2T< unsigned int > Vec2u
Definition: math_types.h:804
geo::QuaternionT::getY
T getY() const
Definition: math_types.h:365
geo::Transform3i
Transform3T< int > Transform3i
Definition: math_types.h:833
geo::Vec2T::operator/
Vec2T operator/(T s) const
divides vector by scalar
Definition: math_types.h:72
geo::Vec3T::operator/
Vec3T operator/(T s) const
divides vector by scalar
Definition: math_types.h:171
geo::Mat2T::operator!=
bool operator!=(const Mat2T &m) const
Definition: math_types.h:255
geo::Mat2
Mat2T< real > Mat2
Definition: math_types.h:812
geo::Transform3T::operator*
Transform3T operator*(const Transform3T &tr) const
Definition: math_types.h:721
geo::Transform3u
Transform3T< unsigned int > Transform3u
Definition: math_types.h:834
geo::Transform2T::projectTo3d
Transform3T< T > projectTo3d() const
Transform with no displacement and rotation of the 3rd coordinate.
Definition: math_types.h:669
geo::Transform3f
Transform3T< float > Transform3f
Definition: math_types.h:831
geo::QuaternionT::getX
T getX() const
Definition: math_types.h:364
geo::Mat3T::yx
T yx
Definition: math_types.h:576
geo::Mat3T::operator<<
friend std::ostream & operator<<(std::ostream &out, const Mat3T &m)
Definition: math_types.h:568
geo::Mat3u
Mat3T< unsigned int > Mat3u
Definition: math_types.h:822
geo::Vec3T::normalized
Vec3T normalized() const
Returns the normalized version of the vector.
Definition: math_types.h:183
geo::Transform3d
Transform3T< double > Transform3d
Definition: math_types.h:832
geo::Transform3T::R
Mat3T< T > R
Definition: math_types.h:793
geo::Mat2T::operator*
Vec2T< T > operator*(const Vec2T< T > &v) const
Definition: math_types.h:265
geo::Mat2T::operator*
friend Mat2T operator*(T s, const Mat2T &m)
multiplies vector with a scalar
Definition: math_types.h:291
geo::Mat2T::xy
T xy
Definition: math_types.h:313
geo::Transform3T::operator!=
bool operator!=(const Transform3T &tr) const
Definition: math_types.h:713
geo::QuaternionT::operator[]
const T & operator[](const uint i) const
Definition: math_types.h:345
geo::Transform2d
Transform2T< double > Transform2d
Definition: math_types.h:826
geo::Vec3T::projectTo2d
Vec2T< T > projectTo2d() const
Drop the displacement of the 3rd coordinate.
Definition: math_types.h:206
geo::Mat3T::yz
T yz
Definition: math_types.h:576
geo::Mat2T::yx
T yx
Definition: math_types.h:313
geo::Vec3T::z
T z
Definition: math_types.h:217
geo::QuaternionT::operator+
QuaternionT operator+(const QuaternionT &q) const
returns addition with q
Definition: math_types.h:359
geo::Mat3d
Mat3T< double > Mat3d
Definition: math_types.h:820
geo::QuaternionT::z
T z
Definition: math_types.h:391
geo::Mat3T::getColumn
Vec3T< T > getColumn(int i) const
Definition: math_types.h:495
geo::Transform3T::Transform3T
Transform3T(T x, T y, T z, T roll=0, T pitch=0, T yaw=0)
Definition: math_types.h:693
geo::Vec3T::dot
T dot(const Vec3T &v) const
returns dot product
Definition: math_types.h:156
geo::QuaternionT::length
T length() const
Returns the length of the vector.
Definition: math_types.h:374
geo::Transform2T::setOrigin
void setOrigin(const Vec2T< T > &v)
Definition: math_types.h:643
geo::Mat3T::Mat3T
Mat3T()
Definition: math_types.h:403
geo::Vec3f
Vec3T< float > Vec3f
Definition: math_types.h:807
c
void c()
geo::Vec3T::operator*=
Vec3T & operator*=(const Vec3T &v)
Definition: math_types.h:192
geo::Mat3T::operator*
friend Mat3T operator*(T s, const Mat3T &m)
multiplies vector with a scalar
Definition: math_types.h:481
geo::Mat2u
Mat2T< unsigned int > Mat2u
Definition: math_types.h:816
geo::Transform3T::Transform3T
Transform3T()
Definition: math_types.h:690
geo::QuaternionT::QuaternionT
QuaternionT()
Definition: math_types.h:327
geo::Mat2T::operator=
Mat2T & operator=(const Mat2T &v)
Definition: math_types.h:234
geo::Transform2T::operator*
Transform2T operator*(const Transform2T &tr) const
Definition: math_types.h:626
geo::Vec2T::operator-=
Vec2T & operator-=(const Vec2T &v)
Definition: math_types.h:92
geo::QuaternionT::dot
T dot(const QuaternionT &q) const
returns dot product
Definition: math_types.h:356
geo::Vec2T::operator<<
friend std::ostream & operator<<(std::ostream &out, const Vec2T &v)
Definition: math_types.h:108
geo::Mat3T::operator=
Mat3T & operator=(const Mat3T &m)
Definition: math_types.h:416
geo::Mat3T::xy
T xy
Definition: math_types.h:576
geo::Mat3T::setRPY
void setRPY(T roll, T pitch, T yaw)
Definition: math_types.h:499
geo::QuaternionT::operator!=
bool operator!=(const QuaternionT &q) const
Definition: math_types.h:351
geo::Vec3T::getX
T getX() const
Definition: math_types.h:198
geo::Transform2T::inverse
Transform2T inverse() const
Definition: math_types.h:646
geo::Mat3T::operator*
Mat3T operator*(const Mat3T &m) const
Definition: math_types.h:457
geo::Vec3T::x
T x
Definition: math_types.h:217
geo::QuaternionT::operator*
friend QuaternionT operator*(T s, const QuaternionT &q)
Definition: math_types.h:369
geo::Vec2T::Vec2T
Vec2T(const T *values)
Definition: math_types.h:32
geo::Vec2T
Definition: math_types.h:24
geo::Vec2d
Vec2T< double > Vec2d
Definition: math_types.h:802
geo::Mat3T::normalize
void normalize()
Definition: math_types.h:580
geo::Mat3T::operator+
Mat3T operator+(const Mat3T &m) const
returns addition with v
Definition: math_types.h:442
geo::Vec3T::length
T length() const
Returns the length of the vector.
Definition: math_types.h:177
geo::QuaternionT::getW
T getW() const
Definition: math_types.h:367
geo::Transform3T::setRPY
void setRPY(double roll, double pitch, double yaw)
Definition: math_types.h:752
geo::Vec2T::Vec2T
Vec2T()
Definition: math_types.h:28
geo::Vec3T::operator-=
Vec3T & operator-=(const Vec3T &v)
Definition: math_types.h:191
geo::QuaternionT::operator*
QuaternionT operator*(T s) const
Definition: math_types.h:371
geo::Vec2T::normalized
Vec2T normalized() const
Returns the normalized version of the vector.
Definition: math_types.h:84
geo::Mat3T::operator==
bool operator==(const Mat3T &m) const
Definition: math_types.h:431
geo::Mat2T::m
T m[4]
Definition: math_types.h:314
geo::Vec3T::getZ
T getZ() const
Definition: math_types.h:200