TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
Basic.h
Go to the documentation of this file.
1/*
2 3D - C++ Class Library for 3D Transformations
3 Copyright (C) 1996-1998 Gino van den Bergen
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 Please send remarks, questions and bug reports to gino@win.tue.nl,
20 or write to:
21 Gino van den Bergen
22 Department of Mathematics and Computing Science
23 Eindhoven University of Technology
24 P.O. Box 513, 5600 MB Eindhoven, The Netherlands
25*/
26
27#ifndef _BASIC_H_
28#define _BASIC_H_
29
30#include <math.h>
31#include <stdlib.h>
32
33/* typedef double Scalar; */
34#define Scalar double
35
36const Scalar DEGS_PER_RAD = 57.29577951308232286465;
37const Scalar RADS_PER_DEG = 0.01745329251994329547;
38const Scalar TWO_PI = 6.28318530717958623200;
39const Scalar EPSILON = 1.0e-10;
40const Scalar EPSILON2 = 1.0e-20;
41const Scalar INFINITY_ = 1.0e50;
42
43
44/* inline Scalar abs(Scalar x) { return x < 0 ? -x : x; } */
45inline Scalar rnd() { return (Scalar(rand()) + 0.5) / (Scalar(RAND_MAX) + 1); }
46inline int sgn(Scalar x) { return x < 0 ? -1 : x > 0 ? 1 : 0; }
47inline bool eqz(Scalar x) { return fabs(x) <= EPSILON; }
48
49inline Scalar min(Scalar x, Scalar y) { return x > y ? y : x; }
50inline Scalar max(Scalar x, Scalar y) { return x < y ? y : x; }
51
52inline void set_min(Scalar& x, Scalar y) { if (x > y) x = y; }
53inline void set_max(Scalar& x, Scalar y) { if (x < y) x = y; }
54
55inline Scalar rads(Scalar x) { return x * RADS_PER_DEG; }
56inline Scalar degs(Scalar x) { return x * DEGS_PER_RAD; }
57
58enum { X = 0, Y = 1, Z = 2, W = 3 };
59
60#endif
Scalar rnd()
Definition Basic.h:45
Scalar min(Scalar x, Scalar y)
Definition Basic.h:49
const Scalar EPSILON2
Definition Basic.h:40
const Scalar INFINITY_
Definition Basic.h:41
@ Y
Definition Basic.h:58
@ X
Definition Basic.h:58
@ Z
Definition Basic.h:58
@ W
Definition Basic.h:58
int sgn(Scalar x)
Definition Basic.h:46
Scalar degs(Scalar x)
Definition Basic.h:56
const Scalar TWO_PI
Definition Basic.h:38
Scalar max(Scalar x, Scalar y)
Definition Basic.h:50
const Scalar EPSILON
Definition Basic.h:39
bool eqz(Scalar x)
Definition Basic.h:47
const Scalar DEGS_PER_RAD
Definition Basic.h:36
#define Scalar
Definition Basic.h:34
void set_max(Scalar &x, Scalar y)
Definition Basic.h:53
void set_min(Scalar &x, Scalar y)
Definition Basic.h:52
Scalar rads(Scalar x)
Definition Basic.h:55
const Scalar RADS_PER_DEG
Definition Basic.h:37
static Vector y[4]
Definition Convex.cpp:56