SIBCMath.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 // SIBCMath.h | Main header file for Math 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 __CSIBC_MATH_H__
00029 #define __CSIBC_MATH_H__
00030 
00031 
00032 #ifndef XSICOREEXPORT
00033 # if ((defined _WIN32) || (defined WIN32)) && !(defined _WIN32_WCE) && !(defined _XBOX)
00034 #  ifdef XSICORE_IMPL
00035 #   define XSICOREEXPORT __declspec(dllexport)
00036 #  elif defined(XSICORE_STATIC)
00037 #   define XSICOREEXPORT
00038 #  else
00039 #   define XSICOREEXPORT __declspec(dllimport)
00040 #  endif
00041 # else
00042 #  define XSICOREEXPORT
00043 # endif
00044 #endif
00045 
00046 //***************************************************************************************
00047 // Includes
00048 //***************************************************************************************
00049 #include <math.h>
00050 #include <float.h>
00051 
00052 /****************************************/
00053 /*         GLOBAL CONSTANTS             */
00054 /****************************************/
00055 
00060 #define SI_DODECA_EPS   1.0e-12         
00061 #define SI_FLOAT_MIN    FLT_MIN         
00062 #define SI_FLOAT_MAX    FLT_MAX         
00063 #define SI_TWO_PI       ( 2 * M_PI )    
00064 #define SI_QUADRA_EPS   0.0001          
00065 #define SI_PROJ_EPS1    0.0002          
00066 #define SI_PROJ_EPS2    0.001           
00067 #define SI_EPSILON      0.0001          
00068 #define SI_PENTA_EPS    1.0e-05         
00069 #define SI_HEXA_EPS     1.0e-6          
00072 // The follow are not used, and should be removed in future versions.
00073 #define SI_LENGTH_EPS   0.01
00074 #define SI_VOLUME_EPS   5.0e-3
00075 #define SI_PREC         1e-6
00076 #define SI_IK_EPS2      0.0008
00077 #define SI_IK_EPS1      0.00001
00078 #define SI_PROT_EPS     0.05
00079 
00080 /****************************************/
00081 /*         GLOBAL CONSTANTS             */
00082 /****************************************/
00083 /* Some useful constants - These Match SGI's constants*/
00084 /*  As defined in <math.h>  - these aren't defined in */
00085 /*  NT's <math.h>                                     */
00086 /******************************************************/
00087 
00088 #ifndef M_E
00089 
00094 #define M_E         2.7182818284590452354   
00095 #define M_LOG2E     1.4426950408889634074   
00096 #define M_LOG10E    0.43429448190325182765  
00097 #define M_LN2       0.69314718055994530942  
00098 #define M_PI_4      0.78539816339744830962  
00099 #define M_1_PI      0.31830988618379067154  
00100 #define M_2_PI      0.63661977236758134308  
00101 #define M_SQRT1_2   0.70710678118654752440  
00104 #endif
00105 
00109 #define M_LN10      2.30258509299404568402  
00112 #ifndef M_PI
00113 
00116 #define M_PI        3.14159265358979323846  
00118 #endif
00119 
00123 #define M_PI_2      1.57079632679489661923  
00124 #define M_2_SQRTPI  1.12837916709551257390  
00125 #define M_SQRT2     1.41421356237309504880  
00126 #define MAXINT      INT_MAX                 
00129 /****************************************/
00130 /*          LOCAL CONSTANTS             */
00131 /****************************************/
00132 
00133 // These are used internally by InvertParamCubic, and thus do not need documentation.
00134 #define _2PI    (2.0 * M_PI)
00135 #define _1_2PI  (0.5 * M_1_PI)
00136 #define INVERTPARAMCUBIC_TOL        1.0e-09
00137 #define INVERTPARAMCUBIC_SMALLERTOL 1.0e-20
00138 #define INVERTPARAMCUBIC_MAXIT      100
00139 
00140 
00141 /****************************************/
00142 /*      LOCAL FUNCTION PROTOTYPES       */
00143 /****************************************/
00144 
00154 XSICOREEXPORT float angleDistance ( double angle1, double angle2 ); // 
00155 
00161 XSICOREEXPORT float arcSinCos ( double sinus, double cosinus );
00162 
00171 XSICOREEXPORT float InvertParamCubic ( float Param, float x0, float x1, float x2, float x3 );
00172 
00178 #define _SI_LIMIT( x, a, b ) if (x < a) x = a; if (x > b) x = b;
00179 
00181 #endif //