![]() |
torcs - 1.2.2 | ![]() |
00001 /* 00002 3D - C++ Class Library for 3D Transformations 00003 Copyright (C) 1996-1998 Gino van den Bergen 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 00019 Please send remarks, questions and bug reports to gino@win.tue.nl, 00020 or write to: 00021 Gino van den Bergen 00022 Department of Mathematics and Computing Science 00023 Eindhoven University of Technology 00024 P.O. Box 513, 5600 MB Eindhoven, The Netherlands 00025 */ 00026 00027 #ifndef _BASIC_H_ 00028 #define _BASIC_H_ 00029 00030 #include <math.h> 00031 #include <stdlib.h> 00032 00033 /* typedef double Scalar; */ 00034 #define Scalar double 00035 00036 const Scalar DEGS_PER_RAD = 57.29577951308232286465; 00037 const Scalar RADS_PER_DEG = 0.01745329251994329547; 00038 const Scalar TWO_PI = 6.28318530717958623200; 00039 const Scalar EPSILON = 1.0e-10; 00040 const Scalar EPSILON2 = 1.0e-20; 00041 const Scalar INFINITY_ = 1.0e50; 00042 00043 00044 /* inline Scalar abs(Scalar x) { return x < 0 ? -x : x; } */ 00045 inline Scalar rnd() { return (Scalar(rand()) + 0.5) / (Scalar(RAND_MAX) + 1); } 00046 inline int sgn(Scalar x) { return x < 0 ? -1 : x > 0 ? 1 : 0; } 00047 inline bool eqz(Scalar x) { return fabs(x) <= EPSILON; } 00048 00049 inline Scalar min(Scalar x, Scalar y) { return x > y ? y : x; } 00050 inline Scalar max(Scalar x, Scalar y) { return x < y ? y : x; } 00051 00052 inline void set_min(Scalar& x, Scalar y) { if (x > y) x = y; } 00053 inline void set_max(Scalar& x, Scalar y) { if (x < y) x = y; } 00054 00055 inline Scalar rads(Scalar x) { return x * RADS_PER_DEG; } 00056 inline Scalar degs(Scalar x) { return x * DEGS_PER_RAD; } 00057 00058 enum { X = 0, Y = 1, Z = 2, W = 3 }; 00059 00060 #endif