#include #include #include #include extern GLUmat4 rotate_x_axis(float theta); extern GLUmat4 rotate_y_axis(float theta); #define EPSILONS 2 static inline bool equal(const float & a, const float & b) { return (fabs(a - b) < EPSILONS * FLT_EPSILON); } static inline bool equal(const GLUvec4 & a, const GLUvec4 & b) { return equal(a.values[0], b.values[0]) && equal(a.values[1], b.values[1]) && equal(a.values[2], b.values[2]) && equal(a.values[3], b.values[3]); } static inline bool equal(const GLUmat4 & a, const GLUmat4 & b) { return equal(a.col[0], b.col[0]) && equal(a.col[1], b.col[1]) && equal(a.col[2], b.col[2]) && equal(a.col[3], b.col[3]); } void check_rotation(void) { // Rotation by 0 and 2PI are equal (within 2 epsilons) assert(equal(rotate_x_axis(0.0f), rotate_x_axis(2.0f * M_PI))); assert(equal(rotate_y_axis(0.0f), rotate_y_axis(2.0f * M_PI))); assert(equal(rotate_x_axis(M_PI) * rotate_x_axis(M_PI), rotate_x_axis(0.0f))); assert(equal(rotate_y_axis(M_PI) * rotate_y_axis(M_PI), rotate_y_axis(0.0f))); assert(equal(rotate_x_axis(M_PI) * rotate_y_axis(M_PI), rotate_y_axis(M_PI) * rotate_x_axis(M_PI))); }