SIBCVector4Dd.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 // SIBCVector4Dd.h | Main header file for CSIBCVector4Dd 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 #if (_MSC_VER > 1000) || defined(SGI_COMPILER)
00026 #pragma once
00027 #endif
00028 
00029 //******************************************************************************
00030 // Defines
00031 //******************************************************************************
00032 #ifndef _VECTOR4_H_
00033 #define _VECTOR4_H_
00034 
00035 //******************************************************************************
00036 // Includes
00037 //****************************************************************************** 
00038 #include "SIBCMathLib.h"
00039 
00040 //******************************************************************************
00041 // Typedefs
00042 //******************************************************************************
00043 
00044 
00045 //******************************************************************************
00046 // CSIBCVector4Dd | General 3D vector.
00047 //******************************************************************************
00048 
00050 
00060 class XSICOREEXPORT CSIBCVector4Dd
00061 {
00062     // Public members
00063     public:
00064 
00065         //****************************************
00066         // IMPLEMENTATION
00067         //****************************************
00068 
00072         CSIBCVector4Dd( );
00073 
00082         CSIBCVector4Dd( const double  in_dX, const double in_dY,
00083             const double  in_dZ, const double in_dW );
00084 
00091         CSIBCVector4Dd( const CSIBCVector3Dd &in_vct, double in_dW );
00092 
00093         ~CSIBCVector4Dd();
00094 
00095         // Individual access to private members:
00096 
00105         double GetX( void ) const;
00106 
00115         double GetY( void ) const;
00116 
00125         double GetZ( void ) const;
00126 
00135         double GetW( void ) const;
00136 
00147         double Get( const int in_nIndex ) const;
00148 
00160         void Get(   double& out_dX, double& out_dY,
00161                     double& out_dZ, double& out_dW  ) const;
00162 
00172         CSIBCVector4Dd& SetX ( const double in_dVal );
00173 
00183         CSIBCVector4Dd& SetY ( const double in_dVal );
00184 
00194         CSIBCVector4Dd& SetZ ( const double in_dVal );
00195 
00205         CSIBCVector4Dd& SetW ( const double in_dVal );
00206 
00214         CSIBCVector4Dd& Set ( const int in_nIndex, const double in_dVal );
00215 
00229         CSIBCVector4Dd& Set( const double in_dX, const double in_dY,
00230             const double in_dZ, const double in_dW );
00231 
00241         void Set( const CSIBCVector4Dd& in_vct);
00242 
00248         CSIBCVector4Dd& SetNull( void );
00249 
00258         bool IsNull( const double in_dEpsilon=PICO_EPS ) const;
00259 
00266         CSIBCVector4Dd& SetMinimal ( const double in_dEpsilon=PICO_EPS );
00267 
00278         friend  bool AreAlmostEqual( const CSIBCVector4Dd& in_vct1,
00279             const CSIBCVector4Dd& in_vct2, const double in_dEpsilon = PICO_EPS ) ;
00280 
00288         bool operator == ( const CSIBCVector4Dd& in_vct ) const;
00289 
00297         bool operator != ( const CSIBCVector4Dd& in_vct ) const;
00298 
00304         CSIBCVector4Dd& Negate( const CSIBCVector4Dd& in_vct );
00305 
00310         CSIBCVector4Dd& Negate( void );
00311 
00318         double GetSquaredLength( void ) const;
00319 
00326         double GetLength( void ) const;
00327 
00335         bool SetLength( const double in_dLength );
00336 
00343         bool Normalize( void );
00344 
00345 
00346         // Efficient arithmetic operations.
00347 
00348 
00355         CSIBCVector4Dd& Add( const CSIBCVector4Dd& in_vct  );
00356 
00364         CSIBCVector4Dd& Add( const CSIBCVector4Dd& in_vct1, const CSIBCVector4Dd& in_vct2);
00365 
00372         CSIBCVector4Dd& Sub( const CSIBCVector4Dd& in_vct );
00373 
00381         CSIBCVector4Dd& Sub( const CSIBCVector4Dd& in_vct1, const CSIBCVector4Dd& in_vct2); 
00382 
00392         CSIBCVector4Dd& Mul( const double in_dFactor );
00393 
00404         CSIBCVector4Dd& Mul( const double in_dFactor, const CSIBCVector4Dd& in_vct );
00405 
00416         CSIBCVector4Dd& Mul( const CSIBCVector4Dd& in_vct, const double in_dFactor );
00417 
00427         CSIBCVector4Dd& Div( const double in_dFactor );
00428 
00439         CSIBCVector4Dd& Div( const CSIBCVector4Dd& in_vct, const double in_dFactor );
00440 
00451         CSIBCVector4Dd& MulComp( const CSIBCVector4Dd& in_vct1, const CSIBCVector4Dd& in_vct2  );
00452 
00462         CSIBCVector4Dd& MulComp( const CSIBCVector4Dd& in_vct ); 
00463 
00473         CSIBCVector4Dd& DivComp( const CSIBCVector4Dd& in_vct );
00474 
00485         CSIBCVector4Dd& DivComp( const CSIBCVector4Dd& in_vct1, const CSIBCVector4Dd& in_vct2 );
00486 
00487 
00498         CSIBCVector4Dd& Mul( const CSIBCMatrix44d& in_mat );
00499 
00510         CSIBCVector4Dd& Mul( const CSIBCVector4Dd& in_vct, const CSIBCMatrix44d& in_mat );
00511 
00522         CSIBCVector4Dd& Mul( const CSIBCMatrix44d& in_mat, const CSIBCVector4Dd& in_vct );
00523 
00524         // TODO  Remove set of functions to multiply by CSIBCXfoMatd as soon as 
00525         //       CSIBCXfoMatd and CSIBCMatrix44d will both derived public from a
00526         //       common base matrix class.
00527 
00538         CSIBCVector4Dd& Mul( const CSIBCVector4Dd& in_vct, const CSIBCXfoMatd& in_mat );
00539 
00540 
00551         CSIBCVector4Dd& Mul( const CSIBCXfoMatd& in_mat, const CSIBCVector4Dd& in_vct );
00552 
00553 
00559         friend double GetDot( const CSIBCVector4Dd& in_vct1,
00560             const CSIBCVector4Dd& in_vct2 );
00561 
00569         friend double GetDistance( const CSIBCVector4Dd& in_pnt1, 
00570             const CSIBCVector4Dd& in_pnt2 );
00571 
00579         friend double GetSquaredDistance( const CSIBCVector4Dd& in_pnt1, 
00580             const CSIBCVector4Dd& in_pnt2 );
00581 
00588         bool SetProjection ( const CSIBCVector4Dd& in_vct );
00589 
00590     // Private Members
00591     private:
00592 
00593         //****************************************
00594         // ATTRIBUTES
00595         //****************************************
00596         // double | CSIBCVector4Dd | m_dX | X component of the vector.
00597         // double | CSIBCVector4Dd | m_dY | Y component of the vector.
00598         // double | CSIBCVector4Dd | m_dZ | Z component of the vector.
00599         double  m_dX, m_dY, m_dZ, m_dW;
00600 
00601         // Disable copy constructor and operator =
00602         // CSIBCVector4Dd       | The copy Constructor
00603         CSIBCVector4Dd( const CSIBCVector4Dd& in_vct );
00604         // operator=            | Assigment operator.
00605         CSIBCVector4Dd& operator = ( const CSIBCVector4Dd& in_vct );
00606 
00607 };
00608 
00609 //******************************************************************************
00610 //
00611 // Author : Michel Carigan
00612 // Date  : 08/05/96
00613 //
00614 // CSIBCVector4Dd& | CSIBCVector4Dd | SetMinimal |   Sets each component to be at least
00615 //        epsilon (in absolute). A component is changed only if smaller than epsilon.
00616 //
00617 // CSIBCVector4Dd& SetMinimal( const double in_dEpsilon = PICO_EPS )
00618 //
00619 // double | in_dEpsilon | Specify the user minimal value. If not given, the default
00620 //                                        value will be PICO_EPS
00621 //
00622 // A reference on this.
00623 //
00624 //
00625 // This function works like the macro _SI_VCT_EPS in v3.51
00626 // That is, each component are set to eps only if they are less than epsilon.
00627 // In that case the sign is unchanged.
00628 //
00629 //******************************************************************************
00630 inline  CSIBCVector4Dd&  
00631 CSIBCVector4Dd::SetMinimal
00632     (
00633         const double in_dEpsilon /* = PICO_EPS */
00634     )
00635 {
00636     if( fabs(m_dX) < in_dEpsilon )
00637         m_dX = ( ( m_dX >= 0 ) ? in_dEpsilon : -in_dEpsilon ) ;
00638     if( fabs(m_dY) < in_dEpsilon )
00639         m_dY = ( ( m_dY >= 0 ) ? in_dEpsilon : -in_dEpsilon ) ;
00640     if( fabs(m_dZ) < in_dEpsilon )
00641         m_dZ = ( ( m_dZ >= 0 ) ? in_dEpsilon : -in_dEpsilon ) ;
00642     if( fabs(m_dW) < in_dEpsilon )
00643         m_dW = ( ( m_dW >= 0 ) ? in_dEpsilon : -in_dEpsilon ) ;
00644     return *this;
00645 }
00646 
00647 #endif