Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

base.h

00001 /*
00002   File: base.h
00003 
00004   Copyright(C) C. Kotterink, Computed Graphics
00005 */
00006 #ifndef BASE_H
00007 #define BASE_H
00008 
00009 #include<assertion.h>
00010 
00014 namespace Base
00015 {
00016     void init();        
00017 };
00018 
00020 typedef char int8;
00022 typedef short int16;
00024 typedef int int32;
00025 
00027 typedef unsigned char uint8;
00029 typedef unsigned short uint16;
00031 typedef unsigned long uint32;
00032 
00033 STATIC_ASSERT(sizeof(int8) == 1);
00034 STATIC_ASSERT(sizeof(int16) == 2);
00035 STATIC_ASSERT(sizeof(int32) == 4);
00036 
00039 typedef enum
00040 {
00041     BigEndian,          
00042     LittleEndian        
00043 } EndianShip;
00044 
00049 template<typename T>
00050 T abs(T x)
00051 {
00052     return (x < T() ? -x : x);
00053 }
00054 
00058 template<typename T>
00059 T clamp(T x)
00060 {
00061     if (x < 0.0) return 0.0;
00062     else if (x > 1.0) return 1.0;
00063     else return x;
00064 }
00065 
00071 template<typename T>
00072 T round(T x)
00073 {
00074     if (x > 0.0) return (int)(x+.5);
00075     else return -(int)(.5-x);
00076 }
00077 
00078 #endif

This documentation was generated using doxygen. If you have any comments or additions please mail me.