Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

vhdVector3.inl

00001 00002 // Copyright : Sebastien Schertenleib 00003 // : VRLab-EPFL 00004 // 00005 // Email :Sebastien.Schertenleib@epfl.ch 00006 // 00007 // This source code is a part of the Game Programming Gems 5 Source Code 00008 // 00009 // Permission to copy, modify, reproduce or redistribute this source code is 00010 // granted provided the above copyright notice is retained in the resulting 00011 // source code. 00012 // 00013 // This file is provided 'as is' with no expressed or implied warranty. 00014 // The author accepts no liability if it causes any damage to your computer. 00015 // 00016 // Do expect bugs. 00017 // Please let me know of any bugs/mods/improvements. 00018 // and I will try to fix/incorporate them into this file. 00019 // Enjoy! 00020 // 00022 00023 00024 00025 #include <math.h> 00026 00027 00028 inline vhdVector3::vhdVector3() 00029 { 00030 //x=0; 00031 //y=0; 00032 //z=0; 00033 //For effeciency reasons the constructor does NOT initialize the vector. 00034 } 00035 00036 inline vhdVector3::vhdVector3( vhtReal fX, vhtReal fY, vhtReal fZ ) 00037 : x( fX ), y( fY ), z( fZ ) 00038 { 00039 } 00040 00041 inline vhdVector3::vhdVector3( const vhdVector3& rkVector ) 00042 : x( rkVector.x ), y( rkVector.y ), z( rkVector.z ) 00043 { 00044 } 00045 00046 00047 inline vhtReal& vhdVector3::operator [] ( int index ) const 00048 { 00049 return ((vhtReal*)this)[index]; 00050 } 00051 00052 00057 inline vhdVector3& vhdVector3::operator = ( const vhdVector3& rkVector ) 00058 { 00059 x = rkVector.x; 00060 y = rkVector.y; 00061 z = rkVector.z; 00062 00063 return *this; 00064 } 00065 00066 inline bool vhdVector3::operator == ( const vhdVector3& rkVector ) const 00067 { 00068 return ( x == rkVector.x && y == rkVector.y && z == rkVector.z ); 00069 } 00070 00071 inline bool vhdVector3::operator != ( const vhdVector3& rkVector ) const 00072 { 00073 return ( x != rkVector.x || y != rkVector.y || z != rkVector.z ); 00074 } 00075 00076 // arithmetic operations 00077 inline vhdVector3 vhdVector3::operator + ( const vhdVector3& rkVector ) const 00078 { 00079 vhdVector3 kSum; 00080 00081 kSum.x = x + rkVector.x; 00082 kSum.y = y + rkVector.y; 00083 kSum.z = z + rkVector.z; 00084 00085 return kSum; 00086 } 00087 00088 inline vhdVector3 vhdVector3::operator - ( const vhdVector3& rkVector ) const 00089 { 00090 vhdVector3 kDiff; 00091 00092 kDiff.x = x - rkVector.x; 00093 kDiff.y = y - rkVector.y; 00094 kDiff.z = z - rkVector.z; 00095 00096 return kDiff; 00097 } 00098 00099 inline vhdVector3 vhdVector3::operator * ( vhtReal fScalar ) const 00100 { 00101 vhdVector3 kProd; 00102 00103 kProd.x = fScalar*x; 00104 kProd.y = fScalar*y; 00105 kProd.z = fScalar*z; 00106 00107 return kProd; 00108 } 00109 00110 inline vhdVector3 vhdVector3::operator * ( const vhdVector3& rhs) const 00111 { 00112 vhdVector3 kProd; 00113 00114 kProd.x = rhs.x * x; 00115 kProd.y = rhs.y * y; 00116 kProd.z = rhs.z * z; 00117 00118 return kProd; 00119 } 00120 00121 inline vhdVector3 vhdVector3::operator / ( vhtReal fScalar ) const 00122 { 00123 vhdVector3 kDiv; 00124 00125 vhtReal fInv = 1.0 / fScalar; 00126 kDiv.x = x * fInv; 00127 kDiv.y = y * fInv; 00128 kDiv.z = z * fInv; 00129 00130 return kDiv; 00131 } 00132 00133 00134 00135 inline vhdVector3 vhdVector3::operator - () const 00136 { 00137 vhdVector3 kNeg; 00138 00139 kNeg.x = -x; 00140 kNeg.y = -y; 00141 kNeg.z = -z; 00142 00143 return kNeg; 00144 } 00145 00146 inline vhdVector3 operator * ( vhtReal fScalar, const vhdVector3& rkVector ) 00147 { 00148 vhdVector3 kProd; 00149 00150 kProd.x = fScalar * rkVector.x; 00151 kProd.y = fScalar * rkVector.y; 00152 kProd.z = fScalar * rkVector.z; 00153 00154 return kProd; 00155 } 00156 00157 // arithmetic updates 00158 inline vhdVector3& vhdVector3::operator += ( const vhdVector3& rkVector ) 00159 { 00160 x += rkVector.x; 00161 y += rkVector.y; 00162 z += rkVector.z; 00163 00164 return *this; 00165 } 00166 00167 inline vhdVector3& vhdVector3::operator -= ( const vhdVector3& rkVector ) 00168 { 00169 x -= rkVector.x; 00170 y -= rkVector.y; 00171 z -= rkVector.z; 00172 00173 return *this; 00174 } 00175 00176 inline vhdVector3& vhdVector3::operator *= ( vhtReal fScalar ) 00177 { 00178 x *= fScalar; 00179 y *= fScalar; 00180 z *= fScalar; 00181 return *this; 00182 } 00183 00184 inline vhdVector3& vhdVector3::operator /= ( vhtReal fScalar ) 00185 { 00186 vhtReal fInv = 1.0 / fScalar; 00187 00188 x *= fInv; 00189 y *= fInv; 00190 z *= fInv; 00191 00192 return *this; 00193 } 00194 00195 inline vhdVector3& vhdVector3::operator *= ( const vhdVector3& rhs) 00196 { 00197 x *= rhs.x; 00198 y *= rhs.y; 00199 z *= rhs.z; 00200 return *this; 00201 } 00202 00203 inline vhdVector3& vhdVector3::operator /= ( const vhdVector3& rhs) 00204 { 00205 x /= rhs.x; 00206 y /= rhs.y; 00207 z /= rhs.z; 00208 return *this; 00209 } 00210 00211

Generated on Sun Oct 3 16:32:22 2004 for vhdABTTree by doxygen 1.3.8