Main Page | Class Hierarchy | Class List | File List | Class Members

types.h

00001 /* ************************************************************************* 00002 types.h - description 00003 ------------------- 00004 begin : Wed Oct 16 2002 00005 copyright : (C) 2002 by Micha Riser 00006 email : mriser@gmx.net 00007 ************************************************************************* */ 00008 00009 /* ************************************************************************* 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ************************************************************************* */ 00017 00018 #ifndef TYPES_H 00019 #define TYPES_H 00020 00021 #if defined(__GNUC__) && (__GNUC__ < 3) 00022 00023 // gcc 2.95 does not have limits 00024 // gcc handles access from inner classes to private attributes wrong 00025 #define WRONG_INNER_CLASSES_ACCESS 00026 // gcc 2.95 hast no limits include file 00027 00028 #else 00029 00030 #define HAS_LIMITS 00031 00032 #endif 00033 00034 00035 #ifdef HAS_LIMITS 00036 #include<limits> 00037 #endif 00038 00039 #include <algorithm> 00040 00041 /* ************************************************************ 00042 * Type definitions 00043 ************************************************************ */ 00044 00048 typedef double DBL; 00049 00051 typedef float FLT; 00052 00054 typedef float CLR; 00055 00056 00058 typedef unsigned short int CNT8; 00059 00061 typedef unsigned int CNT; 00062 00066 typedef unsigned int CNTREF; 00067 00068 00069 /* ************************************************************ 00070 * Global constants 00071 ************************************************************ */ 00072 00073 static const DBL PI = 3.1415926535897932384626; 00074 00075 #ifdef HAS_LIMITS 00076 static const DBL DBL_INFINITY = std::numeric_limits<DBL>::max(); 00077 #else 00078 static const DBL DBL_INFINITY = 1.79769e308; 00079 #endif 00080 00081 static const DBL DIRECTION_EPSILON = 1e-10; 00082 00083 static const DBL INTERSECTION_INFINIT_TIME = DBL_INFINITY; 00084 static const DBL INTERSECTION_TIME_EPSILON = 1e-6; 00085 00086 class Scene; 00087 extern Scene* globalscene; //tmp 00088 00089 /* **************************************************************** 00090 * Global functions 00091 **************************************************************** */ 00092 00093 inline FLT rad2deg(FLT angle) {return angle * (180.0/PI);} // this will probably be converted to DBL for the calculation... cast the constant to float? 00094 inline DBL rad2deg(DBL angle) {return angle * (180.0/PI);} 00095 00096 inline FLT deg2rad(FLT angle) {return angle * (PI/180.0);} // this will probably be converted to DBL for the calculation... cast the constant to float? 00097 inline DBL deg2rad(DBL angle) {return angle * (PI/180.0);} 00098 00099 template<class T> static T sqr(T a) {return a*a;} 00100 template<class T> static T pow3(T a) {return a*a*a;} 00101 template<class T> static T pow4(T a) {return a*a*a*a;} 00102 template<class T> static T pow5(T a) {return a*a*a*a*a;} 00103 00104 template<class T> static T clip01(T a) {return std::max(std::min((T)1,a),(T)0);} 00105 00106 /*inline DBL sqr(DBL a) {return a*a;} 00107 inline FLT sqr(FLT a) {return a*a;} 00108 00109 inline DBL pow3(DBL a) {return a*a*a;} 00110 inline FLT pow3(FLT a) {return a*a*a;}*/ 00111 00112 #endif

Generated on Thu Jan 27 12:16:06 2005 for raytracer.kdevelop by doxygen 1.3.8