Main Page -
Class Hierarchy -
Class List -
File List -
Class Members -
Related Pages -

Information | Reference | SourceForge Project | Author
Muli3D

Reference: Muli3D: m3dmath_common.h Source File

m3dmath_common.h

Go to the documentation of this file.
00001 /* 00002 Muli3D - a software rendering library 00003 Copyright (C) 2004, 2005 Stephan Reiter <streiter@aon.at> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 */ 00019 00022 00023 #ifndef __M3DMATH_COMMON_H__ 00024 #define __M3DMATH_COMMON_H__ 00025 00026 #include "../m3dbase.h" 00027 #include <float.h> 00028 #include <math.h> 00029 00030 #define M3D_PI 3.141592654f 00031 00035 inline float32 fRadToDeg( const float32 i_fVal ) 00036 { 00037 return 180.0f * i_fVal / M3D_PI; 00038 } 00039 00043 inline float32 fDegToRad( const float32 i_fVal ) 00044 { 00045 return M3D_PI * i_fVal / 180.0f; 00046 } 00047 00053 inline float32 fClamp( const float32 i_fVal, const float32 i_fLower, 00054 const float32 i_fUpper ) 00055 { 00056 if( i_fVal <= i_fLower ) return i_fLower; 00057 else if( i_fVal >= i_fUpper ) return i_fUpper; 00058 else return i_fVal; 00059 } 00060 00066 inline int32 iClamp( const int32 i_iVal, const int32 i_iLower, 00067 const int32 i_iUpper ) 00068 { 00069 if( i_iVal <= i_iLower ) return i_iLower; 00070 else if( i_iVal >= i_iUpper ) return i_iUpper; 00071 else return i_iVal; 00072 } 00073 00077 inline float32 fSaturate( const float32 i_fVal ) 00078 { 00079 return fClamp( i_fVal, 0.0f, 1.0f ); 00080 } 00081 00087 inline float32 fLerp( const float32 i_fValA, const float32 i_fValB, 00088 const float32 i_fInterpolation ) 00089 { 00090 return i_fValA + ( i_fValB - i_fValA ) * i_fInterpolation; 00091 } 00092 00093 #endif // __M3DMATH_COMMON_H__

Documentation created with doxygen SourceForge.net Logo