summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/trace-viewer/third_party/gl-matrix/src/gl-matrix/quat.js
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/trace-viewer/third_party/gl-matrix/src/gl-matrix/quat.js')
-rw-r--r--chromium/third_party/trace-viewer/third_party/gl-matrix/src/gl-matrix/quat.js457
1 files changed, 0 insertions, 457 deletions
diff --git a/chromium/third_party/trace-viewer/third_party/gl-matrix/src/gl-matrix/quat.js b/chromium/third_party/trace-viewer/third_party/gl-matrix/src/gl-matrix/quat.js
deleted file mode 100644
index c2290d3f1af..00000000000
--- a/chromium/third_party/trace-viewer/third_party/gl-matrix/src/gl-matrix/quat.js
+++ /dev/null
@@ -1,457 +0,0 @@
-/* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification,
-are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
-
-/**
- * @class Quaternion
- * @name quat
- */
-var quat = {};
-
-/**
- * Creates a new identity quat
- *
- * @returns {quat} a new quaternion
- */
-quat.create = function() {
- var out = new GLMAT_ARRAY_TYPE(4);
- out[0] = 0;
- out[1] = 0;
- out[2] = 0;
- out[3] = 1;
- return out;
-};
-
-/**
- * Creates a new quat initialized with values from an existing quaternion
- *
- * @param {quat} a quaternion to clone
- * @returns {quat} a new quaternion
- * @function
- */
-quat.clone = vec4.clone;
-
-/**
- * Creates a new quat initialized with the given values
- *
- * @param {Number} x X component
- * @param {Number} y Y component
- * @param {Number} z Z component
- * @param {Number} w W component
- * @returns {quat} a new quaternion
- * @function
- */
-quat.fromValues = vec4.fromValues;
-
-/**
- * Copy the values from one quat to another
- *
- * @param {quat} out the receiving quaternion
- * @param {quat} a the source quaternion
- * @returns {quat} out
- * @function
- */
-quat.copy = vec4.copy;
-
-/**
- * Set the components of a quat to the given values
- *
- * @param {quat} out the receiving quaternion
- * @param {Number} x X component
- * @param {Number} y Y component
- * @param {Number} z Z component
- * @param {Number} w W component
- * @returns {quat} out
- * @function
- */
-quat.set = vec4.set;
-
-/**
- * Set a quat to the identity quaternion
- *
- * @param {quat} out the receiving quaternion
- * @returns {quat} out
- */
-quat.identity = function(out) {
- out[0] = 0;
- out[1] = 0;
- out[2] = 0;
- out[3] = 1;
- return out;
-};
-
-/**
- * Sets a quat from the given angle and rotation axis,
- * then returns it.
- *
- * @param {quat} out the receiving quaternion
- * @param {vec3} axis the axis around which to rotate
- * @param {Number} rad the angle in radians
- * @returns {quat} out
- **/
-quat.setAxisAngle = function(out, axis, rad) {
- rad = rad * 0.5;
- var s = Math.sin(rad);
- out[0] = s * axis[0];
- out[1] = s * axis[1];
- out[2] = s * axis[2];
- out[3] = Math.cos(rad);
- return out;
-};
-
-/**
- * Adds two quat's
- *
- * @param {quat} out the receiving quaternion
- * @param {quat} a the first operand
- * @param {quat} b the second operand
- * @returns {quat} out
- * @function
- */
-quat.add = vec4.add;
-
-/**
- * Multiplies two quat's
- *
- * @param {quat} out the receiving quaternion
- * @param {quat} a the first operand
- * @param {quat} b the second operand
- * @returns {quat} out
- */
-quat.multiply = function(out, a, b) {
- var ax = a[0], ay = a[1], az = a[2], aw = a[3],
- bx = b[0], by = b[1], bz = b[2], bw = b[3];
-
- out[0] = ax * bw + aw * bx + ay * bz - az * by;
- out[1] = ay * bw + aw * by + az * bx - ax * bz;
- out[2] = az * bw + aw * bz + ax * by - ay * bx;
- out[3] = aw * bw - ax * bx - ay * by - az * bz;
- return out;
-};
-
-/**
- * Alias for {@link quat.multiply}
- * @function
- */
-quat.mul = quat.multiply;
-
-/**
- * Scales a quat by a scalar number
- *
- * @param {quat} out the receiving vector
- * @param {quat} a the vector to scale
- * @param {Number} b amount to scale the vector by
- * @returns {quat} out
- * @function
- */
-quat.scale = vec4.scale;
-
-/**
- * Rotates a quaternion by the given angle around the X axis
- *
- * @param {quat} out quat receiving operation result
- * @param {quat} a quat to rotate
- * @param {number} rad angle (in radians) to rotate
- * @returns {quat} out
- */
-quat.rotateX = function (out, a, rad) {
- rad *= 0.5;
-
- var ax = a[0], ay = a[1], az = a[2], aw = a[3],
- bx = Math.sin(rad), bw = Math.cos(rad);
-
- out[0] = ax * bw + aw * bx;
- out[1] = ay * bw + az * bx;
- out[2] = az * bw - ay * bx;
- out[3] = aw * bw - ax * bx;
- return out;
-};
-
-/**
- * Rotates a quaternion by the given angle around the Y axis
- *
- * @param {quat} out quat receiving operation result
- * @param {quat} a quat to rotate
- * @param {number} rad angle (in radians) to rotate
- * @returns {quat} out
- */
-quat.rotateY = function (out, a, rad) {
- rad *= 0.5;
-
- var ax = a[0], ay = a[1], az = a[2], aw = a[3],
- by = Math.sin(rad), bw = Math.cos(rad);
-
- out[0] = ax * bw - az * by;
- out[1] = ay * bw + aw * by;
- out[2] = az * bw + ax * by;
- out[3] = aw * bw - ay * by;
- return out;
-};
-
-/**
- * Rotates a quaternion by the given angle around the Z axis
- *
- * @param {quat} out quat receiving operation result
- * @param {quat} a quat to rotate
- * @param {number} rad angle (in radians) to rotate
- * @returns {quat} out
- */
-quat.rotateZ = function (out, a, rad) {
- rad *= 0.5;
-
- var ax = a[0], ay = a[1], az = a[2], aw = a[3],
- bz = Math.sin(rad), bw = Math.cos(rad);
-
- out[0] = ax * bw + ay * bz;
- out[1] = ay * bw - ax * bz;
- out[2] = az * bw + aw * bz;
- out[3] = aw * bw - az * bz;
- return out;
-};
-
-/**
- * Calculates the W component of a quat from the X, Y, and Z components.
- * Assumes that quaternion is 1 unit in length.
- * Any existing W component will be ignored.
- *
- * @param {quat} out the receiving quaternion
- * @param {quat} a quat to calculate W component of
- * @returns {quat} out
- */
-quat.calculateW = function (out, a) {
- var x = a[0], y = a[1], z = a[2];
-
- out[0] = x;
- out[1] = y;
- out[2] = z;
- out[3] = -Math.sqrt(Math.abs(1.0 - x * x - y * y - z * z));
- return out;
-};
-
-/**
- * Calculates the dot product of two quat's
- *
- * @param {quat} a the first operand
- * @param {quat} b the second operand
- * @returns {Number} dot product of a and b
- * @function
- */
-quat.dot = vec4.dot;
-
-/**
- * Performs a linear interpolation between two quat's
- *
- * @param {quat} out the receiving quaternion
- * @param {quat} a the first operand
- * @param {quat} b the second operand
- * @param {Number} t interpolation amount between the two inputs
- * @returns {quat} out
- * @function
- */
-quat.lerp = vec4.lerp;
-
-/**
- * Performs a spherical linear interpolation between two quat
- *
- * @param {quat} out the receiving quaternion
- * @param {quat} a the first operand
- * @param {quat} b the second operand
- * @param {Number} t interpolation amount between the two inputs
- * @returns {quat} out
- */
-quat.slerp = function (out, a, b, t) {
- var ax = a[0], ay = a[1], az = a[2], aw = a[3],
- bx = b[0], by = b[1], bz = b[2], bw = b[3];
-
- var cosHalfTheta = ax * bx + ay * by + az * bz + aw * bw,
- halfTheta,
- sinHalfTheta,
- ratioA,
- ratioB;
-
- if (Math.abs(cosHalfTheta) >= 1.0) {
- if (out !== a) {
- out[0] = ax;
- out[1] = ay;
- out[2] = az;
- out[3] = aw;
- }
- return out;
- }
-
- halfTheta = Math.acos(cosHalfTheta);
- sinHalfTheta = Math.sqrt(1.0 - cosHalfTheta * cosHalfTheta);
-
- if (Math.abs(sinHalfTheta) < 0.001) {
- out[0] = (ax * 0.5 + bx * 0.5);
- out[1] = (ay * 0.5 + by * 0.5);
- out[2] = (az * 0.5 + bz * 0.5);
- out[3] = (aw * 0.5 + bw * 0.5);
- return out;
- }
-
- ratioA = Math.sin((1 - t) * halfTheta) / sinHalfTheta;
- ratioB = Math.sin(t * halfTheta) / sinHalfTheta;
-
- out[0] = (ax * ratioA + bx * ratioB);
- out[1] = (ay * ratioA + by * ratioB);
- out[2] = (az * ratioA + bz * ratioB);
- out[3] = (aw * ratioA + bw * ratioB);
-
- return out;
-};
-
-/**
- * Calculates the inverse of a quat
- *
- * @param {quat} out the receiving quaternion
- * @param {quat} a quat to calculate inverse of
- * @returns {quat} out
- */
-quat.invert = function(out, a) {
- var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3],
- dot = a0*a0 + a1*a1 + a2*a2 + a3*a3,
- invDot = dot ? 1.0/dot : 0;
-
- // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0
-
- out[0] = -a0*invDot;
- out[1] = -a1*invDot;
- out[2] = -a2*invDot;
- out[3] = a3*invDot;
- return out;
-};
-
-/**
- * Calculates the conjugate of a quat
- * If the quaternion is normalized, this function is faster than quat.inverse and produces the same result.
- *
- * @param {quat} out the receiving quaternion
- * @param {quat} a quat to calculate conjugate of
- * @returns {quat} out
- */
-quat.conjugate = function (out, a) {
- out[0] = -a[0];
- out[1] = -a[1];
- out[2] = -a[2];
- out[3] = a[3];
- return out;
-};
-
-/**
- * Calculates the length of a quat
- *
- * @param {quat} a vector to calculate length of
- * @returns {Number} length of a
- * @function
- */
-quat.length = vec4.length;
-
-/**
- * Alias for {@link quat.length}
- * @function
- */
-quat.len = quat.length;
-
-/**
- * Calculates the squared length of a quat
- *
- * @param {quat} a vector to calculate squared length of
- * @returns {Number} squared length of a
- * @function
- */
-quat.squaredLength = vec4.squaredLength;
-
-/**
- * Alias for {@link quat.squaredLength}
- * @function
- */
-quat.sqrLen = quat.squaredLength;
-
-/**
- * Normalize a quat
- *
- * @param {quat} out the receiving quaternion
- * @param {quat} a quaternion to normalize
- * @returns {quat} out
- * @function
- */
-quat.normalize = vec4.normalize;
-
-/**
- * Creates a quaternion from the given 3x3 rotation matrix.
- *
- * @param {quat} out the receiving quaternion
- * @param {mat3} m rotation matrix
- * @returns {quat} out
- * @function
- */
-quat.fromMat3 = (function() {
- var s_iNext = [1,2,0];
- return function(out, m) {
- // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes
- // article "Quaternion Calculus and Fast Animation".
- var fTrace = m[0] + m[4] + m[8];
- var fRoot;
-
- if ( fTrace > 0.0 ) {
- // |w| > 1/2, may as well choose w > 1/2
- fRoot = Math.sqrt(fTrace + 1.0); // 2w
- out[3] = 0.5 * fRoot;
- fRoot = 0.5/fRoot; // 1/(4w)
- out[0] = (m[7]-m[5])*fRoot;
- out[1] = (m[2]-m[6])*fRoot;
- out[2] = (m[3]-m[1])*fRoot;
- } else {
- // |w| <= 1/2
- var i = 0;
- if ( m[4] > m[0] )
- i = 1;
- if ( m[8] > m[i*3+i] )
- i = 2;
- var j = s_iNext[i];
- var k = s_iNext[j];
-
- fRoot = Math.sqrt(m[i*3+i]-m[j*3+j]-m[k*3+k] + 1.0);
- out[i] = 0.5 * fRoot;
- fRoot = 0.5 / fRoot;
- out[3] = (m[k*3+j] - m[j*3+k]) * fRoot;
- out[j] = (m[j*3+i] + m[i*3+j]) * fRoot;
- out[k] = (m[k*3+i] + m[i*3+k]) * fRoot;
- }
-
- return out;
- };
-})();
-
-/**
- * Returns a string representation of a quatenion
- *
- * @param {quat} vec vector to represent as a string
- * @returns {String} string representation of the vector
- */
-quat.str = function (a) {
- return 'quat(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')';
-};
-
-if(typeof(exports) !== 'undefined') {
- exports.quat = quat;
-}