]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/include/mathdefs.h
creaMaracasVisu Library
[creaMaracasVisu.git] / lib / maracasVisuLib / include / mathdefs.h
1 ////////////////////////////////////////////////////////////////////////////////
2 // matrix.h
3 // Creation : 20/01/2000
4 // Author   : Leonardo FLOREZ VALENCIA
5 //               l-florez@uniandes.edu.co
6 //               lflorez@creatis.insa-lyon.fr
7 // Copyright (C) 2000-2002 Leonardo FLOREZ VALENCIA
8 //
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License
11 // as published by the Free Software Foundation; either version 2
12 // of the License, or (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 ////////////////////////////////////////////////////////////////////////////////
23
24 #ifndef GTMLIB__MATH__MATHDEFS__HXX
25 #define GTMLIB__MATH__MATHDEFS__HXX
26
27 #include <math.h>
28
29 /// PI constant.
30 #define GTM_PI  3.14159265359
31 /// 2 * PI constant.
32 #define GTM_PI2 6.28318530717
33 /// ln1 constant.
34 #define GTM_NE  2.71828182846
35
36 /// Minimum.
37 #define GTM_MIN( a, b ) ( ( ( a ) < ( b ) )? ( a ): ( b ) )
38 /// Maximum.
39 #define GTM_MAX( a, b ) ( ( ( a ) > ( b ) )? ( a ): ( b ) )
40 #define GTM_POW2( a ) ( ( a ) * ( a ) )
41
42 // Useful typedefs.
43 typedef unsigned char  uchar;
44 typedef unsigned short ushort;
45 typedef unsigned int   uint;
46
47 namespace gtm
48 {
49
50     /** Rounds a double number.
51      *
52      *  @param n Number.
53      */
54     inline
55     double round( double n )
56     {
57         double tmp;
58         tmp = floor( n );
59         if ( ( n - tmp ) < 0.5 )
60             return( tmp );
61         else
62             return( ceil( n ) );
63
64     }
65
66 }
67
68 #endif // GTMLIB__MATH__MATHDEFS__HXX
69
70 // EOF - mathdefs.h