OdinAI
 All Classes Namespaces Functions Variables
MathUtil.h
1 /*******************************************************************************
2  * ________ .___.__ _____ .___
3  * \_____ \ __| _/|__| ____ / _ \ | |
4  * / | \ / __ | | |/ \ / /_\ \| |
5  * / | \/ /_/ | | | | \/ | \ |
6  * \_______ /\____ | |__|___| /\____|__ /___|
7  * \/ \/ \/ \/
8  *
9  * THIS FILE IS PREGENERATED BY CMAKE!
10  *
11  * Copyright (c) Emil Sandst� 2012
12  *******************************************************************************/
13 #ifndef ODINAI_MATH_UTIL_H_
14 #define ODINAI_MATH_UTIL_H_
15 
16 #ifdef _WINDOWS
17 #undef max
18 #pragma once
19 #endif
20 
21 #include <cmath>
22 #include <limits>
23 
24 namespace OdinAI
25 {
26  typedef unsigned int uint;
27  typedef unsigned short ushort;
28  typedef unsigned char byte;
29 
30  const double kDoubleEpsilon = std::numeric_limits<double>::epsilon();
31  const double kMaxDouble = std::numeric_limits<double>::max();
32  const int kMaxInt = std::numeric_limits<int>::max();
33  const double kPI = 3.1415926536;
34 
39  inline bool IsEqual(double a, double b)
40  {
41  return std::abs(a - b) < kDoubleEpsilon;
42  }
43 
47  inline int DoubleInt(int a)
48  {
49  return a << 1;
50  }
51 
52  inline int DoubleToIntRound(double value)
53  {
54  return int(value > 0.0 ? floor(value + 0.5) : ceil(value - 0.5));
55  }
56 }
57 #endif
int DoubleInt(int a)
Definition: MathUtil.h:47
bool IsEqual(double a, double b)
Definition: MathUtil.h:39