Ответ: Достать угол с mat4.
Есть! нашел в том же файле (glMatrix.js)...
/**
* Stores the angle and axis in a vec4, where the XYZ components represent
* the axis and the W (4th) component is the angle in radians.
*
* If dest is not given, src will be modified in place and returned, after
* which it should not be considered not a quaternion (just an axis and angle).
*
* @param {quat4} quat the quaternion whose angle and axis to store
* @param {vec4} [dest] the optional vec4 to receive the data
*
* @returns {vec4} dest
*/
quat4.toAngleAxis = function(src, dest) {
if (!dest) dest = src;
// The quaternion representing the rotation is
// q = cos(A/2)+sin(A/2)*(x*i+y*j+z*k)
var sqrlen = src[0]*src[0]+src[1]*src[1]+src[2]*src[2];
if (sqrlen > 0)
{
dest[3] = 2 * Math.acos(src[3]);
var invlen = glMath.invsqrt(sqrlen);
dest[0] = src[0]*invlen;
dest[1] = src[1]*invlen;
dest[2] = src[2]*invlen;
} else {
// angle is 0 (mod 2*pi), so any axis will do
dest[3] = 0;
dest[0] = 1;
dest[1] = 0;
dest[2] = 0;
}
return dest;
};
Теперь только матрицу в кватернион конвертнуть...
__________________
Blitz3D, XNA, WebGL, OpenGL, Unity3D
PC: ASUS A55VM Core i3 (2.4Ghz), 6 Gb RAM, Nvidia GF 630M GT 2Gb
|