The quaternion corresponding to the rotation resulting from (Clifford Algebra-induced) reflections about the two normalized vectors A and B is simply
q = ( A · B, A × B )where clearly, since A and B are both unit-length three-vectors, there is something wrong -- we have four free variables instead of three. But it's fine because this is really a circle bundle: there is a one-parameter rotation in the (A, B) plane that, for any rotation, generates the same quaternion, and thus the needed reduction to three free variables is achieved.
quat->x = (m[2][1] - m[1][2]) * s ;
quat->y = (m[0][2] - m[2][0]) * s ;
quat->z = (m[1][0] - m[0][1]) * s ;
q[3] = (m[k][j] - m[j][k]) * s ;
double q0, double q1, double q2, double q3,
double q0, double q1, double q2, double
q3)
MatToQuat(double m[4][4], QUAT
*quat)
MatToQuat(double m[4][4], Quat
*quat)
QuatToMatrix(QUAT * quat, double
m[4][4])
QuatToMatrix(Quat * quat, double
m[4][4])