Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OgreMath.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://ogre.sourceforge.net/
00006 
00007 Copyright © 2000-2002 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #ifndef __Math_H__
00026 #define __Math_H__
00027 
00028 #include "OgrePrerequisites.h"
00029 #include "OgreSingleton.h"
00030 
00031 namespace Ogre
00032 {
00043     class _OgreExport Math : public Singleton<Math>
00044     {
00045    public:
00050        enum AngleUnit
00051        {
00052            AU_DEGREE,
00053            AU_RADIAN
00054        };
00055 
00056     protected:
00057        // angle units used by the api
00058        static AngleUnit msAngleUnit;
00059 
00061         static int mTrigTableSize;
00062 
00064         static Real mTrigTableFactor;
00065         static Real* mSinTable;
00066         static Real* mTanTable;
00067 
00070         void buildTrigTables();
00071     public:
00077         Math(unsigned int trigTableSize = 4096);
00078 
00081         ~Math();
00082 
00083         static int IAbs (int iValue);
00084         static int ICeil (float fValue);
00085         static int IFloor (float fValue);
00086         static int ISign (int iValue);
00087 
00088         static Real Abs (Real fValue);
00089         static Real ACos (Real fValue);
00090         static Real ASin (Real fValue);
00091         static Real ATan (Real fValue);
00092         static Real ATan2 (Real fY, Real fX);
00093         static Real Ceil (Real fValue);
00094 
00102         static Real Cos (Real fValue, bool useTables = false);
00103 
00104         static Real Exp (Real fValue);
00105 
00106         static Real Floor (Real fValue);
00107 
00108         static Real Log (Real fValue);
00109 
00110         static Real Pow (Real kBase, Real kExponent);
00111 
00112         static Real Sign (Real fValue);
00113 
00121         static Real Sin (Real fValue, bool useTables = false);
00122 
00123         static Real Sqr (Real fValue);
00124 
00125         static Real Sqrt (Real fValue);
00126 
00130         static Real InvSqrt(Real fValue);
00131 
00132         static Real UnitRandom ();  // in [0,1]
00133 
00134         static Real RangeRandom (Real fLow, Real fHigh);  // in [fLow,fHigh]
00135 
00136         static Real SymmetricRandom ();  // in [-1,1]
00137 
00145         static Real Tan (Real fValue, bool useTables = false);
00146 
00147         static Real DegreesToRadians(Real degrees);
00148         static Real RadiansToDegrees(Real radians);
00149 
00165        static void setAngleUnit(AngleUnit unit);
00167        static AngleUnit getAngleUnit(void);
00168 
00170        static Real AngleUnitsToRadians(Real units);
00172        static Real RadiansToAngleUnits(Real radians);
00173 
00203         static bool pointInTri2D( Real px, Real pz, Real ax, Real az, Real bx, Real bz, Real cx, Real cz );
00204 
00207         static bool RealEqual(Real a, Real b,
00208             Real tolerance = std::numeric_limits<Real>::epsilon());
00209 
00210         static const Real POS_INFINITY;
00211         static const Real NEG_INFINITY;
00212         static const Real PI;
00213         static const Real TWO_PI;
00214         static const Real HALF_PI;
00215 
00231         static Math& getSingleton(void);
00232     };
00233 }
00234 #endif

Copyright © 2002 by The OGRE Team