8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * Used as value for the _rounding method.
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @property _rounder
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * Rounds values
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @method _round
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp val = Math.round(val * MatrixUtil._rounder) / MatrixUtil._rounder;
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * Converts a radian value to a degree.
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @method rad2deg
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @param {Number} rad Radian value to be converted.
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @return Number
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * Converts a degree value to a radian.
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @method deg2rad
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @param {Number} deg Degree value to be converted to radian.
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @return Number
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * Converts an angle to a radian
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @method angle2rad
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @param {Objecxt} val Value to be converted to radian.
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @return Number
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp if (typeof val === 'string' && val.indexOf('rad') > -1) {
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp } else { // default to deg
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * Converts a transform object to an array of column vectors.
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * | matrix[0][0] matrix[1][0] matrix[2][0] |
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * | matrix[0][1] matrix[1][1] matrix[2][1] |
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * | matrix[0][2] matrix[1][2] matrix[2][2] |
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @method getnxn
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @return Array
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * Returns the determinant of a given matrix.
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * | matrix[0][0] matrix[1][0] matrix[2][0] |
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * | matrix[0][1] matrix[1][1] matrix[2][1] |
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * | matrix[0][2] matrix[1][2] matrix[2][2] |
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * | matrix[0][3] matrix[1][3] matrix[2][3] |
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @method getDeterminant
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @param {Array} matrix An nxn matrix represented an array of vector (column) arrays. Each vector array has index for each row.
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @return Number
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp return matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0];
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp for(; i < len; ++i)
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp determinant += multiplier * MatrixUtil.getDeterminant(MatrixUtil.getMinors(matrix, i, 0));
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp determinant -= multiplier * MatrixUtil.getDeterminant(MatrixUtil.getMinors(matrix, i, 0));
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * Returns the inverse of a matrix
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @method inverse
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @param Array matrix An array representing an nxn matrix
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @return Array
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * | matrix[0][0] matrix[1][0] matrix[2][0] |
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * | matrix[0][1] matrix[1][1] matrix[2][1] |
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * | matrix[0][2] matrix[1][2] matrix[2][2] |
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * | matrix[0][3] matrix[1][3] matrix[2][3] |
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp //vector representing 2x2 matrix
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp determinant = matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0];
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp [matrix[1][1] * determinant, -matrix[1][0] * determinant],
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp [-matrix[0][1] * determinant, matrix[0][0] * determinant]
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp for(; i < len; ++i)
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp inverse = MatrixUtil.scalarMultiply(adjunct, 1/determinant);
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * Multiplies a matrix by a numeric value.
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @method scalarMultiply
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @param {Array} matrix The matrix to be altered.
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @param {Number} multiplier The number to multiply against the matrix.
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @return Array
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp for(; i < len; ++i)
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp matrix[i][j] = MatrixUtil._round(matrix[i][j] * multiplier);
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * Returns the transpose for an nxn matrix.
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @method transpose
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @param matrix An nxn matrix represented by an array of vector arrays.
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @return Array
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp for(; i < len; ++i)
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * Returns a matrix of minors based on a matrix, column index and row index.
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @method getMinors
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @param {Array} matrix The matrix from which to extract the matrix of minors.
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @param {Number} columnIndex A zero-based index representing the specified column to exclude.
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @param {Number} rowIndex A zero-based index represeenting the specified row to exclude.
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @return Array
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp for(; i < len; ++i)
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * Returns the sign of value
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @method sign
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @param {Number} val value to be interpreted
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @return Number
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * Multiplies a vector and a matrix
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @method vectorMatrixProduct
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @param {Array} vector Array representing a column vector
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @param {Array} matrix Array representing an nxn matrix
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @return Array
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * Breaks up a 2d transform matrix into a series of transform operations.
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @method decompose
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @param {Array} 3x3 matrix array
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @return Array
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp if((a * d - b * c) === 0)
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp return false;
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp //get length of vector(ab)
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp //normalize components of vector(ab)
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp //get length of vector(cd)
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp //normalize components of vector(cd)
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp if(a * b < c * d)
83e1c423e969705408dfcf7d94c7cd3c762e18f8Tripp shear = MatrixUtil._round(MatrixUtil.rad2deg(Math.atan(shear)));
83e1c423e969705408dfcf7d94c7cd3c762e18f8Tripp rotate = MatrixUtil._round(MatrixUtil.rad2deg(Math.atan2(matrix[1][0], matrix[0][0])));
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * Parses a transform string and returns an array of transform arrays.
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @method getTransformArray
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @param {String} val A transform string
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @return Array
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * Returns an array of transform arrays representing transform functions and arguments.
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @method getTransformFunctionArray
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @return Array
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp case "skew" :
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp case "scale" :
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp case "scaleX" :
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp case "scaleY" :
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp case "translate" :
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * Compares to arrays or transform functions to ensure both contain the same functions in the same
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @method compareTransformSequence
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @param {Array} list1 Array to compare
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @param {Array} list2 Array to compare
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @return Boolean
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp for(; i < len; ++i)
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * Mapping of possible transform method names.
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @property transformMethods
8ab6afc0ff1f6b225e52d7489864024d814b37fcTripp * @type Object