quat.h (586B)
1 2 3 #ifndef POLYADVENT_QUAT4_ 4 #define POLYADVENT_QUAT4_ 5 6 #include <math.h> 7 8 typedef float quat; 9 #define QUAT(x,y,z,w) ((quat[4]){x,y,z,w}) 10 11 void quat_id(quat *dest); 12 void quat_multiply(quat *a, quat *b, quat *dest); 13 void quat_axis_angle(float *axis, float angle, quat *dest); 14 void quat_from_axes(float yaw, float pitch, float roll); 15 void quat_to_mat3(quat *quat, float *dest); 16 void quat_multiply_vec3(quat *quat, float *vec, float *dest); 17 quat *quat_inverse(quat *q, quat *dest); 18 19 static inline float quat_yaw(quat *q) { 20 return atan2(q[2],q[3])*2.0; 21 } 22 23 #endif /* POLYADVENT_QUAT4_ */