Oolite
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#pragma once
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36#ifdef __OBJC__
37#import <Foundation/Foundation.h>
38#endif
39
41#include "OOOpenGL.h"
42#include <assert.h>
43#include <limits.h>
44#include <stdbool.h>
45#include <stdint.h>
46#include <stdlib.h>
47#include <tgmath.h>
48
49typedef GLfloat OOScalar;
50
51typedef double OOHPScalar;
52
53#ifndef M_PI
54#define M_PI 3.14159265358979323846 /* pi */
55#endif
56#ifndef M_PI_2
57#define M_PI_2 1.57079632679489661923 /* pi/2 */
58#endif
59#ifndef M_PI_4
60#define M_PI_4 0.78539816339744830962 /* pi/4 */
61#endif
62#ifndef M_1_PI
63#define M_1_PI 0.31830988618379067154 /* 1/pi */
64#endif
65#ifndef M_2_PI
66#define M_2_PI 0.63661977236758134308 /* 2/pi */
67#endif
68#ifndef M_2_SQRTPI
69#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
70#endif
71#ifndef M_SQRT2
72#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
73#endif
74#ifndef M_SQRT1_2
75#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
76#endif
77
78#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
79#ifndef MIN
80#define MIN(A, B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __a : __b; })
81#endif
82#if !defined(MAX)
83#define MAX(A, B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
84#endif
85#if !defined(ABS)
86#define ABS(A) ({ __typeof__(A) __a = (A); __a < 0 ? -__a : __a; })
87#endif
88#else
89/* These definitions are unsafe in that the "winning" expression is evaluated twice. */
90#if !defined(MIN)
91#define MIN(A, B) ((A) < (B) ? (A) : (B))
92#endif
93#if !defined(MAX)
94#define MAX(A, B) ((A) > (B) ? (A) : (B))
95#endif
96#if !defined(ABS)
97#define ABS(A) ((A) < 0 ? (-(A)) : (A))
98#endif
99#endif
100
101#include "OOBoundingBox.h"
102#include "OOHPVector.h"
103#include "OOMatrix.h"
104#include "OOTriangle.h"
105#include "OOVoxel.h"
106#include "legacy_random.h"
107
108#ifdef __cplusplus
109}
110#endif
double OOHPScalar
Definition OOMaths.h:51
GLfloat OOScalar
Definition OOMaths.h:49