{ "name": "MatrixMath", "script": "matrixMath.js", "version": "1.0", "previousversions": [], "description": "# Matrix Math\r\rThis script provides a library of matrix mathematical operations for\rlinear algebra and 2D affine transformations. It has no behavior on its own\rand is meant to be used by other scripts to do neat things, particularly\rfor transforming geometric systems.\r\rAll of this scripts operations are exposed through the ```MatrixMath``` object.\r\r## Other scripts\r\rMatrixMath has no dependencies, but it does play nice with the ```Vector Math```\rscript's library, particularly for ```MatrixMath.multiply()``` when used to\rtransform a vector.\r\r## Unit tests\rUnit tests are implemented for all its operations, and they run automatically\rwhen the script is loaded.\r\r## API Documentation\r\rThis script's documentation makes use of the follow typedefs:\r\r```\r/**\r * An NxN square matrix, represented as a 2D array of numbers in column-major\r * order. For example, mat[3][2] would get the value in column 3 and row 2.\r * order.\r * @typedef {number[][]} Matrix\r */\r```\r\r```\r/**\r * An N-degree vector.\r * @typedef {number[]} Vector\r */\r```\r\rThe following functions are exposed by the ```MatrixMath``` object:\r\r```\r/**\r * Gets the adjugate of a matrix, the tranpose of its cofactor matrix.\r * @param {Matrix} mat\r * @return {Matrix}\r */\rfunction adjoint(mat)\r```\r\r```\r/**\r * Produces a clone of an NxN square matrix.\r * @param {Matrix} mat\r * @return {Matrix}\r */\rfunction clone(mat)\r```\r\r```\r/**\r * Gets the cofactor of a matrix at a specified column and row.\r * @param {Matrix} mat\r * @param {uint} col\r * @param {uint} row\r * @return {number}\r */\rfunction cofactor(mat, col, row)\r```\r\r```\r/**\r * Gets the cofactor matrix of a matrix.\r * @param {Matrix} mat\r * @return {Matrix}\r */\rfunction cofactorMatrix(mat)\r```\r\r```\r/**\r * Gets the determinant of an NxN matrix.\r * @param {Matrix} mat\r * @return {number}\r */\rfunction determinant(mat)\r```\r\r```\r/**\r * Tests if two matrices are equal.\r * @param {Matrix} a\r * @param {Matrix} b\r * @param {number} [tolerance=0]\r * If specified, this specifies the amount of tolerance to use for\r * each value of the matrices when testing for equality.\r * @return {boolean}\r */\rfunction equal(a, b, tolerance)\r```\r\r```\r/**\r * Produces an identity matrix of some size.\r * @param {uint} size\r * @return {Matrix}\r */\rfunction identity(size)\r```\r\r```\r/**\r * Gets the inverse of a matrix.\r * @param {Matrix} mat\r * @return {Matrix}\r */\rfunction inverse(mat)\r```\r\r```\r/**\r * Gets the determinant of a matrix omitting some column and row.\r * @param {Matrix} mat\r * @param {uint} col\r * @param {uint} row\r * @return {number}\r */\rfunction minor(mat, col, row)\r```\r\r```\r/**\r * Returns the matrix multiplication of a*b.\r * This function works for non-square matrices (and also for transforming\r * vectors by a matrix).\r * For matrix multiplication to work, the # of columns in A must be equal\r * to the # of rows in B.\r * The resulting matrix will have the same number of rows as A and the\r * same number of columns as B.\r * If b was given as a vector, then the result will also be a vector.\r * @param {Matrix} a\r * @param {Matrix|Vector} b\r * @return {Matrix|Vector}\r */\rfunction multiply(a, b)\r```\r\r```\r/**\r * Returns a matrix with a column and row omitted.\r * @param {Matrix} mat\r * @param {uint} col\r * @param {uint} row\r * @return {Matrix}\r */\rfunction omit(mat, col, row)\r```\r\r```\r/**\r * Produces a 2D rotation affine transformation. The direction of the\r * rotation depends upon the coordinate system.\r * @param {number} angle\r * The angle, in radians.\r * @return {Matrix}\r */\rfunction rotate(angle)\r```\r\r```\r/**\r * Produces a 2D scale affine transformation matrix.\r * The matrix is used to transform homogenous coordinates, so it is\r * actually size 3 instead of size 2, despite being used for 2D geometry.\r * @param {(number|Vector)} amount\r * If specified as a number, then it is a uniform scale. Otherwise,\r * it defines a scale by parts.\r * @return {Matrix}\r */\rfunction scale(amount)\r```\r\r```\r/**\r * Gets the size N of a NxN square matrix.\r * @param {Matrix} mat\r * @return {uint}\r */\rfunction size(mat)\r```\r\r```\r/**\r * Produces a 2D translation affine transformation matrix.\r * The matrix is used to transform homogenous coordinates, so it is\r * actually size 3 instead of size 2, despite being used for 2D geometry.\r * @param {Vector} vec\r * @return {Matrix}\r */\rfunction translate(vec)\r```\r\r```\r/**\r * Returns the transpose of a matrix.\r * @param {Matrix} mat\r * @return {Matrix}\r */\rfunction transpose(mat)\r```\r", "authors": "Stephen Lindberg", "roll20userid": 46544, "useroptions": [], "dependencies": {}, "modifies": {}, "conflicts": [] }