xsi_vector3f.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 __XSIVECTOR3F_H__
00018 #define __XSIVECTOR3F_H__
00019 
00020 #include "sicppsdk.h"
00021 #include <xsi_math.h>
00022 #include <xsi_matrix3f.h>
00023 #include <xsi_matrix4f.h>
00024 
00025 namespace XSI {
00026 
00027 namespace MATH {
00028 
00029 //*****************************************************************************
00036 //*****************************************************************************
00037 class CVector3f
00038 {
00039 public:
00041     SICPPSDK_INLINE CVector3f();
00042 
00048     SICPPSDK_INLINE CVector3f(float in_fX, float in_fY, float in_fZ);
00049 
00053     SICPPSDK_INLINE CVector3f( const CVector3f& in_vector3);
00054 
00056     SICPPSDK_INLINE ~CVector3f();
00057 
00062     SICPPSDK_INLINE CVector3f & operator=( const CVector3f & in_vector3 );
00063 
00069     SICPPSDK_INLINE bool operator ==(const CVector3f & in_vector3 )const;
00070 
00076     SICPPSDK_INLINE bool operator !=(const CVector3f & in_vector3 )const;
00077 
00082     SICPPSDK_INLINE CVector3f& operator ~();
00083 
00089     SICPPSDK_INLINE CVector3f& operator +=(const CVector3f& in_vector3);
00090 
00096     SICPPSDK_INLINE CVector3f& operator -=(const CVector3f & in_vector3);
00097 
00103     SICPPSDK_INLINE CVector3f& operator *=(const CMatrix3f& in_matrix3);
00104 
00110     SICPPSDK_INLINE CVector3f& operator *=(const CMatrix4f& in_matrix4);
00111 
00117     SICPPSDK_INLINE CVector3f& operator *=(const float in_fAlpha);
00118 
00124     SICPPSDK_INLINE float operator[](const short& in_sIndex) const;
00125 
00131     SICPPSDK_INLINE float& operator[](const short& in_sIndex);
00132 
00140     SICPPSDK_INLINE bool operator < ( const CVector3f & in_vector3 ) const;
00141 
00146     SICPPSDK_INLINE CVector3f& MulByMatrix3InPlace(const CMatrix3f& in_matrix3);
00147 
00153     SICPPSDK_INLINE CVector3f& MulByMatrix3( const CVector3f& in_vector3, const CMatrix3f& in_matrix3 );
00154 
00159     SICPPSDK_INLINE CVector3f& MulByMatrix4InPlace(const CMatrix4f& in_matrix4);
00160 
00166     SICPPSDK_INLINE CVector3f& MulByMatrix4( const CVector3f& in_vector3, const CMatrix4f& in_matrix4 );
00167 
00171     SICPPSDK_INLINE CVector3f& SetNull();
00172 
00177     SICPPSDK_INLINE bool IsNull(const float in_fEpsilon = MicroEPS);
00178 
00182     SICPPSDK_INLINE short GetMaxComponentIndex()const;
00183 
00187     SICPPSDK_INLINE float GetMaxComponent()const;
00188 
00192     SICPPSDK_INLINE short GetMinComponentIndex()const;
00193 
00197     SICPPSDK_INLINE float GetMinComponent()const;
00198 
00202     SICPPSDK_INLINE float GetLength()const;
00203 
00207     SICPPSDK_INLINE void SetLength( const float in_val );
00208 
00212     SICPPSDK_INLINE float GetLengthSquared()const;
00213 
00217     SICPPSDK_INLINE CStatus NormalizeInPlace();
00218 
00223     SICPPSDK_INLINE CStatus Normalize(const CVector3f& in_vector3);
00224 
00229     SICPPSDK_INLINE float Dot(const CVector3f& in_vector3)const;
00230 
00236     SICPPSDK_INLINE CVector3f& Cross(const CVector3f& in_vector3A, const CVector3f& in_vector3B);
00237 
00242     SICPPSDK_INLINE float GetAngle(const CVector3f& in_vector3 )const;
00243 
00252     SICPPSDK_INLINE CVector3f& LinearlyInterpolate
00253     (
00254         const CVector3f& in_vector3A,
00255         const CVector3f& in_vector3B,
00256         const float in_fAlpha
00257     );
00258 
00262     SICPPSDK_INLINE CVector3f& AbsoluteInPlace();
00263 
00269     SICPPSDK_INLINE CVector3f& Absolute(const CVector3f& in_vector3);
00270 
00276     SICPPSDK_INLINE CVector3f& ClampInPlace(const float in_fMinValue, const float in_fMaxValue);
00277 
00285     SICPPSDK_INLINE CVector3f& Clamp
00286     (
00287         const float         in_fMinValue,
00288         const float         in_fMaxValue,
00289         const CVector3f&    in_vector3
00290     );
00291 
00297     SICPPSDK_INLINE bool EpsilonEquals
00298     (
00299         const CVector3f& in_vector3,
00300         const float in_fEpsilon
00301     )const;
00302 
00307     SICPPSDK_INLINE bool Equals(const CVector3f& in_vector3)const;
00308 
00315     SICPPSDK_INLINE CVector3f& ScaleAddInPlace(const float in_fS,const CVector3f& in_vector3);
00316 
00324     SICPPSDK_INLINE CVector3f& ScaleAdd
00325     (
00326         const float             in_fS,
00327         const CVector3f&        in_vector3A,
00328         const CVector3f&        in_vector3B
00329     );
00330 
00335     SICPPSDK_INLINE CVector3f& ScaleInPlace(const float in_fAlpha);
00336 
00342     SICPPSDK_INLINE CVector3f& Scale(const float in_fAlpha, const CVector3f& in_vector3);
00343 
00347     SICPPSDK_INLINE CVector3f& NegateInPlace();
00348 
00353     SICPPSDK_INLINE CVector3f& Negate(const CVector3f& in_vector3);
00354 
00359     SICPPSDK_INLINE CVector3f& SubInPlace(const CVector3f&in_vector3);
00360 
00367     SICPPSDK_INLINE CVector3f& Sub(const CVector3f& in_vector3A, const CVector3f& in_vector3B);
00368 
00373     SICPPSDK_INLINE CVector3f& AddInPlace(const CVector3f& in_vector3);
00374 
00380     SICPPSDK_INLINE CVector3f& Add(const CVector3f& in_vector3A,const CVector3f& in_vector3B);
00381 
00387     SICPPSDK_INLINE float Get(const short& in_sIndex)const;
00388 
00394     SICPPSDK_INLINE void Set(const short& in_sIndex, const float in_val );
00395 
00401     SICPPSDK_INLINE void Get(float& io_fX, float& io_fY, float& io_fZ)const;
00402 
00409     SICPPSDK_INLINE CVector3f& Set(const float in_fX, const float in_fY, const float in_fZ);
00410 
00414     SICPPSDK_INLINE float GetZ()const;
00415 
00420     SICPPSDK_INLINE CVector3f& PutZ(const float in_fZ);
00421 
00425     SICPPSDK_INLINE float GetY()const;
00426 
00431     SICPPSDK_INLINE CVector3f& PutY(const float in_fY);
00432 
00436     SICPPSDK_INLINE float GetX()const;
00437 
00442     SICPPSDK_INLINE CVector3f& PutX(const float in_fX);
00443 
00444 private:
00445     float m_fX,m_fY,m_fZ;
00446 };
00447 
00448 //inline functions
00449 SICPPSDK_INLINE CVector3f::CVector3f()
00450 {
00451     m_fX = 0;
00452     m_fY = 0;
00453     m_fZ = 0;
00454 }
00455 
00456 SICPPSDK_INLINE CVector3f::CVector3f( const CVector3f& in_vct )
00457 {
00458     in_vct.Get(m_fX,m_fY,m_fZ);
00459 }
00460 
00461 SICPPSDK_INLINE CVector3f::CVector3f
00462 (
00463  float in_fX, float in_fY, float in_fZ
00464 ):m_fX(in_fX),m_fY(in_fY),m_fZ(in_fZ)
00465 {}
00466 
00467 SICPPSDK_INLINE CVector3f::~CVector3f()
00468 {}
00469 
00470 SICPPSDK_INLINE CVector3f& CVector3f::operator=( const CVector3f & in_vct )
00471 {
00472     in_vct.Get(m_fX,m_fY,m_fZ);
00473     return (*this);
00474 }
00475 
00476 SICPPSDK_INLINE bool CVector3f::operator ==(const CVector3f & in_vector3 )const
00477 {
00478     return Equals(in_vector3);
00479 }
00480 
00481 SICPPSDK_INLINE bool CVector3f::operator !=(const CVector3f & in_vector3 )const
00482 {
00483     return ! Equals(in_vector3);
00484 }
00485 
00486 SICPPSDK_INLINE CVector3f& CVector3f::operator ~()
00487 {
00488     return NegateInPlace();
00489 }
00490 
00491 SICPPSDK_INLINE CVector3f& CVector3f::operator +=(const CVector3f& in_vector3)
00492 {
00493     return AddInPlace(in_vector3);
00494 }
00495 
00496 SICPPSDK_INLINE CVector3f& CVector3f::operator -=(const CVector3f& in_vector3)
00497 {
00498     return SubInPlace(in_vector3);
00499 }
00500 
00501 SICPPSDK_INLINE CVector3f& CVector3f::operator *=(const CMatrix3f& in_matrix3)
00502 {
00503     return MulByMatrix3InPlace(in_matrix3);
00504 }
00505 
00506 SICPPSDK_INLINE CVector3f& CVector3f::operator *=(const CMatrix4f& in_matrix4)
00507 {
00508     return MulByMatrix4InPlace(in_matrix4);
00509 }
00510 
00511 SICPPSDK_INLINE CVector3f& CVector3f::operator *=(const float in_fAlpha)
00512 {
00513     return ScaleInPlace(in_fAlpha);
00514 }
00515 
00516 SICPPSDK_INLINE float CVector3f::operator[](const short& in_sIndex) const
00517 {
00518     assert(in_sIndex >= 0 && in_sIndex < 3);
00519     switch(in_sIndex)
00520     {
00521         case 0:
00522             return m_fX;
00523             break;
00524         case 1:
00525             return m_fY;
00526             break;
00527         case 2:
00528             return m_fZ;
00529             break;
00530     }
00531     return FLT_MAX;
00532 }
00533 
00534 SICPPSDK_INLINE float& CVector3f::operator[](const short& in_sIndex)
00535 {
00536     assert(in_sIndex >= 0 && in_sIndex < 3);
00537     switch(in_sIndex)
00538     {
00539         case 0:
00540             return m_fX;
00541             break;
00542         case 1:
00543             return m_fY;
00544             break;
00545         case 2:
00546             return m_fZ;
00547             break;
00548     }
00549     static float fMAX = FLT_MAX;
00550     return fMAX;
00551 }
00552 
00553 SICPPSDK_INLINE bool CVector3f::operator < ( const CVector3f& in_v3f) const
00554 {
00555     if ( m_fZ != in_v3f.m_fZ ) return m_fZ < in_v3f.m_fZ;
00556     if ( m_fY != in_v3f.m_fY ) return m_fY < in_v3f.m_fY;
00557     if ( m_fX != in_v3f.m_fX ) return m_fX < in_v3f.m_fX;
00558     return false;
00559 }
00560 
00561 SICPPSDK_INLINE float CVector3f::Get(const short& in_sIndex) const
00562 {
00563     assert(in_sIndex >= 0 && in_sIndex < 3);
00564     switch(in_sIndex)
00565     {
00566         case 0:
00567             return m_fX;
00568             break;
00569         case 1:
00570             return m_fY;
00571             break;
00572         case 2:
00573             return m_fZ;
00574             break;
00575     }
00576     return FLT_MAX;
00577 }
00578 
00579 SICPPSDK_INLINE void CVector3f::Set(const short& in_sIndex, const float in_value )
00580 {
00581     assert(in_sIndex >= 0 && in_sIndex < 3);
00582     switch(in_sIndex)
00583     {
00584         case 0:m_fX = in_value;
00585         case 1:m_fY = in_value;
00586         case 2:m_fZ = in_value;
00587     }
00588 }
00589 
00590 SICPPSDK_INLINE CVector3f& CVector3f::MulByMatrix3InPlace(const CMatrix3f& in_matrix3)
00591 {
00592     return MulByMatrix3((*this),in_matrix3);
00593 }
00594 
00595 SICPPSDK_INLINE CVector3f& CVector3f::MulByMatrix3
00596 (
00597     const CVector3f& in_vector3,
00598     const CMatrix3f& in_matrix3
00599 )
00600 {
00601     float l_fX, l_fY,l_fZ;
00602     l_fX = in_vector3.GetX() * in_matrix3.GetValue(0,0) +
00603            in_vector3.GetY() * in_matrix3.GetValue(1,0) +
00604            in_vector3.GetZ() * in_matrix3.GetValue(2,0);
00605     l_fY = in_vector3.GetX() * in_matrix3.GetValue(0,1) +
00606            in_vector3.GetY() * in_matrix3.GetValue(1,1) +
00607            in_vector3.GetZ() * in_matrix3.GetValue(2,1);
00608     l_fZ = in_vector3.GetX() * in_matrix3.GetValue(0,2) +
00609            in_vector3.GetY() * in_matrix3.GetValue(1,2) +
00610            in_vector3.GetZ() * in_matrix3.GetValue(2,2);
00611 
00612     return Set(l_fX,l_fY,l_fZ);
00613 }
00614 
00615 SICPPSDK_INLINE CVector3f& CVector3f::MulByMatrix4InPlace(const CMatrix4f& in_matrix4)
00616 {
00617     return MulByMatrix4((*this),in_matrix4);
00618 }
00619 
00620 SICPPSDK_INLINE CVector3f& CVector3f::MulByMatrix4
00621 (
00622     const CVector3f& in_vector3,
00623     const CMatrix4f& in_matrix4
00624 )
00625 {
00626     float l_fX, l_fY, l_fZ, l_fW;
00627 
00628     l_fX =  in_vector3.GetX() * in_matrix4.GetValue( 0, 0 ) +
00629             in_vector3.GetY() * in_matrix4.GetValue( 1, 0 ) +
00630             in_vector3.GetZ() * in_matrix4.GetValue( 2, 0 ) +
00631             in_matrix4.GetValue( 3, 0 );
00632     l_fY =  in_vector3.GetX() * in_matrix4.GetValue( 0, 1 ) +
00633             in_vector3.GetY() * in_matrix4.GetValue( 1, 1 ) +
00634             in_vector3.GetZ() * in_matrix4.GetValue( 2, 1 ) +
00635             in_matrix4.GetValue( 3, 1 );
00636     l_fZ =  in_vector3.GetX() * in_matrix4.GetValue( 0, 2 ) +
00637             in_vector3.GetY() * in_matrix4.GetValue( 1, 2 ) +
00638             in_vector3.GetZ() * in_matrix4.GetValue( 2, 2 ) +
00639             in_matrix4.GetValue( 3, 2 );
00640     l_fW =  in_vector3.GetX() * in_matrix4.GetValue( 0, 3 ) +
00641             in_vector3.GetY() * in_matrix4.GetValue( 1, 3 ) +
00642             in_vector3.GetZ() * in_matrix4.GetValue( 2, 3 ) +
00643             in_matrix4.GetValue( 3, 3 );
00644 
00645     return Set(l_fX/l_fW, l_fY/l_fW, l_fZ/l_fW);
00646 }
00647 
00648 SICPPSDK_INLINE CVector3f& CVector3f::SetNull()
00649 {
00650     m_fX = m_fY = m_fZ = 0.0;
00651     return (*this);
00652 }
00653 
00654 SICPPSDK_INLINE bool CVector3f::IsNull( const float in_fEpsilon )
00655 {
00656     return( fabs(m_fX) <= in_fEpsilon && fabs(m_fY)<= in_fEpsilon && fabs(m_fZ)<= in_fEpsilon );
00657 }
00658 
00659 SICPPSDK_INLINE short CVector3f::GetMaxComponentIndex()const
00660 {
00661     if( m_fX > m_fY )
00662     {
00663         return (short)(( m_fX > m_fZ ) ? 0 : 2);
00664     }
00665     else
00666     {
00667         return (short)(( m_fY > m_fZ ) ? 1 : 2);
00668     }
00669     return 0;
00670 }
00671 
00672 SICPPSDK_INLINE float CVector3f::GetMaxComponent()const
00673 {
00674     if( m_fX > m_fY )
00675     {
00676         return ( m_fX > m_fZ ) ? m_fX : m_fZ;
00677     }
00678     else
00679     {
00680         return ( m_fY > m_fZ ) ? m_fY : m_fZ;
00681     }
00682     return 0.0;
00683 }
00684 
00685 SICPPSDK_INLINE short CVector3f::GetMinComponentIndex()const
00686 {
00687     if( m_fX < m_fY )
00688     {
00689         return (short)(( m_fX < m_fZ ) ? 0 : 2);
00690     }
00691     else
00692     {
00693         return (short)(( m_fY < m_fZ ) ? 1 : 2);
00694     }
00695     return 0;
00696 }
00697 
00698 SICPPSDK_INLINE float CVector3f::GetMinComponent()const
00699 {
00700     if( m_fX < m_fY )
00701     {
00702         return ( m_fX < m_fZ ) ? m_fX : m_fZ;
00703     }
00704     else
00705     {
00706         return ( m_fY < m_fZ ) ? m_fY : m_fZ;
00707     }
00708     return 0.0;
00709 }
00710 
00711 SICPPSDK_INLINE float CVector3f::GetLength()const
00712 {
00713     return sqrt( GetLengthSquared() );
00714 }
00715 
00716 SICPPSDK_INLINE void CVector3f::SetLength(const float in_val)
00717 {
00718     float rLen = GetLength();
00719 
00720     if ( rLen > MicroEPS )
00721     {
00722         ScaleInPlace( in_val / rLen );
00723     }
00724 }
00725 
00726 SICPPSDK_INLINE float CVector3f::GetLengthSquared()const
00727 {
00728     return(m_fX*m_fX + m_fY*m_fY + m_fZ*m_fZ );
00729 }
00730 
00731 SICPPSDK_INLINE float CVector3f::Dot(const CVector3f& io_vec3)const
00732 {
00733     return ( m_fX*io_vec3.GetX() + m_fY*io_vec3.GetY() + m_fZ*io_vec3.GetZ() );
00734 }
00735 
00736 SICPPSDK_INLINE CVector3f& CVector3f::Cross
00737 (
00738     const CVector3f& in_vec3A,
00739     const CVector3f& in_vec3B
00740 )
00741 {
00742     float dX, dY, dZ;
00743 
00744     dX =    in_vec3A.GetY() * in_vec3B.GetZ() -
00745             in_vec3A.GetZ() * in_vec3B.GetY();
00746     dY =   -in_vec3A.GetX() * in_vec3B.GetZ() +
00747             in_vec3A.GetZ() * in_vec3B.GetX();
00748     dZ =    in_vec3A.GetX() * in_vec3B.GetY() -
00749             in_vec3A.GetY() * in_vec3B.GetX();
00750 
00751    return( Set( dX, dY, dZ ) );
00752 }
00753 
00754 SICPPSDK_INLINE CVector3f& CVector3f::LinearlyInterpolate
00755 (
00756     const CVector3f&    in_vec3A,
00757     const CVector3f&    in_vec3B,
00758     const float         in_fAlpha
00759 )
00760 {
00761     m_fX = (1 - in_fAlpha) * in_vec3A.GetX() + in_fAlpha * in_vec3B.GetX();
00762     m_fY = (1 - in_fAlpha) * in_vec3A.GetY() + in_fAlpha * in_vec3B.GetY();
00763     m_fZ = (1 - in_fAlpha) * in_vec3A.GetZ() + in_fAlpha * in_vec3B.GetZ();
00764 
00765     return (*this);
00766 }
00767 
00768 SICPPSDK_INLINE bool CVector3f::EpsilonEquals
00769 (
00770     const CVector3f& in_cVec3,
00771     const float in_fEpsilon
00772 )const
00773 {
00774     return (this == &in_cVec3) ? true :
00775         (fabs( m_fX - in_cVec3.GetX() ) < ::fabs(in_fEpsilon) &&
00776            fabs( m_fY - in_cVec3.GetY() ) < ::fabs(in_fEpsilon) &&
00777            fabs( m_fZ - in_cVec3.GetZ() ) < ::fabs(in_fEpsilon) );
00778 }
00779 
00780 
00781 SICPPSDK_INLINE bool CVector3f::Equals(const CVector3f& in_vec3)const
00782 {
00783     return (this == &in_vec3) ? true :
00784         ( ( m_fX == in_vec3.GetX() ) &&
00785           ( m_fY == in_vec3.GetY() ) &&
00786           ( m_fZ == in_vec3.GetZ() ) );
00787 }
00788 
00789 SICPPSDK_INLINE CVector3f& CVector3f::ScaleAddInPlace
00790 (
00791     const float in_fScalingFactor,
00792     const CVector3f& in_vec3
00793 )
00794 {
00795     ScaleInPlace(in_fScalingFactor);
00796     return AddInPlace(in_vec3);
00797 }
00798 
00799 
00800 SICPPSDK_INLINE CVector3f& CVector3f::ScaleAdd
00801 (
00802     const float in_fScalingFactor,
00803     const CVector3f& in_vec3A,
00804     const CVector3f& in_vec3B
00805 )
00806 {
00807     Scale(in_fScalingFactor, in_vec3A);
00808     return AddInPlace(in_vec3B);
00809 }
00810 
00811 SICPPSDK_INLINE CVector3f& CVector3f::ScaleInPlace(const float in_fScalingFactor)
00812 {
00813     m_fX *= in_fScalingFactor;
00814     m_fY *= in_fScalingFactor;
00815     m_fZ *= in_fScalingFactor;
00816     return (*this);
00817 }
00818 
00819 SICPPSDK_INLINE CVector3f& CVector3f::Scale
00820 (
00821     const float in_fScalingFactor,
00822     const CVector3f& in_vec3
00823 )
00824 {
00825     m_fX = in_vec3.GetX() * in_fScalingFactor;
00826     m_fY = in_vec3.GetY() * in_fScalingFactor;
00827     m_fZ = in_vec3.GetZ() * in_fScalingFactor;
00828     return (*this);
00829 }
00830 
00831 SICPPSDK_INLINE CVector3f& CVector3f::NegateInPlace()
00832 {
00833     m_fX = -m_fX;
00834     m_fY = -m_fY;
00835     m_fZ = -m_fZ;
00836     return (*this);
00837 }
00838 
00839 SICPPSDK_INLINE CVector3f& CVector3f::Negate(const CVector3f& in_vec3 )
00840 {
00841     m_fX = -in_vec3.GetX();
00842     m_fY = -in_vec3.GetY();
00843     m_fZ = -in_vec3.GetZ();
00844     return (*this);
00845 }
00846 
00847 SICPPSDK_INLINE CVector3f& CVector3f::SubInPlace(const CVector3f& in_vec3)
00848 {
00849     m_fX -= in_vec3.GetX();
00850     m_fY -= in_vec3.GetY();
00851     m_fZ -= in_vec3.GetZ();
00852     return (*this);
00853 }
00854 
00855 SICPPSDK_INLINE CVector3f& CVector3f::Sub
00856 (
00857     const CVector3f& in_vec3A,
00858     const CVector3f& in_vec3B
00859 )
00860 {
00861     m_fX = in_vec3A.GetX() - in_vec3B.GetX();
00862     m_fY = in_vec3A.GetY() - in_vec3B.GetY();
00863     m_fZ = in_vec3A.GetZ() - in_vec3B.GetZ();
00864     return (*this);
00865 }
00866 
00867 SICPPSDK_INLINE CVector3f& CVector3f::AddInPlace(const CVector3f& in_vec3)
00868 {
00869     m_fX += in_vec3.GetX();
00870     m_fY += in_vec3.GetY();
00871     m_fZ += in_vec3.GetZ();
00872     return (*this);
00873 }
00874 
00875 SICPPSDK_INLINE CVector3f& CVector3f::Add
00876 (
00877     const CVector3f& in_vec3A,
00878     const CVector3f& in_vec3B
00879 )
00880 {
00881     m_fX = in_vec3A.GetX() + in_vec3B.GetX();
00882     m_fY = in_vec3A.GetY() + in_vec3B.GetY();
00883     m_fZ = in_vec3A.GetZ() + in_vec3B.GetZ();
00884     return (*this);
00885 }
00886 
00887 SICPPSDK_INLINE void CVector3f::Get(float& io_rfX, float& io_rfY, float& io_rfZ)const
00888 {
00889     io_rfX = m_fX;
00890     io_rfY = m_fY;
00891     io_rfZ = m_fZ;
00892 }
00893 
00894 SICPPSDK_INLINE CVector3f& CVector3f::Set(const float in_fX, const float in_fY, const float in_fZ)
00895 {
00896     m_fX = in_fX;
00897     m_fY = in_fY;
00898     m_fZ = in_fZ;
00899     return (*this);
00900 }
00901 
00902 SICPPSDK_INLINE float CVector3f::GetZ()const
00903 {
00904     return m_fZ;
00905 }
00906 
00907 SICPPSDK_INLINE CVector3f&  CVector3f::PutZ(const float in_fZ)
00908 {
00909     m_fZ = in_fZ;
00910     return (*this);
00911 }
00912 
00913 SICPPSDK_INLINE float CVector3f::GetY()const
00914 {
00915     return m_fY;
00916 }
00917 
00918 SICPPSDK_INLINE CVector3f& CVector3f::PutY(const float in_fY)
00919 {
00920     m_fY = in_fY;
00921     return (*this);
00922 }
00923 
00924 SICPPSDK_INLINE float CVector3f::GetX()const
00925 {
00926     return m_fX;
00927 }
00928 
00929 SICPPSDK_INLINE CVector3f& CVector3f::PutX(const float in_fX)
00930 {
00931     m_fX = in_fX;
00932     return (*this);
00933 }
00934 
00935 SICPPSDK_INLINE CStatus CVector3f::NormalizeInPlace()
00936 {
00937     float rLen = GetLength();
00938 
00939     if ( rLen > MicroEPS )
00940     {
00941         m_fX /= rLen ;
00942         m_fY /= rLen ;
00943         m_fZ /= rLen ;
00944         return CStatus::OK;
00945     }
00946 
00947     return CStatus::Fail;
00948 }
00949 
00950 SICPPSDK_INLINE CStatus CVector3f::Normalize(const CVector3f& in_vec3)
00951 {
00952     float rLen = in_vec3.GetLength();
00953 
00954     if ( rLen > MicroEPS )
00955     {
00956         m_fX = in_vec3.GetX() / rLen ;
00957         m_fY = in_vec3.GetY() / rLen ;
00958         m_fZ = in_vec3.GetZ() / rLen ;
00959         return CStatus::OK;
00960     }
00961 
00962     return CStatus::Fail;
00963 }
00964 
00965 SICPPSDK_INLINE float CVector3f::GetAngle( const CVector3f& in_vec3 ) const
00966 {
00967     float fCosAngle, fLen;
00968 
00969     fLen = GetLength();
00970     fLen *= in_vec3.GetLength();
00971     if( fLen < MicroEPS )
00972     {
00973         return( 0.0 );
00974     }
00975     else
00976     {
00977         fCosAngle = ( m_fX*in_vec3.GetX() + m_fY*in_vec3.GetY() + m_fZ*in_vec3.GetZ() ) / fLen;
00978         LimitValue( fCosAngle, -1.0, 1.0 );
00979         return( acos( fCosAngle ) );
00980     }
00981     return( 0.0 );
00982 }
00983 
00984 SICPPSDK_INLINE CVector3f& CVector3f::AbsoluteInPlace()
00985 {
00986     float l_fX, l_fY, l_fZ;
00987     Get(l_fX, l_fY, l_fZ);
00988     Set(::fabs(l_fX), ::fabs(l_fY), ::fabs(l_fZ));
00989     return (*this);
00990 }
00991 
00992 SICPPSDK_INLINE CVector3f& CVector3f::Absolute(const CVector3f& in_rCVec3)
00993 {
00994     float l_fX, l_fY, l_fZ;
00995     in_rCVec3.Get(l_fX, l_fY, l_fZ);
00996     m_fX = ::fabs(l_fX);
00997     m_fY = ::fabs(l_fY);
00998     m_fZ = ::fabs(l_fZ);
00999 
01000     return (*this);
01001 }
01002 
01003 SICPPSDK_INLINE CVector3f& CVector3f::ClampInPlace(const float in_fMin, const float in_fMax)
01004 {
01005     float l_fX, l_fY, l_fZ;
01006 
01007     Get( l_fX, l_fY, l_fZ );
01008 
01009     LimitValue( l_fX, in_fMin, in_fMax );
01010     LimitValue( l_fY, in_fMin, in_fMax );
01011     LimitValue( l_fZ, in_fMin, in_fMax );
01012 
01013     Set( l_fX, l_fY, l_fZ );
01014 
01015     return (*this);
01016 }
01017 
01018 };
01019 };
01020 
01021 #endif // __XSIVECTOR3F_H__