Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef VectorH
00033 #define VectorH
00034
00035 #include <zeusmath/System/Interfaces/IVector.hpp>
00036 #include <zeusbase/System/ArrayList.hpp>
00037 #include <zeusbase/System/String.h>
00038
00039 BEGIN_NAMESPACE_Zeus
00040
00041
00044
00045 zeusmath_class TVector : public IVector
00046 {
00047 public:
00048 TVector();
00049 TVector(Int iSize);
00050 TVector(const TVector& rVector);
00051 TVector(const IVector& rVector);
00052 TVector(Int* paComp, Int iSize);
00053 TVector(Float* paComp, Int iSize);
00054 TVector(const TString& rstrValues);
00055
00056
00059
00060 inline virtual ~TVector() {}
00061
00062 TString toString() const;
00063
00064
00065 virtual void MQUALIFIER assign(const IVector& rVector);
00066 virtual void MQUALIFIER assignValues(const Float* apValues, Int iSize);
00067 virtual bool MQUALIFIER equals(const IVector& rVector, Float fPrecision = FLOAT_PRECISION) const;
00068 virtual Float MQUALIFIER getComponent(Int iIndex) const;
00069 virtual Float* MQUALIFIER getComponents();
00070 virtual const Float* MQUALIFIER getComponentsConst() const;
00071 virtual Int MQUALIFIER getDimension() const;
00072 virtual Float MQUALIFIER getNorm() const;
00073 virtual Float MQUALIFIER getNormSquared() const;
00074 virtual Float MQUALIFIER getLength() const;
00075 virtual Float MQUALIFIER getLengthSquared() const;
00076 virtual bool MQUALIFIER setComponent(Int iIndex, Float fValue);
00077 virtual void MQUALIFIER setDimension(Int iValue);
00078 virtual void MQUALIFIER add(const IVector& rVector);
00079 virtual void MQUALIFIER subtract(const IVector& rVector);
00080 virtual Float MQUALIFIER calcScalarProduct(const IVector& rVector) const;
00081 virtual void MQUALIFIER multiply(const Float& f);
00082 virtual void MQUALIFIER divide(const Float& f);
00083
00084
00085 TVector operator+(const IVector& rVector) const;
00086 TVector operator-(const IVector& rVector) const;
00087 Float operator*(const IVector& rVector) const;
00088 TVector operator*(const Float& f) const;
00089 TVector operator/(const Float& f) const;
00090 const TVector& operator+=(const IVector& rVector);
00091 const TVector& operator-=(const IVector& rVector);
00092 const TVector& operator*=(const Float& f);
00093 const TVector& operator/=(const Float& f);
00094
00095
00096 const TVector& operator=(const IVector& rVector);
00097 const TVector& operator=(const TVector& rVector);
00098
00099
00100 bool operator==(const IVector& rVector) const;
00101 bool operator!=(const IVector& rVector) const;
00102
00103 protected:
00104
00105 private:
00107 TArrayList<Float> m_lstComp;
00108 };
00109
00110
00111
00116
00117 inline TVector::TVector()
00118 : m_lstComp(1, etShallowCopy)
00119 {
00120 }
00121
00122
00126
00127 inline TVector::TVector(Int iSize)
00128 : m_lstComp(iSize+2, etShallowCopy)
00129 {
00130 setDimension(iSize);
00131 }
00132
00133
00137
00138 inline TVector::TVector(const TVector& rVector)
00139 : m_lstComp(rVector.getComponentsConst(), rVector.getDimension(), etShallowCopy)
00140 {}
00141
00142
00146
00147 inline TVector::TVector(const IVector& rVector)
00148 : m_lstComp(rVector.getComponentsConst(), rVector.getDimension(), etShallowCopy)
00149 {
00150 }
00151
00152
00157
00158 inline TVector::TVector(Int* paComp, Int iSize)
00159 : m_lstComp(iSize+2, etShallowCopy)
00160 {
00161 for(Int i = 0; i < iSize; i++)
00162 {
00163 m_lstComp.add(paComp[i]);
00164 }
00165 }
00166
00167
00172
00173 inline TVector::TVector(Float* paComp, Int iSize)
00174 : m_lstComp(paComp, iSize, etShallowCopy)
00175 {}
00176
00177
00184
00185 inline TVector TVector::operator/(const Float& f) const
00186 {
00187 return *this * (f == 0 ? 0 : Float(1) / f);
00188 }
00189
00190
00197
00198 inline const TVector& TVector::operator+=(const IVector& rVector)
00199 {
00200 *this = *this + rVector;
00201 return *this;
00202 }
00203
00204
00212
00213 inline const TVector& TVector::operator-=(const IVector& rVector)
00214 {
00215 *this = *this - rVector;
00216 return *this;
00217 }
00218
00219
00227
00228 inline const TVector& TVector::operator*=(const Float& f)
00229 {
00230 *this = *this * f;
00231 return *this;
00232 }
00233
00234
00242
00243 inline const TVector& TVector::operator/=(const Float& f)
00244 {
00245 *this = *this / f;
00246 return *this;
00247 }
00248
00249
00256
00257 inline const TVector& TVector::operator=(const IVector& rVector)
00258 {
00259 assign(rVector);
00260 return *this;
00261 }
00262
00263
00270
00271 inline const TVector& TVector::operator=(const TVector& rVector)
00272 {
00273 assign(rVector);
00274 return *this;
00275 }
00276
00277
00278
00279
00285
00286 inline bool TVector::operator==(const IVector& rVector) const
00287 {
00288 return equals(rVector);
00289 }
00290
00291
00297
00298 inline bool TVector::operator!=(const IVector& rVector) const
00299 {
00300 return !equals(rVector);
00301 }
00302
00303
00304
00307
00308 inline void MQUALIFIER TVector::assign(const IVector& rVector)
00309 {
00310 m_lstComp.setArray(rVector.getComponentsConst(), rVector.getDimension(), false);
00311 }
00312
00313
00316
00317 inline void MQUALIFIER TVector::assignValues(const Float* apValues, Int iSize)
00318 {
00319 m_lstComp.setArray(apValues, iSize, false);
00320 }
00321
00322
00323
00326
00327 inline Float* MQUALIFIER TVector::getComponents()
00328 {
00329 return m_lstComp.getArray();
00330 }
00331
00332
00335
00336 inline const Float* MQUALIFIER TVector::getComponentsConst() const
00337 {
00338 return m_lstComp.getArray();
00339 }
00340
00341
00344
00345 inline Int MQUALIFIER TVector::getDimension() const
00346 {
00347 return m_lstComp.getCount();
00348 }
00349
00350
00353
00354 inline Float MQUALIFIER TVector::getLength() const
00355 {
00356 return getNorm();
00357 }
00358
00359
00362
00363 inline Float MQUALIFIER TVector::getLengthSquared() const
00364 {
00365 return getNormSquared();
00366 }
00367
00368
00371
00372 inline void MQUALIFIER TVector::add(const IVector& rVector)
00373 {
00374 *this += rVector;
00375 }
00376
00377
00380
00381 inline void MQUALIFIER TVector::subtract(const IVector& rVector)
00382 {
00383 *this -= rVector;
00384 }
00385
00386
00389
00390 inline Float MQUALIFIER TVector::calcScalarProduct(const IVector& rVector) const
00391 {
00392 return *this * rVector;
00393 }
00394
00395
00398
00399 inline void MQUALIFIER TVector::multiply(const Float& f)
00400 {
00401 *this *= f;
00402 }
00403
00404
00407
00408 inline void MQUALIFIER TVector::divide(const Float& f)
00409 {
00410 *this /= f;
00411 }
00412
00413
00414 END_NAMESPACE_Zeus
00415
00416 #endif