1
0
forked from 0ad/0ad
0ad/source/maths/MathUtil.h
Ykkrosh 8a11f53011 # More consistent terrain-space coordinate names
# Removed more ancient unused code
# Partial VC2005 compatibility for Atlas editor / AoE3Ed
# Terrain overlay rendering system; used to implemented Atlas brush
display
# Renamed 'right' to 'left'

This was SVN commit r3771.
2006-04-17 20:02:51 +00:00

47 lines
817 B
C++
Executable File

#ifndef MATH_UTIL_H
#define MATH_UTIL_H
#ifndef PI
#define PI 3.14159265358979323846f
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef M_PI_2
#define M_PI_2 1.57079632679489661923
#endif
#define DEGTORAD(a) ((a) * (PI/180.0f))
#define RADTODEG(a) ((a) * (180.0f/PI))
#define SQR(x) ((x) * (x))
#define MAX3(a,b,c) ( MAX (MAX(a,b), c) )
#define ABS(a) ((a > 0) ? (a) : (-a))
template <typename T>
T Interpolate( T& a, T& b, float l )
{
return( a + ( b - a ) * l );
}
template <typename T>
inline T clamp(T value, T min, T max)
{
if (value<=min) return min;
else if (value>=max) return max;
else return value;
}
static inline int RoundUpToPowerOf2(int x)
{
if ((x & (x-1))==0) return x;
int d=x;
while (d & (d-1)) {
d&=(d-1);
}
return d<<1;
}
#endif