Oolite 1.91.0.7604-240417-a536cbe
Loading...
Searching...
No Matches
OOMaths.h
Go to the documentation of this file.
1/*
2
3OOMaths.h
4
5Mathematical framework for Oolite.
6
7Provides utility routines for Vectors, Quaternions, rotation matrices, and
8conversion to OpenGL transformation matrices.
9
10Oolite
11Copyright (C) 2004-2013 Giles C Williams and contributors
12
13This program is free software; you can redistribute it and/or
14modify it under the terms of the GNU General Public License
15as published by the Free Software Foundation; either version 2
16of the License, or (at your option) any later version.
17
18This program is distributed in the hope that it will be useful,
19but WITHOUT ANY WARRANTY; without even the implied warranty of
20MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21GNU General Public License for more details.
22
23You should have received a copy of the GNU General Public License
24along with this program; if not, write to the Free Software
25Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26MA 02110-1301, USA.
27
28*/
29
30
31#ifndef INCLUDED_OOMATHS_h
32#define INCLUDED_OOMATHS_h
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38#ifndef OOMATHS_STANDALONE
39#define OOMATHS_STANDALONE 0
40#endif
41
42#ifndef OOMATHS_OPENGL_INTEGRATION
43#define OOMATHS_OPENGL_INTEGRATION !OOMATHS_STANDALONE
44#endif
45
46#ifdef __OBJC__
47#import <Foundation/Foundation.h>
48#endif
49
51#include <tgmath.h>
52#include <stdbool.h>
53#include <stdlib.h>
54#include <stdint.h>
55#include <limits.h>
56#include <assert.h>
57
58#if OOMATHS_OPENGL_INTEGRATION
59#include "OOOpenGL.h"
60#endif
61
62
63#if OOMATHS_OPENGL_INTEGRATION
64typedef GLfloat OOScalar;
65#else
66typedef float OOScalar;
67#endif
68
69typedef double OOHPScalar;
70
71
72#ifndef M_PI
73 #define M_PI 3.14159265358979323846 /* pi */
74#endif
75#ifndef M_PI_2
76 #define M_PI_2 1.57079632679489661923 /* pi/2 */
77#endif
78#ifndef M_PI_4
79 #define M_PI_4 0.78539816339744830962 /* pi/4 */
80#endif
81#ifndef M_1_PI
82 #define M_1_PI 0.31830988618379067154 /* 1/pi */
83#endif
84#ifndef M_2_PI
85 #define M_2_PI 0.63661977236758134308 /* 2/pi */
86#endif
87#ifndef M_2_SQRTPI
88 #define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
89#endif
90#ifndef M_SQRT2
91 #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
92#endif
93#ifndef M_SQRT1_2
94 #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
95#endif
96
97
98#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
99 #ifndef MIN
100 #define MIN(A,B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __a : __b; })
101 #endif
102 #if !defined(MAX)
103 #define MAX(A,B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
104 #endif
105 #if !defined(ABS)
106 #define ABS(A) ({ __typeof__(A) __a = (A); __a < 0 ? -__a : __a; })
107 #endif
108#else
109 /* These definitions are unsafe in that the "winning" expression is evaluated twice. */
110 #if !defined(MIN)
111 #define MIN(A,B) ((A) < (B) ? (A) : (B))
112 #endif
113 #if !defined(MAX)
114 #define MAX(A,B) ((A) > (B) ? (A) : (B))
115 #endif
116 #if !defined(ABS)
117 #define ABS(A) ((A) < 0 ? (-(A)) : (A))
118 #endif
119#endif
120
121
122#include "OOFastArithmetic.h"
123#include "OOVector.h"
124#include "OOHPVector.h"
125#include "OOQuaternion.h"
126#include "OOMatrix.h"
127
128#if !OOMATHS_STANDALONE
129#include "OOVoxel.h"
130#include "OOTriangle.h"
131#include "OOBoundingBox.h"
132
133#include "legacy_random.h"
134#endif
135
136
137#ifdef __cplusplus
138}
139#endif
140
141#endif /* INCLUDED_OOMATHS_h */
double OOHPScalar
Definition OOMaths.h:69
GLfloat OOScalar
Definition OOMaths.h:64