/****************************************************************************************


		MCBasicDefines.h

		Copyright: (c) 2001 Eovia Corp. All rights reserved.

		Author:	Ian
		Date:	12/13/97

		Revision History

		when		who			what & why
		==========	==========	======================================================
		12/10/98	dsm			removed warning

*****************************************************************************************/

#ifndef __MCBasicDefines__		 
#define __MCBasicDefines__

#ifndef NULL
#define NULL 0
#endif

#ifndef nil
#define nil  0
#endif

#define ReturnIfNULL(e) if((e) == NULL) return; \
						else 0;
#define ReturnIfNil(e) if((e) == nil) return; \
						else 0;
						
//Since gcc's float to int conversion warnings cannot be turned off,
//the following macros help do the job with maximum type checking.
#if __GNUC__
	#define STATIC_CAST(varOfType, varToCast)	static_cast< typeof(varOfType) > (varToCast)
	#define ASSIGN_CAST(var, value)				var= static_cast< typeof(var) > (value)
#else
	#define STATIC_CAST(varOfType, varToCast)	(varToCast)
	#define ASSIGN_CAST(var, value)				var= (value)
#endif

						

/*---  Math related ---*/

#define FOUR_PI   		12.5663706143592          	/* PI * 4		*/   
#define TWO_PI   		6.28318530717959          	/* PI * 2		*/                                                                              
#define	PI				3.14159265358979323846		/* PI			*/
#define	PI2				1.57079632679489661923		/* PI / 2		*/
#define	PI4				0.78539816339744830966		/* PI / 4		*/

#define	EXP				2.71828182845904523536

#define SQRT2 			1.41421356237309504880		/* sqrt(2.0)	*/
#define INV_SQRT2		0.70710678118654752440		/* 1.0/sqrt(2.0)*/

#define DEG_RAD   		0.0174532925199433			/* (2*PI) / 360	*/
#define RAD_DEG   		57.2957795130823			/* 360 / (2*PI)	*/

/* See <float.h> for floating-point constants FLT_MIN, FLT_MAX, etc. */

#define kUINT8_MIN		0							/* 0x00			*/
#define kUINT8_MAX		255							/* 0xFF			*/
#define kINT8_MIN		-128						/* 0x80			*/
#define kINT8_MAX		127							/* 0x7F			*/

#define kUINT16_MIN		0							/* 0x0000		*/
#define kUINT16_MAX		65535						/* 0xFFFF		*/
#define kINT16_MIN		-32768						/* 0x8000		*/
#define kINT16_MAX		32767						/* 0x7FFF		*/

#define kUINT32_MIN		0							/* 0x00000000	*/
#define kUINT32_MAX		0xFFFFFFFF					/* 0xFFFFFFFF	*/
#define kINT32_MAX		2147483647					/* 0x7FFFFFFF	*/
#define kINT32_MIN		(-kINT32_MAX-1)					/* 0x80000000	*/


//The following 3 defines, enable to write
//#pragma __MESSAGE__("compile warning")
//which will show the warning message in the output window with the file name and line number
//In visual, double click on the output to go to the file.
#define __STR1__(x)  #x
#define __STR2__(x) __STR1__(x)
#define __MESSAGE__(x) message (__FILE__ "(" __STR2__(__LINE__) ") : " #x)


#endif