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

base/consts

Go to the documentation of this file.
00001 /****************************************************************************
00002   Copyright (C)2002 David Jung <opensim@pobox.com>
00003 
00004   This program/file is free software; you can redistribute it and/or modify
00005   it under the terms of the GNU General Public License as published by
00006   the Free Software Foundation; either version 2 of the License, or
00007   (at your option) any later version.
00008   
00009   This program is distributed in the hope that it will be useful,
00010   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012   GNU General Public License for more details. (http://www.gnu.org)
00013   
00014   You should have received a copy of the GNU General Public License
00015   along with this program; if not, write to the Free Software
00016   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017   
00018   $Id: consts 1029 2004-02-11 20:45:54Z jungd $
00019   $Revision: 1.2 $
00020   $Date: 2004-02-11 15:45:54 -0500 (Wed, 11 Feb 2004) $
00021   $Author: jungd $
00022  
00023 ****************************************************************************/
00024 
00025 #ifndef _BASE_CONSTS_
00026 #define _BASE_CONSTS_
00027 
00028 #include <base/Object>
00029 
00030 #include <limits>
00031 
00032 // we make a namespace consts and them alias consts to base::consts
00033 //  so that we can write consts::epsilon, which is more readable than
00034 //  base::epsilon
00035 
00036 namespace base {
00037 namespace consts {
00038 
00039   const  Real epsilon = Real(1e-10);  
00040   const  Real epsilon2 = Real(1e-20);
00041   const  Real minReal = Real(1.17549435e-38f);
00042   const  Real maxReal = Real(3.40282347e+38f);
00043   const  SInt minSInt  = (-2147483647-1);
00044   const  SInt maxSInt  = 2147483647;
00045   const  Int  minInt  = 0;
00046   const  Int  maxInt  = 4294967293U;
00047   const  Real Pi = Real(3.1415926535897932384626433832795029L);
00048   const  Real SqrtHalf = Real(0.7071067811865475244008443621048490);
00049   const  Real TwoPi = Real(Pi*2.0);
00050   const  Real Infinity = maxReal;
00051 
00052   // unit conversion
00053   const Real inchesPerMeter = 39.37007874;
00054   const Real metersPerInch = 0.0254;
00055 
00056 } // consts
00057 
00058 
00059 
00060   // NB: Unfortunately, these are identical to functions in Math, just here 
00061   //     as they are used in many inline headers before they can include
00062   //     Math (otherwise they'd have to be not inline and we'd take
00063   //     a performance hit.
00064 
00065   // equals within eps (i.e. true if |r1-r2| < eps)
00066   inline bool equals(const Real r1, const Real r2, Real eps = consts::epsilon)
00067   { return ::fabs(r1-r2) < eps; }
00068 
00069   // absolute value (i.e. |s|)
00070   inline Real abs(Real s) { return ::fabs(s); }
00071 
00072   // squate root (i.e. n^.5)
00073   inline Real sqrt(Real n) { return ::sqrt(n); }
00074 
00075   inline Real sin(Real a) { return ::sin(a); }
00076   inline Real cos(Real a) { return ::cos(a); }
00077 
00078 
00079 } // base
00080 
00081 namespace consts = base::consts;
00082 
00083 #endif

Generated on Thu Jul 29 15:56:04 2004 for OpenSim by doxygen 1.3.6