Panda3D
|
00001 // Filename: cmath.h 00002 // Created by: drose (19May00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef CMATH_H 00016 #define CMATH_H 00017 00018 // This file declares a number of C++-style overloading wrappers 00019 // around the standard math library functions, so we can use 00020 // overloading to differentiate on type instead of having to know 00021 // explicitly whether we need to call, for instance, sqrtf() or 00022 // sqrt(). 00023 00024 #include "dtoolbase.h" 00025 00026 #include <math.h> 00027 00028 // Windows defines isnan() in a different place and with a different 00029 // name than everyone else. Sheesh. 00030 #ifdef _WIN32 00031 #include <float.h> 00032 #endif 00033 00034 INLINE float csqrt(float v); 00035 INLINE float csin(float v); 00036 INLINE float ccos(float v); 00037 INLINE float ctan(float v); 00038 INLINE void csincos(float v, float *sin_result, float *cos_result); 00039 INLINE float csin_over_x(float v); 00040 INLINE float cabs(float v); 00041 INLINE float catan(float v); 00042 INLINE float catan2(float y, float x); 00043 INLINE float casin(float v); 00044 INLINE float cacos(float v); 00045 INLINE float cmod(float x, float y); 00046 INLINE float cpow(float x, float y); 00047 00048 INLINE double cfloor(double f); 00049 INLINE double cceil(double f); 00050 INLINE double cfrac(double f); 00051 INLINE double csqrt(double v); 00052 INLINE double csin(double v); 00053 INLINE double ccos(double v); 00054 INLINE double ctan(double v); 00055 INLINE void csincos(double v, double *sin_result, double *cos_result); 00056 INLINE double cabs(double v); 00057 INLINE double catan(double v); 00058 INLINE double catan2(double y, double x); 00059 INLINE double casin(double v); 00060 INLINE double cacos(double v); 00061 INLINE double cmod(double x, double y); 00062 INLINE double cpow(double x, double y); 00063 00064 // Returns true if the number is nan, false if it's a genuine number 00065 // or infinity. 00066 INLINE bool cnan(double v); 00067 00068 INLINE int cmod(int x, int y); 00069 00070 #include "cmath.I" 00071 00072 #endif 00073