otbMath.h 3.46 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
/*=========================================================================

  Program:   ORFEO Toolbox
  Language:  C++
  Date:      $Date$
  Version:   $Revision$


  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
  See OTBCopyright.txt for details.


13
14
     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
16
17
18
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/

19
20
#ifndef __otbMath_h
#define __otbMath_h
21
22
23
24

/**
 * otbMath.h defines standard math macros, constants, and other
 * parameters.
25
 * All mathematics constans, functions (used in the OTB code) are the vcl version (vcl..., CONST_PI, ).
26
 */
27

28
29
30
#include "vcl_cmath.h"

namespace otb{
31

32
// For Windows MSVC, defines these macros.
33
34
#ifdef _USE_MATH_DEFINES
#define _MATH_DEFINES_DEFINED
35
36
37
#endif


Julien Michel's avatar
Julien Michel committed
38
/** Define constants if not define in the "vcl_cmath.h" */
39
40

/* Some useful constants.  */
41
42
43
44
45
46
47
48
const double CONST_E =        2.7182818284590452354;   /* e */
const double CONST_LOG2E =    1.4426950408889634074;   /* log_2 e */
const double CONST_LOG10E =   0.43429448190325182765;  /* log_10 e */
const double CONST_LN2 =      0.69314718055994530942;  /* log_e 2 */
const double CONST_LN10 =     2.30258509299404568402;  /* log_e 10 */
const double CONST_PI =       3.14159265358979323846;  /* pi */
const double CONST_PI_2 =     1.57079632679489661923;  /* pi/2 */
const double CONST_PI_4 =     0.78539816339744830962;  /* pi/4 */
Cyrille Valladeau's avatar
Cyrille Valladeau committed
49
const double CONST_PI_8 =     0.39269908169872415481;  /* pi/8 */
50
51
const double CONST_1_PI =     0.31830988618379067154;  /* 1/pi */
const double CONST_2_PI =     0.63661977236758134308;  /* 2/pi */
Cyrille Valladeau's avatar
Cyrille Valladeau committed
52
53
const double CONST_2PI =      6.28318530717958647693;  /* 2*pi */
const double CONST_PI_180 =   0.01745329251994329577;  /* pi/180 */ 
Cyrille Valladeau's avatar
Cyrille Valladeau committed
54
const double CONST_180_PI =   57.2957795130823208768;  /* 180/pi */ 
55
56
57
const double CONST_2_SQRTPI = 1.12837916709551257390;  /* 2/sqrt(pi) */
const double CONST_SQRT2 =    1.41421356237309504880;  /* sqrt(2) */
const double CONST_SQRT1_2 =  0.70710678118654752440;  /* 1/sqrt(2) */
58
59
60
61
62

/* The above constants are not adequate for computation using `long double's.
   Therefore we provide as an extension constants with similar names as a
   GNU extension.  Provide enough digits for the 128-bit IEEE quad.  */
#ifdef __USE_GNU
63

64
65
66
67
68
69
70
71
72
73
74
75
76
const double CONST_El =        2.7182818284590452353602874713526625L;  /* e */
const double CONST_LOG2El =    1.4426950408889634073599246810018921L;  /* log_2 e */
const double CONST_LOG10El =   0.4342944819032518276511289189166051L;  /* log_10 e */
const double CONST_LN2l =      0.6931471805599453094172321214581766L;  /* log_e 2 */
const double CONST_LN10l =     2.3025850929940456840179914546843642L;  /* log_e 10 */
const double CONST_PIl =       3.1415926535897932384626433832795029L;  /* pi */
const double CONST_PI_2l =     1.5707963267948966192313216916397514L;  /* pi/2 */
const double CONST_PI_4l =     0.7853981633974483096156608458198757L;  /* pi/4 */
const double CONST_1_PIl =     0.3183098861837906715377675267450287L;  /* 1/pi */
const double CONST_2_PIl =     0.6366197723675813430755350534900574L;  /* 2/pi */
const double CONST_2_SQRTPIl = 1.1283791670955125738961589031215452L;  /* 2/sqrt(pi) */
const double CONST_SQRT2l =    1.4142135623730950488016887242096981L;  /* sqrt(2) */
const double CONST_SQRT1_2l =  0.7071067811865475244008443621048490L;  /* 1/sqrt(2) */
77
78
79

#endif

80
}
81
82

#endif