Math.h

Go to the documentation of this file.
00001 #ifndef __LANG_MATH_HPP
00002 #define __LANG_MATH_HPP
00003 
00004 //#ifndef __LANG_OBJECT_HPP
00005 //#include <java/lang/Object.h>
00006 //#endif
00007 
00008 #define _USE_MATH_DEFINES 
00009 #include <math.h>
00010 #include <float.h>
00011 
00012 #include <vecmath/Export>
00013 
00014 typedef unsigned char byte;
00015 
00016 class Math {
00017 public:
00018     static const double PI;// = M_PI;
00019     static const double MAXDOUBLE;// = DBL_MAX;
00020     static const double MINDOUBLE;// = DBL_MIN;
00021     static const double EPSILON;// = 1.0e-12;
00022 
00023     static byte abs(byte x) {
00024         return abs(x);
00025     }
00026 
00027     static double abs(double x) {
00028         return fabs(x);
00029     }
00030 
00031     static float abs(float x) {
00032         return fabs(x);
00033     }
00034 
00035     static byte abs(int x) {
00036         return abs(x);
00037     }
00038 
00039     template <class  T> static bool epsilonEquals(T f, T g = (T) 0, T e = (T) EPSILON) {
00040         return (f <= g) ? (f >= g - e) : (f <= g + e);
00041     }
00042 
00043     template <class  T> static T max(T x, T y) {
00044         return (x > y) ? x : y;
00045     }
00046 
00047     template <class  T> static T max3(T x[3]) {
00048         return (x[0] > x[1]) ? max(x[0], x[2]) : max(x[1], x[2]);
00049     }
00050 
00051     template <class  T> static T min(T x, T y) {
00052         return (x < y) ? x : y;
00053     }
00054 
00055     template <class  T> static T sqr(T f) {
00056         return f * f;
00057     }
00058 
00059     template <class  T> static void swap(T& x, T& y) {
00060         T t = x;
00061         x = y;
00062         y = t;
00063     }
00064 
00065     static double toDegrees(double angrad) {
00066         return (double) (angrad * (180.0 / PI));
00067     }
00068 
00069     static double toRadians(double angdeg) {
00070         return (double) (angdeg * (PI / 180.0));
00071     }
00072 };
00073 
00074 #endif

Generated on Thu Sep 29 13:39:44 2005 for vecmath by  doxygen 1.4.4