export declare namespace vec { /** * @fileinfo * * Mafs' internal linear algebra functions. * * A lot of the code here was adapted from [vec-la](https://github.com/francisrstokes/vec-la) 1.4.0, * which was released under the MIT license. */ /** * A two-dimensional vector */ type Vector2 = [x: number, y: number]; /** * A 2x3 representation of a 3x3 matrix used to transform and translate a * two-dimensional vector. */ type Matrix = [number, number, number, number, number, number]; /** * Add two vectors */ function add(v: Vector2, v2: Vector2): Vector2; /** * Subtract one vector from another */ function sub(v: Vector2, v2: Vector2): Vector2; /** * Get the magnitude of a vector */ function mag(v: Vector2): number; /** * Get the normal vector of a vector */ function normal(v: Vector2): Vector2; /** * Linear interpolation between two vectors */ function lerp(v1: Vector2, v2: Vector2, t: number): Vector2; function withMag(v: Vector2, m: number): Vector2; /** * Return a normalized version of a vector */ function normalize(v: Vector2): Vector2; /** * Scale a vector by a scalar */ function scale(v: Vector2, sc: number): Vector2; /** * Apply a matrix transformation to a vector */ function transform(v: Vector2, m: Matrix): Vector2; /** * Multiply two matrices (compose 2D transformations) */ function matrixMult(m: Matrix, m2: Matrix): Matrix; /** * Rotates a vector around the origin. Shorthand for a rotation matrix */ function rotate(v: Vector2, a: number): Vector2; /** * Rotates a vector around a given point. */ function rotateAbout(v: Vector2, cp: Vector2, a: number): Vector2; /** * Gets the midpoint of two vectors */ function midpoint(v: Vector2, v2: Vector2): Vector2; /** * Gets the distance between two vectors */ function dist(v: Vector2, v2: Vector2): number; /** * Get the square distance between two vectors */ function squareDist(v: Vector2, v2: Vector2): number; /** * Dot product of two vectors */ function dot(v: Vector2, v2: Vector2): number; /** * Determinant of a matrix */ function det(m: Matrix): number; /** * Inverts a 3x3 matrix, returning null if the determinant is zero * (indicating a degenerate transformation) */ function matrixInvert(a: Matrix): Matrix | null; /** * Returns a builder object for easily creating a matrix from several transformations. * * ```ts * const matrix = * vec.matrixBuilder().translate(10, 10).scale(2).get() * ``` * * An existing matrix can also be passed in to start with. */ function matrixBuilder(m?: Matrix | null): { mult: (m: Matrix) => any; translate: (x: number, y: number) => any; rotate: (a: number) => any; scale: (x: number, y: number) => any; shear: (x: number, y: number) => any; get: () => Matrix; }; /** * Represent a matrix as a CSS transform `matrix(...)` string */ function toCSS(matrix: Matrix): string; const identity: Matrix; }