SIBCMath.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 //***************************************************************************************
00013 // Defines
00014 //***************************************************************************************
00015 #ifndef __CSIBC_MATH_H__
00016 #define __CSIBC_MATH_H__
00017 
00018 
00019 #ifndef XSICOREEXPORT
00020 # if ((defined _WIN32) || (defined WIN32)) && !(defined _WIN32_WCE) && !(defined _XBOX)
00021 #  ifdef XSICORE_IMPL
00022 #   define XSICOREEXPORT __declspec(dllexport)
00023 #  elif defined(XSICORE_STATIC)
00024 #   define XSICOREEXPORT
00025 #  else
00026 #   define XSICOREEXPORT __declspec(dllimport)
00027 #  endif
00028 # else
00029 #  define XSICOREEXPORT
00030 # endif
00031 #endif
00032 
00033 //***************************************************************************************
00034 // Includes
00035 //***************************************************************************************
00036 #include <math.h>
00037 #include <float.h>
00038 
00039 /****************************************/
00040 /*         GLOBAL CONSTANTS             */
00041 /****************************************/
00042 
00047 #define SI_DODECA_EPS   1.0e-12         
00048 #define SI_FLOAT_MIN    FLT_MIN         
00049 #define SI_FLOAT_MAX    FLT_MAX         
00050 #define SI_TWO_PI       ( 2 * M_PI )    
00051 #define SI_QUADRA_EPS   0.0001          
00052 #define SI_PROJ_EPS1    0.0002          
00053 #define SI_PROJ_EPS2    0.001           
00054 #define SI_EPSILON      0.0001          
00055 #define SI_PENTA_EPS    1.0e-05         
00056 #define SI_HEXA_EPS     1.0e-6          
00059 // The follow are not used, and should be removed in future versions.
00060 #define SI_LENGTH_EPS   0.01
00061 #define SI_VOLUME_EPS   5.0e-3
00062 #define SI_PREC         1e-6
00063 #define SI_IK_EPS2      0.0008
00064 #define SI_IK_EPS1      0.00001
00065 #define SI_PROT_EPS     0.05
00066 
00067 /****************************************/
00068 /*         GLOBAL CONSTANTS             */
00069 /****************************************/
00070 /* Some useful constants - These Match SGI's constants*/
00071 /*  As defined in <math.h>  - these aren't defined in */
00072 /*  NT's <math.h>                                     */
00073 /******************************************************/
00074 
00075 #ifndef M_E
00076 
00081 #define M_E         2.7182818284590452354   
00082 #define M_LOG2E     1.4426950408889634074   
00083 #define M_LOG10E    0.43429448190325182765  
00084 #define M_LN2       0.69314718055994530942  
00085 #define M_PI_4      0.78539816339744830962  
00086 #define M_1_PI      0.31830988618379067154  
00087 #define M_2_PI      0.63661977236758134308  
00088 #define M_SQRT1_2   0.70710678118654752440  
00091 #endif
00092 
00096 #define M_LN10      2.30258509299404568402  
00099 #ifndef M_PI
00100 
00103 #define M_PI        3.14159265358979323846  
00105 #endif
00106 
00110 #define M_PI_2      1.57079632679489661923  
00111 #define M_2_SQRTPI  1.12837916709551257390  
00112 #define M_SQRT2     1.41421356237309504880  
00113 #define MAXINT      INT_MAX                 
00116 /****************************************/
00117 /*          LOCAL CONSTANTS             */
00118 /****************************************/
00119 
00120 // These are used internally by InvertParamCubic, and thus do not need documentation.
00121 #define _2PI    (2.0 * M_PI)
00122 #define _1_2PI  (0.5 * M_1_PI)
00123 #define INVERTPARAMCUBIC_TOL        1.0e-09
00124 #define INVERTPARAMCUBIC_SMALLERTOL 1.0e-20
00125 #define INVERTPARAMCUBIC_MAXIT      100
00126 
00127 
00128 /****************************************/
00129 /*      LOCAL FUNCTION PROTOTYPES       */
00130 /****************************************/
00131 
00141 XSICOREEXPORT float angleDistance ( double angle1, double angle2 ); // 
00142 
00148 XSICOREEXPORT float arcSinCos ( double sinus, double cosinus );
00149 
00158 XSICOREEXPORT float InvertParamCubic ( float Param, float x0, float x1, float x2, float x3 );
00159 
00165 #define _SI_LIMIT( x, a, b ) if (x < a) x = a; if (x > b) x = b;
00166 
00168 #endif //