import { mat2 } from './mat2'; import { vec2 } from './vec2'; /** * Represents 2D affine transformation (translation, rotation, scaling, skewing), omitting the redundant third row which is always set to `[0, 0, 1]`. The order of six elements is the same as CSS transform matrix. * * A mat2d contains six elements defined as: * ```ts * [a, b, * c, d, * tx, ty] * ``` * This is a short form for the {@link mat3}: * ```ts * [xx, xy, 0, * yx, yy, 0, * tx, ty, 1] * ``` * The last column is ignored so the array is shorter and operations are faster. * * @category Types * @see https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix */ export type mat2d = readonly [ a: number, b: number, c: number, d: number, tx: number, ty: number ]; /** * Functions for {@link mat2d}, 2D affine transformation (translation, rotation, scaling, skewing). * @see https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix * @category Modules */ export declare namespace mat2d { /** * Mutable version of {@link mat2d} * @category Types */ type Mutable = [ a: number, b: number, c: number, d: number, tx: number, ty: number ]; /** * Creates a new matrix from given elements * @category Generators */ function of(a: number, b: number, c: number, d: number, tx: number, ty: number): mat2d; /** * Creates a mutable clone of given mat2d * @category Generators */ function clone(a: mat2d): Mutable; /** * The identity matrix of mat2d * ```ts * [1, 0, * 0, 1, * 0, 0] * ``` * @category Constants * * @shorthands * - {@link id} * - {@link ident} */ const identity: mat2d; /** * Alias for {@link identity} * @category Shorthands */ const I: mat2d; /** * Alias for {@link identity} * @category Shorthands */ const id: mat2d; /** * Alias for {@link identity} * @category Shorthands */ const ident: mat2d; /** * The mat2d matrix filled with zeros. * @category Constants */ const zero: mat2d; /** * Inverts a mat2d * * @shorthands * - {@link inv} */ function invert(a: mat2d): mat2d | null; /** * Alias for {@link invert} * @category Shorthands */ const inv: typeof invert; /** * Calculates the determinant of a mat2d * * @shorthands * - {@link det} */ function determinant(a: mat2d): number; /** * Alias for {@link determinant} * @category Shorthands */ const det: typeof determinant; /** * Multiplies given mat2d's * * @shorthands * - {@link mul} */ function multiply(...ms: mat2d[]): mat2d; /** * Alias for {@link multiply} * @category Shorthands */ const mul: typeof multiply; /** * Rotates a mat2d by the given angle */ function rotate(m: mat2d, deg: number, origin?: vec2): mat2d; /** * Scales the mat2d by the dimensions in the given vec2 **/ function scale(m: mat2d, s: vec2, origin?: vec2): mat2d; /** * Translates the mat2d by the dimensions in the given vec2 **/ function translate(m: mat2d, v: vec2): mat2d; /** * Applies a transformation around a given origin point */ function pivot(m: mat2d, origin: vec2): mat2d; /** * Applies skew to the mat2d by the given angles in degrees * @see https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/skew */ function skew(m: mat2d, deg: vec2, origin: vec2): mat2d; /** * Creates a matrix from a given angle. * @param deg The angle to rotate the matrix by, in degrees * @category Generators * * @shorthands * - {@link rotation} */ function fromRotation(deg: number, origin?: vec2): mat2d; /** * Alias for {@link fromRotation} * @category Shorthands */ const rotation: typeof fromRotation; /** * Creates a matrix from a vector scaling * @category Generators * * @shorthands * - {@link scaling} */ function fromScaling(v: vec2 | number, origin?: vec2): mat2d; /** * Alias for {@link fromScaling} * @category Shorthands */ const scaling: typeof fromScaling; /** * Creates a matrix from a vector translation * @category Generators * * @shorthands * - {@link translation} */ function fromTranslation(v: vec2 | number): mat2d; /** * Alias for {@link fromTranslation} * @category Shorthands */ const translation: typeof fromTranslation; /** * Creates a matrix from a vector skew * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/skew * @category Generators * * @shorthands * - {@link skewing} */ function fromSkew(deg: vec2, origin?: vec2): mat2d; /** * Alias for {@link fromSkew} * @category Shorthands */ const skewing: typeof fromSkew; /** * Computes a fixed point of the given matrix. * @param m The matrix to compute a fixed point of * @returns The fixed point of the given matrix, or null if the matrix is not invertible */ function fixedPoint(m: mat2d): vec2 | null; /** * Returns Frobenius norm of a mat2d */ function frob(a: mat2d): number; /** * Adds given mat2d's */ function add(...ms: mat2d[]): mat2d; /** * Subtracts matrix b from matrix a * * @shorthands * - {@link sub} */ function subtract(...ms: mat2d[]): mat2d; /** * Alias for {@link subtract} * @category Shorthands */ const sub: typeof subtract; /** * Subtracts b from a */ function delta(a: mat2d, b: mat2d): mat2d; /** * Multiply each element of the matrix by a scalar. */ function multiplyScalar(a: mat2d, s: number): mat2d; /** Adds given mat2d's after multiplying each element of the second operand by a scalar value. */ function multiplyScalarAndAdd(a: mat2d, b: mat2d, scale: number): mat2d; /** * Constrain each element to lie between min and max * @see https://thebookofshaders.com/glossary/?search=clamp */ function clamp(a: mat2d, min: number, max: number): mat2d; /** * Clamps each element to [0, 1] */ function clamp01(a: mat2d): mat2d; /** * Clamps each element to [-1, 1] */ function clamp11(a: mat2d): mat2d; /** * Creates a matrix that maps from the given points to another. If the third point is not given, the orthogonal matrix is returned. * ```text * f-s f'-s' * |/ ---M--> |/ * t t' * ``` * @category Generators * @param first a pair of first point * @param second a pair of second point * @param third a pair of third point */ function fromPoints(first: [vec2, vec2], second: [vec2, vec2], third?: [vec2, vec2]): mat2d | null; /** * Creates a matrix from given translation, rotation, and scaling. The order of the transformations is translation, rotation, and scaling, like most of the graphics software. * @param t Translation vector * @param r Rotation angle in degrees * @param s Scaling vector or a number * @returns The matrix that represents the transformation * * @shorthands * - {@link trs} */ function fromTRS(t?: vec2 | null, r?: number | null, s?: vec2 | number | null): mat2d; /** * Alias for {@link fromTRS} * @category Shorthands */ const trs: typeof fromTRS; /** * Copies a the values from {@link mat2}, assuming the translation component is `[0, 0]` * @param m The matrix to convert * @returns The newly created matrix * @category Generators */ function fromMat2(m: mat2): mat2d; /** * Returns whether or not the matrices have exactly the same elements in the same position (when compared with `===`) * * @shorthands * - {@link eq} */ function exactEquals(a: mat2d, b: mat2d): boolean; /** * Alias for {@link exactEquals} * @category Shorthands */ const eq: typeof exactEquals; /** * Returns whether or not the matrices have approximately the same elements in the same position. * * @shorthands * - {@link approx} * - {@link equals} */ function approxEquals(a: mat2d, b: mat2d): boolean; /** * Alias for {@link approxEquals} * @category Shorthands */ const approx: typeof approxEquals; /** * Alias for {@link approxEquals}. This is provided for compatibility with gl-matrix. * @category Shorthands * @deprecated Use {@link approxEquals} instead */ const equals: typeof approxEquals; /** * Returns a string representation of a mat2d * @param m matrix to represent as a string * @param fractionDigits number of digits to appear after the decimal point */ const toString: (m: mat2d, fractionDigits?: number) => string; } //# sourceMappingURL=mat2d.d.ts.map