Wm4Vector3.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef WM4VECTOR3_H
00018 #define WM4VECTOR3_H
00019
00020 #include "Wm4FoundationLIB.h"
00021 #include "Wm4Math.h"
00022
00023 namespace Wm4
00024 {
00025
00026 template <class Real>
00027 class Vector3
00028 {
00029 public:
00030
00031 Vector3 ();
00032 Vector3 (Real fX, Real fY, Real fZ);
00033 Vector3 (const Real* afTuple);
00034 Vector3 (const Vector3& rkV);
00035
00036
00037 operator const Real* () const;
00038 operator Real* ();
00039 Real operator[] (int i) const;
00040 Real& operator[] (int i);
00041 Real X () const;
00042 Real& X ();
00043 Real Y () const;
00044 Real& Y ();
00045 Real Z () const;
00046 Real& Z ();
00047
00048
00049 Vector3& operator= (const Vector3& rkV);
00050
00051
00052 bool operator== (const Vector3& rkV) const;
00053 bool operator!= (const Vector3& rkV) const;
00054 bool operator< (const Vector3& rkV) const;
00055 bool operator<= (const Vector3& rkV) const;
00056 bool operator> (const Vector3& rkV) const;
00057 bool operator>= (const Vector3& rkV) const;
00058
00059
00060 Vector3 operator+ (const Vector3& rkV) const;
00061 Vector3 operator- (const Vector3& rkV) const;
00062 Vector3 operator* (Real fScalar) const;
00063 Vector3 operator/ (Real fScalar) const;
00064 Vector3 operator- () const;
00065
00066
00067 Vector3& operator+= (const Vector3& rkV);
00068 Vector3& operator-= (const Vector3& rkV);
00069 Vector3& operator*= (Real fScalar);
00070 Vector3& operator/= (Real fScalar);
00071
00072
00073 Real Length () const;
00074 Real SquaredLength () const;
00075 Real Dot (const Vector3& rkV) const;
00076 Real Normalize ();
00077
00078
00079
00080
00081
00082
00083 Vector3 Cross (const Vector3& rkV) const;
00084 Vector3 UnitCross (const Vector3& rkV) const;
00085
00086
00087
00088
00089 void GetBarycentrics (const Vector3& rkV0, const Vector3& rkV1,
00090 const Vector3& rkV2, const Vector3& rkV3, Real afBary[4]) const;
00091
00092
00093
00094
00095 static void Orthonormalize (Vector3& rkU, Vector3& rkV, Vector3& rkW);
00096 static void Orthonormalize (Vector3* akV);
00097
00098
00099
00100
00101
00102 static void GenerateOrthonormalBasis (Vector3& rkU, Vector3& rkV,
00103 Vector3& rkW);
00104
00105
00106
00107
00108 static void GenerateComplementBasis (Vector3& rkU, Vector3& rkV,
00109 const Vector3& rkW);
00110
00111
00112 static void ComputeExtremes (int iVQuantity, const Vector3* akPoint,
00113 Vector3& rkMin, Vector3& rkMax);
00114
00115
00116 WM4_FOUNDATION_ITEM static const Vector3 ZERO;
00117 WM4_FOUNDATION_ITEM static const Vector3 UNIT_X;
00118 WM4_FOUNDATION_ITEM static const Vector3 UNIT_Y;
00119 WM4_FOUNDATION_ITEM static const Vector3 UNIT_Z;
00120 WM4_FOUNDATION_ITEM static const Vector3 ONE;
00121
00122 private:
00123
00124 int CompareArrays (const Vector3& rkV) const;
00125
00126 Real m_afTuple[3];
00127 };
00128
00129
00130 template <class Real>
00131 Vector3<Real> operator* (Real fScalar, const Vector3<Real>& rkV);
00132
00133
00134 template <class Real>
00135 std::ostream& operator<< (std::ostream& rkOStr, const Vector3<Real>& rkV);
00136
00137 }
00138
00139 #include "Wm4Vector3.inl"
00140
00141 namespace Wm4
00142 {
00143 typedef Vector3<float> Vector3f;
00144 typedef Vector3<double> Vector3d;
00145
00146 }
00147
00148 #endif