FMath/FMath.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2005-2006 Feeling Software Inc.
00003     MIT License: http://www.opensource.org/licenses/mit-license.php
00004 */
00005 
00013 #ifndef _F_MATH_H_
00014 #define _F_MATH_H_
00015 
00016 #include <math.h>
00017 #include <algorithm>
00018 
00019 // Includes the improved vector class.
00020 #include "FMath/FMArray.h"
00021 
00022 // Includes the common integer and floating-point definitions and functions.
00023 #include "FMath/FMFloat.h"
00024 #include "FMath/FMInteger.h"
00025 
00031 namespace FMath
00032 {
00033     const double Pi = 3.14159;  
00041     inline double RadToDeg(double val) { return (val * 180.0/Pi); }
00042 
00049     inline float RadToDeg(float val) { return (val * 180.0f/(float)Pi); }
00050 
00057     inline double DegToRad(double val) { return (val * Pi/180.0); }
00058 
00065     inline float DegToRad(float val) { return (val * (float)Pi/180.0f); }
00066 
00073 #ifdef WIN32
00074     inline int IsNotANumber(float f) { return _isnan(f); }
00075 #elif __PPU__
00076     inline int IsNotANumber(float f) { return !isfinite(f); }
00077 #else // Linux and Mac
00078     inline int IsNotANumber(float f) { return !finite(f); }
00079 #endif
00080 
00087     inline double Sign(double val) { return (val >= 0.0) ? 1.0 : -1.0; }
00088 
00095     inline float Sign(float val) { return (val >= 0.0f) ? 1.0f : -1.0f; }
00096 
00103     inline int32 Sign(int32 val) { return (val >= 0) ? 1 : -1; }
00104 
00118     template <class T>
00119     inline T Clamp(T val, T mn, T mx) { return std::max(std::min(val, mx), mn); }
00120 };
00121 
00122 // Include commonly used mathematical classes
00123 #include "FMath/FMVector2.h"
00124 #include "FMath/FMVector3.h"
00125 #include "FMath/FMVector4.h"
00126 #include "FMath/FMColor.h"
00127 #include "FMath/FMMatrix33.h"
00128 #include "FMath/FMMatrix44.h"
00129 
00130 #endif // _F_MATH_H_

Generated on Fri May 12 16:44:39 2006 for FCollada by  doxygen 1.4.6-NO