Open Broadcaster Software
Free, open source software for live streaming and recording
math-defs.h
Go to the documentation of this file.
1 /******************************************************************************
2  Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.com>
3 
4  This program is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16 ******************************************************************************/
17 
18 #pragma once
19 
20 #include "../util/c99defs.h"
21 #include <math.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #ifndef M_PI
28 #define M_PI 3.1415926535897932384626433832795f
29 #endif
30 
31 #define RAD(val) ((val)*0.0174532925199432957692369076848f)
32 #define DEG(val) ((val)*57.295779513082320876798154814105f)
33 #define LARGE_EPSILON 1e-2f
34 #define EPSILON 1e-4f
35 #define TINY_EPSILON 1e-5f
36 #define M_INFINITE 3.4e38f
37 
38 static inline bool close_float(float f1, float f2, float precision)
39 {
40  return fabsf(f1 - f2) <= precision;
41 }
42 
43 #ifdef __cplusplus
44 }
45 #endif