export var createQuaternion = function (x, y, z, w) {
    if (x === void 0) { x = 0; }
    if (y === void 0) { y = 0; }
    if (z === void 0) { z = 0; }
    if (w === void 0) { w = 1; }
    return ({
        x: x,
        y: y,
        z: z,
        w: w,
    });
};
/**
 * Conversion function form Euler to Quaternion, taken from ThreeJS
 * @param euler euler (only order 'xyz' is implemented)
 */
export function createQuaternionFromEuler(euler) {
    // http://www.mathworks.com/matlabcentral/fileexchange/
    // 	20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/
    //	content/SpinCalc.m
    if (euler.order !== "xyz") {
        throw new Error("Unknown order");
    }
    var c1 = Math.cos(euler.x / 2);
    var c2 = Math.cos(euler.y / 2);
    var c3 = Math.cos(euler.z / 2);
    var s1 = Math.sin(euler.x / 2);
    var s2 = Math.sin(euler.y / 2);
    var s3 = Math.sin(euler.z / 2);
    var x = s1 * c2 * c3 + c1 * s2 * s3;
    var y = c1 * s2 * c3 - s1 * c2 * s3;
    var z = c1 * c2 * s3 + s1 * s2 * c3;
    var w = c1 * c2 * c3 - s1 * s2 * s3;
    var result = createQuaternion(x, y, z, w);
    return result;
}
