# xsi_vector2f.h

Go to the documentation of this file.

    00001 //*****************************************************************************
    00011 //*****************************************************************************
    00012
    00013 #if (_MSC_VER > 1000) || defined(SGI_COMPILER)
    00014 #pragma once
    00015 #endif
    00016
    00017 #ifndef __XSIVECTOR2F_H__
    00018 #define __XSIVECTOR2F_H__
    00019
    00020 #include "sicppsdk.h"
    00021 #include <math.h>
    00022
    00023 namespace XSI {
    00024
    00025 namespace MATH {
    00026
    00027 //*****************************************************************************
    00034 //*****************************************************************************
    00035 class CVector2f
    00036 {
    00037 public:
    00039     SICPPSDK_INLINE CVector2f();
    00040
    00045     SICPPSDK_INLINE CVector2f(float in_X, float in_Y );
    00046
    00050     SICPPSDK_INLINE CVector2f( const CVector2f& in_vector2);
    00051
    00053     ~CVector2f() {}
    00054
    00059     SICPPSDK_INLINE CVector2f & operator=( const CVector2f & in_vector2 );
    00060
    00066     SICPPSDK_INLINE bool operator ==(const CVector2f & in_vector2 )const;
    00067
    00073     SICPPSDK_INLINE bool operator !=(const CVector2f & in_vector2 )const;
    00074
    00082     SICPPSDK_INLINE bool operator < ( const CVector2f & in_vector2 ) const;
    00083
    00088     SICPPSDK_INLINE CVector2f& operator ~();
    00089
    00095     SICPPSDK_INLINE CVector2f& operator +=(const CVector2f& in_vector2);
    00096
    00102     SICPPSDK_INLINE CVector2f& operator -=(const CVector2f & in_vector2);
    00103
    00109     SICPPSDK_INLINE CVector2f& operator *=(const float& in_dAlpha);
    00110
    00114     SICPPSDK_INLINE CVector2f& SetNull();
    00115
    00119     SICPPSDK_INLINE float GetLength()const;
    00120
    00124     SICPPSDK_INLINE float GetLengthSquared()const;
    00125
    00130     SICPPSDK_INLINE bool Equals(const CVector2f& in_vector2)const;
    00131
    00138     SICPPSDK_INLINE bool EpsilonEquals
    00139     (
    00140         const CVector2f& in_vector,
    00141         const float in_fEpsilon
    00142     )const;
    00143
    00150     SICPPSDK_INLINE CVector2f& ScaleAddInPlace(float in_dS,const CVector2f& in_vector2);
    00151
    00159     SICPPSDK_INLINE CVector2f& ScaleAdd
    00160     (
    00161         float               in_dS,
    00162         const CVector2f&    in_vector3A,
    00163         const CVector2f&    in_vector3B
    00164     );
    00165
    00170     SICPPSDK_INLINE CVector2f& ScaleInPlace(float in_dAlpha);
    00171
    00177     SICPPSDK_INLINE CVector2f& Scale(float in_Alpha, const CVector2f& in_vector2);
    00178
    00182     SICPPSDK_INLINE CVector2f& NegateInPlace();
    00183
    00188     SICPPSDK_INLINE CVector2f& Negate(const CVector2f& in_vector2);
    00189
    00194     SICPPSDK_INLINE CVector2f& SubInPlace(const CVector2f& in_vector2);
    00195
    00202     SICPPSDK_INLINE CVector2f& Sub(const CVector2f& in_vector3A, const CVector2f& in_vector3B);
    00203
    00208     SICPPSDK_INLINE CVector2f& AddInPlace(const CVector2f& in_vector2);
    00209
    00215     SICPPSDK_INLINE CVector2f& Add(const CVector2f& in_vector3A, const CVector2f& in_vector3B);
    00216
    00220     SICPPSDK_INLINE float GetY()const;
    00221
    00226     SICPPSDK_INLINE CVector2f& PutY(float in_X);
    00227
    00231     SICPPSDK_INLINE float GetX()const;
    00232
    00237     SICPPSDK_INLINE CVector2f& PutX(float in_X);
    00238
    00239 private:
    00240     float m_X,m_Y;
    00241 };
    00242
    00243 //inline functions
    00244 SICPPSDK_INLINE CVector2f::CVector2f()
    00245 {
    00246     m_X = 0;
    00247     m_Y = 0;
    00248 }
    00249
    00250 SICPPSDK_INLINE CVector2f::CVector2f( const CVector2f& in_vct )
    00251 {
    00252     *this = in_vct;
    00253 }
    00254
    00255 SICPPSDK_INLINE CVector2f::CVector2f(float in_X, float in_Y):m_X(in_X),m_Y(in_X){}
    00256
    00257
    00258 SICPPSDK_INLINE CVector2f& CVector2f::operator=( const CVector2f & in_vct )
    00259 {
    00260     m_X = in_vct.m_X;
    00261     m_Y = in_vct.m_Y;
    00262     return (*this);
    00263 }
    00264
    00265 SICPPSDK_INLINE bool CVector2f::operator ==(const CVector2f & in_vector2 )const
    00266 {
    00267     return Equals(in_vector2);
    00268 }
    00269
    00270 SICPPSDK_INLINE bool CVector2f::operator !=(const CVector2f & in_vector2 )const
    00271 {
    00272     return ! Equals(in_vector2);
    00273 }
    00274
    00275 SICPPSDK_INLINE bool CVector2f::operator < ( const CVector2f& in_vector2 ) const
    00276 {
    00277     if ( m_X != in_vector2.m_X ) return m_X < in_vector2.m_X;
    00278     if ( m_Y != in_vector2.m_Y ) return m_Y < in_vector2.m_Y;
    00279     return false;
    00280 }
    00281
    00282 SICPPSDK_INLINE CVector2f& CVector2f::operator ~()
    00283 {
    00284     return NegateInPlace();
    00285 }
    00286
    00287 SICPPSDK_INLINE CVector2f& CVector2f::operator +=(const CVector2f& in_vector2)
    00288 {
    00289     return AddInPlace(in_vector2);
    00290 }
    00291
    00292 SICPPSDK_INLINE CVector2f& CVector2f::operator -=(const CVector2f& in_vector2)
    00293 {
    00294     return SubInPlace(in_vector2);
    00295 }
    00296
    00297 SICPPSDK_INLINE CVector2f& CVector2f::operator *=(const float& in_dAlpha)
    00298 {
    00299     return ScaleInPlace(in_dAlpha);
    00300 }
    00301
    00302 SICPPSDK_INLINE CVector2f& CVector2f::SetNull()
    00303 {
    00304     m_X = m_Y = 0.0;
    00305     return (*this);
    00306 }
    00307
    00308 SICPPSDK_INLINE float CVector2f::GetLength()const
    00309 {
    00310     return sqrt( GetLengthSquared() );
    00311 }
    00312
    00313 SICPPSDK_INLINE float CVector2f::GetLengthSquared()const
    00314 {
    00315     return(m_X*m_X + m_Y*m_Y );
    00316 }
    00317
    00318 SICPPSDK_INLINE bool CVector2f::Equals(const CVector2f& in_vec)const
    00319 {
    00320     return (this == &in_vec) ? true : ( ( m_X == in_vec.GetX() ) && ( m_Y == in_vec.GetY() ) );
    00321 }
    00322
    00323 SICPPSDK_INLINE bool CVector2f::EpsilonEquals
    00324 (
    00325     const CVector2f& in_cVec2,
    00326     const float in_fEpsilon
    00327 )const
    00328 {
    00329     return (this == &in_cVec2) ? true :
    00330         (   fabs( m_X - in_cVec2.GetX() ) < ::fabs(in_fEpsilon) &&
    00331             fabs( m_Y - in_cVec2.GetY() ) < ::fabs(in_fEpsilon) );
    00332 }
    00333
    00334 SICPPSDK_INLINE CVector2f& CVector2f::ScaleAddInPlace
    00335 (
    00336     float in_ScalingFactor,
    00337     const CVector2f& in_vec
    00338 )
    00339 {
    00340     ScaleInPlace(in_ScalingFactor);
    00341     return AddInPlace(in_vec);
    00342 }
    00343
    00344 SICPPSDK_INLINE CVector2f& CVector2f::ScaleAdd
    00345 (
    00346     const float in_ScalingFactor,
    00347     const CVector2f& in_vec3A,
    00348     const CVector2f& in_vec3B
    00349 )
    00350 {
    00351     Scale(in_ScalingFactor, in_vec3A);
    00352     return AddInPlace(in_vec3B);
    00353 }
    00354
    00355 SICPPSDK_INLINE CVector2f& CVector2f::ScaleInPlace(float in_dScalingFactor)
    00356 {
    00357     m_X *= in_dScalingFactor;
    00358     m_Y *= in_dScalingFactor;
    00359     return (*this);
    00360 }
    00361
    00362 SICPPSDK_INLINE CVector2f& CVector2f::Scale
    00363 (
    00364     float in_dScalingFactor,
    00365     const CVector2f& in_vec
    00366 )
    00367 {
    00368     m_X = in_vec.GetX() * in_dScalingFactor;
    00369     m_Y = in_vec.GetY() * in_dScalingFactor;
    00370     return (*this);
    00371 }
    00372
    00373 SICPPSDK_INLINE CVector2f& CVector2f::NegateInPlace()
    00374 {
    00375     m_X = -m_X;
    00376     m_Y = -m_Y;
    00377     return (*this);
    00378 }
    00379
    00380 SICPPSDK_INLINE CVector2f& CVector2f::Negate(const CVector2f& in_vec )
    00381 {
    00382     m_X = -in_vec.GetX();
    00383     m_Y = -in_vec.GetY();
    00384     return (*this);
    00385 }
    00386
    00387 SICPPSDK_INLINE CVector2f& CVector2f::SubInPlace(const CVector2f& in_vec)
    00388 {
    00389     m_X -= in_vec.GetX();
    00390     m_Y -= in_vec.GetY();
    00391     return (*this);
    00392 }
    00393
    00394 SICPPSDK_INLINE CVector2f& CVector2f::Sub
    00395 (
    00396     const CVector2f& in_vec3A,
    00397     const CVector2f& in_vec3B
    00398 )
    00399 {
    00400     m_X = in_vec3A.GetX() - in_vec3B.GetX();
    00401     m_Y = in_vec3A.GetY() - in_vec3B.GetY();
    00402     return (*this);
    00403 }
    00404
    00405 SICPPSDK_INLINE CVector2f& CVector2f::AddInPlace(const CVector2f& in_vec)
    00406 {
    00407     m_X += in_vec.GetX();
    00408     m_Y += in_vec.GetY();
    00409     return (*this);
    00410 }
    00411
    00412 SICPPSDK_INLINE CVector2f& CVector2f::Add
    00413 (
    00414     const CVector2f& in_vec3A,
    00415     const CVector2f& in_vec3B
    00416 )
    00417 {
    00418     m_X = in_vec3A.GetX() + in_vec3B.GetX();
    00419     m_Y = in_vec3A.GetY() + in_vec3B.GetY();
    00420     return (*this);
    00421 }
    00422
    00423 SICPPSDK_INLINE float CVector2f::GetY()const
    00424 {
    00425     return m_Y;
    00426 }
    00427
    00428 SICPPSDK_INLINE CVector2f& CVector2f::PutY(float in_Y)
    00429 {
    00430     m_Y = in_Y;
    00431     return (*this);
    00432 }
    00433
    00434 SICPPSDK_INLINE float CVector2f::GetX()const
    00435 {
    00436     return m_X;
    00437 }
    00438
    00439 SICPPSDK_INLINE CVector2f& CVector2f::PutX(float in_X)
    00440 {
    00441     m_X = in_X;
    00442     return (*this);
    00443 }
    00444
    00445 };
    00446 };
    00447
    00448 #endif // __XSIVECTOR2F_H__