www.pudn.com > cad3d.zip > MathDefs.h


#ifndef __MATH_DEFS_H 
#define __MATH_DEFS_H 
 
#include  
#include "defs.h" 
 
//trigonometric defines 
#ifndef M_PI 
#define M_PI			3.14159265359 
#endif 
 
#ifndef M_2_PI 
#define M_2_PI			(2*M_PI) 
#endif 
 
#ifndef M_PI_2 
#define M_PI_2			(M_PI/2) 
#endif 
 
#ifndef M_PI_3 
#define M_PI_3			(M_PI/3) 
#endif 
 
#ifndef M_PI_4 
#define M_PI_4			(M_PI/4) 
#endif 
 
#ifndef M_PI_6 
#define M_PI_6			(M_PI/6) 
#endif 
 
#define DEG_TO_RAD		(M_PI/180) 
#define RAD_TO_DEG		(180/M_PI) 
 
//geometric defines 
#define M_X				0 		 
#define M_Y				1 
#define M_Z				2 
#define M_W				3 
 
//numerical defines 
#ifdef SINGLE_PRECISION 
	#define EPS				1e-5f 
#else //DOUBLE_PRECISION 
	#define EPS				1e-10 
#endif 
 
template  
inline bool IsZero(const _T& a)  
{ 
	return (fabs(a) < EPS); 
} 
 
template  
inline bool IsEq(const _T1& a, const _T2& b) 
{ 
	return IsZero(a-b); 
} 
 
template  
inline bool IsGt(const _T1& a, const _T2& b) 
{ 
	return (a > b) && !IsEq(a,b); 
} 
 
template  
inline bool IsGe(const _T1& a, const _T2& b) 
{ 
	return (a > b) || IsEq(a,b); 
} 
 
template  
inline bool IsLt(const _T1& a, const _T2& b) 
{ 
	return (a < b) && !IsEq(a,b); 
} 
 
template  
inline bool IsLe(const _T1& a, const _T2& b) 
{ 
	return (a < b) || IsEq(a,b); 
} 
 
#endif