gl-matrix
Version:
Javascript Matrix and Vector library for High Performance WebGL apps
1,314 lines (1,298 loc) • 125 kB
TypeScript
declare module "gl-matrix" {
interface IndexedCollection extends Iterable<number> {
readonly length: number;
[index: number]: number;
}
// prettier-ignore
export type mat2 =
| [number, number,
number, number]
| IndexedCollection;
// prettier-ignore
export type mat2d =
| [number, number,
number, number,
number, number]
| IndexedCollection;
// prettier-ignore
export type mat3 =
| [number, number, number,
number, number, number,
number, number, number]
| IndexedCollection;
// prettier-ignore
export type mat4 =
| [number, number, number, number,
number, number, number, number,
number, number, number, number,
number, number, number, number]
| IndexedCollection;
export type quat = [number, number, number, number] | IndexedCollection;
// prettier-ignore
export type quat2 =
| [number, number, number, number,
number, number, number, number]
| IndexedCollection;
export type vec2 = [number, number] | IndexedCollection;
export type vec3 = [number, number, number] | IndexedCollection;
export type vec4 = [number, number, number, number] | IndexedCollection;
// prettier-ignore
export type ReadonlyMat2 =
| readonly [
number, number,
number, number
]
| IndexedCollection;
// prettier-ignore
export type ReadonlyMat2d =
| readonly [
number, number,
number, number,
number, number
]
| IndexedCollection;
// prettier-ignore
export type ReadonlyMat3 =
| readonly [
number, number, number,
number, number, number,
number, number, number
]
| IndexedCollection;
// prettier-ignore
export type ReadonlyMat4 =
| readonly [
number, number, number, number,
number, number, number, number,
number, number, number, number,
number, number, number, number
]
| IndexedCollection;
export type ReadonlyQuat =
| readonly [number, number, number, number]
| IndexedCollection;
export type ReadonlyQuat2 =
| readonly [number, number, number, number, number, number, number, number]
| IndexedCollection;
export type ReadonlyVec2 = readonly [number, number] | IndexedCollection;
export type ReadonlyVec3 = readonly [number, number, number] | IndexedCollection;
export type ReadonlyVec4 =
| readonly [number, number, number, number]
| IndexedCollection;
export namespace glMatrix {
/**
* Symmetric round
* see https://www.npmjs.com/package/round-half-up-symmetric#user-content-detailed-background
*
* @param {Number} a value to round
*/
export function round(a: number): number;
/**
* Sets the type of array used when creating new vectors and matrices
*
* @param {Float32ArrayConstructor | ArrayConstructor} type Array type, such as Float32Array or Array
*/
export function setMatrixArrayType(type: Float32ArrayConstructor | ArrayConstructor): void;
/**
* Convert Degree To Radian
*
* @param {Number} a Angle in Degrees
*/
export function toRadian(a: number): number;
/**
* Convert Radian To Degree
*
* @param {Number} a Angle in Radians
*/
export function toDegree(a: number): number;
/**
* Tests whether or not the arguments have approximately the same value, within an absolute
* or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less
* than or equal to 1.0, and a relative tolerance is used for larger values)
*
* @param {Number} a The first number to test.
* @param {Number} b The second number to test.
* @param {Number} tolerance Absolute or relative tolerance (default glMatrix.EPSILON)
* @returns {Boolean} True if the numbers are approximately equal, false otherwise.
*/
export function equals(a: number, b: number, tolerance?: number): boolean;
/**
* Common utilities
* @module glMatrix
*/
export const EPSILON: 0.000001;
export let ARRAY_TYPE: ArrayConstructor | Float32ArrayConstructor;
export let RANDOM: () => number;
export let ANGLE_ORDER: string;
}
export namespace mat2 {
/**
* 2x2 Matrix
* @module mat2
*/
/**
* Creates a new identity mat2
*
* @returns {mat2} a new 2x2 matrix
*/
export function create(): mat2;
/**
* Creates a new mat2 initialized with values from an existing matrix
*
* @param {ReadonlyMat2} a matrix to clone
* @returns {mat2} a new 2x2 matrix
*/
export function clone(a: ReadonlyMat2): mat2;
/**
* Copy the values from one mat2 to another
*
* @param {mat2} out the receiving matrix
* @param {ReadonlyMat2} a the source matrix
* @returns {mat2} out
*/
export function copy(out: mat2, a: ReadonlyMat2): mat2;
/**
* Set a mat2 to the identity matrix
*
* @param {mat2} out the receiving matrix
* @returns {mat2} out
*/
export function identity(out: mat2): mat2;
/**
* Create a new mat2 with the given values
*
* @param {Number} m00 Component in column 0, row 0 position (index 0)
* @param {Number} m01 Component in column 0, row 1 position (index 1)
* @param {Number} m10 Component in column 1, row 0 position (index 2)
* @param {Number} m11 Component in column 1, row 1 position (index 3)
* @returns {mat2} out A new 2x2 matrix
*/
export function fromValues(m00: number, m01: number, m10: number, m11: number): mat2;
/**
* Set the components of a mat2 to the given values
*
* @param {mat2} out the receiving matrix
* @param {Number} m00 Component in column 0, row 0 position (index 0)
* @param {Number} m01 Component in column 0, row 1 position (index 1)
* @param {Number} m10 Component in column 1, row 0 position (index 2)
* @param {Number} m11 Component in column 1, row 1 position (index 3)
* @returns {mat2} out
*/
export function set(out: mat2, m00: number, m01: number, m10: number, m11: number): mat2;
/**
* Transpose the values of a mat2
*
* @param {mat2} out the receiving matrix
* @param {ReadonlyMat2} a the source matrix
* @returns {mat2} out
*/
export function transpose(out: mat2, a: ReadonlyMat2): mat2;
/**
* Inverts a mat2
*
* @param {mat2} out the receiving matrix
* @param {ReadonlyMat2} a the source matrix
* @returns {mat2 | null} out, or null if source matrix is not invertible
*/
export function invert(out: mat2, a: ReadonlyMat2): mat2 | null;
/**
* Calculates the adjugate of a mat2
*
* @param {mat2} out the receiving matrix
* @param {ReadonlyMat2} a the source matrix
* @returns {mat2} out
*/
export function adjoint(out: mat2, a: ReadonlyMat2): mat2;
/**
* Calculates the determinant of a mat2
*
* @param {ReadonlyMat2} a the source matrix
* @returns {Number} determinant of a
*/
export function determinant(a: ReadonlyMat2): number;
/**
* Multiplies two mat2's
*
* @param {mat2} out the receiving matrix
* @param {ReadonlyMat2} a the first operand
* @param {ReadonlyMat2} b the second operand
* @returns {mat2} out
*/
export function multiply(out: mat2, a: ReadonlyMat2, b: ReadonlyMat2): mat2;
/**
* Rotates a mat2 by the given angle
*
* @param {mat2} out the receiving matrix
* @param {ReadonlyMat2} a the matrix to rotate
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat2} out
*/
export function rotate(out: mat2, a: ReadonlyMat2, rad: number): mat2;
/**
* Scales the mat2 by the dimensions in the given vec2
*
* @param {mat2} out the receiving matrix
* @param {ReadonlyMat2} a the matrix to rotate
* @param {ReadonlyVec2} v the vec2 to scale the matrix by
* @returns {mat2} out
**/
export function scale(out: mat2, a: ReadonlyMat2, v: ReadonlyVec2): mat2;
/**
* Creates a matrix from a given angle
* This is equivalent to (but much faster than):
*
* mat2.identity(dest);
* mat2.rotate(dest, dest, rad);
*
* @param {mat2} out mat2 receiving operation result
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat2} out
*/
export function fromRotation(out: mat2, rad: number): mat2;
/**
* Creates a matrix from a vector scaling
* This is equivalent to (but much faster than):
*
* mat2.identity(dest);
* mat2.scale(dest, dest, vec);
*
* @param {mat2} out mat2 receiving operation result
* @param {ReadonlyVec2} v Scaling vector
* @returns {mat2} out
*/
export function fromScaling(out: mat2, v: ReadonlyVec2): mat2;
/**
* Returns a string representation of a mat2
*
* @param {ReadonlyMat2} a matrix to represent as a string
* @returns {String} string representation of the matrix
*/
export function str(a: ReadonlyMat2): string;
/**
* Returns Frobenius norm of a mat2
*
* @param {ReadonlyMat2} a the matrix to calculate Frobenius norm of
* @returns {Number} Frobenius norm
*/
export function frob(a: ReadonlyMat2): number;
/**
* Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix
* @param {ReadonlyMat2} L the lower triangular matrix
* @param {ReadonlyMat2} D the diagonal matrix
* @param {ReadonlyMat2} U the upper triangular matrix
* @param {ReadonlyMat2} a the input matrix to factorize
*/
export function LDU(L: ReadonlyMat2, D: ReadonlyMat2, U: ReadonlyMat2, a: ReadonlyMat2): ReadonlyMat2[];
/**
* Adds two mat2's
*
* @param {mat2} out the receiving matrix
* @param {ReadonlyMat2} a the first operand
* @param {ReadonlyMat2} b the second operand
* @returns {mat2} out
*/
export function add(out: mat2, a: ReadonlyMat2, b: ReadonlyMat2): mat2;
/**
* Subtracts matrix b from matrix a
*
* @param {mat2} out the receiving matrix
* @param {ReadonlyMat2} a the first operand
* @param {ReadonlyMat2} b the second operand
* @returns {mat2} out
*/
export function subtract(out: mat2, a: ReadonlyMat2, b: ReadonlyMat2): mat2;
/**
* Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
*
* @param {ReadonlyMat2} a The first matrix.
* @param {ReadonlyMat2} b The second matrix.
* @returns {Boolean} True if the matrices are equal, false otherwise.
*/
export function exactEquals(a: ReadonlyMat2, b: ReadonlyMat2): boolean;
/**
* Returns whether or not the matrices have approximately the same elements in the same position.
*
* @param {ReadonlyMat2} a The first matrix.
* @param {ReadonlyMat2} b The second matrix.
* @returns {Boolean} True if the matrices are equal, false otherwise.
*/
export function equals(a: ReadonlyMat2, b: ReadonlyMat2): boolean;
/**
* Multiply each element of the matrix by a scalar.
*
* @param {mat2} out the receiving matrix
* @param {ReadonlyMat2} a the matrix to scale
* @param {Number} b amount to scale the matrix's elements by
* @returns {mat2} out
*/
export function multiplyScalar(out: mat2, a: ReadonlyMat2, b: number): mat2;
/**
* Adds two mat2's after multiplying each element of the second operand by a scalar value.
*
* @param {mat2} out the receiving vector
* @param {ReadonlyMat2} a the first operand
* @param {ReadonlyMat2} b the second operand
* @param {Number} scale the amount to scale b's elements by before adding
* @returns {mat2} out
*/
export function multiplyScalarAndAdd(out: mat2, a: ReadonlyMat2, b: ReadonlyMat2, scale: number): mat2;
/**
* Multiplies two mat2's
*
* @param {mat2} out the receiving matrix
* @param {ReadonlyMat2} a the first operand
* @param {ReadonlyMat2} b the second operand
* @returns {mat2} out
*/
export function mul(out: mat2, a: ReadonlyMat2, b: ReadonlyMat2): mat2;
/**
* Subtracts matrix b from matrix a
*
* @param {mat2} out the receiving matrix
* @param {ReadonlyMat2} a the first operand
* @param {ReadonlyMat2} b the second operand
* @returns {mat2} out
*/
export function sub(out: mat2, a: ReadonlyMat2, b: ReadonlyMat2): mat2;
}
export namespace mat2d {
/**
* 2x3 Matrix
* @module mat2d
* @description
* A mat2d contains six elements defined as:
* <pre>
* [a, b,
* c, d,
* tx, ty]
* </pre>
* This is a short form for the 3x3 matrix:
* <pre>
* [a, b, 0,
* c, d, 0,
* tx, ty, 1]
* </pre>
* The last column is ignored so the array is shorter and operations are faster.
*/
/**
* Creates a new identity mat2d
*
* @returns {mat2d} a new 2x3 matrix
*/
export function create(): mat2d;
/**
* Creates a new mat2d initialized with values from an existing matrix
*
* @param {ReadonlyMat2d} a matrix to clone
* @returns {mat2d} a new 2x3 matrix
*/
export function clone(a: ReadonlyMat2d): mat2d;
/**
* Copy the values from one mat2d to another
*
* @param {mat2d} out the receiving matrix
* @param {ReadonlyMat2d} a the source matrix
* @returns {mat2d} out
*/
export function copy(out: mat2d, a: ReadonlyMat2d): mat2d;
/**
* Set a mat2d to the identity matrix
*
* @param {mat2d} out the receiving matrix
* @returns {mat2d} out
*/
export function identity(out: mat2d): mat2d;
/**
* Create a new mat2d with the given values
*
* @param {Number} a Component A (index 0)
* @param {Number} b Component B (index 1)
* @param {Number} c Component C (index 2)
* @param {Number} d Component D (index 3)
* @param {Number} tx Component TX (index 4)
* @param {Number} ty Component TY (index 5)
* @returns {mat2d} A new mat2d
*/
export function fromValues(a: number, b: number, c: number, d: number, tx: number, ty: number): mat2d;
/**
* Set the components of a mat2d to the given values
*
* @param {mat2d} out the receiving matrix
* @param {Number} a Component A (index 0)
* @param {Number} b Component B (index 1)
* @param {Number} c Component C (index 2)
* @param {Number} d Component D (index 3)
* @param {Number} tx Component TX (index 4)
* @param {Number} ty Component TY (index 5)
* @returns {mat2d} out
*/
export function set(out: mat2d, a: number, b: number, c: number, d: number, tx: number, ty: number): mat2d;
/**
* Inverts a mat2d
*
* @param {mat2d} out the receiving matrix
* @param {ReadonlyMat2d} a the source matrix
* @returns {mat2d | null} out, or null if source matrix is not invertible
*/
export function invert(out: mat2d, a: ReadonlyMat2d): mat2d | null;
/**
* Calculates the determinant of a mat2d
*
* @param {ReadonlyMat2d} a the source matrix
* @returns {Number} determinant of a
*/
export function determinant(a: ReadonlyMat2d): number;
/**
* Multiplies two mat2d's
*
* @param {mat2d} out the receiving matrix
* @param {ReadonlyMat2d} a the first operand
* @param {ReadonlyMat2d} b the second operand
* @returns {mat2d} out
*/
export function multiply(out: mat2d, a: ReadonlyMat2d, b: ReadonlyMat2d): mat2d;
/**
* Rotates a mat2d by the given angle
*
* @param {mat2d} out the receiving matrix
* @param {ReadonlyMat2d} a the matrix to rotate
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat2d} out
*/
export function rotate(out: mat2d, a: ReadonlyMat2d, rad: number): mat2d;
/**
* Scales the mat2d by the dimensions in the given vec2
*
* @param {mat2d} out the receiving matrix
* @param {ReadonlyMat2d} a the matrix to translate
* @param {ReadonlyVec2} v the vec2 to scale the matrix by
* @returns {mat2d} out
**/
export function scale(out: mat2d, a: ReadonlyMat2d, v: ReadonlyVec2): mat2d;
/**
* Translates the mat2d by the dimensions in the given vec2
*
* @param {mat2d} out the receiving matrix
* @param {ReadonlyMat2d} a the matrix to translate
* @param {ReadonlyVec2} v the vec2 to translate the matrix by
* @returns {mat2d} out
**/
export function translate(out: mat2d, a: ReadonlyMat2d, v: ReadonlyVec2): mat2d;
/**
* Creates a matrix from a given angle
* This is equivalent to (but much faster than):
*
* mat2d.identity(dest);
* mat2d.rotate(dest, dest, rad);
*
* @param {mat2d} out mat2d receiving operation result
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat2d} out
*/
export function fromRotation(out: mat2d, rad: number): mat2d;
/**
* Creates a matrix from a vector scaling
* This is equivalent to (but much faster than):
*
* mat2d.identity(dest);
* mat2d.scale(dest, dest, vec);
*
* @param {mat2d} out mat2d receiving operation result
* @param {ReadonlyVec2} v Scaling vector
* @returns {mat2d} out
*/
export function fromScaling(out: mat2d, v: ReadonlyVec2): mat2d;
/**
* Creates a matrix from a vector translation
* This is equivalent to (but much faster than):
*
* mat2d.identity(dest);
* mat2d.translate(dest, dest, vec);
*
* @param {mat2d} out mat2d receiving operation result
* @param {ReadonlyVec2} v Translation vector
* @returns {mat2d} out
*/
export function fromTranslation(out: mat2d, v: ReadonlyVec2): mat2d;
/**
* Returns a string representation of a mat2d
*
* @param {ReadonlyMat2d} a matrix to represent as a string
* @returns {String} string representation of the matrix
*/
export function str(a: ReadonlyMat2d): string;
/**
* Returns Frobenius norm of a mat2d
*
* @param {ReadonlyMat2d} a the matrix to calculate Frobenius norm of
* @returns {Number} Frobenius norm
*/
export function frob(a: ReadonlyMat2d): number;
/**
* Adds two mat2d's
*
* @param {mat2d} out the receiving matrix
* @param {ReadonlyMat2d} a the first operand
* @param {ReadonlyMat2d} b the second operand
* @returns {mat2d} out
*/
export function add(out: mat2d, a: ReadonlyMat2d, b: ReadonlyMat2d): mat2d;
/**
* Subtracts matrix b from matrix a
*
* @param {mat2d} out the receiving matrix
* @param {ReadonlyMat2d} a the first operand
* @param {ReadonlyMat2d} b the second operand
* @returns {mat2d} out
*/
export function subtract(out: mat2d, a: ReadonlyMat2d, b: ReadonlyMat2d): mat2d;
/**
* Multiply each element of the matrix by a scalar.
*
* @param {mat2d} out the receiving matrix
* @param {ReadonlyMat2d} a the matrix to scale
* @param {Number} b amount to scale the matrix's elements by
* @returns {mat2d} out
*/
export function multiplyScalar(out: mat2d, a: ReadonlyMat2d, b: number): mat2d;
/**
* Adds two mat2d's after multiplying each element of the second operand by a scalar value.
*
* @param {mat2d} out the receiving vector
* @param {ReadonlyMat2d} a the first operand
* @param {ReadonlyMat2d} b the second operand
* @param {Number} scale the amount to scale b's elements by before adding
* @returns {mat2d} out
*/
export function multiplyScalarAndAdd(out: mat2d, a: ReadonlyMat2d, b: ReadonlyMat2d, scale: number): mat2d;
/**
* Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
*
* @param {ReadonlyMat2d} a The first matrix.
* @param {ReadonlyMat2d} b The second matrix.
* @returns {Boolean} True if the matrices are equal, false otherwise.
*/
export function exactEquals(a: ReadonlyMat2d, b: ReadonlyMat2d): boolean;
/**
* Returns whether or not the matrices have approximately the same elements in the same position.
*
* @param {ReadonlyMat2d} a The first matrix.
* @param {ReadonlyMat2d} b The second matrix.
* @returns {Boolean} True if the matrices are equal, false otherwise.
*/
export function equals(a: ReadonlyMat2d, b: ReadonlyMat2d): boolean;
/**
* Multiplies two mat2d's
*
* @param {mat2d} out the receiving matrix
* @param {ReadonlyMat2d} a the first operand
* @param {ReadonlyMat2d} b the second operand
* @returns {mat2d} out
*/
export function mul(out: mat2d, a: ReadonlyMat2d, b: ReadonlyMat2d): mat2d;
/**
* Subtracts matrix b from matrix a
*
* @param {mat2d} out the receiving matrix
* @param {ReadonlyMat2d} a the first operand
* @param {ReadonlyMat2d} b the second operand
* @returns {mat2d} out
*/
export function sub(out: mat2d, a: ReadonlyMat2d, b: ReadonlyMat2d): mat2d;
}
export namespace mat3 {
/**
* 3x3 Matrix
* @module mat3
*/
/**
* Creates a new identity mat3
*
* @returns {mat3} a new 3x3 matrix
*/
export function create(): mat3;
/**
* Copies the upper-left 3x3 values into the given mat3.
*
* @param {mat3} out the receiving 3x3 matrix
* @param {ReadonlyMat4} a the source 4x4 matrix
* @returns {mat3} out
*/
export function fromMat4(out: mat3, a: ReadonlyMat4): mat3;
/**
* Creates a new mat3 initialized with values from an existing matrix
*
* @param {ReadonlyMat3} a matrix to clone
* @returns {mat3} a new 3x3 matrix
*/
export function clone(a: ReadonlyMat3): mat3;
/**
* Copy the values from one mat3 to another
*
* @param {mat3} out the receiving matrix
* @param {ReadonlyMat3} a the source matrix
* @returns {mat3} out
*/
export function copy(out: mat3, a: ReadonlyMat3): mat3;
/**
* Create a new mat3 with the given values
*
* @param {Number} m00 Component in column 0, row 0 position (index 0)
* @param {Number} m01 Component in column 0, row 1 position (index 1)
* @param {Number} m02 Component in column 0, row 2 position (index 2)
* @param {Number} m10 Component in column 1, row 0 position (index 3)
* @param {Number} m11 Component in column 1, row 1 position (index 4)
* @param {Number} m12 Component in column 1, row 2 position (index 5)
* @param {Number} m20 Component in column 2, row 0 position (index 6)
* @param {Number} m21 Component in column 2, row 1 position (index 7)
* @param {Number} m22 Component in column 2, row 2 position (index 8)
* @returns {mat3} A new mat3
*/
export function fromValues(m00: number, m01: number, m02: number, m10: number, m11: number, m12: number, m20: number, m21: number, m22: number): mat3;
/**
* Set the components of a mat3 to the given values
*
* @param {mat3} out the receiving matrix
* @param {Number} m00 Component in column 0, row 0 position (index 0)
* @param {Number} m01 Component in column 0, row 1 position (index 1)
* @param {Number} m02 Component in column 0, row 2 position (index 2)
* @param {Number} m10 Component in column 1, row 0 position (index 3)
* @param {Number} m11 Component in column 1, row 1 position (index 4)
* @param {Number} m12 Component in column 1, row 2 position (index 5)
* @param {Number} m20 Component in column 2, row 0 position (index 6)
* @param {Number} m21 Component in column 2, row 1 position (index 7)
* @param {Number} m22 Component in column 2, row 2 position (index 8)
* @returns {mat3} out
*/
export function set(out: mat3, m00: number, m01: number, m02: number, m10: number, m11: number, m12: number, m20: number, m21: number, m22: number): mat3;
/**
* Set a mat3 to the identity matrix
*
* @param {mat3} out the receiving matrix
* @returns {mat3} out
*/
export function identity(out: mat3): mat3;
/**
* Transpose the values of a mat3
*
* @param {mat3} out the receiving matrix
* @param {ReadonlyMat3} a the source matrix
* @returns {mat3} out
*/
export function transpose(out: mat3, a: ReadonlyMat3): mat3;
/**
* Inverts a mat3
*
* @param {mat3} out the receiving matrix
* @param {ReadonlyMat3} a the source matrix
* @returns {mat3 | null} out, or null if source matrix is not invertible
*/
export function invert(out: mat3, a: ReadonlyMat3): mat3 | null;
/**
* Calculates the adjugate of a mat3
*
* @param {mat3} out the receiving matrix
* @param {ReadonlyMat3} a the source matrix
* @returns {mat3} out
*/
export function adjoint(out: mat3, a: ReadonlyMat3): mat3;
/**
* Calculates the determinant of a mat3
*
* @param {ReadonlyMat3} a the source matrix
* @returns {Number} determinant of a
*/
export function determinant(a: ReadonlyMat3): number;
/**
* Multiplies two mat3's
*
* @param {mat3} out the receiving matrix
* @param {ReadonlyMat3} a the first operand
* @param {ReadonlyMat3} b the second operand
* @returns {mat3} out
*/
export function multiply(out: mat3, a: ReadonlyMat3, b: ReadonlyMat3): mat3;
/**
* Translate a mat3 by the given vector
*
* @param {mat3} out the receiving matrix
* @param {ReadonlyMat3} a the matrix to translate
* @param {ReadonlyVec2} v vector to translate by
* @returns {mat3} out
*/
export function translate(out: mat3, a: ReadonlyMat3, v: ReadonlyVec2): mat3;
/**
* Rotates a mat3 by the given angle
*
* @param {mat3} out the receiving matrix
* @param {ReadonlyMat3} a the matrix to rotate
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat3} out
*/
export function rotate(out: mat3, a: ReadonlyMat3, rad: number): mat3;
/**
* Scales the mat3 by the dimensions in the given vec2
*
* @param {mat3} out the receiving matrix
* @param {ReadonlyMat3} a the matrix to scale
* @param {ReadonlyVec2} v the vec2 to scale the matrix by
* @returns {mat3} out
**/
export function scale(out: mat3, a: ReadonlyMat3, v: ReadonlyVec2): mat3;
/**
* Creates a matrix from a vector translation
* This is equivalent to (but much faster than):
*
* mat3.identity(dest);
* mat3.translate(dest, dest, vec);
*
* @param {mat3} out mat3 receiving operation result
* @param {ReadonlyVec2} v Translation vector
* @returns {mat3} out
*/
export function fromTranslation(out: mat3, v: ReadonlyVec2): mat3;
/**
* Creates a matrix from a given angle
* This is equivalent to (but much faster than):
*
* mat3.identity(dest);
* mat3.rotate(dest, dest, rad);
*
* @param {mat3} out mat3 receiving operation result
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat3} out
*/
export function fromRotation(out: mat3, rad: number): mat3;
/**
* Creates a matrix from a vector scaling
* This is equivalent to (but much faster than):
*
* mat3.identity(dest);
* mat3.scale(dest, dest, vec);
*
* @param {mat3} out mat3 receiving operation result
* @param {ReadonlyVec2} v Scaling vector
* @returns {mat3} out
*/
export function fromScaling(out: mat3, v: ReadonlyVec2): mat3;
/**
* Copies the values from a mat2d into a mat3
*
* @param {mat3} out the receiving matrix
* @param {ReadonlyMat2d} a the matrix to copy
* @returns {mat3} out
**/
export function fromMat2d(out: mat3, a: ReadonlyMat2d): mat3;
/**
* Calculates a 3x3 matrix from the given quaternion
*
* @param {mat3} out mat3 receiving operation result
* @param {ReadonlyQuat} q Quaternion to create matrix from
*
* @returns {mat3} out
*/
export function fromQuat(out: mat3, q: ReadonlyQuat): mat3;
/**
* Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix
*
* @param {mat3} out mat3 receiving operation result
* @param {ReadonlyMat4} a Mat4 to derive the normal matrix from
*
* @returns {mat3} out
*/
export function normalFromMat4(out: mat3, a: ReadonlyMat4): mat3;
/**
* Generates a 2D projection matrix with the given bounds
*
* @param {mat3} out mat3 frustum matrix will be written into
* @param {number} width Width of your gl context
* @param {number} height Height of gl context
* @returns {mat3} out
*/
export function projection(out: mat3, width: number, height: number): mat3;
/**
* Returns a string representation of a mat3
*
* @param {ReadonlyMat3} a matrix to represent as a string
* @returns {String} string representation of the matrix
*/
export function str(a: ReadonlyMat3): string;
/**
* Returns Frobenius norm of a mat3
*
* @param {ReadonlyMat3} a the matrix to calculate Frobenius norm of
* @returns {Number} Frobenius norm
*/
export function frob(a: ReadonlyMat3): number;
/**
* Adds two mat3's
*
* @param {mat3} out the receiving matrix
* @param {ReadonlyMat3} a the first operand
* @param {ReadonlyMat3} b the second operand
* @returns {mat3} out
*/
export function add(out: mat3, a: ReadonlyMat3, b: ReadonlyMat3): mat3;
/**
* Subtracts matrix b from matrix a
*
* @param {mat3} out the receiving matrix
* @param {ReadonlyMat3} a the first operand
* @param {ReadonlyMat3} b the second operand
* @returns {mat3} out
*/
export function subtract(out: mat3, a: ReadonlyMat3, b: ReadonlyMat3): mat3;
/**
* Multiply each element of the matrix by a scalar.
*
* @param {mat3} out the receiving matrix
* @param {ReadonlyMat3} a the matrix to scale
* @param {Number} b amount to scale the matrix's elements by
* @returns {mat3} out
*/
export function multiplyScalar(out: mat3, a: ReadonlyMat3, b: number): mat3;
/**
* Adds two mat3's after multiplying each element of the second operand by a scalar value.
*
* @param {mat3} out the receiving vector
* @param {ReadonlyMat3} a the first operand
* @param {ReadonlyMat3} b the second operand
* @param {Number} scale the amount to scale b's elements by before adding
* @returns {mat3} out
*/
export function multiplyScalarAndAdd(out: mat3, a: ReadonlyMat3, b: ReadonlyMat3, scale: number): mat3;
/**
* Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
*
* @param {ReadonlyMat3} a The first matrix.
* @param {ReadonlyMat3} b The second matrix.
* @returns {Boolean} True if the matrices are equal, false otherwise.
*/
export function exactEquals(a: ReadonlyMat3, b: ReadonlyMat3): boolean;
/**
* Returns whether or not the matrices have approximately the same elements in the same position.
*
* @param {ReadonlyMat3} a The first matrix.
* @param {ReadonlyMat3} b The second matrix.
* @returns {Boolean} True if the matrices are equal, false otherwise.
*/
export function equals(a: ReadonlyMat3, b: ReadonlyMat3): boolean;
/**
* Multiplies two mat3's
*
* @param {mat3} out the receiving matrix
* @param {ReadonlyMat3} a the first operand
* @param {ReadonlyMat3} b the second operand
* @returns {mat3} out
*/
export function mul(out: mat3, a: ReadonlyMat3, b: ReadonlyMat3): mat3;
/**
* Subtracts matrix b from matrix a
*
* @param {mat3} out the receiving matrix
* @param {ReadonlyMat3} a the first operand
* @param {ReadonlyMat3} b the second operand
* @returns {mat3} out
*/
export function sub(out: mat3, a: ReadonlyMat3, b: ReadonlyMat3): mat3;
}
export namespace mat4 {
/**
* 4x4 Matrix<br>Format: column-major, when typed out it looks like row-major<br>The matrices are being post multiplied.
* @module mat4
*/
/**
* Creates a new identity mat4
*
* @returns {mat4} a new 4x4 matrix
*/
export function create(): mat4;
/**
* Creates a new mat4 initialized with values from an existing matrix
*
* @param {ReadonlyMat4} a matrix to clone
* @returns {mat4} a new 4x4 matrix
*/
export function clone(a: ReadonlyMat4): mat4;
/**
* Copy the values from one mat4 to another
*
* @param {mat4} out the receiving matrix
* @param {ReadonlyMat4} a the source matrix
* @returns {mat4} out
*/
export function copy(out: mat4, a: ReadonlyMat4): mat4;
/**
* Create a new mat4 with the given values
*
* @param {Number} m00 Component in column 0, row 0 position (index 0)
* @param {Number} m01 Component in column 0, row 1 position (index 1)
* @param {Number} m02 Component in column 0, row 2 position (index 2)
* @param {Number} m03 Component in column 0, row 3 position (index 3)
* @param {Number} m10 Component in column 1, row 0 position (index 4)
* @param {Number} m11 Component in column 1, row 1 position (index 5)
* @param {Number} m12 Component in column 1, row 2 position (index 6)
* @param {Number} m13 Component in column 1, row 3 position (index 7)
* @param {Number} m20 Component in column 2, row 0 position (index 8)
* @param {Number} m21 Component in column 2, row 1 position (index 9)
* @param {Number} m22 Component in column 2, row 2 position (index 10)
* @param {Number} m23 Component in column 2, row 3 position (index 11)
* @param {Number} m30 Component in column 3, row 0 position (index 12)
* @param {Number} m31 Component in column 3, row 1 position (index 13)
* @param {Number} m32 Component in column 3, row 2 position (index 14)
* @param {Number} m33 Component in column 3, row 3 position (index 15)
* @returns {mat4} A new mat4
*/
export function fromValues(m00: number, m01: number, m02: number, m03: number, m10: number, m11: number, m12: number, m13: number, m20: number, m21: number, m22: number, m23: number, m30: number, m31: number, m32: number, m33: number): mat4;
/**
* Set the components of a mat4 to the given values
*
* @param {mat4} out the receiving matrix
* @param {Number} m00 Component in column 0, row 0 position (index 0)
* @param {Number} m01 Component in column 0, row 1 position (index 1)
* @param {Number} m02 Component in column 0, row 2 position (index 2)
* @param {Number} m03 Component in column 0, row 3 position (index 3)
* @param {Number} m10 Component in column 1, row 0 position (index 4)
* @param {Number} m11 Component in column 1, row 1 position (index 5)
* @param {Number} m12 Component in column 1, row 2 position (index 6)
* @param {Number} m13 Component in column 1, row 3 position (index 7)
* @param {Number} m20 Component in column 2, row 0 position (index 8)
* @param {Number} m21 Component in column 2, row 1 position (index 9)
* @param {Number} m22 Component in column 2, row 2 position (index 10)
* @param {Number} m23 Component in column 2, row 3 position (index 11)
* @param {Number} m30 Component in column 3, row 0 position (index 12)
* @param {Number} m31 Component in column 3, row 1 position (index 13)
* @param {Number} m32 Component in column 3, row 2 position (index 14)
* @param {Number} m33 Component in column 3, row 3 position (index 15)
* @returns {mat4} out
*/
export function set(out: mat4, m00: number, m01: number, m02: number, m03: number, m10: number, m11: number, m12: number, m13: number, m20: number, m21: number, m22: number, m23: number, m30: number, m31: number, m32: number, m33: number): mat4;
/**
* Set a mat4 to the identity matrix
*
* @param {mat4} out the receiving matrix
* @returns {mat4} out
*/
export function identity(out: mat4): mat4;
/**
* Transpose the values of a mat4
*
* @param {mat4} out the receiving matrix
* @param {ReadonlyMat4} a the source matrix
* @returns {mat4} out
*/
export function transpose(out: mat4, a: ReadonlyMat4): mat4;
/**
* Inverts a mat4
*
* @param {mat4} out the receiving matrix
* @param {ReadonlyMat4} a the source matrix
* @returns {mat4 | null} out, or null if source matrix is not invertible
*/
export function invert(out: mat4, a: ReadonlyMat4): mat4 | null;
/**
* Calculates the adjugate of a mat4
*
* @param {mat4} out the receiving matrix
* @param {ReadonlyMat4} a the source matrix
* @returns {mat4} out
*/
export function adjoint(out: mat4, a: ReadonlyMat4): mat4;
/**
* Calculates the determinant of a mat4
*
* @param {ReadonlyMat4} a the source matrix
* @returns {Number} determinant of a
*/
export function determinant(a: ReadonlyMat4): number;
/**
* Multiplies two mat4s
*
* @param {mat4} out the receiving matrix
* @param {ReadonlyMat4} a the first operand
* @param {ReadonlyMat4} b the second operand
* @returns {mat4} out
*/
export function multiply(out: mat4, a: ReadonlyMat4, b: ReadonlyMat4): mat4;
/**
* Translate a mat4 by the given vector
*
* @param {mat4} out the receiving matrix
* @param {ReadonlyMat4} a the matrix to translate
* @param {ReadonlyVec3} v vector to translate by
* @returns {mat4} out
*/
export function translate(out: mat4, a: ReadonlyMat4, v: ReadonlyVec3): mat4;
/**
* Scales the mat4 by the dimensions in the given vec3 not using vectorization
*
* @param {mat4} out the receiving matrix
* @param {ReadonlyMat4} a the matrix to scale
* @param {ReadonlyVec3} v the vec3 to scale the matrix by
* @returns {mat4} out
**/
export function scale(out: mat4, a: ReadonlyMat4, v: ReadonlyVec3): mat4;
/**
* Rotates a mat4 by the given angle around the given axis
*
* @param {mat4} out the receiving matrix
* @param {ReadonlyMat4} a the matrix to rotate
* @param {Number} rad the angle to rotate the matrix by
* @param {ReadonlyVec3} axis the axis to rotate around
* @returns {mat4} out
*/
export function rotate(out: mat4, a: ReadonlyMat4, rad: number, axis: ReadonlyVec3): mat4;
/**
* Rotates a matrix by the given angle around the X axis
*
* @param {mat4} out the receiving matrix
* @param {ReadonlyMat4} a the matrix to rotate
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat4} out
*/
export function rotateX(out: mat4, a: ReadonlyMat4, rad: number): mat4;
/**
* Rotates a matrix by the given angle around the Y axis
*
* @param {mat4} out the receiving matrix
* @param {ReadonlyMat4} a the matrix to rotate
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat4} out
*/
export function rotateY(out: mat4, a: ReadonlyMat4, rad: number): mat4;
/**
* Rotates a matrix by the given angle around the Z axis
*
* @param {mat4} out the receiving matrix
* @param {ReadonlyMat4} a the matrix to rotate
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat4} out
*/
export function rotateZ(out: mat4, a: ReadonlyMat4, rad: number): mat4;
/**
* Creates a matrix from a vector translation
* This is equivalent to (but much faster than):
*
* mat4.identity(dest);
* mat4.translate(dest, dest, vec);
*
* @param {mat4} out mat4 receiving operation result
* @param {ReadonlyVec3} v Translation vector
* @returns {mat4} out
*/
export function fromTranslation(out: mat4, v: ReadonlyVec3): mat4;
/**
* Creates a matrix from a vector scaling
* This is equivalent to (but much faster than):
*
* mat4.identity(dest);
* mat4.scale(dest, dest, vec);
*
* @param {mat4} out mat4 receiving operation result
* @param {ReadonlyVec3} v Scaling vector
* @returns {mat4} out
*/
export function fromScaling(out: mat4, v: ReadonlyVec3): mat4;
/**
* Creates a matrix from a given angle around a given axis
* This is equivalent to (but much faster than):
*
* mat4.identity(dest);
* mat4.rotate(dest, dest, rad, axis);
*
* @param {mat4} out mat4 receiving operation result
* @param {Number} rad the angle to rotate the matrix by
* @param {ReadonlyVec3} axis the axis to rotate around
* @returns {mat4} out
*/
export function fromRotation(out: mat4, rad: number, axis: ReadonlyVec3): mat4;
/**
* Creates a matrix from the given angle around the X axis
* This is equivalent to (but much faster than):
*
* mat4.identity(dest);
* mat4.rotateX(dest, dest, rad);
*
* @param {mat4} out mat4 receiving operation result
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat4} out
*/
export function fromXRotation(out: mat4, rad: number): mat4;
/**
* Creates a matrix from the given angle around the Y axis
* This is equivalent to (but much faster than):
*
* mat4.identity(dest);
* mat4.rotateY(dest, dest, rad);
*
* @param {mat4} out mat4 receiving operation result
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat4} out
*/
export function fromYRotation(out: mat4, rad: number): mat4;
/**
* Creates a matrix from the given angle around the Z axis
* This is equivalent to (but much faster than):
*
* mat4.identity(dest);
* mat4.rotateZ(dest, dest, rad);
*
* @param {mat4} out mat4 receiving operation result
* @param {Number} rad the angle to rotate the matrix by
* @returns {mat4} out
*/
export function fromZRotation(out: mat4, rad: number): mat4;
/**
* Creates a matrix from a quaternion rotation and vector translation
* This is equivalent to (but much faster than):
*
* mat4.identity(dest);
* mat4.translate(dest, dest, vec);
* let quatMat = mat4.create();
* mat4.fromQuat(quatMat, quat);
* mat4.multiply(dest, dest, quatMat);
*
* @param {mat4} out mat4 receiving operation result
* @param {quat} q Rotation quaternion
* @param {ReadonlyVec3} v Translation vector
* @returns {mat4} out
*/
export function fromRotationTranslation(out: mat4, q: quat, v: ReadonlyVec3): mat4;
/**
* Creates a new mat4 from a dual quat.
*
* @param {mat4} out Matrix
* @param {ReadonlyQuat2} a Dual Quaternion
* @returns {mat4} mat4 receiving operation result
*/
export function fromQuat2(out: mat4, a: ReadonlyQuat2): mat4;
/**
* Returns the translation vector component of a transformation
* matrix. If a matrix is built with fromRotationTranslation,
* the returned vector will be the same as the translation vector
* originally supplied.
* @param {vec3} out Vector to receive translation component
* @param {ReadonlyMat4} mat Matrix to be decomposed (input)
* @return {vec3} out
*/
export function getTranslation(out: vec3, mat: ReadonlyMat4): vec3;
/**
* Returns the scaling factor component of a transformation
* matrix. If a matrix is built with fromRotationTranslationScale
* with a normalized Quaternion parameter, the returned vector will be
* the same as the scaling vector
* originally supplied.
* @param {vec3} out Vector to receive scaling factor component
* @param {ReadonlyMat4} mat Matrix to be decomposed (input)
* @return {vec3} out
*/
export function getScaling(out: vec3, mat: ReadonlyMat4): vec3;
/**
* Returns a quaternion representing the rotational component
* of a transformation matrix. If a matrix is built with
* fromRotationTranslation, the returned quaternion will be the
* same as the quaternion originally supplied.
* @param {quat} out Quaternion to receive the rotation component
* @param {ReadonlyMat4} mat Matrix to be decomposed (input)
* @return {quat} out
*/
export function getRotation(out: quat, mat: ReadonlyMat4): quat;
/**
* Decomposes a transformation matrix into its rotation, translation
* and scale components. Returns only the rotation component
* @param {quat} out_r Quaternion to receive the rotation component
* @param {vec3} out_t Vector to receive the translation vector
* @param {vec3} out_s Vector to receive the scaling factor
* @param {ReadonlyMat4} mat Matrix to be decomposed (input)
* @returns {quat} out_r
*/
export function decompose(out_r: quat, out_t: vec3, out_s: vec3, mat: ReadonlyMat4): quat;
/**
* Creates a matrix from a quaternion rotation, vector translation and vector scale
* This is equivalent to (but much faster than):
*
* mat4.identity(dest);
* mat4.translate(dest, dest, vec);
* let quatMat = mat4.create();
* mat4.fromQuat(quatMat, quat);
* mat4.multiply(dest, dest, quatMat);
* mat4.scale(dest, dest, scale)
*
* @param {mat4} out mat4 receiving operation result
* @param {quat} q Rotation quaternion
* @param {ReadonlyVec3} v Translation vector
* @param {ReadonlyVec3} s Scaling vector
* @returns {mat4} out
*/
export function fromRotationTranslationScale(out: mat4, q: quat, v: ReadonlyVec3, s: ReadonlyVec3): mat4;
/**
* Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin
* This is equivalent to (but much faster than):
*
* mat4.identity(dest);
* mat4.translate(dest, dest, vec);
* mat4.translate(dest, dest, origin);
* let quatMat = mat4.create();
* mat4.fromQuat(quatMat, quat);
* mat4.multiply(dest, dest, quatMat);
* mat4.scale(dest, dest, scale)
* mat4.translate(dest, dest, negativeOrigin);
*
* @param {mat4} out mat4 receiving operation result
* @param {quat} q Rotation quaternion
* @param {ReadonlyVec3} v Translation vector
* @param {ReadonlyVec3} s Scaling vector
* @param {ReadonlyVec3} o The origin vector around which to scale and rotate
* @returns {mat4} out
*/
export function fromRotationTranslationScaleOrigin(out: mat4, q: quat, v: ReadonlyVec3, s: ReadonlyVec3, o: ReadonlyVec3): mat4;
/**
* Calculates a 4x4 matrix from the given quaternion
*
* @param {mat4} out mat4 receiving operation result
* @param {ReadonlyQuat} q Quaternion to create matrix from
*
* @returns {mat4} out
*/
export function fromQuat(out: mat4, q: ReadonlyQuat): mat4;
/**
* Generates a frustum matrix with the given bounds
*
* @param {mat4} out mat4 frustum matrix will be written into
* @param {Number} left Left bound of the frustum
* @param {Number} right Right bound of the frustum
* @param {Number} bottom Bottom bound of the frustum
* @param {Number} top Top bound of the frustum
* @param {Number} near Near bound of the frustum
* @param {Number} far Far bound of the frustum
* @returns {mat4} out
*/
export function frustum(out: mat4, left: number, right: number, bottom: number, top: number, near: number, far: number): mat4;
/**
* Generates a perspective projection matrix with the given bounds.
* The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1],
* which matches WebGL/OpenGL's clip volume.
* Passing null/undefined/no value for far will generate infinite projection matrix.
*
* @param {mat4} out mat4 frustum matrix will be written into
* @param {number} fovy Vertical field of view in radians
* @param {number} aspect Aspect ratio. typically viewport width/height
* @param {number} near Near bound of the frustum
* @param {number} far Far bound of the frustum, can be null or Infinity
* @returns {mat4} out
*/
export function perspectiveNO(out: mat4, fovy: number, aspect: number, near: number, far: number): mat4;
/**
* Generates a perspective projection matrix suitable for WebGPU with the given bounds.
* The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1],
* which matches WebGPU/Vulkan/DirectX/Metal's clip volume.
* Passing null/undefined/no value for far will generate infinite projection matrix.
*
* @param {mat4} out mat4 frustum matrix will be written into
* @param {number} fovy Vertical field of view in radians
* @param {number} aspect Aspect ratio. typically viewport width/height
* @param {number} near Near bound of the frustum
* @param {number} far Far bound of the frustum, can be null or Infinity
* @returns {mat4} out
*/
export function perspectiveZO(out: mat4, fovy: number, aspect: number,