TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Vector3.h
Go to the documentation of this file.
1 
15 #ifndef G3D_Vector3_h
16 #define G3D_Vector3_h
17 
18 #include "G3D/platform.h"
19 #include "G3D/g3dmath.h"
20 #include "G3D/Random.h"
21 #include "G3D/Vector2.h"
22 #include "G3D/Table.h"
23 #include "G3D/HashTrait.h"
24 #include "G3D/PositionTrait.h"
25 #include "G3D/Vector2.h"
26 #include <iostream>
27 #include <string>
28 
29 namespace G3D {
30 
31 class Vector2;
32 class Vector4;
33 class Vector4int8;
34 class Vector3int32;
35 class Any;
36 
58 class Vector3 {
59 public:
60 
61  // coordinates
62  float x, y, z;
63 
64 private:
65 
66  // Hidden operators
67  bool operator<(const Vector3&) const;
68  bool operator>(const Vector3&) const;
69  bool operator<=(const Vector3&) const;
70  bool operator>=(const Vector3&) const;
71 
72 public:
74  Vector3();
75 
82  explicit Vector3(const Any& any);
83 
85  Any toAny(const std::string& name) const;
86 
88  Any toAny() const;
89 
91  Vector3(const Vector4int8&);
92  Vector3(const class Vector2& v, float z);
93  Vector3(const class Vector3int32& v);
94  explicit Vector3(class BinaryInput& b);
95  Vector3(float _x, float _y, float _z);
96  explicit Vector3(float coordinate[3]);
97  explicit Vector3(double coordinate[3]);
98  Vector3(const class Vector3int16& v);
99  explicit Vector3(class TextInput& t);
100  explicit Vector3(const class Color3& c);
101 
103  void serialize(class BinaryOutput& b) const;
104  void deserialize(class BinaryInput& b);
105 
107  void serialize(class TextOutput& t) const;
108  void deserialize(class TextInput& t);
109 
110  // access vector V as V[0] = V.x, V[1] = V.y, V[2] = V.z
111  //
112  // WARNING. These member functions rely on
113  // (1) Vector3 not having virtual functions
114  // (2) the data packed in a 3*sizeof(float) memory block
115  const float& __fastcall operator[] (int i) const;
116  float& operator[] (int i);
117 
118  bool nonZero() const {
119  return (x != 0) || (y != 0) || (z != 0);
120  }
121 
122  enum Axis {X_AXIS=0, Y_AXIS=1, Z_AXIS=2, DETECT_AXIS=-1};
123 
128  Axis primaryAxis() const;
129 
130  // assignment and comparison
131  Vector3& __fastcall operator= (const Vector3& rkVector);
132  Vector3& operator=(const Any& a);
133  bool operator== (const Vector3& rkVector) const;
134  bool operator!= (const Vector3& rkVector) const;
135  size_t hashCode() const;
136  bool fuzzyEq(const Vector3& other) const;
137  bool fuzzyNe(const Vector3& other) const;
138 
140  bool isFinite() const;
141 
143  bool isNaN() const;
144 
146  bool isZero() const;
147 
149  bool isUnit() const;
150 
152  Vector3 movedTowards(const Vector3& goal, float maxTranslation) const;
153  void moveTowards(const Vector3& goal, float maxTranslation);
154 
155  // arithmetic operations
156  Vector3 __fastcall operator+ (const Vector3& v) const;
157  Vector3 __fastcall operator- (const Vector3& v) const;
158  Vector3 __fastcall operator* (float s) const;
159  inline Vector3 __fastcall operator/ (float s) const {
160  return *this * (1.0f / s);
161  }
162  Vector3 __fastcall operator* (const Vector3& v) const;
163  Vector3 __fastcall operator/ (const Vector3& v) const;
164  Vector3 __fastcall operator- () const;
165 
166  // arithmetic updates
169  Vector3& __fastcall operator*= (float s);
170  inline Vector3& __fastcall operator/= (float s) {
171  return (*this *= (1.0f / s));
172  }
175 
177  float length() const;
178 
179  float magnitude() const;
180 
182  Vector3 pow(float p) const {
183  return Vector3(powf(x, p), powf(y, p), powf(z, p));
184  }
185 
190  Vector3 direction() const;
191 
196  Vector3 fastDirection() const;
197 
217  Vector3 reflectAbout(const Vector3& normal) const;
218 
230  Vector3 reflectionDirection(const Vector3& normal) const;
231 
232 
237  inline Vector3 directionOrZero() const {
238  float mag = magnitude();
239  if (mag < 0.0000001f) {
240  return Vector3::zero();
241  } else if (mag < 1.00001f && mag > 0.99999f) {
242  return *this;
243  } else {
244  return *this * (1.0f / mag);
245  }
246  }
247 
276  const Vector3& normal,
277  float iInside,
278  float iOutside) const;
279 
281  inline Vector3 unit() const {
282  return direction();
283  }
284 
287  inline Vector3 fastUnit() const {
288  return fastDirection();
289  }
290 
292  float squaredLength() const;
293 
294  float squaredMagnitude () const;
295 
296  float __fastcall dot(const Vector3& rkVector) const;
297 
301  Vector3 __fastcall cross(const Vector3& rkVector) const;
302  Vector3 unitCross(const Vector3& rkVector) const;
303 
312  class Matrix3 cross() const;
313 
314  Vector3 __fastcall min(const Vector3 &v) const;
315  Vector3 __fastcall max(const Vector3 &v) const;
316 
318  inline float min() const {
319  return G3D::min(G3D::min(x, y), z);
320  }
321 
323  inline float max() const {
324  return G3D::max(G3D::max(x, y), z);
325  }
326 
327  std::string toString() const;
328 
329  inline Vector3 clamp(const Vector3& low, const Vector3& high) const {
330  return Vector3(
331  G3D::clamp(x, low.x, high.x),
332  G3D::clamp(y, low.y, high.y),
333  G3D::clamp(z, low.z, high.z));
334  }
335 
336  inline Vector3 clamp(float low, float high) const {
337  return Vector3(
338  G3D::clamp(x, low, high),
339  G3D::clamp(y, low, high),
340  G3D::clamp(z, low, high));
341  }
342 
343 
344  inline Vector3 floor() const {
345  return G3D::Vector3(::floor(x), ::floor(y), ::floor(z));
346  }
347 
348 
349  inline Vector3 round() const {
350  return Vector3(G3D::round(x), G3D::round(y), G3D::round(z));
351  }
352 
353 
357  inline Vector3 lerp(const Vector3& v, float alpha) const {
358  return (*this) + (v - *this) * alpha;
359  }
360 
362  static void orthonormalize (Vector3 akVector[3]);
363 
369  static Vector3 random(Random& r = Random::common());
370 
384  static Vector3 cosHemiRandom(const Vector3& n, Random& r = Random::common());
385 
386  static Vector3 cosSphereRandom(const Vector3& n, Random& r = Random::common());
387 
401  static Vector3 cosPowHemiRandom(const Vector3& n, const float k, Random& r = Random::common());
402 
409  static Vector3 hemiRandom(const Vector3& normal, Random& r = Random::common());
410 
411  inline float sum() const {
412  return x + y + z;
413  }
414 
415  inline float average() const {
416  return sum() / 3.0f;
417  }
418 
419  // Special values.
420  static const Vector3& zero();
421  static const Vector3& one();
422  static const Vector3& unitX();
423  static const Vector3& unitY();
424  static const Vector3& unitZ();
425  static const Vector3& inf();
426  static const Vector3& nan();
427 
429  static const Vector3& minFinite();
430 
432  static const Vector3& maxFinite();
433 
434 
437  inline void getTangents(Vector3& X, Vector3& Y) const {
438  debugAssertM(G3D::fuzzyEq(length(), 1.0f),
439  "makeAxes requires Z to have unit length");
440 
441  // Choose another vector not perpendicular
442  X = (abs(x) < 0.9f) ? Vector3::unitX() : Vector3::unitY();
443 
444  // Remove the part that is parallel to Z
445  X -= *this * this->dot(X);
446  X /= X.length();
447 
448  Y = this->cross(X);
449  }
450 
451 
452  // 2-char swizzles
453 
454  Vector2 xx() const;
455  Vector2 yx() const;
456  Vector2 zx() const;
457  Vector2 xy() const;
458  Vector2 yy() const;
459  Vector2 zy() const;
460  Vector2 xz() const;
461  Vector2 yz() const;
462  Vector2 zz() const;
463 
464  // 3-char swizzles
465 
466  Vector3 xxx() const;
467  Vector3 yxx() const;
468  Vector3 zxx() const;
469  Vector3 xyx() const;
470  Vector3 yyx() const;
471  Vector3 zyx() const;
472  Vector3 xzx() const;
473  Vector3 yzx() const;
474  Vector3 zzx() const;
475  Vector3 xxy() const;
476  Vector3 yxy() const;
477  Vector3 zxy() const;
478  Vector3 xyy() const;
479  Vector3 yyy() const;
480  Vector3 zyy() const;
481  Vector3 xzy() const;
482  Vector3 yzy() const;
483  Vector3 zzy() const;
484  Vector3 xxz() const;
485  Vector3 yxz() const;
486  Vector3 zxz() const;
487  Vector3 xyz() const;
488  Vector3 yyz() const;
489  Vector3 zyz() const;
490  Vector3 xzz() const;
491  Vector3 yzz() const;
492  Vector3 zzz() const;
493 
494  // 4-char swizzles
495 
496  Vector4 xxxx() const;
497  Vector4 yxxx() const;
498  Vector4 zxxx() const;
499  Vector4 xyxx() const;
500  Vector4 yyxx() const;
501  Vector4 zyxx() const;
502  Vector4 xzxx() const;
503  Vector4 yzxx() const;
504  Vector4 zzxx() const;
505  Vector4 xxyx() const;
506  Vector4 yxyx() const;
507  Vector4 zxyx() const;
508  Vector4 xyyx() const;
509  Vector4 yyyx() const;
510  Vector4 zyyx() const;
511  Vector4 xzyx() const;
512  Vector4 yzyx() const;
513  Vector4 zzyx() const;
514  Vector4 xxzx() const;
515  Vector4 yxzx() const;
516  Vector4 zxzx() const;
517  Vector4 xyzx() const;
518  Vector4 yyzx() const;
519  Vector4 zyzx() const;
520  Vector4 xzzx() const;
521  Vector4 yzzx() const;
522  Vector4 zzzx() const;
523  Vector4 xxxy() const;
524  Vector4 yxxy() const;
525  Vector4 zxxy() const;
526  Vector4 xyxy() const;
527  Vector4 yyxy() const;
528  Vector4 zyxy() const;
529  Vector4 xzxy() const;
530  Vector4 yzxy() const;
531  Vector4 zzxy() const;
532  Vector4 xxyy() const;
533  Vector4 yxyy() const;
534  Vector4 zxyy() const;
535  Vector4 xyyy() const;
536  Vector4 yyyy() const;
537  Vector4 zyyy() const;
538  Vector4 xzyy() const;
539  Vector4 yzyy() const;
540  Vector4 zzyy() const;
541  Vector4 xxzy() const;
542  Vector4 yxzy() const;
543  Vector4 zxzy() const;
544  Vector4 xyzy() const;
545  Vector4 yyzy() const;
546  Vector4 zyzy() const;
547  Vector4 xzzy() const;
548  Vector4 yzzy() const;
549  Vector4 zzzy() const;
550  Vector4 xxxz() const;
551  Vector4 yxxz() const;
552  Vector4 zxxz() const;
553  Vector4 xyxz() const;
554  Vector4 yyxz() const;
555  Vector4 zyxz() const;
556  Vector4 xzxz() const;
557  Vector4 yzxz() const;
558  Vector4 zzxz() const;
559  Vector4 xxyz() const;
560  Vector4 yxyz() const;
561  Vector4 zxyz() const;
562  Vector4 xyyz() const;
563  Vector4 yyyz() const;
564  Vector4 zyyz() const;
565  Vector4 xzyz() const;
566  Vector4 yzyz() const;
567  Vector4 zzyz() const;
568  Vector4 xxzz() const;
569  Vector4 yxzz() const;
570  Vector4 zxzz() const;
571  Vector4 xyzz() const;
572  Vector4 yyzz() const;
573  Vector4 zyzz() const;
574  Vector4 xzzz() const;
575  Vector4 yzzz() const;
576  Vector4 zzzz() const;
577 
579  static Vector3& ignore();
580 };
581 
582 
583 
584 inline G3D::Vector3 operator*(float s, const G3D::Vector3& v) {
585  return v * s;
586 }
587 
588 inline G3D::Vector3 operator*(double s, const G3D::Vector3& v) {
589  return v * (float)s;
590 }
591 
592 inline G3D::Vector3 operator*(int s, const G3D::Vector3& v) {
593  return v * (float)s;
594 }
595 
596 std::ostream& operator<<(std::ostream& os, const Vector3&);
597 
598 
599 void serialize(const Vector3::Axis& a, class BinaryOutput& bo);
600 void deserialize(Vector3::Axis& a, class BinaryInput& bo);
601 
602 
603 //----------------------------------------------------------------------------
604 inline Vector3::Vector3() : x(0.0f), y(0.0f), z(0.0f) {
605 }
606 
607 //----------------------------------------------------------------------------
608 
609 inline Vector3::Vector3 (float fX, float fY, float fZ) : x(fX), y(fY), z(fZ) {
610 }
611 
612 //----------------------------------------------------------------------------
613 inline Vector3::Vector3 (float V[3]) : x(V[0]), y(V[1]), z(V[2]){
614 }
615 
616 //----------------------------------------------------------------------------
617 inline Vector3::Vector3 (double V[3]) : x((float)V[0]), y((float)V[1]), z((float)V[2]){
618 }
619 
620 //----------------------------------------------------------------------------
621 inline const float& Vector3::operator[] (int i) const {
622  return ((float*)this)[i];
623 }
624 
625 inline float& Vector3::operator[] (int i) {
626  return ((float*)this)[i];
627 }
628 
629 
630 //----------------------------------------------------------------------------
631 inline Vector3& Vector3::operator= (const Vector3& rkVector) {
632  x = rkVector.x;
633  y = rkVector.y;
634  z = rkVector.z;
635  return *this;
636 }
637 
638 //----------------------------------------------------------------------------
639 
640 inline bool Vector3::fuzzyEq(const Vector3& other) const {
641  return G3D::fuzzyEq((*this - other).squaredMagnitude(), 0);
642 }
643 
644 //----------------------------------------------------------------------------
645 
646 inline bool Vector3::fuzzyNe(const Vector3& other) const {
647  return G3D::fuzzyNe((*this - other).squaredMagnitude(), 0);
648 }
649 
650 //----------------------------------------------------------------------------
651 
652 inline bool Vector3::isFinite() const {
653  return G3D::isFinite(x) && G3D::isFinite(y) && G3D::isFinite(z);
654 }
655 
656 //----------------------------------------------------------------------------
657 inline bool Vector3::operator== (const Vector3& rkVector) const {
658  return ( x == rkVector.x && y == rkVector.y && z == rkVector.z );
659 }
660 
661 //----------------------------------------------------------------------------
662 inline bool Vector3::operator!= (const Vector3& rkVector) const {
663  return ( x != rkVector.x || y != rkVector.y || z != rkVector.z );
664 }
665 
666 //----------------------------------------------------------------------------
667 inline Vector3 Vector3::operator+ (const Vector3& rkVector) const {
668  return Vector3(x + rkVector.x, y + rkVector.y, z + rkVector.z);
669 }
670 
671 //----------------------------------------------------------------------------
672 inline Vector3 Vector3::operator- (const Vector3& rkVector) const {
673  return Vector3(x - rkVector.x, y - rkVector.y, z - rkVector.z);
674 }
675 
676 //----------------------------------------------------------------------------
677 inline Vector3 Vector3::operator* (const Vector3& rkVector) const {
678  return Vector3(x * rkVector.x, y * rkVector.y, z * rkVector.z);
679 }
680 
681 inline Vector3 Vector3::operator*(float f) const {
682  return Vector3(x * f, y * f, z * f);
683 }
684 
685 //----------------------------------------------------------------------------
686 inline Vector3 Vector3::operator/ (const Vector3& rkVector) const {
687  return Vector3(x / rkVector.x, y / rkVector.y, z / rkVector.z);
688 }
689 
690 //----------------------------------------------------------------------------
691 inline Vector3 Vector3::operator- () const {
692  return Vector3(-x, -y, -z);
693 }
694 
695 //----------------------------------------------------------------------------
696 inline Vector3& Vector3::operator+= (const Vector3& rkVector) {
697  x += rkVector.x;
698  y += rkVector.y;
699  z += rkVector.z;
700  return *this;
701 }
702 
703 //----------------------------------------------------------------------------
704 inline Vector3& Vector3::operator-= (const Vector3& rkVector) {
705  x -= rkVector.x;
706  y -= rkVector.y;
707  z -= rkVector.z;
708  return *this;
709 }
710 
711 //----------------------------------------------------------------------------
712 inline Vector3& Vector3::operator*= (float fScalar) {
713  x *= fScalar;
714  y *= fScalar;
715  z *= fScalar;
716  return *this;
717 }
718 
719 //----------------------------------------------------------------------------
720 inline Vector3& Vector3::operator*= (const Vector3& rkVector) {
721  x *= rkVector.x;
722  y *= rkVector.y;
723  z *= rkVector.z;
724  return *this;
725 }
726 
727 //----------------------------------------------------------------------------
728 inline Vector3& Vector3::operator/= (const Vector3& rkVector) {
729  x /= rkVector.x;
730  y /= rkVector.y;
731  z /= rkVector.z;
732  return *this;
733 }
734 
735 //----------------------------------------------------------------------------
736 inline float Vector3::squaredMagnitude () const {
737  return x*x + y*y + z*z;
738 }
739 
740 //----------------------------------------------------------------------------
741 inline float Vector3::squaredLength () const {
742  return squaredMagnitude();
743 }
744 
745 //----------------------------------------------------------------------------
746 inline float Vector3::magnitude() const {
747  return ::sqrtf(x*x + y*y + z*z);
748 }
749 
750 //----------------------------------------------------------------------------
751 inline float Vector3::length() const {
752  return magnitude();
753 }
754 
755 //----------------------------------------------------------------------------
756 inline Vector3 Vector3::direction () const {
757  const float lenSquared = squaredMagnitude();
758  const float invSqrt = 1.0f / sqrtf(lenSquared);
759  return Vector3(x * invSqrt, y * invSqrt, z * invSqrt);
760 }
761 
762 //----------------------------------------------------------------------------
763 
765  float lenSquared = x * x + y * y + z * z;
766  float invSqrt = rsq(lenSquared);
767  return Vector3(x * invSqrt, y * invSqrt, z * invSqrt);
768 }
769 
770 //----------------------------------------------------------------------------
771 inline float Vector3::dot (const Vector3& rkVector) const {
772  return x*rkVector.x + y*rkVector.y + z*rkVector.z;
773 }
774 
775 //----------------------------------------------------------------------------
776 inline Vector3 Vector3::cross (const Vector3& rkVector) const {
777  return Vector3(y*rkVector.z - z*rkVector.y, z*rkVector.x - x*rkVector.z,
778  x*rkVector.y - y*rkVector.x);
779 }
780 
781 //----------------------------------------------------------------------------
782 inline Vector3 Vector3::unitCross (const Vector3& rkVector) const {
783  Vector3 kCross(y*rkVector.z - z*rkVector.y, z*rkVector.x - x*rkVector.z,
784  x*rkVector.y - y*rkVector.x);
785  return kCross.direction();
786 }
787 
788 //----------------------------------------------------------------------------
789 inline Vector3 Vector3::min(const Vector3 &v) const {
790  return Vector3(G3D::min(v.x, x), G3D::min(v.y, y), G3D::min(v.z, z));
791 }
792 
793 //----------------------------------------------------------------------------
794 inline Vector3 Vector3::max(const Vector3 &v) const {
795  return Vector3(G3D::max(v.x, x), G3D::max(v.y, y), G3D::max(v.z, z));
796 }
797 
798 //----------------------------------------------------------------------------
799 inline bool Vector3::isZero() const {
800  return G3D::fuzzyEq(fabsf(x) + fabsf(y) + fabsf(z), 0.0f);
801 }
802 
803 //----------------------------------------------------------------------------
804 
805 inline bool Vector3::isUnit() const {
806  return G3D::fuzzyEq(squaredMagnitude(), 1.0f);
807 }
808 
820 typedef Vector3 Point3;
821 
822 void serialize(const Vector3& v, class BinaryOutput& b);
823 void deserialize(Vector3& v, class BinaryInput& b);
824 
825 } // namespace G3D
826 
827 
828 template <>
829 struct HashTrait<G3D::Vector3> {
830  static size_t hashCode(const G3D::Vector3& key) {
831  return key.hashCode();
832  }
833 };
834 
835 
836 template<> struct PositionTrait<class G3D::Vector2> {
837  static void getPosition(const G3D::Vector2& v, G3D::Vector3& p) { p = G3D::Vector3(v, 0); }
838 };
839 
840 template<> struct PositionTrait<class G3D::Vector3> {
841  static void getPosition(const G3D::Vector3& v, G3D::Vector3& p) { p = v; }
842 };
843 
844 
845 #endif
Vector3 &__fastcall operator+=(const Vector3 &v)
Definition: Vector3.h:696
void moveTowards(const Vector3 &goal, float maxTranslation)
Definition: Vector3.cpp:42
Vector4 yyzy() const
Definition: Vector3.cpp:502
Vector4 xzyy() const
Definition: Vector3.cpp:495
Definition: Vector2.h:40
Vector3 yxz() const
Definition: Vector3.cpp:442
Vector3 __fastcall operator+(const Vector3 &v) const
Definition: Vector3.h:667
Vector4 zxzy() const
Definition: Vector3.cpp:500
float squaredMagnitude() const
Definition: Vector3.h:736
bool operator>(const Vector3 &) const
static Vector3 hemiRandom(const Vector3 &normal, Random &r=Random::common())
Random vector distributed over the hemisphere about normal.
Definition: Vector3.cpp:303
Vector3int32
Definition: Vector3int32.h:29
Vector4 yyyz() const
Definition: Vector3.cpp:520
Vector4 zzzx() const
Definition: Vector3.cpp:479
bool isZero() const
Definition: Vector3.h:799
float x
Definition: Vector3.h:62
Vector4 xyyx() const
Definition: Vector3.cpp:465
#define __fastcall
Fast call is a register-based optimized calling convention supported only by Visual C++...
Definition: platform.h:55
Vector4 xyxx() const
Definition: Vector3.cpp:456
Vector3 directionOrZero() const
Definition: Vector3.h:237
Vector3 pow(float p) const
Definition: Vector3.h:182
Vector3 yyy() const
Definition: Vector3.cpp:436
Vector3 zzy() const
Definition: Vector3.cpp:440
Vector3 zxx() const
Definition: Vector3.cpp:425
Vector4 xxyz() const
Definition: Vector3.cpp:516
Vector4 zzzy() const
Definition: Vector3.cpp:506
float sum() const
Definition: Vector3.h:411
class Matrix3 cross() const
Definition: Vector3.cpp:393
Vector4 zzyy() const
Definition: Vector3.cpp:497
Vector2 xz() const
Definition: Vector3.cpp:417
Vector3 xyz() const
Definition: Vector3.cpp:444
Definition: Vector3.h:122
Vector4 yzyz() const
Definition: Vector3.cpp:523
Vector3 yzy() const
Definition: Vector3.cpp:439
Vector3 &__fastcall operator-=(const Vector3 &v)
Definition: Vector3.h:704
double round(double f)
Definition: g3dmath.h:214
Vector4 zzyz() const
Definition: Vector3.cpp:524
Vector3 yyz() const
Definition: Vector3.cpp:445
Vector3 __fastcall operator/(float s) const
Definition: Vector3.h:159
static const Vector3 & minFinite()
Definition: Vector3.cpp:126
Vector4 zzxy() const
Definition: Vector3.cpp:488
Definition: BinaryInput.h:69
bool nonZero() const
Definition: Vector3.h:118
Vector2 xy() const
Definition: Vector3.cpp:414
Vector4 zyxx() const
Definition: Vector3.cpp:458
#define X
Definition: CollisionDetection.cpp:2281
double abs(double fValue)
Definition: g3dmath.h:617
static Vector3 random(Random &r=Random::common())
Random unit vector, uniformly distributed on the sphere.
Definition: Vector3.cpp:226
Vector2 zx() const
Definition: Vector3.cpp:413
Vector4 xyzz() const
Definition: Vector3.cpp:528
Vector4 zyyx() const
Definition: Vector3.cpp:467
Definition: Vector4int8.h:30
Definition: HashTrait.h:105
Vector4 yxyy() const
Definition: Vector3.cpp:490
bool operator>=(const Vector3 &) const
Vector3 clamp(const Vector3 &low, const Vector3 &high) const
Definition: Vector3.h:329
Definition: PositionTrait.h:5
Vector3 fastDirection() const
Definition: Vector3.h:764
Definition: AABox.h:25
Axis primaryAxis() const
Definition: Vector3.cpp:129
bool any(float x)
Definition: g3dmath.h:424
Vector3 &__fastcall operator=(const Vector3 &rkVector)
Definition: Vector3.h:631
Vector4 xxxx() const
Definition: Vector3.cpp:453
bool operator!=(const Vector3 &rkVector) const
Definition: Vector3.h:662
Vector3 yxx() const
Definition: Vector3.cpp:424
void getTangents(Vector3 &X, Vector3 &Y) const
Definition: Vector3.h:437
void deserialize(std::string &s, BinaryInput &b)
Definition: serialize.h:16
Vector4 zyzy() const
Definition: Vector3.cpp:503
Vector2 yy() const
Definition: Vector3.cpp:415
Vector3 zzz() const
Definition: Vector3.cpp:449
bool fuzzyNe(double a, double b)
Definition: g3dmath.h:861
Vector3 &__fastcall operator/=(float s)
Definition: Vector3.h:170
static Vector3 & ignore()
Definition: Vector3.cpp:114
float rsq(float x)
Definition: g3dmath.h:380
double clamp(double val, double low, double hi)
Definition: g3dmath.h:571
Vector4 yyzx() const
Definition: Vector3.cpp:475
Axis
Definition: Vector3.h:122
Vector4 xxyx() const
Definition: Vector3.cpp:462
Vector4 xxxz() const
Definition: Vector3.cpp:507
float __fastcall dot(const Vector3 &rkVector) const
Definition: Vector3.h:771
Vector3 clamp(float low, float high) const
Definition: Vector3.h:336
#define debugAssertM(exp, message)
Definition: debugAssert.h:161
Vector3 xxx() const
Definition: Vector3.cpp:423
Vector3 direction() const
Definition: Vector3.h:756
Vector3 xyx() const
Definition: Vector3.cpp:426
Vector4 yxzy() const
Definition: Vector3.cpp:499
Vector4 yxxy() const
Definition: Vector3.cpp:481
float y
Definition: Vector3.h:62
float length() const
Definition: Vector3.h:751
Vector4 zxzx() const
Definition: Vector3.cpp:473
Vector4 yzyy() const
Definition: Vector3.cpp:496
Vector3 yyx() const
Definition: Vector3.cpp:427
T max(const T &x, const T &y)
Definition: g3dmath.h:320
Vector3 fastUnit() const
Definition: Vector3.h:287
Definition: Vector3.h:58
Vector4 yzyx() const
Definition: Vector3.cpp:469
Vector4 yyxx() const
Definition: Vector3.cpp:457
Vector3 zyy() const
Definition: Vector3.cpp:437
Vector4 zxxy() const
Definition: Vector3.cpp:482
Vector3()
Definition: Vector3.h:604
const float &__fastcall operator[](int i) const
Definition: Vector3.h:621
Vector4 yxzx() const
Definition: Vector3.cpp:472
Vector3 __fastcall operator*(float s) const
Definition: Vector3.h:681
Vector2 xx() const
Definition: Vector3.cpp:411
Vector4 zzyx() const
Definition: Vector3.cpp:470
static const Vector3 & unitX()
Definition: Vector3.cpp:121
Vector4 zxzz() const
Definition: Vector3.cpp:527
static const Vector3 & zero()
Definition: Vector3.cpp:119
Vector3 lerp(const Vector3 &v, float alpha) const
Definition: Vector3.h:357
Vector4 zyzz() const
Definition: Vector3.cpp:530
Definition: Vector3.h:122
Vector4 yxxz() const
Definition: Vector3.cpp:508
Vector4 xzyx() const
Definition: Vector3.cpp:468
T min(const T &x, const T &y)
Definition: g3dmath.h:305
Vector3 xxy() const
Definition: Vector3.cpp:432
Easy loading and saving of human-readable configuration files.
Definition: Any.h:184
Vector4 xyzx() const
Definition: Vector3.cpp:474
Vector4 zzxx() const
Definition: Vector3.cpp:461
bool operator<=(const Vector3 &) const
Vector3 floor() const
Definition: Vector3.h:344
size_t hashCode() const
Definition: Vector3.cpp:155
void serialize(const std::string &s, BinaryOutput &b)
Definition: serialize.h:12
Vector4 xzzz() const
Definition: Vector3.cpp:531
static const Vector3 & unitY()
Definition: Vector3.cpp:122
Vector4 yyxz() const
Definition: Vector3.cpp:511
Vector3 refractionDirection(const Vector3 &normal, float iInside, float iOutside) const
Definition: Vector3.cpp:321
Vector3 zyx() const
Definition: Vector3.cpp:428
Vector4 yzxx() const
Definition: Vector3.cpp:460
Vector3 yxy() const
Definition: Vector3.cpp:433
Vector4 yzxy() const
Definition: Vector3.cpp:487
Vector4 zyzx() const
Definition: Vector3.cpp:476
Vector4 zyyy() const
Definition: Vector3.cpp:494
void deserialize(class BinaryInput &b)
Definition: Vector3.cpp:190
Vector4 xzzx() const
Definition: Vector3.cpp:477
Vector4 zxyy() const
Definition: Vector3.cpp:491
Vector3 unit() const
Definition: Vector3.h:281
A simple tokenizer for parsing text files.
Definition: TextInput.h:223
Vector4 zyxz() const
Definition: Vector3.cpp:512
Vector3 xzy() const
Definition: Vector3.cpp:438
float magnitude() const
Definition: Vector3.h:746
Vector4 xzxy() const
Definition: Vector3.cpp:486
Vector4 xxxy() const
Definition: Vector3.cpp:480
Vector4 yzzz() const
Definition: Vector3.cpp:532
void serialize(class BinaryOutput &b) const
Definition: Vector3.cpp:219
Definition: Vector4.h:39
static void orthonormalize(Vector3 akVector[3])
Definition: Vector3.cpp:357
Vector4 xzzy() const
Definition: Vector3.cpp:504
Vector4 yzzx() const
Definition: Vector3.cpp:478
Definition: Vector3.h:122
Vector3 zzx() const
Definition: Vector3.cpp:431
Vector4 zzxz() const
Definition: Vector3.cpp:515
Vector4 yxyz() const
Definition: Vector3.cpp:517
Vector4 zyxy() const
Definition: Vector3.cpp:485
Vector3 zxy() const
Definition: Vector3.cpp:434
Vector4 xxzz() const
Definition: Vector3.cpp:525
static const Vector3 & unitZ()
Definition: Vector3.cpp:123
Vector4 xxzx() const
Definition: Vector3.cpp:471
Vector4 yyxy() const
Definition: Vector3.cpp:484
Vector3 yzz() const
Definition: Vector3.cpp:448
Definition: TextOutput.h:60
Vector3 xyy() const
Definition: Vector3.cpp:435
bool isFinite() const
Definition: Vector3.h:652
static void getPosition(const G3D::Vector2 &v, G3D::Vector3 &p)
Definition: Vector3.h:837
Definition: Matrix3.h:37
Vector3 zyz() const
Definition: Vector3.cpp:446
Vector4 xyxy() const
Definition: Vector3.cpp:483
Any toAny() const
Definition: Vector3.cpp:94
Definition: Vector3.h:122
Vector4 yxxx() const
Definition: Vector3.cpp:454
Vector3 xzx() const
Definition: Vector3.cpp:429
Vector4 yyyx() const
Definition: Vector3.cpp:466
Vector4 xyyy() const
Definition: Vector3.cpp:492
static Vector3 cosSphereRandom(const Vector3 &n, Random &r=Random::common())
Definition: Vector3.cpp:263
Vector4 yxyx() const
Definition: Vector3.cpp:463
Vector4 zxyx() const
Definition: Vector3.cpp:464
Vector3 round() const
Definition: Vector3.h:349
Vector3 yzx() const
Definition: Vector3.cpp:430
Vector2 yx() const
Definition: Vector3.cpp:412
Vector4 zyyz() const
Definition: Vector3.cpp:521
float z
Definition: Vector3.h:62
static const Vector3 & maxFinite()
Definition: Vector3.cpp:127
Vector3 xzz() const
Definition: Vector3.cpp:447
Vector4 yyyy() const
Definition: Vector3.cpp:493
Vector3 reflectAbout(const Vector3 &normal) const
Definition: Vector3.cpp:233
static Vector3 cosHemiRandom(const Vector3 &n, Random &r=Random::common())
Random unit vector, distributed according to .
Definition: Vector3.cpp:243
Vector4 xxyy() const
Definition: Vector3.cpp:489
Definition: Color3.h:33
Vector4 yxzz() const
Definition: Vector3.cpp:526
Vector3 unitCross(const Vector3 &rkVector) const
Definition: Vector3.h:782
Vector4 zzzz() const
Definition: Vector3.cpp:533
Vector4 yzxz() const
Definition: Vector3.cpp:514
Vector2 zz() const
Definition: Vector3.cpp:419
static size_t hashCode(const G3D::Vector3 &key)
Definition: Vector3.h:830
std::ostream & operator<<(std::ostream &os, const NetAddress &)
Definition: NetworkDevice.cpp:26
bool fuzzyEq(const Vector3 &other) const
Definition: Vector3.h:640
Definition: BinaryOutput.h:52
bool operator==(const Vector3 &rkVector) const
Definition: Vector3.h:657
Vector4 xyxz() const
Definition: Vector3.cpp:510
float max() const
Definition: Vector3.h:323
Vector3 movedTowards(const Vector3 &goal, float maxTranslation) const
Definition: Vector3.cpp:35
static Vector3 cosPowHemiRandom(const Vector3 &n, const float k, Random &r=Random::common())
Random unit vector, distributed according to .
Definition: Vector3.cpp:283
Vector4 zxxx() const
Definition: Vector3.cpp:455
Vector2 yz() const
Definition: Vector3.cpp:418
Vector4 xxzy() const
Definition: Vector3.cpp:498
Vector4 zxxz() const
Definition: Vector3.cpp:509
Vector4 yzzy() const
Definition: Vector3.cpp:505
static void getPosition(const G3D::Vector3 &v, G3D::Vector3 &p)
Definition: Vector3.h:841
Vector4 zxyz() const
Definition: Vector3.cpp:518
Vector2 zy() const
Definition: Vector3.cpp:416
Vector4 xzxx() const
Definition: Vector3.cpp:459
float min() const
Definition: Vector3.h:318
float average() const
Definition: Vector3.h:415
Vector4 xzyz() const
Definition: Vector3.cpp:522
#define const
Definition: zconf.h:217
Vector3 &__fastcall operator*=(float s)
Definition: Vector3.h:712
Vector3 reflectionDirection(const Vector3 &normal) const
Definition: Vector3.cpp:315
static const Vector3 & inf()
Definition: Vector3.cpp:124
bool fuzzyNe(const Vector3 &other) const
Definition: Vector3.h:646
bool operator<(const Vector3 &) const
Vector3 xxz() const
Definition: Vector3.cpp:441
Vector3 Point3
Definition: Vector3.h:820
static const Vector3 & one()
Definition: Vector3.cpp:120
static const Vector3 & nan()
Definition: Vector3.cpp:125
bool isUnit() const
Definition: Vector3.h:805
Vector4 xzxz() const
Definition: Vector3.cpp:513
bool isNaN() const
Definition: Vector3.cpp:83
float squaredLength() const
Definition: Vector3.h:741
static Random & common()
Definition: Random.cpp:16
Vector4 yyzz() const
Definition: Vector3.cpp:529
bool fuzzyEq(double a, double b)
Definition: g3dmath.h:857
Vector3 zxz() const
Definition: Vector3.cpp:443
G3D::Color3 operator*(float s, const G3D::Color3 &c)
Definition: Color3.h:275
Vector3 __fastcall operator-() const
Definition: Vector3.h:691
#define Y
Definition: CollisionDetection.cpp:2282
bool isFinite(double x)
Definition: g3dmath.h:525
std::string toString() const
Definition: Vector3.cpp:386
Vector4 xyyz() const
Definition: Vector3.cpp:519
Definition: Random.h:39
Vector4 xyzy() const
Definition: Vector3.cpp:501