SIBCVector4Dd.h

Go to the documentation of this file.
00001 //***************************************************************************************
00002 // File supervisor: Crosswalk team
00012 //***************************************************************************************
00013 
00014 #if (_MSC_VER > 1000) || defined(SGI_COMPILER)
00015 #pragma once
00016 #endif
00017 
00018 //******************************************************************************
00019 // Defines
00020 //******************************************************************************
00021 #ifndef _VECTOR4_H_
00022 #define _VECTOR4_H_
00023 
00024 //******************************************************************************
00025 // Includes
00026 //******************************************************************************
00027 #include "SIBCMathLib.h"
00028 
00029 //******************************************************************************
00030 // Typedefs
00031 //******************************************************************************
00032 
00033 
00034 //******************************************************************************
00035 // CSIBCVector4Dd | General 3D vector.
00036 //******************************************************************************
00037 
00050 class XSICOREEXPORT CSIBCVector4Dd
00051 {
00052     // Public members
00053     public:
00054 
00055         //****************************************
00056         // IMPLEMENTATION
00057         //****************************************
00058 
00062         CSIBCVector4Dd( );
00063 
00072         CSIBCVector4Dd( const double  in_dX, const double in_dY,
00073             const double  in_dZ, const double in_dW );
00074 
00081         CSIBCVector4Dd( const CSIBCVector3Dd &in_vct, double in_dW );
00082 
00083         ~CSIBCVector4Dd();
00084 
00085         // Individual access to private members:
00086 
00095         double GetX( void ) const;
00096 
00105         double GetY( void ) const;
00106 
00115         double GetZ( void ) const;
00116 
00125         double GetW( void ) const;
00126 
00136         double Get( const int in_nIndex ) const;
00137 
00149         void Get(   double& out_dX, double& out_dY,
00150                     double& out_dZ, double& out_dW  ) const;
00151 
00161         CSIBCVector4Dd& SetX ( const double in_dVal );
00162 
00172         CSIBCVector4Dd& SetY ( const double in_dVal );
00173 
00183         CSIBCVector4Dd& SetZ ( const double in_dVal );
00184 
00194         CSIBCVector4Dd& SetW ( const double in_dVal );
00195 
00203         CSIBCVector4Dd& Set ( const int in_nIndex, const double in_dVal );
00204 
00218         CSIBCVector4Dd& Set( const double in_dX, const double in_dY,
00219             const double in_dZ, const double in_dW );
00220 
00230         void Set( const CSIBCVector4Dd& in_vct);
00231 
00237         CSIBCVector4Dd& SetNull( void );
00238 
00248         bool IsNull( const double in_dEpsilon=PICO_EPS ) const;
00249 
00256         CSIBCVector4Dd& SetMinimal ( const double in_dEpsilon=PICO_EPS );
00257 
00269         friend  bool AreAlmostEqual( const CSIBCVector4Dd& in_vct1,
00270             const CSIBCVector4Dd& in_vct2, const double in_dEpsilon = PICO_EPS ) ;
00271 
00280         bool operator == ( const CSIBCVector4Dd& in_vct ) const;
00281 
00290         bool operator != ( const CSIBCVector4Dd& in_vct ) const;
00291 
00297         CSIBCVector4Dd& Negate( const CSIBCVector4Dd& in_vct );
00298 
00303         CSIBCVector4Dd& Negate( void );
00304 
00311         double GetSquaredLength( void ) const;
00312 
00319         double GetLength( void ) const;
00320 
00328         bool SetLength( const double in_dLength );
00329 
00336         bool Normalize( void );
00337 
00338 
00339         // Efficient arithmetic operations.
00340 
00341 
00348         CSIBCVector4Dd& Add( const CSIBCVector4Dd& in_vct  );
00349 
00357         CSIBCVector4Dd& Add( const CSIBCVector4Dd& in_vct1, const CSIBCVector4Dd& in_vct2);
00358 
00365         CSIBCVector4Dd& Sub( const CSIBCVector4Dd& in_vct );
00366 
00374         CSIBCVector4Dd& Sub( const CSIBCVector4Dd& in_vct1, const CSIBCVector4Dd& in_vct2);
00375 
00385         CSIBCVector4Dd& Mul( const double in_dFactor );
00386 
00397         CSIBCVector4Dd& Mul( const double in_dFactor, const CSIBCVector4Dd& in_vct );
00398 
00409         CSIBCVector4Dd& Mul( const CSIBCVector4Dd& in_vct, const double in_dFactor );
00410 
00420         CSIBCVector4Dd& Div( const double in_dFactor );
00421 
00432         CSIBCVector4Dd& Div( const CSIBCVector4Dd& in_vct, const double in_dFactor );
00433 
00444         CSIBCVector4Dd& MulComp( const CSIBCVector4Dd& in_vct1, const CSIBCVector4Dd& in_vct2  );
00445 
00455         CSIBCVector4Dd& MulComp( const CSIBCVector4Dd& in_vct );
00456 
00466         CSIBCVector4Dd& DivComp( const CSIBCVector4Dd& in_vct );
00467 
00478         CSIBCVector4Dd& DivComp( const CSIBCVector4Dd& in_vct1, const CSIBCVector4Dd& in_vct2 );
00479 
00480 
00490         CSIBCVector4Dd& Mul( const CSIBCMatrix44d& in_mat );
00491 
00502         CSIBCVector4Dd& Mul( const CSIBCVector4Dd& in_vct, const CSIBCMatrix44d& in_mat );
00503 
00514         CSIBCVector4Dd& Mul( const CSIBCMatrix44d& in_mat, const CSIBCVector4Dd& in_vct );
00515 
00516         // TODO  Remove set of functions to multiply by CSIBCXfoMatd as soon as
00517         //       CSIBCXfoMatd and CSIBCMatrix44d will both derived public from a
00518         //       common base matrix class.
00519 
00530         CSIBCVector4Dd& Mul( const CSIBCVector4Dd& in_vct, const CSIBCXfoMatd& in_mat );
00531 
00532 
00543         CSIBCVector4Dd& Mul( const CSIBCXfoMatd& in_mat, const CSIBCVector4Dd& in_vct );
00544 
00545 
00551         friend double GetDot( const CSIBCVector4Dd& in_vct1,
00552             const CSIBCVector4Dd& in_vct2 );
00553 
00561         friend double GetDistance( const CSIBCVector4Dd& in_pnt1,
00562             const CSIBCVector4Dd& in_pnt2 );
00563 
00571         friend double GetSquaredDistance( const CSIBCVector4Dd& in_pnt1,
00572             const CSIBCVector4Dd& in_pnt2 );
00573 
00581         bool SetProjection ( const CSIBCVector4Dd& in_vct );
00582 
00583     // Private Members
00584     private:
00585 
00586         //****************************************
00587         // ATTRIBUTES
00588         //****************************************
00589         // double | CSIBCVector4Dd | m_dX | X component of the vector.
00590         // double | CSIBCVector4Dd | m_dY | Y component of the vector.
00591         // double | CSIBCVector4Dd | m_dZ | Z component of the vector.
00592         double  m_dX, m_dY, m_dZ, m_dW;
00593 
00594         // Disable copy constructor and operator =
00595         // CSIBCVector4Dd       | The copy Constructor
00596         CSIBCVector4Dd( const CSIBCVector4Dd& in_vct );
00597         // operator=            | Assigment operator.
00598         CSIBCVector4Dd& operator = ( const CSIBCVector4Dd& in_vct );
00599 
00600 };
00601 
00602 //******************************************************************************
00603 //
00604 // Author : Michel Carigan
00605 // Date  : 08/05/96
00606 //
00607 // CSIBCVector4Dd& | CSIBCVector4Dd | SetMinimal |   Sets each component to be at least
00608 //        epsilon (in absolute). A component is changed only if smaller than epsilon.
00609 //
00610 // CSIBCVector4Dd& SetMinimal( const double in_dEpsilon = PICO_EPS )
00611 //
00612 // double | in_dEpsilon | Specify the user minimal value. If not given, the default
00613 //                                        value will be PICO_EPS
00614 //
00615 // A reference on this.
00616 //
00617 //
00618 // This function works like the macro _SI_VCT_EPS in v3.51
00619 // That is, each component are set to eps only if they are less than epsilon.
00620 // In that case the sign is unchanged.
00621 //
00622 //******************************************************************************
00623 inline  CSIBCVector4Dd&
00624 CSIBCVector4Dd::SetMinimal
00625     (
00626         const double in_dEpsilon /* = PICO_EPS */
00627     )
00628 {
00629     if( fabs(m_dX) < in_dEpsilon )
00630         m_dX = ( ( m_dX >= 0 ) ? in_dEpsilon : -in_dEpsilon ) ;
00631     if( fabs(m_dY) < in_dEpsilon )
00632         m_dY = ( ( m_dY >= 0 ) ? in_dEpsilon : -in_dEpsilon ) ;
00633     if( fabs(m_dZ) < in_dEpsilon )
00634         m_dZ = ( ( m_dZ >= 0 ) ? in_dEpsilon : -in_dEpsilon ) ;
00635     if( fabs(m_dW) < in_dEpsilon )
00636         m_dW = ( ( m_dW >= 0 ) ? in_dEpsilon : -in_dEpsilon ) ;
00637     return *this;
00638 }
00639 
00640 #endif