]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/include/mathdefs.h
177bd74cf72670fef1dfde47dd3fc86f49bf04f9
[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. // Useless now // JPR
43 /*
44 typedef unsigned char  uchar;
45 typedef unsigned short ushort;
46 typedef unsigned int   uint;
47 */
48
49 namespace gtm
50 {
51     /** Rounds a double number.
52      *
53      *  @param n Number.
54      */
55     inline
56     double round( double n )
57     {
58         double tmp;
59         tmp = floor( n );
60         if ( ( n - tmp ) < 0.5 )
61             return( tmp );
62         else
63             return( ceil( n ) );
64     }
65 }
66
67 #endif // GTMLIB__MATH__MATHDEFS__HXX
68
69 // EOF - mathdefs.h