latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 00003 * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany 00004 * 00005 * This file is part of the LTI-Computer Vision Library (LTI-Lib) 00006 * 00007 * The LTI-Lib is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public License (LGPL) 00009 * as published by the Free Software Foundation; either version 2.1 of 00010 * the License, or (at your option) any later version. 00011 * 00012 * The LTI-Lib is distributed in the hope that it will be 00013 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 00014 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with the LTI-Lib; see the file LICENSE. If 00019 * not, write to the Free Software Foundation, Inc., 59 Temple Place - 00020 * Suite 330, Boston, MA 02111-1307, USA. 00021 */ 00022 00023 00024 /*---------------------------------------------------------------- 00025 * project ....: LTI Digital Image/Signal Processing Library 00026 * file .......: ltiConstants.h 00027 * authors ....: Pablo Alvarado 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 16.05.01 00030 * revisions ..: $Id: ltiConstants.h,v 1.8 2006/02/08 12:14:46 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_CONSTANTS_H_ 00034 #define _LTI_CONSTANTS_H_ 00035 00036 #include "ltiObject.h" 00037 #include "ltiTypes.h" 00038 00039 /** 00040 * \file ltiConstants.h 00041 * Definition of a template class containing usual mathematical and 00042 * physical constants. 00043 */ 00044 00045 namespace lti { 00046 00047 /** 00048 * This class is a container of some mathematical and physical constants. 00049 * 00050 * Example: 00051 * \code 00052 * constants<float>::Pi 00053 * \endcode 00054 */ 00055 template<class T> 00056 class constants : public object { 00057 public: 00058 /** 00059 * Pi 00060 */ 00061 static inline T Pi() throw() { 00062 return static_cast<T>(3.1415926535897932384626433832795); 00063 }; 00064 00065 /** 00066 * Twice Pi (2*Pi) 00067 */ 00068 static inline T TwoPi() throw() { 00069 return static_cast<T>(3.1415926535897932384626433832795*2.0); 00070 }; 00071 00072 /** 00073 * Half Pi (Pi/2) 00074 */ 00075 static inline T HalfPi() throw() { 00076 return static_cast<T>(3.1415926535897932384626433832795/2.0); 00077 }; 00078 00079 /** 00080 * e (basis of natural logarithm) = 2.7182818284590452353602874713526... 00081 */ 00082 static inline T e() throw() { 00083 return static_cast<T>(2.7182818284590452353602874713526); 00084 // continuing with ... 62497757247093699959574966967627724076630353547594571382178525166427427466391932003059921817413596629043572900334295260 00085 // more at http://sources.wikipedia.org/wiki/E_to_10%2C000_places 00086 }; 00087 00088 /** 00089 * square root of 2 = 1.4142135623730950488016887242097... 00090 */ 00091 static inline T sqrt2() throw() { 00092 return static_cast<T>(1.4142135623730950488016887242097); 00093 }; 00094 00095 protected: 00096 /** 00097 * Protected constructor avoids the creation of 00098 * an instance of this class. 00099 */ 00100 constants() {}; 00101 }; 00102 } 00103 00104 00105 #endif