![]() |
VR-Link API Documentation for DIS
|
00001 /********************************************************************* 00002 ** Copyright (c) 1992-2010 VT MAK 00003 ** All rights reserved. 00004 *********************************************************************/ 00005 00006 #ifndef DtVector_H_ 00007 #define DtVector_H_ 00008 00012 00013 #include <vlutil/vlMachineTypes.h> 00014 #include <vlutil/vlNetTypes.h> 00015 #include <vlutil/vlString.h> 00016 #include <iosfwd> 00017 00018 #ifdef DtUSE_UTILITIES_NAMESPACE 00019 namespace DtUSE_UTILITIES_NAMESPACE 00020 { 00021 #endif 00022 00023 00026 enum DtVectorOffset 00027 { 00028 DtX, 00029 DtY, 00030 DtZ 00031 }; 00032 00033 class DtDcm; 00034 class DtVector; 00035 00036 typedef const DtVector &DtConstVector; 00037 typedef DtVector &DtVectorRef; 00038 typedef double DtThreeIndex[3][3][3]; 00039 typedef double (*DtThreeIndexPtr)[3][3]; 00040 00051 class DT_DLL_MATRIX DtVector 00052 { 00053 public: 00054 00055 DtVector (); 00056 00058 DtVector( const double& x, const double& y, const double& z); 00059 00061 ~DtVector(); 00062 00064 DtVector(const DtVector& vec); 00065 00067 DtVector& operator=(const DtVector& vec); 00068 00070 void setToZero(); 00071 00073 00074 const double& x() const; 00075 void setX(const double& x); 00077 00079 00080 const double& y() const; 00081 void setY(const double& y); 00083 00085 00086 const double& z() const; 00087 void setZ(const double& z); 00089 00091 DtVector &operator+=(const DtVector &other); 00092 00094 DtVector &operator-=(const DtVector &other); 00095 00096 00098 double& operator[](int ind); 00099 00101 double operator[](int ind) const; 00102 00104 double& operator[](DtVectorOffset ind); 00105 00107 double operator[](DtVectorOffset ind) const; 00108 00111 int operator==(const DtVector& vec) const; 00112 00115 int operator!=(const DtVector& vec) const; 00116 00118 DtString string() const; 00119 00122 double magnitudeSquared() const; 00123 00125 void normalize(); 00126 00128 bool isNormalized() const; 00129 00131 DtVector crossProduct(const DtVector& v) const; 00132 00134 double dotProduct(const DtVector& v) const; 00135 00137 bool approxEq(const DtVector& v, const double& tolerance) const; 00138 00140 bool magnitudeIsZero() const; 00141 00145 bool magnitudeIsZero(double tolerance) const; 00146 00148 std::ostream &printDataToStream(std::ostream &str) const; 00149 00150 public: 00151 00154 00155 operator double* (); 00156 operator const double* () const; 00158 00159 public: 00160 00161 00163 static const DtVector& zero(); 00164 00166 static const DtVector& i(); 00167 00169 static const DtVector& j(); 00170 00172 static const DtVector& k(); 00173 00175 static const DtVector& ones(); 00176 00177 00178 protected: 00179 00180 double myRep[3]; 00181 00182 00183 }; 00184 00185 // 00186 // Vector routines. 00187 // 00188 00189 #define DtSetVec(v, x, y, z) v[DtX]=x;v[DtY]=y;v[DtZ]=z; 00190 00192 extern DT_DLL_MATRIX DtThreeIndex DtLevi_Civita; 00193 00196 DT_DLL_MATRIX DtVector operator+(const DtVector& v1, const DtVector &v2); 00197 00200 DT_DLL_MATRIX DtVector operator-(const DtVector& v1, const DtVector &v2); 00201 00203 DT_DLL_MATRIX void DtVecScale(const DtVector& v, double scale_factor, DtVector& result); 00204 00206 DT_DLL_MATRIX void DtVecNeg(const DtVector& v1, DtVector& result); 00207 00210 DT_DLL_MATRIX double DtVecCosProd(const DtVector& v1, const DtVector& v2); 00211 00214 DT_DLL_MATRIX double DtVecBoxProd(const DtVector& v1, const DtVector& v2, const DtVector& v3); 00215 00218 DT_DLL_MATRIX void DtVecDcmMul(const DtVector& v, const DtDcm& m, DtVector& result); 00219 00221 DT_DLL_MATRIX void DtVV_Product(const DtVector& a,const DtVector& b, DtDcm& ans); 00222 00224 DT_DLL_MATRIX double DtVecInfNorm(const DtVector& v1); 00225 00227 DT_DLL_MATRIX void DtVecInit(DtVector& v); 00228 00231 DT_DLL_MATRIX void DtVecCopy(const DtVector& from, DtVector& to); 00232 00235 DT_DLL_MATRIX int DtVecCheck(const DtVector& v); 00236 00239 DT_DLL_MATRIX void DtVecNormalize(const DtVector& v, DtVector& result); 00240 00243 DT_DLL_MATRIX void DtVecCrossProd(const DtVector& v1, const DtVector& v2, DtVector& result); 00244 00247 DT_DLL_MATRIX double DtVecDotProd(const DtVector& v1, const DtVector& v2); 00248 00251 DT_DLL_MATRIX void DtVecDump(const char *str, const DtVector& v); 00252 00255 DT_DLL_MATRIX void DtVecSub(const DtVector& v1, const DtVector& v2, DtVector& result); 00256 00259 DT_DLL_MATRIX void DtVecAdd(const DtVector& v1, const DtVector& v2, DtVector& result); 00260 00264 DT_DLL_MATRIX DtVector DtVelocityFromAToB(const DtVector& a, 00265 const DtVector& b, double time); 00266 00270 DT_DLL_MATRIX double DtHeadingFromAToB(const DtVector& a, const DtVector& b); 00271 00272 /* ||p1-p2||_{2} */ 00274 DT_DLL_MATRIX double DtDistance(const DtVector& p1, const DtVector& p2); 00275 00277 DT_DLL_MATRIX double DtDistSqr(const DtVector& p1, const DtVector& p2); 00278 00279 00282 class DT_DLL_MATRIX DtNetVector32 00283 { 00284 public: 00285 DtNetVector32(); 00286 DtNetVector32(const DtVector &vec); 00287 DtVector operator=(const DtVector &vec); 00288 operator DtVector() const; 00289 DtNetFloat32 &operator[](int i); 00290 DtNetFloat32 operator[](int i) const; 00291 private: 00292 DtNetFloat32 rep[3]; 00293 }; 00294 00297 class DT_DLL_MATRIX DtNetVector64 00298 { 00299 public: 00300 DtNetVector64(); 00301 DtNetVector64(const DtVector &vec); 00302 DtVector operator=(const DtVector &vec); 00303 operator DtVector() const; 00304 DtNetFloat64 &operator[](int i); 00305 DtNetFloat64 operator[](int i) const; 00306 private: 00307 DtNetFloat64 rep[3]; 00308 }; 00309 00310 DT_DLL_MATRIX std::ostream & operator << (std::ostream &str, const DtVector &vec); 00311 00312 00314 #define vlVector_inl 00315 #include "vlVector.inl" 00316 #undef vlVector_inl 00317 00318 #ifdef DtUSE_UTILITIES_NAMESPACE 00319 } 00320 #endif 00321 00322 #endif 00323