126#define Q_EPSILON (1e-10)
129#define Q_MAX(x, y) ( ((x) > (y)) ? (x) : (y) )
130#define Q_MIN(x, y) ( ((x) < (y)) ? (x) : (y) )
132#define Q_ABS(x) ( ((x) > 0 ) ? (x) : (-(x)) )
138#define Q_PI 3.14159265358979323846
140#define Q_ID_QUAT { 0.0, 0.0, 0.0, 1.0 }
142#define Q_ID_MATRIX { {1.0, 0.0, 0.0, 0.0}, \
143 {0.0, 1.0, 0.0, 0.0}, \
144 {0.0, 0.0, 1.0, 0.0}, \
145 {0.0, 0.0, 0.0, 1.0} }
147#define Q_NULL_VECTOR { 0.0, 0.0, 0.0 }
152#define Q_DEG_TO_RAD(deg) ( ((deg)*Q_PI)/180.0 )
153#define Q_RAD_TO_DEG(rad) ( (((rad)*180.0)/Q_PI) )
163typedef double q_type[4];
166typedef double q_vec_type[3];
169typedef double q_matrix_type[4][4];
172typedef float qgl_matrix_type[4][4];
177typedef double qogl_matrix_type[16];
199#if defined(__cplusplus)
202#define EXTERN_QUALIFICATION
204#define EXTERN_QUALIFICATION "C"
207#define BEGIN_EXTERN_BLOCK extern EXTERN_QUALIFICATION {
208#define END_EXTERN_BLOCK }
212#define BEGIN_EXTERN_BLOCK
213#define END_EXTERN_BLOCK
228void q_print (
const q_type quat);
238void q_make (q_type destQuat,
239 double x,
double y,
double z,
241void q_from_axis_angle(q_type destQuat,
242 double x,
double y,
double z,
254void q_to_axis_angle (
double *x,
double *y,
double *z,
double *angle,
255 const q_type srcQuat);
258void q_copy (q_type destQuat,
const q_type srcQuat);
261void q_normalize (q_type destQuat,
const q_type srcQuat);
264void q_invert (q_type destQuat,
const q_type srcQuat);
270void q_mult (q_type destQuat,
const q_type qLeft,
const q_type qRight);
273void q_conjugate (q_type destQuat,
const q_type srcQuat);
276void q_log (q_type destQuat,
const q_type srcQuat);
279void q_exp (q_type destQuat,
const q_type srcQuat);
293void q_slerp (q_type destQuat,
const q_type startQuat,
const q_type endQuat,
double t);
308void q_from_euler (q_type destQuat,
double yaw,
double pitch,
double roll);
318void q_to_euler(q_vec_type yawPitchRoll,
const q_type q);
327void q_xform (q_vec_type destVec,
const q_type q,
const q_vec_type vec);
333void q_from_two_vecs (q_type destQuat,
const q_vec_type v1,
const q_vec_type v2);
336void q_from_vec (q_type destQuat,
const q_vec_type srcVec);
337void q_to_vec (q_vec_type destVec,
const q_type srcQuat);
340void q_from_row_matrix (q_type destQuat,
const q_matrix_type matrix);
341void q_from_col_matrix (q_type destQuat,
const q_matrix_type matrix);
342void q_to_row_matrix (q_matrix_type destMatrix,
const q_type srcQuat);
343void q_to_col_matrix (q_matrix_type destMatrix,
const q_type srcQuat);
346void q_from_ogl_matrix (q_type destQuat,
const qogl_matrix_type matrix);
347void q_to_ogl_matrix (qogl_matrix_type matrix,
const q_type srcQuat);
357void q_vec_print (
const q_vec_type vec);
360#define q_set_vec q_vec_set
363void q_vec_set (q_vec_type vec,
double x,
double y,
double z);
366void q_vec_copy (q_vec_type destVec,
const q_vec_type srcVec);
369void q_vec_add (q_vec_type destVec,
const q_vec_type aVec,
const q_vec_type bVec);
372void q_vec_subtract (q_vec_type destVec,
const q_vec_type v1,
const q_vec_type v2);
375double q_vec_dot_product (
const q_vec_type v1,
const q_vec_type v2);
378void q_vec_scale (q_vec_type destVec,
double scaleFactor,
const q_vec_type srcVec);
382void q_vec_invert (q_vec_type destVec,
const q_vec_type srcVec);
385void q_vec_normalize (q_vec_type destVec,
const q_vec_type srcVec);
388double q_vec_magnitude (
const q_vec_type vec);
391double q_vec_distance (
const q_vec_type vec1,
const q_vec_type vec2);
395void q_vec_cross_product (q_vec_type destVec,
396 const q_vec_type aVec,
const q_vec_type bVec);
406void q_matrix_copy (q_matrix_type destMatrix,
const q_matrix_type srcMatrix);
408void qogl_matrix_copy (qogl_matrix_type dest,
const qogl_matrix_type src);
413void q_matrix_mult (q_matrix_type resultMatrix,
414 const q_matrix_type leftMatrix,
415 const q_matrix_type rightMatrix);
418#define qogl_matrix_mult_fixed qogl_matrix_mult
425void qogl_matrix_mult (qogl_matrix_type result,
426 const qogl_matrix_type left,
427 const qogl_matrix_type right);
456void q_euler_to_col_matrix (q_matrix_type destMatrix,
457 double yaw,
double pitch,
double roll);
481void q_col_matrix_to_euler (q_vec_type yawpitchroll,
const q_matrix_type colMatrix);
484void q_print_matrix (
const q_matrix_type matrix);
486void qogl_print_matrix (
const qogl_matrix_type);
501 const q_matrix_type rowMatrix);
504void q_xyz_quat_to_row_matrix (q_matrix_type rowMatrix,
508 const qogl_matrix_type matrix);
510void q_xyz_quat_to_ogl_matrix (qogl_matrix_type matrix,
519void q_xyz_quat_xform(q_vec_type dest,
const q_xyz_quat_type *xf,
const q_vec_type src);
528void qgl_to_matrix (qgl_matrix_type destMatrix,
const q_type srcQuat);
535void qgl_from_matrix (q_type destQuat,
const qgl_matrix_type srcMatrix);
538void qgl_print_matrix (
const qgl_matrix_type matrix);
542#undef BEGIN_EXTERN_BLOCK
543#undef END_EXTERN_BLOCK
544#undef EXTERN_QUALIFICATION