#ifndef __UTIL_H__ # define __UTIL_H__ #include #include using namespace libnum; /* A platform rectangle, aligned with the camera's view */ struct prect { vec3 nl, nr; /* Near left and near right points */ vec3 fl, fr; /* Far left and far right points */ }; /* Approximations of the sine and cosine of an angle in radians. */ num num_cos(num a); num num_sin(num a); /* Clamp a num between two bounds. */ num num_clamp(num t, num lower_bound, num upper_bound); /* Random num between 0 and 1. */ num num_rand(void); /* String representation of various objects (static strings rotating; can use up to 8 of them at once). */ char const *str(num x); char const *str(vec2 u); char const *str(vec3 u); /* Rotate v by θ around z, when rotator=(cos(θ), sin(θ)) */ vec3 vec_rotate_around_z(vec3 v, vec2 rotator); #define RGB24(hex) \ (((hex & 0xf80000) >> 8) | \ ((hex & 0x00fc00) >> 5) | \ ((hex & 0x0000f8) >> 3)) #endif /* __UTIL_H__ */