SIBCVector.h

00001 //***************************************************************************************
00002 //
00003 // File supervisor: Softimage 3D Games & 3D Bridge team
00004 //
00005 // (c) Copyright 1999-2002 Avid Technology, Inc. . All rights reserved.
00006 //
00007 // SIBCVector.h | Main header file for SIBCVector2D/3D/4D implementation
00008 //***************************************************************************************
00009 
00010 /****************************************************************************************
00011 THIS CODE IS PUBLISHED AS A SAMPLE ONLY AND IS PROVIDED "AS IS".
00012 IN NO EVENT SHALL SOFTIMAGE, AVID TECHNOLOGY, INC. AND/OR THEIR RESPECTIVE
00013 SUPPLIERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
00014 DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00015 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
00016 CONNECTION WITH THE USE OR PERFORMANCE OF THIS CODE .
00017 
00018 COPYRIGHT NOTICE. Copyright © 1999-2002 Avid Technology Inc. . All rights reserved. 
00019 
00020 SOFTIMAGE is a registered trademark of Avid Technology Inc. or its subsidiaries 
00021 or divisions. Windows NT is a registered trademark of Microsoft Corp. All other
00022 trademarks contained herein are the property of their respective owners. 
00023 ****************************************************************************************/
00024 
00025 //***************************************************************************************
00026 // Defines
00027 //***************************************************************************************
00028 #ifndef __CSIBCVector_H__
00029 #define __CSIBCVector_H__
00030 
00031 //***************************************************************************************
00032 // Includes
00033 //**************************************************************************************
00034 #include <math.h>
00035 #include <SIBCUtil.h>
00036 
00037 //***************************************************************************************
00038 // Macros
00039 //***************************************************************************************
00040 #define SIBCVECTOR_EPS 0.00001f
00041 
00042 #ifdef _PSX2_ASM
00043 #include "libvu0.h"
00044 #endif
00045 
00046 
00047 //***************************************************************************************
00048 // CSIBCVector2D | General purpose 2D vector class.
00049 //***************************************************************************************
00050 
00052 
00062 class XSICOREEXPORT CSIBCVector2D
00063 {
00064     public:     
00065 
00069         CSIBCVector2D();
00070 
00075         CSIBCVector2D(const CSIBCVector2D& i_vVector);
00076 
00082         CSIBCVector2D(const SI_Float i_fX, const SI_Float i_fY);
00083 
00084         ~CSIBCVector2D();
00085         
00086         // Comparison
00087 
00097         SI_Bool IsAlmostEqualTo(const CSIBCVector2D& i_vVector, const SI_Float i_fEpsilon);
00098 
00108         SI_Bool IsOrthogonalTo(const CSIBCVector2D& i_vVector);
00109 
00117         SI_Bool IsNull() const;
00118 
00119         // Computed Info
00120 
00126         SI_Float GetDot(const CSIBCVector2D& i_vVector) const;
00127 
00133         SI_Float GetDistanceFrom(const CSIBCVector2D& i_vVector) const;
00134 
00141         SI_Float GetLength() const;
00142 
00149         SI_Float GetSquaredLength() const;
00150 
00157         SI_Float GetMaxComponent(SI_Int * o_nIndex) const;
00158 
00165         SI_Float GetMinComponent(SI_Int * o_nIndex) const;
00166         
00167         // Components
00168 
00176         void Get(SI_Float* o_fX, SI_Float* o_fY) const;
00177 
00184         const SI_Float GetX() const { return m_fX; }
00185 
00192         const SI_Float GetY() const { return m_fY; }
00193 
00202         CSIBCVector2D& Set(SI_Float i_fX, SI_Float i_fY);
00203 
00210         const void SetX(const SI_Float i_fX) { m_fX = i_fX; }
00211 
00218         const void SetY(const SI_Float i_fY) { m_fY = i_fY; }
00219 
00220         // Operations
00221 
00228         CSIBCVector2D& Normalize();
00229 
00235         CSIBCVector2D& SetNull();
00236 
00244         CSIBCVector2D& SetLength(const SI_Float i_fLength);
00245 
00250         CSIBCVector2D& Negate();
00251 
00257         CSIBCVector2D& Add(const CSIBCVector2D& i_vVector);
00258 
00264         CSIBCVector2D& Sub(const CSIBCVector2D&);
00265 
00272         CSIBCVector2D& Scale(const SI_Float i_fScale);
00273 
00280         CSIBCVector2D& MulComp(const CSIBCVector2D& i_vVector);
00281 
00289         CSIBCVector2D& DivComp(const CSIBCVector2D& i_vVector);
00290         
00291         // overloaded operators
00292 
00301         SI_Bool operator == (const CSIBCVector2D& i_vVector) const;
00302 
00311         SI_Bool operator != (const CSIBCVector2D& i_vVector) const;
00312         
00319         CSIBCVector2D operator+(const CSIBCVector2D &i_vVector) const;
00320 
00327         CSIBCVector2D operator-(const CSIBCVector2D &i_vVector) const;
00328 
00334         CSIBCVector2D operator/(const CSIBCVector2D &i_vVector) const;
00335 
00342         CSIBCVector2D operator*(const SI_Float i_fFloat) const;
00343 
00344         // Debug functions
00345 
00350         void    Dump();
00351         
00353         float   m_fX;
00354 
00356         float   m_fY;
00357 
00358 
00359     protected:
00360 };
00361 
00362 //***************************************************************************************
00363 // CSIBCVector3D | General purpose 3D vector class.
00364 //***************************************************************************************
00365 
00367 
00377 class XSICOREEXPORT CSIBCVector3D
00378 {
00379     public:     
00380 
00381         // Constructors and destructor
00385         CSIBCVector3D();
00386 
00391         CSIBCVector3D(const CSIBCVector3D& i_vVector);
00392 
00400         CSIBCVector3D(const SI_Float i_fX, const SI_Float i_fY, const SI_Float i_fZ);
00401 
00402         ~CSIBCVector3D() {;}
00403         
00404         // Comparison
00405 
00416         SI_Bool IsAlmostEqualTo(const CSIBCVector3D& i_vVector, const SI_Float i_fEpsilon);
00417 
00427         SI_Bool IsOrthogonalTo(const CSIBCVector3D& i_vVector);
00428 
00436         SI_Bool IsNull() const;
00437 
00438         // Computed Info
00439 
00445         SI_Float GetDot(const CSIBCVector3D& i_vVector) const;
00446 
00452         SI_Float GetDistanceFrom(const CSIBCVector3D& i_vVector) const;
00453         
00460         SI_Float GetLength() const;
00461 
00468         SI_Float GetSquaredLength() const;
00469 
00476         SI_Float GetMaxComponent(SI_Int * o_nIndex) const;
00477 
00484         SI_Float GetMinComponent(SI_Int * o_nIndex) const;
00485         
00486         // Components
00487 
00498         void Get(SI_Float* o_fX, SI_Float* o_fY, SI_Float* o_fZ) const;
00499 
00507         SI_Float GetX() const { return m_fX; }
00508 
00516         SI_Float GetY() const { return m_fY; }
00517 
00525         SI_Float GetZ() const { return m_fZ; }
00526 
00535         SI_Float GetW() const { return 1.0; }
00536 
00537 
00545         CSIBCVector3D& Set(SI_Float i_fX, SI_Float i_fY, SI_Float i_fZ);
00546         
00547         // Operations
00548 
00555         CSIBCVector3D& Normalize();
00556 
00562         CSIBCVector3D& SetNull();
00563 
00571         CSIBCVector3D& SetLength(const SI_Float i_fLength);
00572 
00578         CSIBCVector3D& SetCross(const CSIBCVector3D& i_vVector);
00579 
00584         CSIBCVector3D& Negate();
00585 
00591         CSIBCVector3D& Add(const CSIBCVector3D& i_vVector);
00592 
00598         CSIBCVector3D& Sub(const CSIBCVector3D& i_vVector);
00599 
00607         CSIBCVector3D& Scale(const SI_Float i_fScale);
00608 
00614         CSIBCVector3D& Scale(CSIBCVector3D& o_vDest, const SI_Float i_fScale);
00615 
00624         CSIBCVector3D& MulComp(const CSIBCVector3D& i_vVector);
00625         
00633         CSIBCVector3D& DivComp(const CSIBCVector3D& i_vVector);
00634         
00642         CSIBCVector3D  CrossProduct( const CSIBCVector3D& i_vVector)  const;
00643 
00652         void ScaleAndAdd(CSIBCVector3D& io_vDest, const SI_Float i_fScale);
00653 
00654         // overloaded operators
00655 
00664         SI_Bool operator == (const CSIBCVector3D& i_vVector) const;
00665 
00674         SI_Bool operator != (const CSIBCVector3D& i_vVector) const;
00675 
00684         CSIBCVector3D operator+(const CSIBCVector3D &i_vVector) const;
00685 
00695         CSIBCVector3D operator+(const SI_Float &i_fFloat) const;
00696 
00705         CSIBCVector3D operator-(const CSIBCVector3D &i_vVector) const;
00706 
00716         CSIBCVector3D operator-(const SI_Float &i_fFloat) const;
00717 
00723         CSIBCVector3D operator/(const CSIBCVector3D &i_vVector) const;
00724 
00731         CSIBCVector3D operator*(const SI_Float i_fFloat) const;
00732 
00737         void    Dump();
00738 
00740         float   m_fX;
00741 #ifdef _PSX2_ASM
00742             __attribute__((aligned (16)))   // XYZ components (W is just padding)
00743 #endif
00744 
00746         float   m_fY;
00747 
00749         float   m_fZ;
00750 
00751 
00752 };
00753 
00754 
00755 //***************************************************************************************
00756 // CSIBCVector4D | General purpose vector class.
00757 //***************************************************************************************
00758 
00760 
00770 class XSICOREEXPORT CSIBCVector4D
00771 {
00772     public:     
00773 
00774         // Constructors and destructor
00775 
00779         CSIBCVector4D();
00780 
00785         CSIBCVector4D(const CSIBCVector4D& i_vVector);
00786 
00795         CSIBCVector4D(  const SI_Float i_fX, const SI_Float i_fY, 
00796                         const SI_Float i_fZ, const SI_Float i_fW);
00797 
00804         CSIBCVector4D(  const CSIBCVector3D& i_vVct, const SI_Float i_fW = 1.0f);
00805 
00806         ~CSIBCVector4D();
00807         
00808         // Comparison
00809 
00819         SI_Bool IsAlmostEqualTo(const CSIBCVector4D& i_vVector, const SI_Float i_fEpsilon);
00820 
00830         SI_Bool IsOrthogonalTo(const CSIBCVector4D& i_vVector);
00831 
00839         SI_Bool IsNull() const;
00840 
00841         // Computed Info
00842 
00848         SI_Float GetDot(const CSIBCVector4D& i_vVector) const;
00849         
00855         SI_Float GetDistanceFrom(const CSIBCVector4D& i_vVector) const;
00856 
00863         SI_Float GetLength() const;
00864 
00871         SI_Float GetSquaredLength() const;
00872 
00879         SI_Float GetMaxComponent(SI_Int * o_nIndex) const;
00880 
00887         SI_Float GetMinComponent(SI_Int * o_nIndex) const;
00888         
00889         // Components
00890 
00898         void Get(SI_Float* o_fX, SI_Float* o_fY, SI_Float* o_fZ, SI_Float* o_fW) const;
00899         
00909         CSIBCVector4D& Set(SI_Float i_fX, SI_Float i_fY, SI_Float i_fZ, SI_Float i_fW);
00910         
00911         // Operations
00912 
00919         CSIBCVector4D& Normalize();
00920 
00926         CSIBCVector4D& SetNull();
00927 
00935         CSIBCVector4D& SetLength(const SI_Float i_fLength);
00936 
00941         CSIBCVector4D& Negate();
00942 
00948         CSIBCVector4D& Add(const CSIBCVector4D& i_vVector);
00949 
00955         CSIBCVector4D& Sub(const CSIBCVector4D& i_vVector);
00956 
00962         CSIBCVector4D& Scale(const SI_Float i_fScale);
00963 
00970         CSIBCVector4D& MulComp(const CSIBCVector4D& i_vVector);
00971 
00979         CSIBCVector4D& DivComp(const CSIBCVector4D& i_vVector);
00980         
00981         // overloaded operators
00982 
00991         SI_Bool operator == (const CSIBCVector4D& i_vVector) const;
00992 
01001         SI_Bool operator != (const CSIBCVector4D& i_vVector) const;
01002 
01009         CSIBCVector4D operator+(const CSIBCVector4D & i_vVector);
01010 
01017         CSIBCVector4D operator-(const CSIBCVector4D & i_vVector);
01018 
01024         CSIBCVector4D operator/(const CSIBCVector4D & i_vVector);
01025 
01031         CSIBCVector4D &operator = (const CSIBCVector3D & i_vVector);
01032 
01033         // Debug functions
01034 
01039         void    Dump();
01040         
01042         float   m_fX; 
01043 #ifdef _PSX2_ASM
01044             __attribute__((aligned (16)))
01045 #endif
01046 
01047         float   m_fY;
01048 
01050         float   m_fZ;
01051         
01053         float   m_fW;
01054 
01055     protected:
01056 };
01057 
01058 //***************************************************************************************
01059 //
01060 // Author : Softimage Games Team
01061 // Date   : 
01062 //
01063 // Constructor.
01064 // CSIBCVector2D::CSIBCVector2D();
01065 // CSIBCVector2D::CSIBCVector2D( const CSIBCVector2D& in_vct );
01066 // CSIBCVector2D::CSIBCVector2D( const SI_Float in_dX, const SI_Float in_dY );
01067 //
01068 //***************************************************************************************
01069 inline CSIBCVector2D::CSIBCVector2D()
01070 {
01071     m_fX = 0.0f;
01072     m_fY = 0.0f;
01073 }
01074 
01075 
01076 //***************************************************************************************
01077 //
01078 // Author : Softimage Games Team
01079 // Date   : 
01080 //
01081 // Copy constructor.
01082 // CSIBCVector2D& | in_vct | 2D vector to copy.
01083 //
01084 //***************************************************************************************
01085 inline CSIBCVector2D::CSIBCVector2D
01086 (
01087     const CSIBCVector2D& in_vct 
01088 )
01089 {
01090     m_fX = in_vct.m_fX;
01091     m_fY = in_vct.m_fY;
01092 }
01093 
01094 
01095 
01096 
01097 //***************************************************************************************
01098 //
01099 // Author : Softimage Games Team
01100 // Date   : 
01101 //
01102 // Constructor with xy values.
01103 // SI_Float | in_dX | X value of 2D vector.
01104 // SI_Float | in_dY | Y value of 2D vector.
01105 //
01106 //***************************************************************************************
01107 inline CSIBCVector2D::CSIBCVector2D
01108 (
01109     const SI_Float in_dX,
01110     const SI_Float in_dY
01111 )
01112 {
01113     m_fX = (SI_Float) in_dX;
01114     m_fY = (SI_Float) in_dY;
01115 }
01116 
01117  
01118 
01119 //***************************************************************************************
01120 //
01121 // Author : Softimage Games Team
01122 // Date   : 
01123 //
01124 // Destructor. No dynamic allocation is done so this is empty.
01125 //
01126 //
01127 //***************************************************************************************
01128 inline CSIBCVector2D::~CSIBCVector2D()
01129 {
01130 }
01131 
01132 
01133 //***************************************************************************************
01134 //
01135 // Author : Softimage Games Team
01136 // Date   : 
01137 //
01138 // Tests if this vector is almost equal to the other vector.
01139 //
01140 // CSIBCVector2D& | in_vct | 2D vector to compare.
01141 // SI_Float | in_dEpsilon | Error tolerance.
01142 // Returns a bool.
01143 //
01144 //***************************************************************************************
01145 inline SI_Bool CSIBCVector2D::IsAlmostEqualTo
01146 ( 
01147     const CSIBCVector2D&    in_vct,
01148     const SI_Float          in_dEpsilon  
01149 )
01150 {
01151     return( fabs( m_fX - in_vct.m_fX ) < in_dEpsilon &&
01152             fabs( m_fY - in_vct.m_fY ) < in_dEpsilon);
01153 }
01154 
01155 
01156 //***************************************************************************************
01157 //
01158 // Author : Softimage Games Team
01159 // Date   : 
01160 //
01161 // Tests if this vector is orthogonal (90 degrees) to another.
01162 //
01163 // CSIBCVector2D& | in_vct | 2D vector to compare. 
01164 // Returns a bool
01165 //
01166 //***************************************************************************************
01167 inline SI_Bool CSIBCVector2D::IsOrthogonalTo
01168 ( 
01169     const CSIBCVector2D& in_vct
01170 )
01171 {
01172     if( fabs( GetDot( in_vct ) ) < SIBCVECTOR_EPS) 
01173         return TRUE;
01174     else
01175         return FALSE;
01176 }
01177 
01178 //***************************************************************************************
01179 //
01180 // Author : Softimage Games Team
01181 // Date   : 
01182 //
01183 // Tests if this vector is the null vector.
01184 //
01185 //
01186 //***************************************************************************************
01187 inline SI_Bool CSIBCVector2D::IsNull() const 
01188 {
01189     // No test is done on W
01190     const SI_Float l_dEpsilon = SIBCVECTOR_EPS;
01191     return ( fabs( m_fX ) < l_dEpsilon &&
01192         fabs( m_fY ) < l_dEpsilon );
01193 }
01194 
01195 //***************************************************************************************
01196 //
01197 // Author : Softimage Games Team
01198 // Date   : 
01199 //
01200 // Returns the dot product of this vector with another vector.
01201 // CSIBCVector2D& | in_vct | Input vector.
01202 // Returns dot product.
01203 //
01204 //***************************************************************************************
01205 inline SI_Float CSIBCVector2D::GetDot
01206 ( 
01207     const CSIBCVector2D& in_vct
01208 ) const
01209 {
01210     return ( m_fX*in_vct.m_fX + m_fY*in_vct.m_fY);
01211 }
01212 
01213  
01214 //***************************************************************************************
01215 //
01216 // Author : Softimage Games Team
01217 // Date   : 
01218 //
01219 // Returns the distance of this vector to another one.
01220 //
01221 // CSIBCVector2D& | in_vct | Input vector.
01222 // Distance of input vector from another vector.
01223 //
01224 //***************************************************************************************
01225 inline SI_Float CSIBCVector2D::GetDistanceFrom
01226 ( 
01227     const CSIBCVector2D& in_vct 
01228 ) const
01229 {
01230     SI_Float rx, ry;
01231 
01232     rx = m_fX-in_vct.m_fX;  
01233     ry = m_fY-in_vct.m_fY;  
01234 
01235     return (SI_Float)sqrt( rx*rx + ry*ry );
01236 }
01237 
01238 //***************************************************************************************
01239 //
01240 // Author : Softimage Games Team
01241 // Date   : 
01242 //
01243 // Gets the squared length of this vector.
01244 // Returns the squared length of this vector.
01245 //
01246 //***************************************************************************************
01247 inline SI_Float CSIBCVector2D::GetSquaredLength() const
01248 {
01249     return( m_fX*m_fX + m_fY*m_fY );
01250 }
01251 
01252 //***************************************************************************************
01253 //
01254 // Author : Softimage Games Team
01255 // Date   : 
01256 //
01257 // Gets the length of this vector.
01258 // Returns the length of this vector.
01259 //
01260 //***************************************************************************************
01261 inline SI_Float CSIBCVector2D::GetLength() const
01262 {
01263     return (SI_Float)sqrt( GetSquaredLength() );
01264 }
01265 
01266 
01267 //***************************************************************************************
01268 //
01269 // Author : Softimage Games Team
01270 // Date   : 
01271 //
01272 // Retuns the XY values of this vector.
01273 //
01274 // SI_Float* | out_dX | X value of the vector to be returned.
01275 // SI_Float* | out_dY | Y value of the vector to be returned.
01276 //
01277 //***************************************************************************************
01278 inline void CSIBCVector2D::Get
01279 (
01280     SI_Float* out_dX,
01281     SI_Float* out_dY
01282 ) const
01283 {
01284     *out_dX = m_fX;
01285     *out_dY = m_fY;
01286 }
01287 
01288  
01289 //***************************************************************************************
01290 //
01291 // Author : Softimage Games Team
01292 // Date   : 
01293 //
01294 // Sets the length of the vector to in_dLength units.
01295 // 
01296 // SI_Float | in_dLength | Length to set the vector to.
01297 // Returns a pointer to the CSIBCVector2D object.
01298 //
01299 //***************************************************************************************
01300 inline CSIBCVector2D& CSIBCVector2D::SetLength
01301 ( 
01302     const SI_Float in_dLength 
01303 )
01304 {
01305     SI_Float  rLen = GetLength();
01306 
01307     if ( rLen > SIBCVECTOR_EPS )
01308     {
01309         Scale( in_dLength / rLen );
01310         return *this;
01311     }
01312     else
01313         return *this;
01314 }
01315 
01316 
01317 //***************************************************************************************
01318 //
01319 // Author : Softimage Games Team
01320 // Date   : 
01321 //
01322 // Normalizes the vector. If the vector is null then we initialize to (1,0).
01323 // Returns the normalized vector.
01324 //
01325 //***************************************************************************************
01326 inline CSIBCVector2D& CSIBCVector2D::Normalize()
01327 {
01328     SI_Float  rLen = GetLength();
01329 
01330     if ( rLen > SIBCVECTOR_EPS )
01331     {
01332         m_fX /= (SI_Float) rLen ;
01333         m_fY /= (SI_Float) rLen ;
01334         return *this;
01335     }
01336     else
01337     {
01338         return Set(1.0f, 0.0f);
01339     }
01340 }
01341 
01342 
01343   
01344 
01345 
01346 //***************************************************************************************
01347 //
01348 // Author : Softimage Games Team
01349 // Date   : 
01350 //
01351 // Returns TRUE if this vector is the same as the other.
01352 //
01353 // CSIBCVector2D& | in_v | Input vector.
01354 // Returns a bool.
01355 //
01356 //***************************************************************************************
01357 inline SI_Bool CSIBCVector2D::operator ==
01358 ( 
01359     const CSIBCVector2D& in_v
01360 ) const
01361 {
01362     return ( ( m_fX == in_v.m_fX ) && ( m_fY == in_v.m_fY ) );
01363 }
01364 
01365 //***************************************************************************************
01366 //
01367 // Author : Softimage Games Team
01368 // Date   : 
01369 //
01370 // Returns TRUE if this vector is different from the other.
01371 // CSIBCVector2D& | in_vct | Input vector.
01372 // Returns a bool.
01373 //
01374 //***************************************************************************************
01375 inline SI_Bool CSIBCVector2D::operator !=
01376 ( 
01377     const CSIBCVector2D& in_vct 
01378 ) const
01379 {
01380     return !( *this==in_vct ) ;
01381 }
01382 
01383 //***************************************************************************************
01384 //
01385 // Author : Softimage Games Team
01386 // Date   : 
01387 //
01388 // Adds two vectors.
01389 // CSIBCVector2D& | in_vtx | Input vector.
01390 // Returns a new CSIBCVector2D.
01391 //
01392 //***************************************************************************************
01393 inline CSIBCVector2D CSIBCVector2D::operator+
01394 (
01395     const CSIBCVector2D &in_vtx
01396 )  const
01397 {
01398     CSIBCVector2D v2;
01399 
01400     v2.m_fX = m_fX + in_vtx.m_fX;
01401     v2.m_fY = m_fY + in_vtx.m_fY;
01402 
01403     return v2;
01404 }
01405 
01406 //***************************************************************************************
01407 //
01408 // Author : Softimage Games Team
01409 // Date   : 
01410 //
01411 // Vector sub operator.
01412 // CSIBCVector2D& | in_vtx | Input vector.
01413 // Returns a new CSIBCVector2D.
01414 //
01415 //***************************************************************************************
01416 inline CSIBCVector2D CSIBCVector2D::operator-
01417 (
01418     const CSIBCVector2D &in_vtx 
01419 ) const
01420 {
01421     CSIBCVector2D v2;
01422 
01423     v2.m_fX = m_fX - in_vtx.m_fX;
01424     v2.m_fY = m_fY - in_vtx.m_fY;
01425 
01426     return v2;
01427 }
01428 
01429 //***************************************************************************************
01430 //
01431 // Author : Softimage Games Team
01432 // Date   : 
01433 //
01434 // Vector divide operator.
01435 // CSIBCVector2D& | in_vtx | Input vector.
01436 // Returns a new CSIBCVector2D.
01437 //
01438 //***************************************************************************************
01439 inline CSIBCVector2D CSIBCVector2D::operator/
01440 (
01441     const CSIBCVector2D &in_vtx
01442 ) const
01443 {
01444     CSIBCVector2D v2;
01445 
01446     if ((in_vtx.m_fX != 0.0f) &&
01447         (in_vtx.m_fY != 0.0f))
01448     {
01449         v2.m_fX = m_fX / in_vtx.m_fX;
01450         v2.m_fY = m_fY / in_vtx.m_fY;
01451     }
01452 
01453     return v2;
01454 }
01455 
01456 //***************************************************************************************
01457 //
01458 // Author : Softimage Games Team
01459 // Date   : 
01460 //
01461 // Vector multiply operator.
01462 // CSIBCVector2D& | in_vtx | Input vector.
01463 // Returns a new CSIBCVector2D.
01464 //
01465 //***************************************************************************************
01466 inline CSIBCVector2D CSIBCVector2D::operator*
01467 (
01468     const SI_Float in_flt
01469 ) const
01470 {
01471     CSIBCVector2D v2;
01472 
01473     v2.m_fX = m_fX * in_flt;
01474     v2.m_fY = m_fY * in_flt;
01475 
01476     return v2;
01477 }
01478 
01479 //***************************************************************************************
01480 //
01481 // Author : Softimage Games Team
01482 // Date   : 
01483 //
01484 // Sets the vector to the NULL vector.
01485 // Returns a NULL vector.
01486 //
01487 //***************************************************************************************
01488 inline CSIBCVector2D& CSIBCVector2D::SetNull()
01489 { 
01490     m_fX = m_fY = 0.0f; 
01491 
01492     return *this;
01493 }
01494 
01495 //***************************************************************************************
01496 //
01497 // Author : Softimage Games Team
01498 // Date   : 
01499 //
01500 // Sets this vector to be the opposite vector.
01501 // Returns a vector which is the opposite.
01502 //
01503 //***************************************************************************************
01504 inline CSIBCVector2D& CSIBCVector2D::Negate()
01505 {
01506     m_fX = -m_fX;
01507     m_fY = -m_fY;
01508     return *this;
01509 }
01510 
01511 
01512 //***************************************************************************************
01513 //
01514 // Author : Softimage Games Team
01515 // Date   : 
01516 //
01517 // Adds a vector to this vector.
01518 // CSIBCVector2D& | in_vct | Input vector.
01519 // Returns a pointer to a new CSIBCVector2D.
01520 //
01521 //***************************************************************************************
01522 inline CSIBCVector2D& CSIBCVector2D::Add
01523 (
01524     const CSIBCVector2D& in_vct
01525 )
01526 {
01527     m_fX += in_vct.m_fX;
01528     m_fY += in_vct.m_fY;
01529     return *this;
01530 }
01531 
01532 
01533 //***************************************************************************************
01534 //
01535 // Author : Softimage Games Team
01536 // Date   : 
01537 //
01538 // Substracts a vector from this vector.
01539 // CSIBCVector2D& | in_vct | Input vector.
01540 // Returns a pointer to a new CSIBCVector2D.
01541 //
01542 //***************************************************************************************
01543 inline CSIBCVector2D& CSIBCVector2D::Sub
01544 ( 
01545     const CSIBCVector2D& in_vct
01546 )
01547 {
01548     m_fX -= in_vct.m_fX;
01549     m_fY -= in_vct.m_fY;
01550     return *this;
01551 }
01552 
01553 
01554 //***************************************************************************************
01555 //
01556 // Author : Softimage Games Team
01557 // Date   : 
01558 //
01559 // Scales a vector by a given factor.
01560 // SI_Float | in_dFactor | Scale factor.
01561 // Returns a pointer to a new CSIBCVector2D.
01562 //
01563 //***************************************************************************************
01564 inline CSIBCVector2D& CSIBCVector2D::Scale
01565 ( 
01566     const SI_Float in_dFactor
01567 )
01568 {
01569     m_fX *= (SI_Float) in_dFactor;
01570     m_fY *= (SI_Float) in_dFactor;
01571     return *this;
01572 }
01573 
01574 
01575 //***************************************************************************************
01576 //
01577 // Author : Softimage Games Team
01578 // Date   : 
01579 //
01580 // Does component-wise multiplication of the vector.
01581 // CSIBCVector2D& | in_vct | Input vector.
01582 // Returns a pointer to a new CSIBCVector2D.
01583 //
01584 //***************************************************************************************
01585 inline CSIBCVector2D& CSIBCVector2D::MulComp
01586 ( 
01587      const CSIBCVector2D& in_vct    
01588 )
01589 {
01590     m_fX *= in_vct.m_fX;
01591     m_fY *= in_vct.m_fY;
01592     return *this; 
01593 }
01594 
01595 
01596 //***************************************************************************************
01597 //
01598 // Author : Softimage Games Team
01599 // Date   : 
01600 //
01601 // Does component-wise division of the vector. 
01602 // CSIBCVector2D& | in_vct | Input vector.
01603 // Returns a pointer to a new CSIBCVector2D.
01604 //
01605 //***************************************************************************************
01606 inline CSIBCVector2D& CSIBCVector2D::DivComp
01607 ( 
01608     const CSIBCVector2D& in_vct
01609 )
01610 {
01611     if (in_vct.m_fX != 0.0f &&
01612         in_vct.m_fY != 0.0f)
01613     {
01614         m_fX /= in_vct.m_fX;
01615         m_fY /= in_vct.m_fY;
01616     }
01617 
01618     return *this;
01619 }
01620 
01621 
01622 //***************************************************************************************
01623 //
01624 // Author : Softimage Games Team
01625 // Date   : 
01626 //
01627 // Sets the xy values of this vector.
01628 //
01629 // SI_Float | in_dX | x value of the vector.
01630 // SI_Float | in_dY | y value of the vector.
01631 // Returns a pointer to the new CSIBCVector2D object.
01632 //
01633 //***************************************************************************************
01634 inline CSIBCVector2D& CSIBCVector2D::Set
01635 (
01636     SI_Float in_dX,
01637     SI_Float in_dY
01638 )
01639 {
01640     m_fX = (SI_Float) in_dX;
01641     m_fY = (SI_Float) in_dY;
01642     return *this;
01643 }
01644 
01645 //***************************************************************************************
01646 //
01647 // Author : Softimage Games Team
01648 // Date   : 
01649 //
01650 // Constructor.
01651 //
01652 // CSIBCVector3D::CSIBCVector3D();
01653 // CSIBCVector3D::CSIBCVector3D( const CSIBCVector3D& in_vct );
01654 // CSIBCVector3D::CSIBCVector3D( const SI_Float in_dX, const SI_Float in_dY, const SI_Float in_dZ );
01655 //
01656 //***************************************************************************************
01657 inline CSIBCVector3D::CSIBCVector3D()
01658 {
01659     m_fX = 0.0f;
01660     m_fY = 0.0f;
01661     m_fZ = 0.0f;
01662 }
01663 
01664 
01665 //***************************************************************************************
01666 //
01667 // Author : Softimage Games Team
01668 // Date   : 
01669 //
01670 // Copy constructor.
01671 // CSIBCVector3D& | in_vct | Input vector to be copied.
01672 //
01673 //***************************************************************************************
01674 inline CSIBCVector3D::CSIBCVector3D
01675 (
01676     const CSIBCVector3D& in_vct 
01677 )
01678 {
01679     m_fX = in_vct.m_fX;
01680     m_fY = in_vct.m_fY;
01681     m_fZ = in_vct.m_fZ;
01682 }
01683 
01684 
01685 
01686 
01687 //***************************************************************************************
01688 //
01689 // Author : Softimage Games Team
01690 // Date   : 
01691 //
01692 // Constructor with xyz values. We assume w = 1.
01693 // SI_Float | in_dX | x value of the vector.
01694 // SI_Float | in_dY | y value of the vector.
01695 // SI_Float | in_dZ | z value of the vector.
01696 //
01697 //***************************************************************************************
01698 inline CSIBCVector3D::CSIBCVector3D
01699 (
01700     const SI_Float in_dX,
01701     const SI_Float in_dY,
01702     const SI_Float in_dZ
01703 )
01704 {
01705     m_fX = (SI_Float) in_dX;
01706     m_fY = (SI_Float) in_dY;
01707     m_fZ = (SI_Float) in_dZ;
01708 }
01709 
01710  
01711 
01712 
01713 //***************************************************************************************
01714 //
01715 // Author : Softimage Games Team
01716 // Date   : 
01717 //
01718 // Tests if this vector is almost equal to the other vector.
01719 //
01720 // CSIBCVector3D& | in_vct | 3D vector to compare.
01721 // SI_Float | in_dEpsilon | Error tolerance.
01722 // Returns a boolean.
01723 //***************************************************************************************
01724 inline SI_Bool CSIBCVector3D::IsAlmostEqualTo
01725 ( 
01726     const CSIBCVector3D&    in_vct,
01727     const SI_Float          in_dEpsilon  
01728 )
01729 {
01730     return( fabs( m_fX - in_vct.m_fX ) < in_dEpsilon &&
01731               fabs( m_fY - in_vct.m_fY ) < in_dEpsilon &&
01732               fabs( m_fZ - in_vct.m_fZ ) < in_dEpsilon ) ;
01733 }
01734 
01735 
01736 //***************************************************************************************
01737 //
01738 // Author : Softimage Games Team
01739 // Date   : 
01740 //
01741 // Tests if this vector is orthogonal (90 degrees) to another.
01742 // CSIBCVector3D& | in_vct | 3D vector to compare.
01743 // Returns a boolean.
01744 //
01745 //***************************************************************************************
01746 inline SI_Bool CSIBCVector3D::IsOrthogonalTo
01747 ( 
01748     const CSIBCVector3D& in_vct
01749 )
01750 {
01751     if( fabs( GetDot( in_vct ) ) < SIBCVECTOR_EPS) 
01752         return TRUE;
01753     else
01754         return FALSE;
01755 }
01756 
01757 
01758 //***************************************************************************************
01759 //
01760 // Author : Softimage Games Team
01761 // Date   : 
01762 //
01763 // Tests if this vector is the null vector.
01764 // Returns a boolean.
01765 // 
01766 //
01767 //***************************************************************************************
01768 inline SI_Bool CSIBCVector3D::IsNull() const 
01769 {
01770     // No test is done on W
01771     const SI_Float l_dEpsilon = SIBCVECTOR_EPS;
01772     return ( fabs( m_fX ) < l_dEpsilon &&
01773             fabs( m_fY ) < l_dEpsilon &&
01774             fabs( m_fZ ) < l_dEpsilon );
01775 }
01776 
01777 //***************************************************************************************
01778 //
01779 // Author : Softimage Games Team
01780 // Date   : 
01781 //
01782 // Gets the dot product of this vector with another vector.
01783 // CSIBCVector3D& | in_vct | 3D vector to compare.
01784 // Returns the dot product of this vector with another vector.
01785 //
01786 //***************************************************************************************
01787 inline SI_Float CSIBCVector3D::GetDot
01788 ( 
01789     const CSIBCVector3D& in_vct
01790 ) const
01791 {
01792 #ifdef _PSX2_ASM
01793     float fRet[4] __attribute__((aligned (16)));
01794     asm ("
01795         lqc2            vf4,0x0(%1)
01796         lqc2            vf5,0x0(%2)
01797         vmul.xyz        vf5,vf4,vf5
01798         vaddy.x         vf5,vf5,vf5
01799         vaddz.x         vf5,vf5,vf5
01800         sqc2            vf5,0x0(%0)
01801     ": : "=r" (fRet), "r" (&m_fX), "r" ( &(in_vct.m_fX)) );
01802     
01803     return fRet[0];
01804 #else
01805     return ( in_vct.m_fX * m_fX + in_vct.m_fY * m_fY + in_vct.m_fZ * m_fZ );
01806 #endif  
01807 }
01808 
01809  
01810 //***************************************************************************************
01811 //
01812 // Author : Softimage Games Team
01813 // Date   : 
01814 //
01815 // Gets the distance of this vector to another one.
01816 // Returns the dot product of this vector with another vector.
01817 // Returns the distance of this vector to another one.
01818 //***************************************************************************************
01819 inline SI_Float CSIBCVector3D::GetDistanceFrom
01820 ( 
01821     const CSIBCVector3D& in_vct 
01822 ) const
01823 {
01824 #ifdef _PSX2_ASM
01825     float fRet[4] __attribute__((aligned (16)));
01826     
01827     asm ("
01828         lqc2            vf4,0x0(%1)
01829         lqc2            vf5,0x0(%2)
01830         vsub.xyz        vf5,vf4,vf5
01831         vmul.xyz        vf5,vf5,vf5
01832         vaddy.x         vf5,vf5,vf5
01833         vaddz.x         vf5,vf5,vf5
01834         sqc2            vf5,0x0(%0)
01835     ": : "=r" (fRet), "r" (&m_fX), "r" ( &(in_vct.m_fX)) );
01836     
01837     return (SI_Float)sqrt(fRet[0]);
01838 #else
01839     SI_Float rx, ry, rz;
01840 
01841     rx = m_fX-in_vct.m_fX;  
01842     ry = m_fY-in_vct.m_fY;  
01843     rz = m_fZ-in_vct.m_fZ;  
01844 
01845     return (SI_Float)sqrt( rx*rx + ry*ry + rz*rz );
01846 #endif  
01847 }
01848 
01849 //***************************************************************************************
01850 //
01851 // Author : Softimage Games Team
01852 // Date   : 
01853 //
01854 // Gets the length of this vector.
01855 // Returns the length of this vector.
01856 //
01857 //***************************************************************************************
01858 inline SI_Float CSIBCVector3D::GetLength() const
01859 {
01860 #ifdef _PSX2_ASM
01861     SI_Float fRet[4] __attribute__((aligned (16)));
01862     
01863     asm ("
01864         lqc2            vf5,0x0(%1)
01865         vmul.xyz        vf5,vf5,vf5
01866         vaddy.x         vf5,vf5,vf5
01867         vaddz.x         vf5,vf5,vf5
01868         cop2            2425789
01869         vwaitq
01870         vaddq.x         vf5,vf0,Q
01871         sqc2            vf5,0x0(%0)
01872     ": : "=r" (fRet), "r" (&m_fX) );
01873     
01874     return fRet[0];
01875 #else
01876    return (SI_Float)sqrt( GetSquaredLength() );
01877 #endif  
01878 }
01879 
01880 //***************************************************************************************
01881 //
01882 // Author : Softimage Games Team
01883 // Date   : 
01884 //
01885 // Gets the squared length of this vector.
01886 // Returns the squared length of this vector.
01887 //
01888 //***************************************************************************************
01889 inline SI_Float CSIBCVector3D::GetSquaredLength() const
01890 {
01891 #ifdef _PSX2_ASM
01892     SI_Float fRet[4] __attribute__((aligned (16)));
01893     
01894     asm ("
01895         lqc2            vf4,0x0(%1)
01896         vmul.xyz        vf4,vf4,vf4
01897         vaddy.x         vf4,vf4,vf4
01898         vaddz.x         vf4,vf4,vf4
01899         sqc2            vf4,0x0(%0)
01900     ": : "=r" (fRet), "r" (&m_fX) );
01901     
01902     return fRet[0];
01903 #else   
01904     return( m_fX*m_fX + m_fY*m_fY + m_fZ*m_fZ );
01905 #endif  
01906 }
01907 
01908 //***************************************************************************************
01909 //
01910 // Author : Softimage Games Team
01911 // Date   : 
01912 //
01913 // Returns the XYZ values of this vector.
01914 //
01915 // SI_Float* | out_dX | x component of the vector. 
01916 // SI_Float* | out_dY | y component of the vector.
01917 // SI_Float* | out_dZ | z component of the vector.
01918 //
01919 //***************************************************************************************
01920 inline void CSIBCVector3D::Get
01921 (
01922     SI_Float* out_dX,
01923     SI_Float* out_dY,
01924     SI_Float* out_dZ
01925 ) const
01926 {
01927     *out_dX = m_fX;
01928     *out_dY = m_fY;
01929     *out_dZ = m_fZ;
01930 }
01931 
01932  
01933 //***************************************************************************************
01934 //
01935 // Author : Softimage Games Team
01936 // Date   : 
01937 //
01938 // Sets the length of the vector to in_dLength units.
01939 //
01940 // SI_Float | in_dLength | length to set the vector to.
01941 // Returns a pointer to the new vector.
01942 //
01943 //***************************************************************************************
01944 inline CSIBCVector3D& CSIBCVector3D::SetLength
01945 ( 
01946     const SI_Float in_dLength 
01947 )
01948 {
01949     SI_Float  rLen = GetLength();
01950 
01951     if ( rLen > SIBCVECTOR_EPS )
01952     {
01953         Scale( in_dLength / rLen );
01954         return *this;
01955     }
01956     else
01957         return *this;
01958 }
01959 
01960 
01961 //***************************************************************************************
01962 //
01963 // Author : Softimage Games Team
01964 // Date   : 
01965 //
01966 // Normalizes the vector. If the vector is null then we initialize to (1,0,0,0).
01967 // Returns the normalized vector.
01968 //
01969 //***************************************************************************************
01970 inline CSIBCVector3D& CSIBCVector3D::Normalize()
01971 {
01972 #ifdef _PSX2_ASM
01973     sceVu0Normalize( &m_fX, &m_fX );
01974         
01975     return *this;
01976 #else
01977     SI_Float  rLen = GetLength();
01978 
01979     if ( rLen > SIBCVECTOR_EPS )
01980     {
01981         m_fX /= (SI_Float) rLen ;
01982         m_fY /= (SI_Float) rLen ;
01983         m_fZ /= (SI_Float) rLen ; 
01984         return *this;
01985     }
01986     else
01987     {
01988         return Set(1.0f, 0.0f, 0.0f);
01989     }
01990 #endif
01991 }
01992 
01993 
01994   
01995 
01996 
01997 //***************************************************************************************
01998 //
01999 // Author : Softimage Games Team
02000 // Date   : 
02001 //
02002 // Returns TRUE if this vector is the same as the other.
02003 // CSIBCVector3D& | in_v | Input vector.
02004 // Returns a boolean.
02005 //
02006 //***************************************************************************************
02007 inline SI_Bool CSIBCVector3D::operator ==
02008 ( 
02009     const CSIBCVector3D& in_v
02010 ) const
02011 {
02012     return ( ( m_fX == in_v.m_fX ) && ( m_fY == in_v.m_fY ) && ( m_fZ == in_v.m_fZ ) );
02013 }
02014 
02015 //***************************************************************************************
02016 //
02017 // Author : Softimage Games Team
02018 // Date   : 
02019 //
02020 // Returns TRUE if this vector is different from the other.
02021 // CSIBCVector3D& | in_v | Input vector.
02022 // Returns a boolean.
02023 //
02024 //***************************************************************************************
02025 inline SI_Bool CSIBCVector3D::operator !=
02026 ( 
02027     const CSIBCVector3D& in_vct 
02028 ) const
02029 {
02030     return !( *this==in_vct ) ;
02031 }
02032 
02033 //***************************************************************************************
02034 //
02035 // Author : Softimage Games Team
02036 // Date   : 
02037 //
02038 // Vector add operator.
02039 //
02040 // CSIBCVector3D& | in_vtx | Input vector.
02041 // Returns a new vector.
02042 //***************************************************************************************
02043 inline CSIBCVector3D CSIBCVector3D::operator+
02044 (
02045     const CSIBCVector3D &in_vtx             
02046 ) const
02047 {
02048     CSIBCVector3D v2;
02049 
02050     v2.m_fX = m_fX + in_vtx.m_fX;
02051     v2.m_fY = m_fY + in_vtx.m_fY;
02052     v2.m_fZ = m_fZ + in_vtx.m_fZ;
02053 
02054     return v2;
02055 }
02056 
02057 inline CSIBCVector3D CSIBCVector3D::operator+
02058 (
02059     const SI_Float &in_flt              
02060 ) const
02061 {
02062     CSIBCVector3D v2;
02063 
02064     v2.m_fX = m_fX + in_flt;
02065     v2.m_fY = m_fY + in_flt;
02066     v2.m_fZ = m_fZ + in_flt;
02067 
02068     return v2;
02069 }
02070 
02071 //***************************************************************************************
02072 //
02073 // Author : Softimage Games Team
02074 // Date   : 
02075 //
02076 // Vector subtract operator.
02077 //
02078 // CSIBCVector3D& | in_vtx | Input vector.
02079 // Returns a new vector.
02080 //
02081 //***************************************************************************************
02082 inline CSIBCVector3D CSIBCVector3D::operator-
02083 (
02084     const CSIBCVector3D &in_vtx
02085 ) const
02086 {
02087     CSIBCVector3D v2;
02088 
02089     v2.m_fX = m_fX - in_vtx.m_fX;
02090     v2.m_fY = m_fY - in_vtx.m_fY;
02091     v2.m_fZ = m_fZ - in_vtx.m_fZ;
02092 
02093     return v2;
02094 }
02095 //***************************************************************************************
02096 //
02097 // Author : Softimage Games Team
02098 // Date   : 
02099 //
02100 // Vector subtract operator.
02101 //
02102 // CSIBCVector3D& | in_flt | Input vector.
02103 // Returns a new vector.
02104 //
02105 //***************************************************************************************
02106 
02107 inline CSIBCVector3D CSIBCVector3D::operator-
02108 (
02109     const SI_Float &in_flt
02110 ) const
02111 {
02112     CSIBCVector3D v2;
02113 
02114     v2.m_fX = m_fX - in_flt;
02115     v2.m_fY = m_fY - in_flt;
02116     v2.m_fZ = m_fZ - in_flt;
02117 
02118     return v2;
02119 }
02120 
02121 //***************************************************************************************
02122 //
02123 // Author : Softimage Games Team
02124 // Date   : 
02125 //
02126 // Vector divide operator.
02127 // CSIBCVector3D& | in_vtx | Iinput vector.
02128 // Returns a new vector.
02129 //
02130 //***************************************************************************************
02131 inline CSIBCVector3D CSIBCVector3D::operator/
02132 (
02133     const CSIBCVector3D &in_vtx
02134 ) const
02135 {
02136     CSIBCVector3D v2;
02137 
02138     if ((in_vtx.m_fX != 0.0f) &&
02139         (in_vtx.m_fY != 0.0f) &&
02140         (in_vtx.m_fZ != 0.0f))
02141     {
02142         v2.m_fX = m_fX / in_vtx.m_fX;
02143         v2.m_fY = m_fY / in_vtx.m_fY;
02144         v2.m_fZ = m_fZ / in_vtx.m_fZ;
02145     }
02146 
02147     return v2;
02148 }
02149 
02150 //***************************************************************************************
02151 //
02152 // Author : Softimage Games Team
02153 // Date   : 
02154 //
02155 // Vector multiply operator.
02156 // SI_Float| factor | Multiplication factor.
02157 // Returns a new vector.
02158 //
02159 //***************************************************************************************
02160 inline CSIBCVector3D CSIBCVector3D::operator*
02161 (
02162     const SI_Float factor
02163 ) const
02164 {
02165     CSIBCVector3D v2;
02166     
02167     v2.m_fX = m_fX * factor;
02168     v2.m_fY = m_fY * factor;
02169     v2.m_fZ = m_fZ * factor;
02170 
02171     return v2;
02172 }
02173 //***************************************************************************************
02174 //
02175 // Author : Softimage Games Team
02176 // Date   : 
02177 //
02178 // Sets the vector to the NULL vector.
02179 // Returns a pointer to the vector.
02180 //
02181 //***************************************************************************************
02182 inline CSIBCVector3D& CSIBCVector3D::SetNull()
02183 { 
02184     m_fX = m_fY = m_fZ = 0.0f; 
02185 
02186     return *this;
02187 }
02188 
02189 //***************************************************************************************
02190 //
02191 // Author : Softimage Games Team
02192 // Date   : 
02193 //
02194 // Sets this vector to be the opposite vector.
02195 // Returns a pointer to the vector.
02196 //
02197 //***************************************************************************************
02198 inline CSIBCVector3D& CSIBCVector3D::Negate()
02199 {
02200     m_fX = -m_fX;
02201     m_fY = -m_fY;
02202     m_fZ = -m_fZ;
02203     return *this;
02204 }
02205 
02206 
02207 //***************************************************************************************
02208 //
02209 // Author : Softimage Games Team
02210 // Date   : 
02211 //
02212 // Adds a vector to this vector.
02213 //
02214 // CSIBCVector3D& | in_vct | Input vector.
02215 // Returns a pointer to the vector.
02216 //***************************************************************************************
02217 inline CSIBCVector3D& CSIBCVector3D::Add
02218 (
02219     const CSIBCVector3D& in_vct
02220 )
02221 {
02222     m_fX += in_vct.m_fX;
02223     m_fY += in_vct.m_fY;
02224     m_fZ += in_vct.m_fZ;
02225     return *this;
02226 }
02227 
02228 
02229 //***************************************************************************************
02230 //
02231 // Author : Softimage Games Team
02232 // Date   : 
02233 //
02234 // Substracts a vector from this vector.
02235 // CSIBCVector3D& | in_vct | Input vector.
02236 // Returns a pointer to the vector.
02237 //
02238 //***************************************************************************************
02239 inline CSIBCVector3D& CSIBCVector3D::Sub
02240 ( 
02241     const CSIBCVector3D& in_vct
02242 )
02243 {
02244     m_fX -= in_vct.m_fX;
02245     m_fY -= in_vct.m_fY;
02246     m_fZ -= in_vct.m_fZ;
02247     return *this;
02248 }
02249 
02250 
02251 //***************************************************************************************
02252 //
02253 // Author : Softimage Games Team
02254 // Date   : 
02255 //
02256 // Scales a vector by a given factor.
02257 // SIFloat | in_dFactor | Scale factor.
02258 // Returns a pointer to the vector.
02259 //
02260 //***************************************************************************************
02261 inline CSIBCVector3D& CSIBCVector3D::Scale
02262 ( 
02263     const SI_Float in_dFactor
02264 )
02265 {
02266     m_fX *= (SI_Float) in_dFactor;
02267     m_fY *= (SI_Float) in_dFactor;
02268     m_fZ *= (SI_Float) in_dFactor;
02269     return *this;
02270 }
02271 
02272 
02273 //***************************************************************************************
02274 //
02275 // Author : Softimage Games Team
02276 // Date   : 
02277 //
02278 // Scales a vector by a given factor.
02279 //
02280 // CSIBCVector3D& | o_V | Vector to apply scaling to.
02281 // SI_Float | in_dFactor | Scaling factor.
02282 // Returns a pointer to the vector.
02283 //
02284 //***************************************************************************************
02285 inline CSIBCVector3D& CSIBCVector3D::Scale
02286 ( 
02287     CSIBCVector3D &o_V,
02288     const SI_Float in_dFactor
02289 )
02290 {
02291     o_V.m_fX = m_fX * in_dFactor;
02292     o_V.m_fY = m_fY * in_dFactor;
02293     o_V.m_fZ = m_fZ * in_dFactor;
02294     
02295     return *this;
02296 }
02297 //***************************************************************************************
02298 //
02299 // Author : Softimage Games Team
02300 // Date   : 
02301 //
02302 // Scales a vector by a given factor.
02303 //
02304 // CSIBCVector3D& | o_V | Vector to apply scaling to.
02305 // SI_Float | in_dFactor | Scaling factor.
02306 // Returns a pointer to the vector.
02307 //
02308 //***************************************************************************************
02309 inline void CSIBCVector3D::ScaleAndAdd
02310 (
02311     CSIBCVector3D &o_V, 
02312     const SI_Float in_dFactor
02313 )
02314 {
02315     o_V.m_fX += (m_fX * in_dFactor);
02316     o_V.m_fY += (m_fY * in_dFactor);
02317     o_V.m_fZ += (m_fZ * in_dFactor);
02318 }
02319 
02320 //***************************************************************************************
02321 //
02322 // Author : Softimage Games Team
02323 // Date   : 
02324 //
02325 // Does component wise multiplication of the vector. 
02326 // CSIBCVector3D& | in_vct | Input vector.
02327 // Returns a pointer to the vector.
02328 //
02329 //***************************************************************************************
02330 inline CSIBCVector3D& CSIBCVector3D::MulComp
02331 ( 
02332      const CSIBCVector3D& in_vct    
02333 )
02334 {
02335     m_fX *= in_vct.m_fX;
02336     m_fY *= in_vct.m_fY;
02337     m_fZ *= in_vct.m_fZ;
02338     return *this; 
02339 }
02340 
02341 
02342 //***************************************************************************************
02343 //
02344 // Author : Softimage Games Team
02345 // Date   : 
02346 //
02347 // Does component wise division of the vector. 
02348 // CSIBCVector3D& | in_vct | Input vector.
02349 // Returns a pointer to the vector.
02350 //
02351 //***************************************************************************************
02352 inline CSIBCVector3D& CSIBCVector3D::DivComp
02353 ( 
02354     const CSIBCVector3D& in_vct
02355 )
02356 {
02357     if (in_vct.m_fX != 0.0f &&
02358         in_vct.m_fY != 0.0f &&
02359         in_vct.m_fZ != 0.0f)
02360     {
02361         m_fX /= in_vct.m_fX;
02362         m_fY /= in_vct.m_fY;
02363         m_fZ /= in_vct.m_fZ;
02364     }
02365 
02366     return *this;
02367 }
02368 
02369 //***************************************************************************************
02370 //
02371 // Author : Softimage Games Team
02372 // Date   : 
02373 //
02374 // Sets this vector to be the cross product of this and the other vector.
02375 // CSIBCVector3D& | in_vct | Input vector.
02376 // Returns a pointer to the vector.
02377 //
02378 //***************************************************************************************
02379 inline CSIBCVector3D& CSIBCVector3D::SetCross
02380 ( 
02381     const CSIBCVector3D& in_vct
02382 )
02383 {
02384     SI_Float dX, dY, dZ;
02385     
02386     dX =  m_fY * in_vct.m_fZ - m_fZ * in_vct.m_fY ;
02387     dY = -m_fX * in_vct.m_fZ + m_fZ * in_vct.m_fX ;
02388     dZ =  m_fX * in_vct.m_fY - m_fY * in_vct.m_fX ;
02389 
02390    return( Set( dX, dY, dZ ) );
02391 }
02392 
02393 //***************************************************************************************
02394 //
02395 // Author : Softimage Games Team
02396 // Date   : 
02397 //
02398 // Returns a cross product.
02399 // CSIBCVector3D& | in_vct | Input vector.
02400 // Returns the new.
02401 //
02402 //***************************************************************************************
02403 inline CSIBCVector3D  CSIBCVector3D::CrossProduct( const CSIBCVector3D &in_vct )  const
02404 {
02405     CSIBCVector3D tmp;
02406 #ifdef _PSX2_ASM
02407     sceVu0OuterProduct( &tmp.m_fX, (float*)&m_fX, (float*)&in_vct.m_fX );
02408 #else
02409     tmp.m_fX =  m_fY * in_vct.m_fZ - m_fZ * in_vct.m_fY ;
02410     tmp.m_fY = -m_fX * in_vct.m_fZ + m_fZ * in_vct.m_fX ;
02411     tmp.m_fZ =  m_fX * in_vct.m_fY - m_fY * in_vct.m_fX ;
02412 #endif
02413     return tmp;
02414 }
02415 
02416 //***************************************************************************************
02417 //
02418 // Author : Softimage Games Team
02419 // Date   : 
02420 //
02421 // Sets the xyz values of this vector.
02422 //
02423 // SI_Float | in_dX | x component of the vector.
02424 // SI_Float | in_dY | y component of the vector.
02425 // SI_Float | in_dZ | z component of the vector.
02426 // Returns a pointer to the vector.
02427 //***************************************************************************************
02428 inline CSIBCVector3D& CSIBCVector3D::Set
02429 (
02430     SI_Float in_dX,
02431     SI_Float in_dY,
02432     SI_Float in_dZ
02433 )
02434 {
02435     m_fX = (SI_Float) in_dX;
02436     m_fY = (SI_Float) in_dY;
02437     m_fZ = (SI_Float) in_dZ;
02438 
02439     return *this;
02440 }
02441 
02442 //***************************************************************************************
02443 //
02444 // Author : Softimage Games Team
02445 // Date   : 
02446 //
02447 // Constructor.
02448 //
02449 // CSIBCVector4D::CSIBCVector4D();
02450 // CSIBCVector4D::CSIBCVector4D( const CSIBCVector4D& in_vct );
02451 // inline CSIBCVector4D::CSIBCVector4D( const SI_Float in_dX, const SI_Float in_dY, const SI_Float in_dZ, const SI_Float in_dW );
02452 //
02453 //***************************************************************************************
02454 inline CSIBCVector4D::CSIBCVector4D()
02455 {
02456     m_fX = 0.0f;
02457     m_fY = 0.0f;
02458     m_fZ = 0.0f;
02459     m_fW = 0.0f;
02460 }
02461 
02462 
02463 //***************************************************************************************
02464 //
02465 // Author : Softimage Games Team
02466 // Date   : 
02467 //
02468 // Copy constructor.
02469 // CSIBCVector4D& | in_vct | Input vector.
02470 //
02471 //
02472 //***************************************************************************************
02473 inline CSIBCVector4D::CSIBCVector4D
02474 (
02475     const CSIBCVector4D& in_vct 
02476 )
02477 {
02478     m_fX = in_vct.m_fX;
02479     m_fY = in_vct.m_fY;
02480     m_fZ = in_vct.m_fZ;
02481     m_fW = in_vct.m_fW;
02482 }
02483 
02484 
02485 
02486 
02487 //***************************************************************************************
02488 //
02489 // Author : Softimage Games Team
02490 // Date   : 
02491 //
02492 // Constructor with xyzw values.
02493 // SI_Float | in_dX | x component of the vector.
02494 // SI_Float | in_dY | y component of the vector.
02495 // SI_Float | in_dZ | z component of the vector.
02496 // SI_Float | in_dW | w component of the vector.
02497 //***************************************************************************************
02498 inline CSIBCVector4D::CSIBCVector4D
02499 (
02500     const SI_Float in_dX,
02501     const SI_Float in_dY,
02502     const SI_Float in_dZ,
02503     const SI_Float in_dW
02504 )
02505 {
02506     m_fX = (SI_Float) in_dX;
02507     m_fY = (SI_Float) in_dY;
02508     m_fZ = (SI_Float) in_dZ;
02509     m_fW = (SI_Float) in_dW;
02510 }
02511 
02512 //***************************************************************************************
02513 //
02514 // Author : Softimage Games Team
02515 // Date   : 
02516 //
02517 // Constructor with xyzw values.
02518 // SIBCVector3D& | in_vVct | xyz component of the vector.
02519 // SI_Float | in_dW | w component of the vector.
02520 //***************************************************************************************
02521 inline CSIBCVector4D::CSIBCVector4D
02522 (
02523     const CSIBCVector3D& in_vVct, const SI_Float in_dW
02524 )
02525 {
02526     m_fX = in_vVct.m_fX;
02527     m_fY = in_vVct.m_fY;
02528     m_fZ = in_vVct.m_fZ;
02529     m_fW = in_dW;
02530 }
02531 
02532 //***************************************************************************************
02533 //
02534 // Author : Softimage Games Team
02535 // Date   : 
02536 //
02537 // Destructor. No dynamic allocation is done so this is empty.
02538 //
02539 //
02540 //***************************************************************************************
02541 inline CSIBCVector4D::~CSIBCVector4D()
02542 {
02543 }
02544 
02545 
02546 //***************************************************************************************
02547 //
02548 // Author : Softimage Games Team
02549 // Date   : 
02550 //
02551 // Tests if this vector is almost equal to the other vector.
02552 //
02553 // CSIBCVector4D& | in_vct | Input vector.
02554 // SI_Float | in_dEpsilon | Error tolerance.
02555 // Returns a boolean.
02556 //
02557 //***************************************************************************************
02558 inline SI_Bool CSIBCVector4D::IsAlmostEqualTo
02559 ( 
02560     const CSIBCVector4D&    in_vct,
02561     const SI_Float          in_dEpsilon  
02562 )
02563 {
02564     return( fabs( m_fX - in_vct.m_fX ) < in_dEpsilon &&
02565         fabs( m_fY - in_vct.m_fY ) < in_dEpsilon &&
02566         fabs( m_fZ - in_vct.m_fZ ) < in_dEpsilon &&
02567         fabs( m_fW - in_vct.m_fW ) < in_dEpsilon ) ;
02568 }
02569 
02570 
02571 //***************************************************************************************
02572 //
02573 // Author : Softimage Games Team
02574 // Date   : 
02575 //
02576 // Tests if this vector is orthogonal (90 degrees) to another.
02577 // CSIBCVector4D& | in_vct | Input vector.
02578 // Returns a boolean.
02579 //
02580 //***************************************************************************************
02581 inline SI_Bool CSIBCVector4D::IsOrthogonalTo
02582 ( 
02583     const CSIBCVector4D& in_vct
02584 )
02585 {
02586     if( fabs( GetDot( in_vct ) ) < SIBCVECTOR_EPS) 
02587         return TRUE;
02588     else
02589         return FALSE;
02590 }
02591 
02592 
02593 //***************************************************************************************
02594 //
02595 // Author : Softimage Games Team
02596 // Date   : 
02597 //
02598 // Tests if this vector is the null vector.
02599 // Returns a boolean.
02600 //
02601 //***************************************************************************************
02602 inline SI_Bool CSIBCVector4D::IsNull() const 
02603 {
02604     // No test is done on W
02605     const SI_Float l_dEpsilon = SIBCVECTOR_EPS;
02606     return ( fabs( m_fX ) < l_dEpsilon &&
02607         fabs( m_fY ) < l_dEpsilon &&
02608         fabs( m_fZ ) < l_dEpsilon &&
02609         fabs( m_fW ) < l_dEpsilon );
02610 }
02611 
02612 //***************************************************************************************
02613 //
02614 // Author : Softimage Games Team
02615 // Date   : 
02616 //
02617 // Gets the dot product of this vector with another vector.
02618 //
02619 // CSIBCVector4D& | in_vct | Input vector.
02620 // Returns the dot product of this vector with another vector.
02621 //
02622 //***************************************************************************************
02623 inline SI_Float CSIBCVector4D::GetDot
02624 ( 
02625     const CSIBCVector4D& in_vct
02626 ) const
02627 {
02628     return ( m_fX*in_vct.m_fX + m_fY*in_vct.m_fY + m_fZ*in_vct.m_fZ + m_fW*in_vct.m_fW);
02629 }
02630 
02631  
02632 //***************************************************************************************
02633 //
02634 // Author : Softimage Games Team
02635 // Date   : 
02636 //
02637 // Gets the distance of this vector to another one.
02638 //
02639 // CSIBCVector4D& | in_vct | Input vector.
02640 // Returns the distance of this vector to another one.
02641 //
02642 //***************************************************************************************
02643 inline SI_Float CSIBCVector4D::GetDistanceFrom
02644 ( 
02645     const CSIBCVector4D& in_vct 
02646 ) const
02647 {
02648     SI_Float rx, ry, rz, rw;
02649 
02650     rx = m_fX-in_vct.m_fX;  
02651     ry = m_fY-in_vct.m_fY;  
02652     rz = m_fZ-in_vct.m_fZ;  
02653     rw = m_fW-in_vct.m_fW;  
02654 
02655     return (SI_Float)sqrt( rx*rx + ry*ry + rz*rz + rw*rw );
02656 }
02657 
02658 //***************************************************************************************
02659 //
02660 // Author : Softimage Games Team
02661 // Date   : 
02662 //
02663 // Returns the length of this vector.
02664 //
02665 //***************************************************************************************
02666 inline SI_Float CSIBCVector4D::GetLength() const
02667 {
02668     return (SI_Float)sqrt( GetSquaredLength() );
02669 }
02670 
02671 //***************************************************************************************
02672 //
02673 // Author : Softimage Games Team
02674 // Date   : 
02675 //
02676 // Gets the squared length of this vector.
02677 // Returns the suqared length of this vector.
02678 //
02679 //***************************************************************************************
02680 inline SI_Float CSIBCVector4D::GetSquaredLength() const
02681 {
02682     return( m_fX*m_fX + m_fY*m_fY + m_fZ*m_fZ + m_fW*m_fW);
02683 }
02684 
02685 //***************************************************************************************
02686 //
02687 // Author : Softimage Games Team
02688 // Date   : 
02689 //
02690 // Gets the XYZW values of this vector.
02691 //
02692 // SI_Float* | out_dX | the x component of the vector.
02693 // SI_Float* | out_dY | the y component of the vector.
02694 // SI_Float* | out_dZ | the z component of the vector.
02695 // SI_Float* | out_dW | the w component of the vector.
02696 //***************************************************************************************
02697 inline void CSIBCVector4D::Get
02698 (
02699     SI_Float* out_dX,
02700     SI_Float* out_dY,
02701     SI_Float* out_dZ,
02702     SI_Float* out_dW
02703 ) const
02704 {
02705     *out_dX = m_fX;
02706     *out_dY = m_fY;
02707     *out_dZ = m_fZ;
02708     *out_dW = m_fW;
02709 }
02710  
02711 //***************************************************************************************
02712 //
02713 // Author : Softimage Games Team
02714 // Date   : 
02715 //
02716 // Sets the length of the vector to in_dLength units.
02717 //
02718 // SI_Float | in_dLength | Length of the vector.
02719 // Returns a pointer to a vector object.
02720 //
02721 //***************************************************************************************
02722 inline CSIBCVector4D& CSIBCVector4D::SetLength
02723 ( 
02724     const SI_Float in_dLength 
02725 )
02726 {
02727     SI_Float  rLen = GetLength();
02728 
02729     if ( rLen > SIBCVECTOR_EPS )
02730     {
02731         Scale( in_dLength / rLen );
02732         return *this;
02733     }
02734     else
02735         return *this;
02736 }
02737 
02738 
02739 //***************************************************************************************
02740 //
02741 // Author : Softimage Games Team
02742 // Date   : 
02743 //
02744 // Normalizes the vector. If the vector is null then we initialize to (1,0,0,0).
02745 // Returns a pointer to a vector object.
02746 //
02747 //***************************************************************************************
02748 inline CSIBCVector4D& CSIBCVector4D::Normalize()
02749 {
02750     SI_Float  rLen = GetLength();
02751 
02752     if ( rLen > SIBCVECTOR_EPS )
02753     {
02754         m_fX /= (SI_Float) rLen ;
02755         m_fY /= (SI_Float) rLen ;
02756         m_fZ /= (SI_Float) rLen ; 
02757         m_fW /= (SI_Float) rLen ; 
02758         return *this;
02759     }
02760     else
02761     {
02762         return Set(1.0f, 0.0f, 0.0f, 0.0f);
02763     }
02764 }
02765 
02766 //***************************************************************************************
02767 //
02768 // Author : Softimage Games Team
02769 // Date   : 
02770 //
02771 // Returns TRUE if this vector is the same as the other.
02772 //
02773 // CSIBCVector4D& | in_v | Input vector.
02774 // Returns a boolean.
02775 //***************************************************************************************
02776 inline SI_Bool CSIBCVector4D::operator ==
02777 ( 
02778     const CSIBCVector4D& in_v
02779 ) const
02780 {
02781     return ( ( m_fX == in_v.m_fX ) && ( m_fY == in_v.m_fY ) 
02782         && ( m_fZ == in_v.m_fZ ) && ( m_fW == in_v.m_fW ) );
02783 }
02784 
02785 //***************************************************************************************
02786 //
02787 // Author : Softimage Games Team
02788 // Date   : 
02789 //
02790 // Returns TRUE if this vector is different from the other.
02791 // CSIBCVector4D& | in_vct | Input vector.
02792 //
02793 //***************************************************************************************
02794 inline SI_Bool CSIBCVector4D::operator !=
02795 ( 
02796     const CSIBCVector4D& in_vct 
02797 ) const
02798 {
02799     return !( *this==in_vct ) ;
02800 }
02801 
02802 //***************************************************************************************
02803 //
02804 // Author : Softimage Games Team
02805 // Date   : 
02806 //
02807 // Vector add operator.
02808 // CSIBCVector4D& | in_vtx | Input vector.
02809 // Returns a vector.
02810 //
02811 //***************************************************************************************
02812 inline CSIBCVector4D CSIBCVector4D::operator+
02813 (
02814     const CSIBCVector4D &in_vtx
02815 )
02816 {
02817     CSIBCVector4D v2;
02818 
02819     v2.m_fX = m_fX + in_vtx.m_fX;
02820     v2.m_fY = m_fY + in_vtx.m_fY;
02821     v2.m_fZ = m_fZ + in_vtx.m_fZ;
02822     v2.m_fW = m_fW + in_vtx.m_fW;
02823 
02824     return v2;
02825 }
02826 
02827 //***************************************************************************************
02828 //
02829 // Author : Softimage Games Team
02830 // Date   : 
02831 //
02832 // Vector sub operator.
02833 // CSIBCVector4D& | in_vtx | Input vector.
02834 // Returns a vector.
02835 //
02836 //***************************************************************************************
02837 inline CSIBCVector4D CSIBCVector4D::operator-
02838 (
02839     const CSIBCVector4D &in_vtx
02840 )
02841 {
02842     CSIBCVector4D v2;
02843 
02844     v2.m_fX = m_fX - in_vtx.m_fX;
02845     v2.m_fY = m_fY - in_vtx.m_fY;
02846     v2.m_fZ = m_fZ - in_vtx.m_fZ;
02847     v2.m_fW = m_fW - in_vtx.m_fW;
02848 
02849     return v2;
02850 }
02851 
02852 //***************************************************************************************
02853 //
02854 // Author : Softimage Games Team
02855 // Date   : 
02856 //
02857 // Vector divide operator.
02858 // CSIBCVector4D& | in_vtx | Input vector.
02859 // Returns a vector.
02860 //
02861 //***************************************************************************************
02862 inline CSIBCVector4D CSIBCVector4D::operator/
02863 (
02864     const CSIBCVector4D &in_vtx
02865 )
02866 {
02867     CSIBCVector4D v2;
02868 
02869     if ((in_vtx.m_fX != 0.0f) &&
02870         (in_vtx.m_fY != 0.0f) &&
02871         (in_vtx.m_fZ != 0.0f) &&
02872         (in_vtx.m_fW != 0.0f))
02873     {
02874         v2.m_fX = m_fX / in_vtx.m_fX;
02875         v2.m_fY = m_fY / in_vtx.m_fY;
02876         v2.m_fZ = m_fZ / in_vtx.m_fZ;
02877         v2.m_fW = m_fW / in_vtx.m_fW;
02878     }
02879 
02880     return v2;
02881 }
02882 
02883 //***************************************************************************************
02884 //
02885 // Author : Softimage Games Team
02886 // Date   : 
02887 //
02888 // Assignment operator.
02889 // CSIBCVector4D& | in_vtx | Input vector.
02890 // Returns a pointer to a vector.
02891 //
02892 //***************************************************************************************
02893 inline CSIBCVector4D &CSIBCVector4D::operator = (const CSIBCVector3D &in_vtx )
02894 {
02895     m_fX = in_vtx.m_fX;
02896     m_fY = in_vtx.m_fY;
02897     m_fZ = in_vtx.m_fZ; 
02898     return *this;
02899 }
02900 
02901 //***************************************************************************************
02902 //
02903 // Author : Softimage Games Team
02904 // Date   : 
02905 //
02906 // Sets the vector to the NULL vector.
02907 // Returns a pointer to a vector.
02908 //
02909 //***************************************************************************************
02910 inline CSIBCVector4D& CSIBCVector4D::SetNull()
02911 { 
02912     m_fX = m_fY = m_fZ = m_fW = 0.0f; 
02913 
02914     return *this;
02915 }
02916 
02917 //***************************************************************************************
02918 //
02919 // Author : Softimage Games Team
02920 // Date   : 
02921 //
02922 // Sets this vector to be the opposite vector.
02923 // Returns a pointer to a vector.
02924 //
02925 //***************************************************************************************
02926 inline CSIBCVector4D& CSIBCVector4D::Negate()
02927 {
02928     m_fX = -m_fX;
02929     m_fY = -m_fY;
02930     m_fZ = -m_fZ;
02931     m_fW = -m_fW;
02932     return *this;
02933 }
02934 
02935 
02936 //***************************************************************************************
02937 //
02938 // Author : Softimage Games Team
02939 // Date   : 
02940 //
02941 // Adds a vector to this vector.
02942 // CSIBCVector4D& | in_vct | Input vector.
02943 // Returns a pointer to a vector.
02944 //
02945 //***************************************************************************************
02946 inline CSIBCVector4D& CSIBCVector4D::Add
02947 (
02948     const CSIBCVector4D& in_vct
02949 )
02950 {
02951     m_fX += in_vct.m_fX;
02952     m_fY += in_vct.m_fY;
02953     m_fZ += in_vct.m_fZ;
02954     m_fW += in_vct.m_fW;
02955     return *this;
02956 }
02957 
02958 
02959 //***************************************************************************************
02960 //
02961 // Author : Softimage Games Team
02962 // Date   : 
02963 //
02964 // Substracts a vector from this vector.
02965 // CSIBCVector4D& | in_vct | Input vector.
02966 // Returns a pointer to a vector.
02967 //
02968 //***************************************************************************************
02969 inline CSIBCVector4D& CSIBCVector4D::Sub
02970 ( 
02971     const CSIBCVector4D& in_vct
02972 )
02973 {
02974     m_fX -= in_vct.m_fX;
02975     m_fY -= in_vct.m_fY;
02976     m_fZ -= in_vct.m_fZ;
02977     m_fW -= in_vct.m_fW;
02978     return *this;
02979 }
02980 
02981 
02982 //***************************************************************************************
02983 //
02984 // Author : Softimage Games Team
02985 // Date   : 
02986 //
02987 // Scales a vector by a given factor.
02988 //
02989 // SI_Float | in_dFactor | Scale factor.
02990 // Returns a pointer to a vector object.
02991 //
02992 //***************************************************************************************
02993 inline CSIBCVector4D& CSIBCVector4D::Scale
02994 ( 
02995     const SI_Float in_dFactor
02996 )
02997 {
02998     m_fX *= (SI_Float) in_dFactor;
02999     m_fY *= (SI_Float) in_dFactor;
03000     m_fZ *= (SI_Float) in_dFactor;
03001     m_fW *= (SI_Float) in_dFactor;
03002     return *this;
03003 }
03004 
03005 
03006 //***************************************************************************************
03007 //
03008 // Author : Softimage Games Team
03009 // Date   : 
03010 //
03011 // Does component-wise multiplication of the vector. 
03012 //
03013 // CSIBCVector4D& | in_vct | Input vector.
03014 // Returns a pointer to a vector.
03015 //
03016 //***************************************************************************************
03017 inline CSIBCVector4D& CSIBCVector4D::MulComp
03018 ( 
03019      const CSIBCVector4D& in_vct    
03020 )
03021 {
03022     m_fX *= in_vct.m_fX;
03023     m_fY *= in_vct.m_fY;
03024     m_fZ *= in_vct.m_fZ;
03025     return *this; 
03026 }
03027 
03028 
03029 //***************************************************************************************
03030 //
03031 // Author : Softimage Games Team
03032 // Date   : 
03033 //
03034 // Does component wise division of the vector. 
03035 // CSIBCVector4D& | in_vct | Input vector.
03036 // Returns a pointer to a vector.
03037 //
03038 //***************************************************************************************
03039 inline CSIBCVector4D& CSIBCVector4D::DivComp
03040 ( 
03041     const CSIBCVector4D& in_vct
03042 )
03043 {
03044     if (in_vct.m_fX != 0.0f &&
03045         in_vct.m_fY != 0.0f &&
03046         in_vct.m_fZ != 0.0f &&
03047         in_vct.m_fW != 0.0f)
03048     {
03049         m_fX /= in_vct.m_fX;
03050         m_fY /= in_vct.m_fY;
03051         m_fZ /= in_vct.m_fZ;
03052         m_fW /= in_vct.m_fW;
03053     }
03054 
03055     return *this;
03056 }
03057 
03058 //***************************************************************************************
03059 //
03060 // Author : Softimage Games Team
03061 // Date   : 
03062 //
03063 // Sets the xyzw values of this vector.
03064 //
03065 // SI_Float | in_dX | x component of vector.
03066 // SI_Float | in_dY | y component of vector.
03067 // SI_Float | in_dZ | z component of vector.
03068 // SI_Float | in_dW | w component of vector.
03069 // Returns a pointer to a vector.
03070 //***************************************************************************************
03071 inline CSIBCVector4D& CSIBCVector4D::Set
03072 (
03073     SI_Float in_dX,
03074     SI_Float in_dY,
03075     SI_Float in_dZ,
03076     SI_Float in_dW
03077 )
03078 {
03079     m_fX = (SI_Float) in_dX;
03080     m_fY = (SI_Float) in_dY;
03081     m_fZ = (SI_Float) in_dZ;
03082     m_fW = (SI_Float) in_dW;
03083     return *this;
03084 }
03085 
03086 
03087 #endif // CSIBCVector