
}
function setQ(q)
{
    q.normalize();
    quat = q;
    doOutput();
}
function doOutput()
{
    var q = quat;
    var m = new THREE.Matrix4();
    m.makeRotationFromQuaternion(q);
    document.getElementById("resmatrix").value = matrixToString(m);
    document.getElementById("resq").value = '[ '+toReal(q.x)+', '+toReal(q.y)+', '+toReal(q.z)+', '+toReal(q.w)+' ]';
    
    var axis = [0, 0, 0];
    var angle = 2 * Math.acos(q.w);
    if (1 - (q.w * q.w) < 0.000001)
    {
        axis[0] = q.x;
        axi