ciao ho trovato una libreria js sui quaternioni.
vi posto un pezzo:

codice:
tdl.provide('tdl.quaternions');

/**
* A Module for quaternion math.
* @namespace
*/
tdl.quaternions = tdl.quaternions || {};

/**
* A Quaternion.
* @type {!Array.<number>}
*/
tdl.quaternions.Quaterion = goog.typedef;

/**
* Quickly determines if the object a is a scalar or a quaternion;
* assumes that the argument is either a number (scalar), or an array of
* numbers.
* @param {(number|!tdl.quaternions.Quaterion)} a A number or array the type
*     of which is in question.
* @return {string} Either the string 'Scalar' or 'Quaternion'.
*/
tdl.quaternions.mathType = function (a) {
    if (typeof (a) === 'number')
        return 'Scalar';
    return 'Quaternion';
};

/**
* Copies a quaternion.
* @param {!tdl.quaternions.Quaterion} q The quaternion.
* @return {!tdl.quaternions.Quaterion} A new quaternion identical to q.
*/
tdl.quaternions.copy = function (q) {
    return q.slice();
};

/**
* Negates a quaternion.
* @param {!tdl.quaternions.Quaterion} q The quaternion.
* @return {!tdl.quaternions.Quaterion} -q.
*/
tdl.quaternions.negative = function (q) {
    return [-q[0], -q[1], -q[2], -q[3]];
};

/**
* Adds two Quaternions.
* @param {!tdl.quaternions.Quaterion} a Operand Quaternion.
* @param {!tdl.quaternions.Quaterion} b Operand Quaternion.
* @return {!tdl.quaternions.Quaterion} The sum of a and b.
*/
tdl.quaternions.addQuaternionQuaternion = function (a, b) {
    return [a[0] + b[0],
          a[1] + b[1],
          a[2] + b[2],
          a[3] + b[3]];
};

/**
* Adds a quaternion to a scalar.
* @param {!tdl.quaternions.Quaterion} a Operand Quaternion.
* @param {number} b Operand Scalar.
* @return {!tdl.quaternions.Quaterion} The sum of a and b.
*/
tdl.quaternions.addQuaternionScalar = function (a, b) {
    return a.slice(0, 3).concat(a[3] + b);
};

/**
* Adds a scalar to a quaternion.
* @param {number} a Operand scalar.
* @param {!tdl.quaternions.Quaterion} b Operand quaternion.
* @return {!tdl.quaternions.Quaterion} The sum of a and b.
*/
tdl.quaternions.addScalarQuaternion = function (a, b) {
    return b.slice(0, 3).concat(a + b[3]);
};

/**
* Subtracts two quaternions.
* @param {!tdl.quaternions.Quaterion} a Operand quaternion.
* @param {!tdl.quaternions.Quaterion} b Operand quaternion.
* @return {!tdl.quaternions.Quaterion} The difference a - b.
*/
tdl.quaternions.subQuaternionQuaternion = function (a, b) {
    return [a[0] - b[0],
          a[1] - b[1],
          a[2] - b[2],
          a[3] - b[3]];
};

/**
* Subtracts a scalar from a quaternion.
* @param {!tdl.quaternions.Quaterion} a Operand quaternion.
* @param {number} b Operand scalar.
* @return {!tdl.quaternions.Quaterion} The difference a - b.
*/
tdl.quaternions.subQuaternionScalar = function (a, b) {
    return a.slice(0, 3).concat(a[3] - b);
};
non riesco ad accedere alle funzioni, come si fa?
e come è strutturato il modulo?
perchè tdl.quaternions.xxxx?

grazie