]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/include/mathdefs.h
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / lib / maracasVisuLib / include / mathdefs.h
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 ////////////////////////////////////////////////////////////////////////////////
27 // matrix.h
28 // Creation : 20/01/2000
29 // Author   : Leonardo FLOREZ VALENCIA
30 //               l-florez@uniandes.edu.co
31 //               lflorez@creatis.insa-lyon.fr
32 // Copyright (C) 2000-2002 Leonardo FLOREZ VALENCIA
33 //
34 // This program is free software; you can redistribute it and/or
35 // modify it under the terms of the GNU General Public License
36 // as published by the Free Software Foundation; either version 2
37 // of the License, or (at your option) any later version.
38 //
39 // This program is distributed in the hope that it will be useful,
40 // but WITHOUT ANY WARRANTY; without even the implied warranty of
41 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
42 // GNU General Public License for more details.
43 //
44 // You should have received a copy of the GNU General Public License
45 // along with this program; if not, write to the Free Software
46 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
47 ////////////////////////////////////////////////////////////////////////////////
48
49 #ifndef GTMLIB__MATH__MATHDEFS__HXX
50 #define GTMLIB__MATH__MATHDEFS__HXX
51
52 #include <math.h>
53
54 /// PI constant.
55 #define GTM_PI  3.14159265359
56 /// 2 * PI constant.
57 #define GTM_PI2 6.28318530717
58 /// ln1 constant.
59 #define GTM_NE  2.71828182846
60
61 /// Minimum.
62 #define GTM_MIN( a, b ) ( ( ( a ) < ( b ) )? ( a ): ( b ) )
63 /// Maximum.
64 #define GTM_MAX( a, b ) ( ( ( a ) > ( b ) )? ( a ): ( b ) )
65 #define GTM_POW2( a ) ( ( a ) * ( a ) )
66
67 // Useful typedefs. // Useless now // JPR
68 /*
69 typedef unsigned char  uchar;
70 typedef unsigned short ushort;
71 typedef unsigned int   uint;
72 */
73
74 namespace gtm
75 {
76     /** Rounds a double number.
77      *
78      *  @param n Number.
79      */
80     inline
81     double round( double n )
82     {
83         double tmp;
84         tmp = floor( n );
85         if ( ( n - tmp ) < 0.5 )
86             return( tmp );
87         else
88             return( ceil( n ) );
89     }
90 }
91
92 #endif // GTMLIB__MATH__MATHDEFS__HXX
93
94 // EOF - mathdefs.h