TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Quat.h
Go to the documentation of this file.
1 
12 #ifndef G3D_Quat_h
13 #define G3D_Quat_h
14 
15 #include "G3D/platform.h"
16 #include "G3D/g3dmath.h"
17 #include "G3D/Vector3.h"
18 #include "G3D/Matrix3.h"
19 #include <string>
20 
21 namespace G3D {
22 
49 class Quat {
50 private:
51  // Hidden operators
52  bool operator<(const Quat&) const;
53  bool operator>(const Quat&) const;
54  bool operator<=(const Quat&) const;
55  bool operator>=(const Quat&) const;
56 
57 public:
58 
65  float x, y, z, w;
66 
70  Quat() : x(0), y(0), z(0), w(1) {}
71 
73  Quat(const class Any& a);
74 
75  Any toAny() const;
76 
77  Quat(const Matrix3& rot);
78 
79  Quat(float _x, float _y, float _z, float _w) :
80  x(_x), y(_y), z(_z), w(_w) {}
81 
83  Quat(const Vector3& v, float _w = 0) : x(v.x), y(v.y), z(v.z), w(_w) {
84  }
85 
88  bool operator==(const Quat& q) const {
89  return x == q.x && y == q.y && z == q.z && w == q.w;
90  }
91 
95  const float& real() const {
96  return w;
97  }
98 
99  float& real() {
100  return w;
101  }
102 
103  Quat operator-() const {
104  return Quat(-x, -y, -z, -w);
105  }
106 
107  Quat operator-(const Quat& other) const {
108  return Quat(x - other.x, y - other.y, z - other.z, w - other.w);
109  }
110 
111  Quat& operator-=(const Quat& q) {
112  x -= q.x;
113  y -= q.y;
114  z -= q.z;
115  w -= q.w;
116  return *this;
117  }
118 
119  Quat operator+(const Quat& q) const {
120  return Quat(x + q.x, y + q.y, z + q.z, w + q.w);
121  }
122 
123  Quat& operator+=(const Quat& q) {
124  x += q.x;
125  y += q.y;
126  z += q.z;
127  w += q.w;
128  return *this;
129  }
130 
134  Quat conj() const {
135  return Quat(-x, -y, -z, w);
136  }
137 
138  float sum() const {
139  return x + y + z + w;
140  }
141 
142  float average() const {
143  return sum() / 4.0f;
144  }
145 
146  Quat operator*(float s) const {
147  return Quat(x * s, y * s, z * s, w * s);
148  }
149 
150  Quat& operator*=(float s) {
151  x *= s;
152  y *= s;
153  z *= s;
154  w *= s;
155  return *this;
156  }
157 
158 
160  friend Quat operator* (float s, const Quat& q);
161 
162  inline Quat operator/(float s) const {
163  return Quat(x / s, y / s, z / s, w / s);
164  }
165 
166  float dot(const Quat& other) const {
167  return (x * other.x) + (y * other.y) + (z * other.z) + (w * other.w);
168  }
169 
171  bool fuzzyEq(const Quat& q) {
172  return G3D::fuzzyEq(x, q.x) && G3D::fuzzyEq(y, q.y) && G3D::fuzzyEq(z, q.z) && G3D::fuzzyEq(w, q.w);
173  }
174 
178  bool sameRotation(const Quat& q) {
179  return fuzzyEq(q) || fuzzyEq(-q);
180  }
181 
185  const Vector3& imag() const {
186  return *(reinterpret_cast<const Vector3*>(this));
187  }
188 
190  return *(reinterpret_cast<Vector3*>(this));
191  }
192 
195  const Vector3& axis,
196  float angle);
197 
200  void toAxisAngleRotation(
201  Vector3& axis,
202  double& angle) const;
203 
205  Vector3& axis,
206  float& angle) const {
207  double d;
208  toAxisAngleRotation(axis, d);
209  angle = (float)d;
210  }
211 
212  Matrix3 toRotationMatrix() const;
213 
214  void toRotationMatrix(
215  Matrix3& rot) const;
216 
217 private:
219  Quat slerp
220  (const Quat& other,
221  float alpha,
222  float threshold,
223  float maxAngle) const;
224 public:
225 
241  Quat slerp
242  (const Quat& other,
243  float alpha,
244  float threshold = 0.05f) const {
245  return slerp(other, alpha, threshold, finf());
246  }
247 
250  (const Quat& other,
251  float maxAngle) const {
252  return slerp(other, 1.0f, 0.05f, maxAngle);
253  }
254 
256  void moveTowards
257  (const Quat& other,
258  float maxAngle) {
259  *this = movedTowards(other, maxAngle);
260  }
261 
265  float angleBetween(const Quat& other) const;
266 
268  Quat nlerp(const Quat& other, float alpha) const;
269 
270 
273  inline Quat inverse() const {
274  return conj() / dot(*this);
275  }
276 
281  Quat operator*(const Quat& other) const;
282 
283  /* (*this) * other.inverse() */
284  Quat operator/(const Quat& other) const {
285  return (*this) * other.inverse();
286  }
287 
289  bool isUnit(float tolerance = 1e-5) const {
290  return abs(dot(*this) - 1.0f) < tolerance;
291  }
292 
293  float magnitude() const {
294  return sqrtf(dot(*this));
295  }
296 
297  Quat log() const {
298  if ((x == 0) && (y == 0) && (z == 0)) {
299  if (w > 0) {
300  return Quat(0, 0, 0, ::logf(w));
301  } else if (w < 0) {
302  // Log of a negative number. Multivalued, any number of the form
303  // (PI * v, ln(-q.w))
304  return Quat((float)pi(), 0, 0, ::logf(-w));
305  } else {
306  // log of zero!
307  return Quat((float)nan(), (float)nan(), (float)nan(), (float)nan());
308  }
309  } else {
310  // Partly imaginary.
311  float imagLen = sqrtf(x * x + y * y + z * z);
312  float len = sqrtf(imagLen * imagLen + w * w);
313  float theta = atan2f(imagLen, (float)w);
314  float t = theta / imagLen;
315  return Quat(t * x, t * y, t * z, ::logf(len));
316  }
317  }
318 
321  inline Quat exp() const {
322  debugAssertM(w == 0, "exp only defined for vector quaternions");
323  Vector3 u(x, y, z);
324  float A = u.magnitude();
325  Vector3 v = u / A;
326  return Quat(sinf(A) * v, cosf(A));
327  }
328 
329 
338  inline Quat pow(float r) const {
339  return (log() * r).exp();
340  }
341 
343  void unitize() {
344  *this *= rsq(dot(*this));
345  }
346 
351  Quat toUnit() const {
352  Quat copyOfThis = *this;
353  copyOfThis.unitize();
354  return copyOfThis;
355  }
356 
363  float norm() const {
364  return magnitude();
365  }
366 
367  // access quaternion as q[0] = q.x, q[1] = q.y, q[2] = q.z, q[3] = q.w
368  //
369  // WARNING. These member functions rely on
370  // (1) Quat not having virtual functions
371  // (2) the data packed in a 4*sizeof(float) memory block
372  const float& operator[] (int i) const;
373  float& operator[] (int i);
374 
378  static Quat unitRandom();
379 
380  void deserialize(class BinaryInput& b);
381  void serialize(class BinaryOutput& b) const;
382 
383  // 2-char swizzles
384 
385  Vector2 xx() const;
386  Vector2 yx() const;
387  Vector2 zx() const;
388  Vector2 wx() const;
389  Vector2 xy() const;
390  Vector2 yy() const;
391  Vector2 zy() const;
392  Vector2 wy() const;
393  Vector2 xz() const;
394  Vector2 yz() const;
395  Vector2 zz() const;
396  Vector2 wz() const;
397  Vector2 xw() const;
398  Vector2 yw() const;
399  Vector2 zw() const;
400  Vector2 ww() const;
401 
402  // 3-char swizzles
403 
404  Vector3 xxx() const;
405  Vector3 yxx() const;
406  Vector3 zxx() const;
407  Vector3 wxx() const;
408  Vector3 xyx() const;
409  Vector3 yyx() const;
410  Vector3 zyx() const;
411  Vector3 wyx() const;
412  Vector3 xzx() const;
413  Vector3 yzx() const;
414  Vector3 zzx() const;
415  Vector3 wzx() const;
416  Vector3 xwx() const;
417  Vector3 ywx() const;
418  Vector3 zwx() const;
419  Vector3 wwx() const;
420  Vector3 xxy() const;
421  Vector3 yxy() const;
422  Vector3 zxy() const;
423  Vector3 wxy() const;
424  Vector3 xyy() const;
425  Vector3 yyy() const;
426  Vector3 zyy() const;
427  Vector3 wyy() const;
428  Vector3 xzy() const;
429  Vector3 yzy() const;
430  Vector3 zzy() const;
431  Vector3 wzy() const;
432  Vector3 xwy() const;
433  Vector3 ywy() const;
434  Vector3 zwy() const;
435  Vector3 wwy() const;
436  Vector3 xxz() const;
437  Vector3 yxz() const;
438  Vector3 zxz() const;
439  Vector3 wxz() const;
440  Vector3 xyz() const;
441  Vector3 yyz() const;
442  Vector3 zyz() const;
443  Vector3 wyz() const;
444  Vector3 xzz() const;
445  Vector3 yzz() const;
446  Vector3 zzz() const;
447  Vector3 wzz() const;
448  Vector3 xwz() const;
449  Vector3 ywz() const;
450  Vector3 zwz() const;
451  Vector3 wwz() const;
452  Vector3 xxw() const;
453  Vector3 yxw() const;
454  Vector3 zxw() const;
455  Vector3 wxw() const;
456  Vector3 xyw() const;
457  Vector3 yyw() const;
458  Vector3 zyw() const;
459  Vector3 wyw() const;
460  Vector3 xzw() const;
461  Vector3 yzw() const;
462  Vector3 zzw() const;
463  Vector3 wzw() const;
464  Vector3 xww() const;
465  Vector3 yww() const;
466  Vector3 zww() const;
467  Vector3 www() const;
468 
469  // 4-char swizzles
470 
471  Vector4 xxxx() const;
472  Vector4 yxxx() const;
473  Vector4 zxxx() const;
474  Vector4 wxxx() const;
475  Vector4 xyxx() const;
476  Vector4 yyxx() const;
477  Vector4 zyxx() const;
478  Vector4 wyxx() const;
479  Vector4 xzxx() const;
480  Vector4 yzxx() const;
481  Vector4 zzxx() const;
482  Vector4 wzxx() const;
483  Vector4 xwxx() const;
484  Vector4 ywxx() const;
485  Vector4 zwxx() const;
486  Vector4 wwxx() const;
487  Vector4 xxyx() const;
488  Vector4 yxyx() const;
489  Vector4 zxyx() const;
490  Vector4 wxyx() const;
491  Vector4 xyyx() const;
492  Vector4 yyyx() const;
493  Vector4 zyyx() const;
494  Vector4 wyyx() const;
495  Vector4 xzyx() const;
496  Vector4 yzyx() const;
497  Vector4 zzyx() const;
498  Vector4 wzyx() const;
499  Vector4 xwyx() const;
500  Vector4 ywyx() const;
501  Vector4 zwyx() const;
502  Vector4 wwyx() const;
503  Vector4 xxzx() const;
504  Vector4 yxzx() const;
505  Vector4 zxzx() const;
506  Vector4 wxzx() const;
507  Vector4 xyzx() const;
508  Vector4 yyzx() const;
509  Vector4 zyzx() const;
510  Vector4 wyzx() const;
511  Vector4 xzzx() const;
512  Vector4 yzzx() const;
513  Vector4 zzzx() const;
514  Vector4 wzzx() const;
515  Vector4 xwzx() const;
516  Vector4 ywzx() const;
517  Vector4 zwzx() const;
518  Vector4 wwzx() const;
519  Vector4 xxwx() const;
520  Vector4 yxwx() const;
521  Vector4 zxwx() const;
522  Vector4 wxwx() const;
523  Vector4 xywx() const;
524  Vector4 yywx() const;
525  Vector4 zywx() const;
526  Vector4 wywx() const;
527  Vector4 xzwx() const;
528  Vector4 yzwx() const;
529  Vector4 zzwx() const;
530  Vector4 wzwx() const;
531  Vector4 xwwx() const;
532  Vector4 ywwx() const;
533  Vector4 zwwx() const;
534  Vector4 wwwx() const;
535  Vector4 xxxy() const;
536  Vector4 yxxy() const;
537  Vector4 zxxy() const;
538  Vector4 wxxy() const;
539  Vector4 xyxy() const;
540  Vector4 yyxy() const;
541  Vector4 zyxy() const;
542  Vector4 wyxy() const;
543  Vector4 xzxy() const;
544  Vector4 yzxy() const;
545  Vector4 zzxy() const;
546  Vector4 wzxy() const;
547  Vector4 xwxy() const;
548  Vector4 ywxy() const;
549  Vector4 zwxy() const;
550  Vector4 wwxy() const;
551  Vector4 xxyy() const;
552  Vector4 yxyy() const;
553  Vector4 zxyy() const;
554  Vector4 wxyy() const;
555  Vector4 xyyy() const;
556  Vector4 yyyy() const;
557  Vector4 zyyy() const;
558  Vector4 wyyy() const;
559  Vector4 xzyy() const;
560  Vector4 yzyy() const;
561  Vector4 zzyy() const;
562  Vector4 wzyy() const;
563  Vector4 xwyy() const;
564  Vector4 ywyy() const;
565  Vector4 zwyy() const;
566  Vector4 wwyy() const;
567  Vector4 xxzy() const;
568  Vector4 yxzy() const;
569  Vector4 zxzy() const;
570  Vector4 wxzy() const;
571  Vector4 xyzy() const;
572  Vector4 yyzy() const;
573  Vector4 zyzy() const;
574  Vector4 wyzy() const;
575  Vector4 xzzy() const;
576  Vector4 yzzy() const;
577  Vector4 zzzy() const;
578  Vector4 wzzy() const;
579  Vector4 xwzy() const;
580  Vector4 ywzy() const;
581  Vector4 zwzy() const;
582  Vector4 wwzy() const;
583  Vector4 xxwy() const;
584  Vector4 yxwy() const;
585  Vector4 zxwy() const;
586  Vector4 wxwy() const;
587  Vector4 xywy() const;
588  Vector4 yywy() const;
589  Vector4 zywy() const;
590  Vector4 wywy() const;
591  Vector4 xzwy() const;
592  Vector4 yzwy() const;
593  Vector4 zzwy() const;
594  Vector4 wzwy() const;
595  Vector4 xwwy() const;
596  Vector4 ywwy() const;
597  Vector4 zwwy() const;
598  Vector4 wwwy() const;
599  Vector4 xxxz() const;
600  Vector4 yxxz() const;
601  Vector4 zxxz() const;
602  Vector4 wxxz() const;
603  Vector4 xyxz() const;
604  Vector4 yyxz() const;
605  Vector4 zyxz() const;
606  Vector4 wyxz() const;
607  Vector4 xzxz() const;
608  Vector4 yzxz() const;
609  Vector4 zzxz() const;
610  Vector4 wzxz() const;
611  Vector4 xwxz() const;
612  Vector4 ywxz() const;
613  Vector4 zwxz() const;
614  Vector4 wwxz() const;
615  Vector4 xxyz() const;
616  Vector4 yxyz() const;
617  Vector4 zxyz() const;
618  Vector4 wxyz() const;
619  Vector4 xyyz() const;
620  Vector4 yyyz() const;
621  Vector4 zyyz() const;
622  Vector4 wyyz() const;
623  Vector4 xzyz() const;
624  Vector4 yzyz() const;
625  Vector4 zzyz() const;
626  Vector4 wzyz() const;
627  Vector4 xwyz() const;
628  Vector4 ywyz() const;
629  Vector4 zwyz() const;
630  Vector4 wwyz() const;
631  Vector4 xxzz() const;
632  Vector4 yxzz() const;
633  Vector4 zxzz() const;
634  Vector4 wxzz() const;
635  Vector4 xyzz() const;
636  Vector4 yyzz() const;
637  Vector4 zyzz() const;
638  Vector4 wyzz() const;
639  Vector4 xzzz() const;
640  Vector4 yzzz() const;
641  Vector4 zzzz() const;
642  Vector4 wzzz() const;
643  Vector4 xwzz() const;
644  Vector4 ywzz() const;
645  Vector4 zwzz() const;
646  Vector4 wwzz() const;
647  Vector4 xxwz() const;
648  Vector4 yxwz() const;
649  Vector4 zxwz() const;
650  Vector4 wxwz() const;
651  Vector4 xywz() const;
652  Vector4 yywz() const;
653  Vector4 zywz() const;
654  Vector4 wywz() const;
655  Vector4 xzwz() const;
656  Vector4 yzwz() const;
657  Vector4 zzwz() const;
658  Vector4 wzwz() const;
659  Vector4 xwwz() const;
660  Vector4 ywwz() const;
661  Vector4 zwwz() const;
662  Vector4 wwwz() const;
663  Vector4 xxxw() const;
664  Vector4 yxxw() const;
665  Vector4 zxxw() const;
666  Vector4 wxxw() const;
667  Vector4 xyxw() const;
668  Vector4 yyxw() const;
669  Vector4 zyxw() const;
670  Vector4 wyxw() const;
671  Vector4 xzxw() const;
672  Vector4 yzxw() const;
673  Vector4 zzxw() const;
674  Vector4 wzxw() const;
675  Vector4 xwxw() const;
676  Vector4 ywxw() const;
677  Vector4 zwxw() const;
678  Vector4 wwxw() const;
679  Vector4 xxyw() const;
680  Vector4 yxyw() const;
681  Vector4 zxyw() const;
682  Vector4 wxyw() const;
683  Vector4 xyyw() const;
684  Vector4 yyyw() const;
685  Vector4 zyyw() const;
686  Vector4 wyyw() const;
687  Vector4 xzyw() const;
688  Vector4 yzyw() const;
689  Vector4 zzyw() const;
690  Vector4 wzyw() const;
691  Vector4 xwyw() const;
692  Vector4 ywyw() const;
693  Vector4 zwyw() const;
694  Vector4 wwyw() const;
695  Vector4 xxzw() const;
696  Vector4 yxzw() const;
697  Vector4 zxzw() const;
698  Vector4 wxzw() const;
699  Vector4 xyzw() const;
700  Vector4 yyzw() const;
701  Vector4 zyzw() const;
702  Vector4 wyzw() const;
703  Vector4 xzzw() const;
704  Vector4 yzzw() const;
705  Vector4 zzzw() const;
706  Vector4 wzzw() const;
707  Vector4 xwzw() const;
708  Vector4 ywzw() const;
709  Vector4 zwzw() const;
710  Vector4 wwzw() const;
711  Vector4 xxww() const;
712  Vector4 yxww() const;
713  Vector4 zxww() const;
714  Vector4 wxww() const;
715  Vector4 xyww() const;
716  Vector4 yyww() const;
717  Vector4 zyww() const;
718  Vector4 wyww() const;
719  Vector4 xzww() const;
720  Vector4 yzww() const;
721  Vector4 zzww() const;
722  Vector4 wzww() const;
723  Vector4 xwww() const;
724  Vector4 ywww() const;
725  Vector4 zwww() const;
726  Vector4 wwww() const;
727 };
728 
729 inline Quat exp(const Quat& q) {
730  return q.exp();
731 }
732 
733 inline Quat log(const Quat& q) {
734  return q.log();
735 }
736 
737 inline G3D::Quat operator*(double s, const G3D::Quat& q) {
738  return q * (float)s;
739 }
740 
741 inline G3D::Quat operator*(float s, const G3D::Quat& q) {
742  return q * s;
743 }
744 
745 inline float& Quat::operator[] (int i) {
746  debugAssert(i >= 0);
747  debugAssert(i < 4);
748  return ((float*)this)[i];
749 }
750 
751 inline const float& Quat::operator[] (int i) const {
752  debugAssert(i >= 0);
753  debugAssert(i < 4);
754  return ((float*)this)[i];
755 }
756 
757 
758 } // Namespace G3D
759 
760 // Outside the namespace to avoid overloading confusion for C++
761 inline G3D::Quat pow(const G3D::Quat& q, double x) {
762  return q.pow((float)x);
763 }
764 
765 
766 #endif
float finf()
Definition: g3dmath.cpp:71
Vector4 ywwz() const
Definition: Quat.cpp:551
Vector3 xww() const
Definition: Quat.cpp:355
Vector4 wxwz() const
Definition: Quat.cpp:541
Vector3 zww() const
Definition: Quat.cpp:357
Quat exp(const Quat &q)
Definition: Quat.h:729
Vector4 ywzw() const
Definition: Quat.cpp:599
Vector4 wyxy() const
Definition: Quat.cpp:433
Quat inverse() const
Definition: Quat.h:273
Vector2 zy() const
Definition: Quat.cpp:282
Vector4 zzxz() const
Definition: Quat.cpp:500
Vector4 wzzx() const
Definition: Quat.cpp:405
Definition: Vector2.h:40
Vector4 zyzw() const
Definition: Quat.cpp:592
float norm() const
Definition: Quat.h:363
Vector4 zyww() const
Definition: Quat.cpp:608
Vector4 xxzx() const
Definition: Quat.cpp:394
Vector4 wxyz() const
Definition: Quat.cpp:509
Vector4 ywxx() const
Definition: Quat.cpp:375
Vector4 ywwy() const
Definition: Quat.cpp:487
Vector4 xzyx() const
Definition: Quat.cpp:386
Vector4 xzxw() const
Definition: Quat.cpp:562
Vector4 yzww() const
Definition: Quat.cpp:611
Vector4 wxxw() const
Definition: Quat.cpp:557
Vector3 yyx() const
Definition: Quat.cpp:300
Vector4 yyzz() const
Definition: Quat.cpp:527
Vector3 zzy() const
Definition: Quat.cpp:321
Vector3 zxw() const
Definition: Quat.cpp:345
Vector4 xzwy() const
Definition: Quat.cpp:482
Vector4 yxxz() const
Definition: Quat.cpp:491
Vector4 zxwy() const
Definition: Quat.cpp:476
Vector4 wzzy() const
Definition: Quat.cpp:469
Vector4 zwwz() const
Definition: Quat.cpp:552
Vector2 yz() const
Definition: Quat.cpp:285
Vector4 zywx() const
Definition: Quat.cpp:416
Vector3 xyx() const
Definition: Quat.cpp:299
Vector2 wy() const
Definition: Quat.cpp:283
Vector3 xxz() const
Definition: Quat.cpp:327
Vector3 zwy() const
Definition: Quat.cpp:325
Vector4 wyzy() const
Definition: Quat.cpp:465
Vector4 xyyw() const
Definition: Quat.cpp:574
Vector4 ywxw() const
Definition: Quat.cpp:567
Vector4 yxyx() const
Definition: Quat.cpp:379
Vector4 yzwz() const
Definition: Quat.cpp:547
Vector4 xyzx() const
Definition: Quat.cpp:398
Vector4 wxzy() const
Definition: Quat.cpp:461
Vector4 wzxy() const
Definition: Quat.cpp:437
Vector4 xwxx() const
Definition: Quat.cpp:374
Vector4 yyxx() const
Definition: Quat.cpp:367
Vector4 xywx() const
Definition: Quat.cpp:414
Vector4 xwyz() const
Definition: Quat.cpp:518
Any toAny() const
Definition: Quat.cpp:48
void toAxisAngleRotation(Vector3 &axis, double &angle) const
Definition: Quat.cpp:109
Quat(const Vector3 &v, float _w=0)
Definition: Quat.h:83
Vector4 zzyz() const
Definition: Quat.cpp:516
Quat log(const Quat &q)
Definition: Quat.h:733
Definition: BinaryInput.h:69
void deserialize(class BinaryInput &b)
Definition: Quat.cpp:258
Vector4 xxwx() const
Definition: Quat.cpp:410
Vector4 zyxy() const
Definition: Quat.cpp:432
Vector4 zyxx() const
Definition: Quat.cpp:368
float z
Definition: Quat.h:65
Vector2 xy() const
Definition: Quat.cpp:280
Vector4 yzwx() const
Definition: Quat.cpp:419
Vector4 wywz() const
Definition: Quat.cpp:545
Vector3 yxy() const
Definition: Quat.cpp:312
Vector4 xwxw() const
Definition: Quat.cpp:566
Vector4 xyxx() const
Definition: Quat.cpp:366
Vector4 ywyz() const
Definition: Quat.cpp:519
Vector2 yw() const
Definition: Quat.cpp:289
Quat toUnit() const
Definition: Quat.h:351
double abs(double fValue)
Definition: g3dmath.h:617
Vector4 wxxx() const
Definition: Quat.cpp:365
bool isUnit(float tolerance=1e-5) const
Definition: Quat.h:289
Vector4 zxxx() const
Definition: Quat.cpp:364
Vector4 yzzx() const
Definition: Quat.cpp:403
Vector2 xw() const
Definition: Quat.cpp:288
float magnitude() const
Definition: Quat.h:293
Vector4 yyyy() const
Definition: Quat.cpp:447
Vector4 zwwx() const
Definition: Quat.cpp:424
Vector4 wzyx() const
Definition: Quat.cpp:389
Vector4 zwyy() const
Definition: Quat.cpp:456
Vector4 wxwx() const
Definition: Quat.cpp:413
float sum() const
Definition: Quat.h:138
Vector3 yyy() const
Definition: Quat.cpp:316
float & real()
Definition: Quat.h:99
void moveTowards(const Quat &other, float maxAngle)
Definition: Quat.h:257
Vector4 zxxw() const
Definition: Quat.cpp:556
Vector4 xzwx() const
Definition: Quat.cpp:418
Vector4 wwyx() const
Definition: Quat.cpp:393
Vector4 xwwy() const
Definition: Quat.cpp:486
Vector4 zzyy() const
Definition: Quat.cpp:452
const Vector3 & imag() const
Definition: Quat.h:185
Definition: AABox.h:25
Vector3 xzx() const
Definition: Quat.cpp:303
Vector4 wyzx() const
Definition: Quat.cpp:401
float dot(const Quat &other) const
Definition: Quat.h:166
Vector4 yzzz() const
Definition: Quat.cpp:531
float w
Definition: Quat.h:65
Vector4 zzzx() const
Definition: Quat.cpp:404
Vector4 wyyy() const
Definition: Quat.cpp:449
Vector4 yxxy() const
Definition: Quat.cpp:427
bool operator<(const Quat &) const
Vector4 xwzx() const
Definition: Quat.cpp:406
Vector4 zxyy() const
Definition: Quat.cpp:444
Vector4 yywy() const
Definition: Quat.cpp:479
Vector4 xxwz() const
Definition: Quat.cpp:538
Vector4 zwyw() const
Definition: Quat.cpp:584
Vector4 zxwx() const
Definition: Quat.cpp:412
Vector3 zxz() const
Definition: Quat.cpp:329
float average() const
Definition: Quat.h:142
Vector3 yyw() const
Definition: Quat.cpp:348
Quat pow(float r) const
Definition: Quat.h:338
Vector4 zzyw() const
Definition: Quat.cpp:580
Vector4 zwzx() const
Definition: Quat.cpp:408
Vector4 wyzw() const
Definition: Quat.cpp:593
Matrix3 toRotationMatrix() const
Definition: Quat.cpp:148
Quat(float _x, float _y, float _z, float _w)
Definition: Quat.h:79
bool operator==(const Quat &q) const
Definition: Quat.h:88
Quat slerp(const Quat &other, float alpha, float threshold, float maxAngle) const
Definition: Quat.cpp:165
Vector3 zwx() const
Definition: Quat.cpp:309
float rsq(float x)
Definition: g3dmath.h:380
Vector4 ywxz() const
Definition: Quat.cpp:503
Vector3 xyy() const
Definition: Quat.cpp:315
Quat operator-() const
Definition: Quat.h:103
Vector4 wwyz() const
Definition: Quat.cpp:521
Vector3 yzz() const
Definition: Quat.cpp:336
bool sameRotation(const Quat &q)
Definition: Quat.h:178
double pi()
Definition: g3dmath.h:147
Vector4 zwxw() const
Definition: Quat.cpp:568
Vector3 xwx() const
Definition: Quat.cpp:307
#define debugAssertM(exp, message)
Definition: debugAssert.h:161
Vector4 wxxz() const
Definition: Quat.cpp:493
float x
Definition: Quat.h:65
Vector4 wyyx() const
Definition: Quat.cpp:385
Vector3 zyx() const
Definition: Quat.cpp:301
Vector4 xyyx() const
Definition: Quat.cpp:382
Vector3 wwz() const
Definition: Quat.cpp:342
Quat & operator-=(const Quat &q)
Definition: Quat.h:111
Vector4 wyxx() const
Definition: Quat.cpp:369
Vector4 yyzy() const
Definition: Quat.cpp:463
Vector4 wzyz() const
Definition: Quat.cpp:517
Vector3 xwy() const
Definition: Quat.cpp:323
Vector4 wxzx() const
Definition: Quat.cpp:397
Quat operator/(const Quat &other) const
Definition: Quat.h:284
Vector4 wxzz() const
Definition: Quat.cpp:525
Vector4 zxww() const
Definition: Quat.cpp:604
Vector4 yzyy() const
Definition: Quat.cpp:451
Vector3 zzw() const
Definition: Quat.cpp:353
Quat operator*(float s) const
Definition: Quat.h:146
Vector4 yxzx() const
Definition: Quat.cpp:395
Vector4 yyyx() const
Definition: Quat.cpp:383
Vector4 xxyw() const
Definition: Quat.cpp:570
Vector4 xwyx() const
Definition: Quat.cpp:390
Vector3 yyz() const
Definition: Quat.cpp:332
Definition: Vector3.h:58
Vector4 xyyz() const
Definition: Quat.cpp:510
Vector4 xwzw() const
Definition: Quat.cpp:598
Vector4 zzzw() const
Definition: Quat.cpp:596
Vector3 yzw() const
Definition: Quat.cpp:352
Vector3 yxw() const
Definition: Quat.cpp:344
Vector4 yzyw() const
Definition: Quat.cpp:579
Vector4 wwww() const
Definition: Quat.cpp:617
Vector4 ywzy() const
Definition: Quat.cpp:471
Vector3 xyw() const
Definition: Quat.cpp:347
Vector4 wxyy() const
Definition: Quat.cpp:445
Vector4 xzyz() const
Definition: Quat.cpp:514
Vector4 ywww() const
Definition: Quat.cpp:615
Vector4 xxxz() const
Definition: Quat.cpp:490
Vector3 wwx() const
Definition: Quat.cpp:310
Vector4 xwzy() const
Definition: Quat.cpp:470
Vector4 wwwx() const
Definition: Quat.cpp:425
Vector4 zxzx() const
Definition: Quat.cpp:396
Vector4 yxyz() const
Definition: Quat.cpp:507
Vector4 yyzx() const
Definition: Quat.cpp:399
Quat operator+(const Quat &q) const
Definition: Quat.h:119
Vector4 wyyz() const
Definition: Quat.cpp:513
Quat exp() const
Definition: Quat.h:321
Vector4 wxww() const
Definition: Quat.cpp:605
Vector4 yzwy() const
Definition: Quat.cpp:483
Vector4 xxyx() const
Definition: Quat.cpp:378
Vector3 xzy() const
Definition: Quat.cpp:319
Vector3 wxz() const
Definition: Quat.cpp:330
Easy loading and saving of human-readable configuration files.
Definition: Any.h:184
Vector4 wzwx() const
Definition: Quat.cpp:421
Vector4 yywz() const
Definition: Quat.cpp:543
Vector4 zyzz() const
Definition: Quat.cpp:528
Vector3 wwy() const
Definition: Quat.cpp:326
Vector4 wxyw() const
Definition: Quat.cpp:573
Vector3 zyy() const
Definition: Quat.cpp:317
Vector4 xxyz() const
Definition: Quat.cpp:506
Vector4 zwww() const
Definition: Quat.cpp:616
Vector4 yxzz() const
Definition: Quat.cpp:523
Vector3 xxx() const
Definition: Quat.cpp:295
Vector4 zzzz() const
Definition: Quat.cpp:532
Definition: Quat.h:49
Vector4 zyyw() const
Definition: Quat.cpp:576
Vector4 zwxz() const
Definition: Quat.cpp:504
Vector4 zwyx() const
Definition: Quat.cpp:392
Vector4 ywxy() const
Definition: Quat.cpp:439
Vector3 zzz() const
Definition: Quat.cpp:337
Vector4 zzwz() const
Definition: Quat.cpp:548
Vector3 wyx() const
Definition: Quat.cpp:302
Vector4 wwzy() const
Definition: Quat.cpp:473
Vector4 wwxz() const
Definition: Quat.cpp:505
Vector4 wzwz() const
Definition: Quat.cpp:549
Vector4 zyyx() const
Definition: Quat.cpp:384
Vector4 zyyz() const
Definition: Quat.cpp:512
Vector4 wxyx() const
Definition: Quat.cpp:381
Vector4 wwzw() const
Definition: Quat.cpp:601
#define debugAssert(exp)
Definition: debugAssert.h:160
Vector3 zzx() const
Definition: Quat.cpp:305
Vector4 xwwz() const
Definition: Quat.cpp:550
Vector3 wxy() const
Definition: Quat.cpp:314
void unitize()
Definition: Quat.h:343
Vector4 zxzw() const
Definition: Quat.cpp:588
Vector3 yxx() const
Definition: Quat.cpp:296
Vector4 zywz() const
Definition: Quat.cpp:544
Vector4 xzzz() const
Definition: Quat.cpp:530
const float & real() const
Definition: Quat.h:95
Vector4 zxyw() const
Definition: Quat.cpp:572
Vector4 zxzz() const
Definition: Quat.cpp:524
Vector4 xwxy() const
Definition: Quat.cpp:438
Vector4 xwxz() const
Definition: Quat.cpp:502
Vector4 xzyw() const
Definition: Quat.cpp:578
Vector2 ww() const
Definition: Quat.cpp:291
Vector2 zz() const
Definition: Quat.cpp:286
Vector4 yzyx() const
Definition: Quat.cpp:387
Vector4 yxzy() const
Definition: Quat.cpp:459
Vector4 xwyy() const
Definition: Quat.cpp:454
Vector3 xxy() const
Definition: Quat.cpp:311
Vector4 wwyy() const
Definition: Quat.cpp:457
Vector4 xxxw() const
Definition: Quat.cpp:554
Vector4 xwwx() const
Definition: Quat.cpp:422
Vector3 ywz() const
Definition: Quat.cpp:340
Vector4 zzxx() const
Definition: Quat.cpp:372
float magnitude() const
Definition: Vector3.h:746
Vector4 yzxx() const
Definition: Quat.cpp:371
Vector4 wzwy() const
Definition: Quat.cpp:485
Vector4 zwzy() const
Definition: Quat.cpp:472
Vector3 yzy() const
Definition: Quat.cpp:320
Definition: Vector4.h:39
Vector4 wzzw() const
Definition: Quat.cpp:597
Vector4 zzyx() const
Definition: Quat.cpp:388
Vector4 xxxy() const
Definition: Quat.cpp:426
Vector4 yyyz() const
Definition: Quat.cpp:511
Vector4 zyzx() const
Definition: Quat.cpp:400
static Quat fromAxisAngleRotation(const Vector3 &axis, float angle)
Definition: Quat.cpp:20
void serialize(class BinaryOutput &b) const
Definition: Quat.cpp:266
Vector4 wywy() const
Definition: Quat.cpp:481
Vector2 zx() const
Definition: Quat.cpp:278
Quat movedTowards(const Quat &other, float maxAngle) const
Definition: Quat.h:250
void toAxisAngleRotation(Vector3 &axis, float &angle) const
Definition: Quat.h:204
Vector4 xzyy() const
Definition: Quat.cpp:450
Vector3 wzz() const
Definition: Quat.cpp:338
Vector4 yxwy() const
Definition: Quat.cpp:475
Vector2 wx() const
Definition: Quat.cpp:279
Vector3 ywy() const
Definition: Quat.cpp:324
float angleBetween(const Quat &other) const
Definition: Quat.cpp:216
Vector4 wzyy() const
Definition: Quat.cpp:453
Vector3 & imag()
Definition: Quat.h:189
Quat operator/(float s) const
Definition: Quat.h:162
Vector4 yxwx() const
Definition: Quat.cpp:411
Vector3 wzx() const
Definition: Quat.cpp:306
Vector4 wzzz() const
Definition: Quat.cpp:533
bool fuzzyEq(const Quat &q)
Definition: Quat.h:171
Vector2 zw() const
Definition: Quat.cpp:290
Vector2 xx() const
Definition: Quat.cpp:276
Definition: Matrix3.h:37
Vector3 xwz() const
Definition: Quat.cpp:339
Vector4 wzxz() const
Definition: Quat.cpp:501
static Quat unitRandom()
Definition: Quat.cpp:244
Vector4 wyxw() const
Definition: Quat.cpp:561
Vector4 yyyw() const
Definition: Quat.cpp:575
Vector4 yxww() const
Definition: Quat.cpp:603
Vector4 zyxz() const
Definition: Quat.cpp:496
Vector3 xxw() const
Definition: Quat.cpp:343
Vector4 yxyy() const
Definition: Quat.cpp:443
Vector4 zxwz() const
Definition: Quat.cpp:540
Vector4 wwyw() const
Definition: Quat.cpp:585
Vector3 xzw() const
Definition: Quat.cpp:351
Vector4 yxxx() const
Definition: Quat.cpp:363
Vector4 wxwy() const
Definition: Quat.cpp:477
Vector4 yxzw() const
Definition: Quat.cpp:587
G3D::Quat pow(const G3D::Quat &q, double x)
Definition: Quat.h:761
Vector4 xxyy() const
Definition: Quat.cpp:442
Vector4 wwxy() const
Definition: Quat.cpp:441
Vector2 yy() const
Definition: Quat.cpp:281
Quat & operator+=(const Quat &q)
Definition: Quat.h:123
Vector3 yxz() const
Definition: Quat.cpp:328
Vector3 wyy() const
Definition: Quat.cpp:318
Vector4 zyxw() const
Definition: Quat.cpp:560
Quat()
Definition: Quat.h:70
Vector4 yzzy() const
Definition: Quat.cpp:467
Vector3 ywx() const
Definition: Quat.cpp:308
Quat & operator*=(float s)
Definition: Quat.h:150
Vector4 yzyz() const
Definition: Quat.cpp:515
Vector4 zzwx() const
Definition: Quat.cpp:420
Vector4 zyzy() const
Definition: Quat.cpp:464
Vector4 xzwz() const
Definition: Quat.cpp:546
Vector4 zxyx() const
Definition: Quat.cpp:380
Vector4 yxxw() const
Definition: Quat.cpp:555
Vector4 zywy() const
Definition: Quat.cpp:480
Vector4 xywy() const
Definition: Quat.cpp:478
Vector3 zxy() const
Definition: Quat.cpp:313
Vector4 wyyw() const
Definition: Quat.cpp:577
Vector4 xxzw() const
Definition: Quat.cpp:586
Vector4 zzxw() const
Definition: Quat.cpp:564
Vector3 wzy() const
Definition: Quat.cpp:322
Vector4 wwwy() const
Definition: Quat.cpp:489
Vector4 xzxy() const
Definition: Quat.cpp:434
Vector4 xxww() const
Definition: Quat.cpp:602
Vector4 zwzz() const
Definition: Quat.cpp:536
Quat operator-(const Quat &other) const
Definition: Quat.h:107
Vector4 xywz() const
Definition: Quat.cpp:542
bool operator>(const Quat &) const
Vector3 yzx() const
Definition: Quat.cpp:304
Vector4 wwzz() const
Definition: Quat.cpp:537
Definition: BinaryOutput.h:52
Vector4 yzxz() const
Definition: Quat.cpp:499
Vector4 yzxw() const
Definition: Quat.cpp:563
Vector4 wwzx() const
Definition: Quat.cpp:409
Vector4 yxyw() const
Definition: Quat.cpp:571
const float & operator[](int i) const
Definition: Quat.h:751
Vector4 zxxy() const
Definition: Quat.cpp:428
Vector4 yyxy() const
Definition: Quat.cpp:431
Vector4 wwxx() const
Definition: Quat.cpp:377
Vector4 ywzx() const
Definition: Quat.cpp:407
bool operator<=(const Quat &) const
Vector4 yyxw() const
Definition: Quat.cpp:559
Vector4 wyww() const
Definition: Quat.cpp:609
Vector3 xzz() const
Definition: Quat.cpp:335
Vector4 xyxy() const
Definition: Quat.cpp:430
Vector3 zxx() const
Definition: Quat.cpp:297
Vector3 wyz() const
Definition: Quat.cpp:334
Vector4 xyzz() const
Definition: Quat.cpp:526
Vector3 wyw() const
Definition: Quat.cpp:350
Vector4 zzww() const
Definition: Quat.cpp:612
Vector4 yyww() const
Definition: Quat.cpp:607
Vector4 wyzz() const
Definition: Quat.cpp:529
Vector4 yyxz() const
Definition: Quat.cpp:495
Vector4 ywyy() const
Definition: Quat.cpp:455
Vector3 zyw() const
Definition: Quat.cpp:349
float y
Definition: Quat.h:65
Vector4 xxwy() const
Definition: Quat.cpp:474
bool operator>=(const Quat &) const
Vector4 xyyy() const
Definition: Quat.cpp:446
Vector4 zzxy() const
Definition: Quat.cpp:436
Vector4 xzzx() const
Definition: Quat.cpp:402
Vector4 xxzz() const
Definition: Quat.cpp:522
Vector4 zwwy() const
Definition: Quat.cpp:488
Vector3 wzw() const
Definition: Quat.cpp:354
Vector4 xzzy() const
Definition: Quat.cpp:466
Quat log() const
Definition: Quat.h:297
Vector4 xyzw() const
Definition: Quat.cpp:590
Vector4 yyzw() const
Definition: Quat.cpp:591
Vector2 wz() const
Definition: Quat.cpp:287
Vector4 xwww() const
Definition: Quat.cpp:614
Vector4 xwzz() const
Definition: Quat.cpp:534
Vector4 ywyw() const
Definition: Quat.cpp:583
Vector4 xwyw() const
Definition: Quat.cpp:582
Quat nlerp(const Quat &other, float alpha) const
Definition: Quat.cpp:223
Vector4 zwyz() const
Definition: Quat.cpp:520
Vector4 ywyx() const
Definition: Quat.cpp:391
Vector4 zxyz() const
Definition: Quat.cpp:508
Vector4 ywwx() const
Definition: Quat.cpp:423
Vector4 yywx() const
Definition: Quat.cpp:415
Quat conj() const
Definition: Quat.h:134
Vector3 yww() const
Definition: Quat.cpp:356
Vector4 wzxw() const
Definition: Quat.cpp:565
Vector4 zwxy() const
Definition: Quat.cpp:440
Vector4 xyxz() const
Definition: Quat.cpp:494
Vector4 yzzw() const
Definition: Quat.cpp:595
Vector4 wwxw() const
Definition: Quat.cpp:569
Vector4 wxzw() const
Definition: Quat.cpp:589
Vector4 yzxy() const
Definition: Quat.cpp:435
Vector4 zwzw() const
Definition: Quat.cpp:600
Vector4 wywx() const
Definition: Quat.cpp:417
Vector4 zzzy() const
Definition: Quat.cpp:468
Vector2 yx() const
Definition: Quat.cpp:277
Vector4 xxxx() const
Definition: Quat.cpp:362
Vector4 wyxz() const
Definition: Quat.cpp:497
Vector2 xz() const
Definition: Quat.cpp:284
Vector4 ywzz() const
Definition: Quat.cpp:535
Vector4 xxzy() const
Definition: Quat.cpp:458
Vector4 wzww() const
Definition: Quat.cpp:613
Vector4 xyww() const
Definition: Quat.cpp:606
Vector4 wzxx() const
Definition: Quat.cpp:373
Vector3 wxx() const
Definition: Quat.cpp:298
Vector4 wxxy() const
Definition: Quat.cpp:429
Vector4 zxxz() const
Definition: Quat.cpp:492
Vector3 www() const
Definition: Quat.cpp:358
bool fuzzyEq(double a, double b)
Definition: g3dmath.h:857
Vector4 zzwy() const
Definition: Quat.cpp:484
Vector3 zwz() const
Definition: Quat.cpp:341
G3D::Color3 operator*(float s, const G3D::Color3 &c)
Definition: Color3.h:275
Vector4 yxwz() const
Definition: Quat.cpp:539
Vector3 xyz() const
Definition: Quat.cpp:331
Vector4 xyzy() const
Definition: Quat.cpp:462
Vector4 xzxx() const
Definition: Quat.cpp:370
double nan()
Definition: g3dmath.cpp:77
Vector4 xyxw() const
Definition: Quat.cpp:558
Vector3 zyz() const
Definition: Quat.cpp:333
Vector4 wwwz() const
Definition: Quat.cpp:553
Vector4 xzzw() const
Definition: Quat.cpp:594
Vector4 zwxx() const
Definition: Quat.cpp:376
Vector4 zyyy() const
Definition: Quat.cpp:448
Vector4 zxzy() const
Definition: Quat.cpp:460
Vector4 xzxz() const
Definition: Quat.cpp:498
Vector4 wzyw() const
Definition: Quat.cpp:581
Vector4 xzww() const
Definition: Quat.cpp:610
Vector3 wxw() const
Definition: Quat.cpp:346