# SIBCVector4Dd.h

    00001 //***************************************************************************************
    00002 //
    00003 // File supervisor: Crosswalk team
    00004 //
    00005 // Copyright 2008 Autodesk, Inc.  All rights reserved.
    00006 // Use of this software is subject to the terms of the Autodesk license agreement
    00007 // provided at the time of installation or download, or which otherwise accompanies
    00008 // this software in either electronic or hard copy form.
    00009 //
    00010 //***************************************************************************************
    00011
    00012 #if (_MSC_VER > 1000) || defined(SGI_COMPILER)
    00013 #pragma once
    00014 #endif
    00015
    00016 //******************************************************************************
    00017 // Defines
    00018 //******************************************************************************
    00019 #ifndef _VECTOR4_H_
    00020 #define _VECTOR4_H_
    00021
    00022 //******************************************************************************
    00023 // Includes
    00024 //******************************************************************************
    00025 #include "SIBCMathLib.h"
    00026
    00027 //******************************************************************************
    00028 // Typedefs
    00029 //******************************************************************************
    00030
    00031
    00032 //******************************************************************************
    00033 // CSIBCVector4Dd | General 3D vector.
    00034 //******************************************************************************
    00035
    00037
    00047 class XSICOREEXPORT CSIBCVector4Dd
    00048 {
    00049     // Public members
    00050     public:
    00051
    00052         //****************************************
    00053         // IMPLEMENTATION
    00054         //****************************************
    00055
    00059         CSIBCVector4Dd( );
    00060
    00069         CSIBCVector4Dd( const double  in_dX, const double in_dY,
    00070             const double  in_dZ, const double in_dW );
    00071
    00078         CSIBCVector4Dd( const CSIBCVector3Dd &in_vct, double in_dW );
    00079
    00080         ~CSIBCVector4Dd();
    00081
    00082         // Individual access to private members:
    00083
    00092         double GetX( void ) const;
    00093
    00102         double GetY( void ) const;
    00103
    00112         double GetZ( void ) const;
    00113
    00122         double GetW( void ) const;
    00123
    00134         double Get( const int in_nIndex ) const;
    00135
    00147         void Get(   double& out_dX, double& out_dY,
    00148                     double& out_dZ, double& out_dW  ) const;
    00149
    00159         CSIBCVector4Dd& SetX ( const double in_dVal );
    00160
    00170         CSIBCVector4Dd& SetY ( const double in_dVal );
    00171
    00181         CSIBCVector4Dd& SetZ ( const double in_dVal );
    00182
    00192         CSIBCVector4Dd& SetW ( const double in_dVal );
    00193
    00201         CSIBCVector4Dd& Set ( const int in_nIndex, const double in_dVal );
    00202
    00216         CSIBCVector4Dd& Set( const double in_dX, const double in_dY,
    00217             const double in_dZ, const double in_dW );
    00218
    00228         void Set( const CSIBCVector4Dd& in_vct);
    00229
    00235         CSIBCVector4Dd& SetNull( void );
    00236
    00245         bool IsNull( const double in_dEpsilon=PICO_EPS ) const;
    00246
    00253         CSIBCVector4Dd& SetMinimal ( const double in_dEpsilon=PICO_EPS );
    00254
    00265         friend  bool AreAlmostEqual( const CSIBCVector4Dd& in_vct1,
    00266             const CSIBCVector4Dd& in_vct2, const double in_dEpsilon = PICO_EPS ) ;
    00267
    00275         bool operator == ( const CSIBCVector4Dd& in_vct ) const;
    00276
    00284         bool operator != ( const CSIBCVector4Dd& in_vct ) const;
    00285
    00291         CSIBCVector4Dd& Negate( const CSIBCVector4Dd& in_vct );
    00292
    00297         CSIBCVector4Dd& Negate( void );
    00298
    00305         double GetSquaredLength( void ) const;
    00306
    00313         double GetLength( void ) const;
    00314
    00322         bool SetLength( const double in_dLength );
    00323
    00330         bool Normalize( void );
    00331
    00332
    00333         // Efficient arithmetic operations.
    00334
    00335
    00342         CSIBCVector4Dd& Add( const CSIBCVector4Dd& in_vct  );
    00343
    00351         CSIBCVector4Dd& Add( const CSIBCVector4Dd& in_vct1, const CSIBCVector4Dd& in_vct2);
    00352
    00359         CSIBCVector4Dd& Sub( const CSIBCVector4Dd& in_vct );
    00360
    00368         CSIBCVector4Dd& Sub( const CSIBCVector4Dd& in_vct1, const CSIBCVector4Dd& in_vct2);
    00369
    00379         CSIBCVector4Dd& Mul( const double in_dFactor );
    00380
    00391         CSIBCVector4Dd& Mul( const double in_dFactor, const CSIBCVector4Dd& in_vct );
    00392
    00403         CSIBCVector4Dd& Mul( const CSIBCVector4Dd& in_vct, const double in_dFactor );
    00404
    00414         CSIBCVector4Dd& Div( const double in_dFactor );
    00415
    00426         CSIBCVector4Dd& Div( const CSIBCVector4Dd& in_vct, const double in_dFactor );
    00427
    00438         CSIBCVector4Dd& MulComp( const CSIBCVector4Dd& in_vct1, const CSIBCVector4Dd& in_vct2  );
    00439
    00449         CSIBCVector4Dd& MulComp( const CSIBCVector4Dd& in_vct );
    00450
    00460         CSIBCVector4Dd& DivComp( const CSIBCVector4Dd& in_vct );
    00461
    00472         CSIBCVector4Dd& DivComp( const CSIBCVector4Dd& in_vct1, const CSIBCVector4Dd& in_vct2 );
    00473
    00474
    00485         CSIBCVector4Dd& Mul( const CSIBCMatrix44d& in_mat );
    00486
    00497         CSIBCVector4Dd& Mul( const CSIBCVector4Dd& in_vct, const CSIBCMatrix44d& in_mat );
    00498
    00509         CSIBCVector4Dd& Mul( const CSIBCMatrix44d& in_mat, const CSIBCVector4Dd& in_vct );
    00510
    00511         // TODO  Remove set of functions to multiply by CSIBCXfoMatd as soon as
    00512         //       CSIBCXfoMatd and CSIBCMatrix44d will both derived public from a
    00513         //       common base matrix class.
    00514
    00525         CSIBCVector4Dd& Mul( const CSIBCVector4Dd& in_vct, const CSIBCXfoMatd& in_mat );
    00526
    00527
    00538         CSIBCVector4Dd& Mul( const CSIBCXfoMatd& in_mat, const CSIBCVector4Dd& in_vct );
    00539
    00540
    00546         friend double GetDot( const CSIBCVector4Dd& in_vct1,
    00547             const CSIBCVector4Dd& in_vct2 );
    00548
    00556         friend double GetDistance( const CSIBCVector4Dd& in_pnt1,
    00557             const CSIBCVector4Dd& in_pnt2 );
    00558
    00566         friend double GetSquaredDistance( const CSIBCVector4Dd& in_pnt1,
    00567             const CSIBCVector4Dd& in_pnt2 );
    00568
    00575         bool SetProjection ( const CSIBCVector4Dd& in_vct );
    00576
    00577     // Private Members
    00578     private:
    00579
    00580         //****************************************
    00581         // ATTRIBUTES
    00582         //****************************************
    00583         // double | CSIBCVector4Dd | m_dX | X component of the vector.
    00584         // double | CSIBCVector4Dd | m_dY | Y component of the vector.
    00585         // double | CSIBCVector4Dd | m_dZ | Z component of the vector.
    00586         double  m_dX, m_dY, m_dZ, m_dW;
    00587
    00588         // Disable copy constructor and operator =
    00589         // CSIBCVector4Dd       | The copy Constructor
    00590         CSIBCVector4Dd( const CSIBCVector4Dd& in_vct );
    00591         // operator=            | Assigment operator.
    00592         CSIBCVector4Dd& operator = ( const CSIBCVector4Dd& in_vct );
    00593
    00594 };
    00595
    00596 //******************************************************************************
    00597 //
    00598 // Author : Michel Carigan
    00599 // Date  : 08/05/96
    00600 //
    00601 // CSIBCVector4Dd& | CSIBCVector4Dd | SetMinimal |   Sets each component to be at least
    00602 //        epsilon (in absolute). A component is changed only if smaller than epsilon.
    00603 //
    00604 // CSIBCVector4Dd& SetMinimal( const double in_dEpsilon = PICO_EPS )
    00605 //
    00606 // double | in_dEpsilon | Specify the user minimal value. If not given, the default
    00607 //                                        value will be PICO_EPS
    00608 //
    00609 // A reference on this.
    00610 //
    00611 //
    00612 // This function works like the macro _SI_VCT_EPS in v3.51
    00613 // That is, each component are set to eps only if they are less than epsilon.
    00614 // In that case the sign is unchanged.
    00615 //
    00616 //******************************************************************************
    00617 inline  CSIBCVector4Dd&
    00618 CSIBCVector4Dd::SetMinimal
    00619     (
    00620         const double in_dEpsilon /* = PICO_EPS */
    00621     )
    00622 {
    00623     if( fabs(m_dX) < in_dEpsilon )
    00624         m_dX = ( ( m_dX >= 0 ) ? in_dEpsilon : -in_dEpsilon ) ;
    00625     if( fabs(m_dY) < in_dEpsilon )
    00626         m_dY = ( ( m_dY >= 0 ) ? in_dEpsilon : -in_dEpsilon ) ;
    00627     if( fabs(m_dZ) < in_dEpsilon )
    00628         m_dZ = ( ( m_dZ >= 0 ) ? in_dEpsilon : -in_dEpsilon ) ;
    00629     if( fabs(m_dW) < in_dEpsilon )
    00630         m_dW = ( ( m_dW >= 0 ) ? in_dEpsilon : -in_dEpsilon ) ;
    00631     return *this;
    00632 }
    00633
    00634 #endif