/* MODULE : COL (Intersection & Collision Library) AUTHOR : Frederic PHILIPPE UBI R&D FILE : Futil.h (Util macro definition) */ #ifndef COL_FUTIL_H #define COL_FUTIL_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #include "cpa_expt.h" /* For Global declaration in C files : */ #ifdef COL_GLOBALS #define COL_EXTERN extern #else /* !COL_GLOBALS */ #define COL_EXTERN #endif /* !COL_GLOBALS */ /* ----------------------------------------------------------------------------- FUNCTIONS DECLARATION: ----------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------------- -- Description : Return true if two values (NOZ) have the same sign -------------------------------------------------------------------------------- -- Creation date : 12 feb 1997 Author : FPI -------------------------------------------------------------------------------- */ #define FUT_M_bSameSign( A, B ) ( MTH_M_bGreaterEqualZero ( A ) == MTH_M_bGreaterEqualZero ( B ) ) /* -------------------------------------------------------------------------------- -- Description : Return the max value of three values -------------------------------------------------------------------------------- -- Creation date : 22 aug 1996 Author : FPI -------------------------------------------------------------------------------- */ #define FUT_M_xMaxValue3( A, B, C ) (\ ( ( (A) > (B) ) && ( (A) > (C) ) ) ?\ (A) :\ ( ( (B) > (C) ) ? (B) : (C) )\ ) #define FUT_M_vMaxValue3( V, A, B, C )\ {\ if ( (A) > (B) )\ {\ if ( (A) > (C) )\ {\ (V) = (A);\ }\ else\ {\ (V) = (C);\ }\ }\ else\ {\ if ( (B) > (C) )\ {\ (V) = (B);\ }\ else\ {\ (V) = (C);\ }\ }\ } /* -------------------------------------------------------------------------------- -- Description : Return the min value of three values -------------------------------------------------------------------------------- -- Creation date : 22 aug 1996 Author : FPI -------------------------------------------------------------------------------- */ #define FUT_M_xMinValue3( A, B, C ) (\ ( ( (A) < (B) ) && ( (A) < (C) ) ) ?\ (A) :\ ( ( (B) < (C) ) ? (B) : (C) )\ ) #define FUT_M_vMinValue3( V, A, B, C )\ {\ if ( (A) < (B) )\ {\ if ( (A) < (C) )\ {\ (V) = (A);\ }\ else\ {\ (V) = (C);\ }\ }\ else\ {\ if ( (B) < (C) )\ {\ (V) = (B);\ }\ else\ {\ (V) = (C);\ }\ }\ } /* -------------------------------------------------------------------------------- -- Description : Return the delta of a trinome -------------------------------------------------------------------------------- -- Creation date : 06 feb 1997 Author : FPI -------------------------------------------------------------------------------- */ #define FUT_M_xTrinomeDelta( A, B, C ) ( MTH_M_xSub ( MTH_M_xSqr ( B ),\ MTH_M_xMul ( MTH_C_4,\ MTH_M_xMul ( A, C )\ )\ )\ ) /* -------------------------------------------------------------------------------- -- Description : Return the interval inclusion for 2 two values -------------------------------------------------------------------------------- -- Creation date : 22 aug 1996 Author : FPI -------------------------------------------------------------------------------- */ #define FUT_M_bInRangeE2( A, B, C, D, E, F ) ( ( (A) <= (B) ) &&\ ( (B) <= (C) ) &&\ ( (D) <= (E) ) &&\ ( (E) <= (F) )\ ) /* -------------------------------------------------------------------------------- -- Description : Add a scalar to a vector -------------------------------------------------------------------------------- -- Creation date : 22 jan 1997 Author : FPI -------------------------------------------------------------------------------- */ /* MTH3D_M_vAddVector(VectDest, VectA, S) : VectDest = VectA + S */ #define FUT_M_vAddScaleVector( VectDest, VectA, S )\ {\ (VectDest)->xX = MTH_M_xAdd ( (VectA)->xX, (S) );\ (VectDest)->xY = MTH_M_xAdd ( (VectA)->xY, (S) );\ (VectDest)->xZ = MTH_M_xAdd ( (VectA)->xZ, (S) );\ } /* -------------------------------------------------------------------------------- -- Description : Sub a scalar to a vector -------------------------------------------------------------------------------- -- Creation date : 22 jan 1997 Author : FPI -------------------------------------------------------------------------------- */ /* MTH3D_M_vSubVector(VectDest, VectA, S) : VectDest = VectA - S */ #define FUT_M_vSubScaleVector( VectDest, VectA, S )\ {\ (VectDest)->xX = MTH_M_xSub ( (VectA)->xX, (S) );\ (VectDest)->xY = MTH_M_xSub ( (VectA)->xY, (S) );\ (VectDest)->xZ = MTH_M_xSub ( (VectA)->xZ, (S) );\ } /* -------------------------------------------------------------------------------- -- Description : Swap two vector 3D pointers -------------------------------------------------------------------------------- -- Creation date : 22 aug 1996 Author : FPI -------------------------------------------------------------------------------- */ #define FUT_M_vSwapVector3DPointer( A, B )\ {\ MTH3D_tdstVector *p_stT;\ \ p_stT = *A;\ *A = *B;\ *B = p_stT;\ } #ifdef __cplusplus }; #endif /* __cplusplus */ #endif /* COL_FUTIL_H */