The indexing for the q variable in quat_from_mat4x4 function is incorrect. I recommend using #defines for the indexes for the whole file, such as:
if(r < 1e-6) {
q[QUAT_S] = 1.f;
q[QUAT_X] = q[QUAT_Y] = q[QUAT_Z] = 0.f;
return;
}
q[QUAT_S] = r/2.f;
q[QUAT_X] = (M[p[0]][p[1]] - M[p[1]][p[0]])/(2.f*r);
q[QUAT_Y] = (M[p[2]][p[0]] - M[p[0]][p[2]])/(2.f*r);
q[QUAT_Z] = (M[p[2]][p[1]] - M[p[1]][p[2]])/(2.f*r);
Great library, by the way.
The indexing for the q variable in quat_from_mat4x4 function is incorrect. I recommend using #defines for the indexes for the whole file, such as:
if(r < 1e-6) {
q[QUAT_S] = 1.f;
q[QUAT_X] = q[QUAT_Y] = q[QUAT_Z] = 0.f;
return;
}
Great library, by the way.