Changeset 2176 for GTP/trunk/Lib/Vis/Preprocessing/src/Vector3.h
- Timestamp:
- 02/28/07 19:38:47 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Vector3.h
r2168 r2176 3 3 4 4 #include <iostream> 5 // using namespace std;5 // 6 6 #include <math.h> 7 7 #include "common.h" 8 8 9 //using std::ostream; 10 //using std::istream; 9 11 10 12 namespace GtpVisibilityPreprocessor { … … 14 16 class Vector2; 15 17 16 17 // HACK of returning vector components as array fields. 18 // HACK of returning std::vector components as array fields. 18 19 // NOT guarrantied to work with some strange variable allignment ! 19 20 #define __VECTOR_HACK … … 39 40 Vector3(const Vector3 &v) { x = v.x; y = v.y; z = v.z; } 40 41 41 // Functions to get at the vector components42 // Functions to get at the std::vector components 42 43 float& operator[] (int inx) { 43 44 #ifndef __VECTOR_HACK … … 80 81 void SetValue(const float a) { x = y = z = a; } 81 82 82 // returns the axis, where the vector has the largest value83 // returns the axis, where the std::vector has the largest value 83 84 int DrivingAxis(void) const; 84 85 85 // returns the axis, where the vector has the smallest value86 // returns the axis, where the std::vector has the smallest value 86 87 int TinyAxis(void) const; 87 88 … … 95 96 } 96 97 97 // normalizes the vector of unit size corresponding to givenvector98 // normalizes the std::vector of unit size corresponding to given std::vector 98 99 inline void Normalize(); 99 100 100 /** Returns false if this vector has a nan component.101 /** Returns false if this std::vector has a nan component. 101 102 */ 102 103 bool CheckValidity() const; … … 109 110 In fact it tries v x (0,0,1) an if the result is too small, 110 111 it definitely does v x (0,1,0). It will always work for 111 non-degenareted vector and is much faster than to use112 non-degenareted std::vector and is much faster than to use 112 113 TangentVectors. 113 114 114 @param v(in) The vector we want to find normal for.115 @return The normal vector to v.115 @param v(in) The std::vector we want to find normal for. 116 @return The normal std::vector to v. 116 117 */ 117 118 friend inline Vector3 ArbitraryNormal(const Vector3 &v); … … 140 141 void RightHandedBase(Vector3& U, Vector3& V) const; 141 142 142 /// Transforms a vector to the global coordinate frame.143 /// Transforms a std::vector to the global coordinate frame. 143 144 /** 144 145 Given a local coordinate frame (U,V,N) (i.e. U,V,N are 145 146 the x,y,z axes of the local coordinate system) and 146 a vector 'loc' in the local coordiante system, this147 function returns a the coordinates of the same vector147 a std::vector 'loc' in the local coordiante system, this 148 function returns a the coordinates of the same std::vector 148 149 in global frame (i.e. frame (1,0,0), (0,1,0), (0,0,1). 149 150 */ … … 153 154 const Vector3& N); 154 155 155 /// Transforms a vector to a local coordinate frame.156 /// Transforms a std::vector to a local coordinate frame. 156 157 /** 157 158 Given a local coordinate frame (U,V,N) (i.e. U,V,N are 158 159 the x,y,z axes of the local coordinate system) and 159 a vector 'loc' in the global coordiante system, this160 function returns a the coordinates of the same vector160 a std::vector 'loc' in the global coordiante system, this 161 function returns a the coordinates of the same std::vector 161 162 in the local frame. 162 163 */ … … 166 167 const Vector3& N); 167 168 168 /// the magnitude=size of the vector169 /// the magnitude=size of the std::vector 169 170 friend inline float Magnitude(const Vector3 &v); 170 /// the squared magnitude of the vector .. for efficiency in some cases171 /// the squared magnitude of the std::vector .. for efficiency in some cases 171 172 friend inline float SqrMagnitude(const Vector3 &v); 172 173 /// Magnitude(v1-v2) … … 175 176 friend inline float SqrDistance(const Vector3 &v1, const Vector3 &v2); 176 177 177 // creates the vector of unit size corresponding to givenvector178 // creates the std::vector of unit size corresponding to given std::vector 178 179 friend inline Vector3 Normalize(const Vector3 &A); 179 180 180 // Rotate a normal vector.181 // Rotate a normal std::vector. 181 182 friend Vector3 PlaneRotate(const Matrix4x4 &, const Vector3 &); 182 183 183 184 // construct view vectors .. DirAt is the main viewing direction 184 // Viewer is the coordinates of viewer location, UpL is the vector.185 // Viewer is the coordinates of viewer location, UpL is the std::vector. 185 186 friend void ViewVectors(const Vector3 &DirAt, const Vector3 &Viewer, 186 187 const Vector3 &UpL, Vector3 &ViewV, … … 224 225 friend inline Vector3 CrossProd (const Vector3 &A, const Vector3 &B); 225 226 226 friend ostream& operator<< (ostream &s, const Vector3 &A);227 friend istream& operator>> (istream &s, Vector3 &A);227 friend std::ostream& operator<< (std::ostream &s, const Vector3 &A); 228 friend std::istream& operator>> (std::istream &s, Vector3 &A); 228 229 229 230 friend void Minimize(Vector3 &min, const Vector3 &candidate); … … 477 478 478 479 // Overload << operator for C++-style output 479 inline ostream&480 operator<< ( ostream &s, const Vector3 &A)480 inline std::ostream& 481 operator<< (std::ostream &s, const Vector3 &A) 481 482 { 482 483 return s << "(" << A.x << ", " << A.y << ", " << A.z << ")"; … … 484 485 485 486 // Overload >> operator for C++-style input 486 inline istream&487 operator>> ( istream &s, Vector3 &A)487 inline std::istream& 488 operator>> (std::istream &s, Vector3 &A) 488 489 { 489 490 char a;
Note: See TracChangeset
for help on using the changeset viewer.