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
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:
00585 m_fX = in_value;
00586 break;
00587 case 1:
00588 m_fY = in_value;
00589 break;
00590 case 2:
00591 m_fZ = in_value;
00592 break;
00593 }
00594 }
00595
00596 SICPPSDK_INLINE CVector3f& CVector3f::MulByMatrix3InPlace(const CMatrix3f& in_matrix3)
00597 {
00598 return MulByMatrix3((*this),in_matrix3);
00599 }
00600
00601 SICPPSDK_INLINE CVector3f& CVector3f::MulByMatrix3
00602 (
00603 const CVector3f& in_vector3,
00604 const CMatrix3f& in_matrix3
00605 )
00606 {
00607 float l_fX, l_fY,l_fZ;
00608 l_fX = in_vector3.GetX() * in_matrix3.GetValue(0,0) +
00609 in_vector3.GetY() * in_matrix3.GetValue(1,0) +
00610 in_vector3.GetZ() * in_matrix3.GetValue(2,0);
00611 l_fY = in_vector3.GetX() * in_matrix3.GetValue(0,1) +
00612 in_vector3.GetY() * in_matrix3.GetValue(1,1) +
00613 in_vector3.GetZ() * in_matrix3.GetValue(2,1);
00614 l_fZ = in_vector3.GetX() * in_matrix3.GetValue(0,2) +
00615 in_vector3.GetY() * in_matrix3.GetValue(1,2) +
00616 in_vector3.GetZ() * in_matrix3.GetValue(2,2);
00617
00618 return Set(l_fX,l_fY,l_fZ);
00619 }
00620
00621 SICPPSDK_INLINE CVector3f& CVector3f::MulByMatrix4InPlace(const CMatrix4f& in_matrix4)
00622 {
00623 return MulByMatrix4((*this),in_matrix4);
00624 }
00625
00626 SICPPSDK_INLINE CVector3f& CVector3f::MulByMatrix4
00627 (
00628 const CVector3f& in_vector3,
00629 const CMatrix4f& in_matrix4
00630 )
00631 {
00632 float l_fX, l_fY, l_fZ, l_fW;
00633
00634 l_fX = in_vector3.GetX() * in_matrix4.GetValue( 0, 0 ) +
00635 in_vector3.GetY() * in_matrix4.GetValue( 1, 0 ) +
00636 in_vector3.GetZ() * in_matrix4.GetValue( 2, 0 ) +
00637 in_matrix4.GetValue( 3, 0 );
00638 l_fY = in_vector3.GetX() * in_matrix4.GetValue( 0, 1 ) +
00639 in_vector3.GetY() * in_matrix4.GetValue( 1, 1 ) +
00640 in_vector3.GetZ() * in_matrix4.GetValue( 2, 1 ) +
00641 in_matrix4.GetValue( 3, 1 );
00642 l_fZ = in_vector3.GetX() * in_matrix4.GetValue( 0, 2 ) +
00643 in_vector3.GetY() * in_matrix4.GetValue( 1, 2 ) +
00644 in_vector3.GetZ() * in_matrix4.GetValue( 2, 2 ) +
00645 in_matrix4.GetValue( 3, 2 );
00646 l_fW = in_vector3.GetX() * in_matrix4.GetValue( 0, 3 ) +
00647 in_vector3.GetY() * in_matrix4.GetValue( 1, 3 ) +
00648 in_vector3.GetZ() * in_matrix4.GetValue( 2, 3 ) +
00649 in_matrix4.GetValue( 3, 3 );
00650
00651 return Set(l_fX/l_fW, l_fY/l_fW, l_fZ/l_fW);
00652 }
00653
00654 SICPPSDK_INLINE CVector3f& CVector3f::SetNull()
00655 {
00656 m_fX = m_fY = m_fZ = 0.0;
00657 return (*this);
00658 }
00659
00660 SICPPSDK_INLINE bool CVector3f::IsNull( const float in_fEpsilon )
00661 {
00662 return( fabs(m_fX) <= in_fEpsilon && fabs(m_fY)<= in_fEpsilon && fabs(m_fZ)<= in_fEpsilon );
00663 }
00664
00665 SICPPSDK_INLINE short CVector3f::GetMaxComponentIndex()const
00666 {
00667 if( m_fX > m_fY )
00668 {
00669 return (short)(( m_fX > m_fZ ) ? 0 : 2);
00670 }
00671 else
00672 {
00673 return (short)(( m_fY > m_fZ ) ? 1 : 2);
00674 }
00675 return 0;
00676 }
00677
00678 SICPPSDK_INLINE float CVector3f::GetMaxComponent()const
00679 {
00680 if( m_fX > m_fY )
00681 {
00682 return ( m_fX > m_fZ ) ? m_fX : m_fZ;
00683 }
00684 else
00685 {
00686 return ( m_fY > m_fZ ) ? m_fY : m_fZ;
00687 }
00688 return 0.0;
00689 }
00690
00691 SICPPSDK_INLINE short CVector3f::GetMinComponentIndex()const
00692 {
00693 if( m_fX < m_fY )
00694 {
00695 return (short)(( m_fX < m_fZ ) ? 0 : 2);
00696 }
00697 else
00698 {
00699 return (short)(( m_fY < m_fZ ) ? 1 : 2);
00700 }
00701 return 0;
00702 }
00703
00704 SICPPSDK_INLINE float CVector3f::GetMinComponent()const
00705 {
00706 if( m_fX < m_fY )
00707 {
00708 return ( m_fX < m_fZ ) ? m_fX : m_fZ;
00709 }
00710 else
00711 {
00712 return ( m_fY < m_fZ ) ? m_fY : m_fZ;
00713 }
00714 return 0.0;
00715 }
00716
00717 SICPPSDK_INLINE float CVector3f::GetLength()const
00718 {
00719 return sqrt( GetLengthSquared() );
00720 }
00721
00722 SICPPSDK_INLINE void CVector3f::SetLength(const float in_val)
00723 {
00724 float rLen = GetLength();
00725
00726 if ( rLen > MicroEPS )
00727 {
00728 ScaleInPlace( in_val / rLen );
00729 }
00730 }
00731
00732 SICPPSDK_INLINE float CVector3f::GetLengthSquared()const
00733 {
00734 return(m_fX*m_fX + m_fY*m_fY + m_fZ*m_fZ );
00735 }
00736
00737 SICPPSDK_INLINE float CVector3f::Dot(const CVector3f& io_vec3)const
00738 {
00739 return ( m_fX*io_vec3.GetX() + m_fY*io_vec3.GetY() + m_fZ*io_vec3.GetZ() );
00740 }
00741
00742 SICPPSDK_INLINE CVector3f& CVector3f::Cross
00743 (
00744 const CVector3f& in_vec3A,
00745 const CVector3f& in_vec3B
00746 )
00747 {
00748 float dX, dY, dZ;
00749
00750 dX = in_vec3A.GetY() * in_vec3B.GetZ() -
00751 in_vec3A.GetZ() * in_vec3B.GetY();
00752 dY = -in_vec3A.GetX() * in_vec3B.GetZ() +
00753 in_vec3A.GetZ() * in_vec3B.GetX();
00754 dZ = in_vec3A.GetX() * in_vec3B.GetY() -
00755 in_vec3A.GetY() * in_vec3B.GetX();
00756
00757 return( Set( dX, dY, dZ ) );
00758 }
00759
00760 SICPPSDK_INLINE CVector3f& CVector3f::LinearlyInterpolate
00761 (
00762 const CVector3f& in_vec3A,
00763 const CVector3f& in_vec3B,
00764 const float in_fAlpha
00765 )
00766 {
00767 m_fX = (1 - in_fAlpha) * in_vec3A.GetX() + in_fAlpha * in_vec3B.GetX();
00768 m_fY = (1 - in_fAlpha) * in_vec3A.GetY() + in_fAlpha * in_vec3B.GetY();
00769 m_fZ = (1 - in_fAlpha) * in_vec3A.GetZ() + in_fAlpha * in_vec3B.GetZ();
00770
00771 return (*this);
00772 }
00773
00774 SICPPSDK_INLINE bool CVector3f::EpsilonEquals
00775 (
00776 const CVector3f& in_cVec3,
00777 const float in_fEpsilon
00778 )const
00779 {
00780 return (this == &in_cVec3) ? true :
00781 (fabs( m_fX - in_cVec3.GetX() ) < ::fabs(in_fEpsilon) &&
00782 fabs( m_fY - in_cVec3.GetY() ) < ::fabs(in_fEpsilon) &&
00783 fabs( m_fZ - in_cVec3.GetZ() ) < ::fabs(in_fEpsilon) );
00784 }
00785
00786
00787 SICPPSDK_INLINE bool CVector3f::Equals(const CVector3f& in_vec3)const
00788 {
00789 return (this == &in_vec3) ? true :
00790 ( ( m_fX == in_vec3.GetX() ) &&
00791 ( m_fY == in_vec3.GetY() ) &&
00792 ( m_fZ == in_vec3.GetZ() ) );
00793 }
00794
00795 SICPPSDK_INLINE CVector3f& CVector3f::ScaleAddInPlace
00796 (
00797 const float in_fScalingFactor,
00798 const CVector3f& in_vec3
00799 )
00800 {
00801 ScaleInPlace(in_fScalingFactor);
00802 return AddInPlace(in_vec3);
00803 }
00804
00805
00806 SICPPSDK_INLINE CVector3f& CVector3f::ScaleAdd
00807 (
00808 const float in_fScalingFactor,
00809 const CVector3f& in_vec3A,
00810 const CVector3f& in_vec3B
00811 )
00812 {
00813 Scale(in_fScalingFactor, in_vec3A);
00814 return AddInPlace(in_vec3B);
00815 }
00816
00817 SICPPSDK_INLINE CVector3f& CVector3f::ScaleInPlace(const float in_fScalingFactor)
00818 {
00819 m_fX *= in_fScalingFactor;
00820 m_fY *= in_fScalingFactor;
00821 m_fZ *= in_fScalingFactor;
00822 return (*this);
00823 }
00824
00825 SICPPSDK_INLINE CVector3f& CVector3f::Scale
00826 (
00827 const float in_fScalingFactor,
00828 const CVector3f& in_vec3
00829 )
00830 {
00831 m_fX = in_vec3.GetX() * in_fScalingFactor;
00832 m_fY = in_vec3.GetY() * in_fScalingFactor;
00833 m_fZ = in_vec3.GetZ() * in_fScalingFactor;
00834 return (*this);
00835 }
00836
00837 SICPPSDK_INLINE CVector3f& CVector3f::NegateInPlace()
00838 {
00839 m_fX = -m_fX;
00840 m_fY = -m_fY;
00841 m_fZ = -m_fZ;
00842 return (*this);
00843 }
00844
00845 SICPPSDK_INLINE CVector3f& CVector3f::Negate(const CVector3f& in_vec3 )
00846 {
00847 m_fX = -in_vec3.GetX();
00848 m_fY = -in_vec3.GetY();
00849 m_fZ = -in_vec3.GetZ();
00850 return (*this);
00851 }
00852
00853 SICPPSDK_INLINE CVector3f& CVector3f::SubInPlace(const CVector3f& in_vec3)
00854 {
00855 m_fX -= in_vec3.GetX();
00856 m_fY -= in_vec3.GetY();
00857 m_fZ -= in_vec3.GetZ();
00858 return (*this);
00859 }
00860
00861 SICPPSDK_INLINE CVector3f& CVector3f::Sub
00862 (
00863 const CVector3f& in_vec3A,
00864 const CVector3f& in_vec3B
00865 )
00866 {
00867 m_fX = in_vec3A.GetX() - in_vec3B.GetX();
00868 m_fY = in_vec3A.GetY() - in_vec3B.GetY();
00869 m_fZ = in_vec3A.GetZ() - in_vec3B.GetZ();
00870 return (*this);
00871 }
00872
00873 SICPPSDK_INLINE CVector3f& CVector3f::AddInPlace(const CVector3f& in_vec3)
00874 {
00875 m_fX += in_vec3.GetX();
00876 m_fY += in_vec3.GetY();
00877 m_fZ += in_vec3.GetZ();
00878 return (*this);
00879 }
00880
00881 SICPPSDK_INLINE CVector3f& CVector3f::Add
00882 (
00883 const CVector3f& in_vec3A,
00884 const CVector3f& in_vec3B
00885 )
00886 {
00887 m_fX = in_vec3A.GetX() + in_vec3B.GetX();
00888 m_fY = in_vec3A.GetY() + in_vec3B.GetY();
00889 m_fZ = in_vec3A.GetZ() + in_vec3B.GetZ();
00890 return (*this);
00891 }
00892
00893 SICPPSDK_INLINE void CVector3f::Get(float& io_rfX, float& io_rfY, float& io_rfZ)const
00894 {
00895 io_rfX = m_fX;
00896 io_rfY = m_fY;
00897 io_rfZ = m_fZ;
00898 }
00899
00900 SICPPSDK_INLINE CVector3f& CVector3f::Set(const float in_fX, const float in_fY, const float in_fZ)
00901 {
00902 m_fX = in_fX;
00903 m_fY = in_fY;
00904 m_fZ = in_fZ;
00905 return (*this);
00906 }
00907
00908 SICPPSDK_INLINE float CVector3f::GetZ()const
00909 {
00910 return m_fZ;
00911 }
00912
00913 SICPPSDK_INLINE CVector3f& CVector3f::PutZ(const float in_fZ)
00914 {
00915 m_fZ = in_fZ;
00916 return (*this);
00917 }
00918
00919 SICPPSDK_INLINE float CVector3f::GetY()const
00920 {
00921 return m_fY;
00922 }
00923
00924 SICPPSDK_INLINE CVector3f& CVector3f::PutY(const float in_fY)
00925 {
00926 m_fY = in_fY;
00927 return (*this);
00928 }
00929
00930 SICPPSDK_INLINE float CVector3f::GetX()const
00931 {
00932 return m_fX;
00933 }
00934
00935 SICPPSDK_INLINE CVector3f& CVector3f::PutX(const float in_fX)
00936 {
00937 m_fX = in_fX;
00938 return (*this);
00939 }
00940
00941 SICPPSDK_INLINE CStatus CVector3f::NormalizeInPlace()
00942 {
00943 float rLen = GetLength();
00944
00945 if ( rLen > MicroEPS )
00946 {
00947 m_fX /= rLen ;
00948 m_fY /= rLen ;
00949 m_fZ /= rLen ;
00950 return CStatus::OK;
00951 }
00952
00953 return CStatus::Fail;
00954 }
00955
00956 SICPPSDK_INLINE CStatus CVector3f::Normalize(const CVector3f& in_vec3)
00957 {
00958 float rLen = in_vec3.GetLength();
00959
00960 if ( rLen > MicroEPS )
00961 {
00962 m_fX = in_vec3.GetX() / rLen ;
00963 m_fY = in_vec3.GetY() / rLen ;
00964 m_fZ = in_vec3.GetZ() / rLen ;
00965 return CStatus::OK;
00966 }
00967
00968 return CStatus::Fail;
00969 }
00970
00971 SICPPSDK_INLINE float CVector3f::GetAngle( const CVector3f& in_vec3 ) const
00972 {
00973 float fCosAngle, fLen;
00974
00975 fLen = GetLength();
00976 fLen *= in_vec3.GetLength();
00977 if( fLen < MicroEPS )
00978 {
00979 return( 0.0 );
00980 }
00981 else
00982 {
00983 fCosAngle = ( m_fX*in_vec3.GetX() + m_fY*in_vec3.GetY() + m_fZ*in_vec3.GetZ() ) / fLen;
00984 LimitValue( fCosAngle, -1.0, 1.0 );
00985 return( acos( fCosAngle ) );
00986 }
00987 return( 0.0 );
00988 }
00989
00990 SICPPSDK_INLINE CVector3f& CVector3f::AbsoluteInPlace()
00991 {
00992 float l_fX, l_fY, l_fZ;
00993 Get(l_fX, l_fY, l_fZ);
00994 Set(::fabs(l_fX), ::fabs(l_fY), ::fabs(l_fZ));
00995 return (*this);
00996 }
00997
00998 SICPPSDK_INLINE CVector3f& CVector3f::Absolute(const CVector3f& in_rCVec3)
00999 {
01000 float l_fX, l_fY, l_fZ;
01001 in_rCVec3.Get(l_fX, l_fY, l_fZ);
01002 m_fX = ::fabs(l_fX);
01003 m_fY = ::fabs(l_fY);
01004 m_fZ = ::fabs(l_fZ);
01005
01006 return (*this);
01007 }
01008
01009 SICPPSDK_INLINE CVector3f& CVector3f::ClampInPlace(const float in_fMin, const float in_fMax)
01010 {
01011 float l_fX, l_fY, l_fZ;
01012
01013 Get( l_fX, l_fY, l_fZ );
01014
01015 LimitValue( l_fX, in_fMin, in_fMax );
01016 LimitValue( l_fY, in_fMin, in_fMax );
01017 LimitValue( l_fZ, in_fMin, in_fMax );
01018
01019 Set( l_fX, l_fY, l_fZ );
01020
01021 return (*this);
01022 }
01023
01024 };
01025 };
01026
01027 #endif // __XSIVECTOR3F_H__