a collection of math helpers for 3D graphics and simulations
npm install mathcat``sh`
> npm install mathcat
mathcat is a collection of math helpers for 3D graphics and simulations.
Features:
- Vector, Quaternion, Euler, and Matrix math
- Easing functions
- Randomness utilities
- Noise utilities
- Simple JSON-serializable data structures (no classes or typed arrays)
- TypeScript-first, great DX for both JavaScript and TypeScript projects
- Excellent tree-shaking support
Acknowledgements:
- The vec, quat, mat* code started as a typescript port of glMatrix (https://glmatrix.net/). This library doesn't aim to stay in sync with glMatrix however.
- Simplex noise functions are adapted from https://github.com/pmndrs/maath, which were adapted from https://github.com/josephg/noisejs :)
types
Vec2 | Vec3 | Vec4 | Quat |
Quat2 | Mat2 | Mat3 | Mat4 |
Mat2d | Box3 | OBB3 | EulerOrder |
Euler | Plane3 | Sphere | Circle |
Ray3 | Raycast3 | MutableArrayLike |
vec2
vec3
vec4
euler
euler.create | euler.fromValues | euler.set |
euler.fromDegrees | euler.fromRotationMat4 | euler.exactEquals |
euler.equals | euler.fromQuat | euler.reorder |
quat
quat2
mat2
mat2d
mat3
mat4
circle
circle.create |
segment2
segment2.closestPoint |
box3
obb3
obb3.create | obb3.clone | obb3.copy |
obb3.set | obb3.setFromBox3 | obb3.containsPoint |
obb3.clampPoint | obb3.intersectsOBB3 | obb3.intersectsBox3 |
obb3.applyMatrix4 |
plane3
sphere
sphere.create |
triangle3
triangle3.bounds | triangle3.normal | triangle3.centroid |
raycast3
quickhull3
quickhull3 |
quickhull2
quickhull2 |
circumcircle
circumcircle |
easing
noise
NoiseGenerator2D | NoiseGenerator3D | createSimplex2D | createSimplex3D |
createPerlin2D | createPerlin3D |
random
createMulberry32Generator | generateMulberry32Seed |
randomInt | randomFloat |
randomBool | randomSign |
randomChoice | randomVec2 |
randomVec3 | randomVec4 |
randomQuat |
common
EPSILON | round | degreesToRadians | radiansToDegrees |
equals | fade | lerp | clamp |
remap | remapClamp |
---
#### Vec2
`ts`
/* A 2D vector /
export type Vec2 = [
x: number,
y: number
];
#### Vec3
`ts`
/* A 3D vector /
export type Vec3 = [
x: number,
y: number,
z: number
];
#### Vec4
`ts`
/* A 4D vector /
export type Vec4 = [
x: number,
y: number,
z: number,
w: number
];
#### Quat
`ts`
/* A quaternion that represents rotation /
export type Quat = [
x: number,
y: number,
z: number,
w: number
];
#### Quat2
`ts`
/* A dual quaternion that represents both rotation and translation /
export type Quat2 = [
x: number,
y: number,
z: number,
w: number,
x2: number,
y2: number,
z2: number,
w2: number
];
#### Mat2
`ts`
/* A 2x2 matrix /
export type Mat2 = [
e1: number,
e2: number,
e3: number,
e4: number
];
#### Mat3
`ts`
/* A 3x3 matrix /
export type Mat3 = [
e1: number,
e2: number,
e3: number,
e4: number,
e5: number,
e6: number,
e7: number,
e8: number,
e9: number
];
#### Mat4
`ts`
/* A 4x4 matrix /
export type Mat4 = [
e1: number,
e2: number,
e3: number,
e4: number,
e5: number,
e6: number,
e7: number,
e8: number,
e9: number,
e10: number,
e11: number,
e12: number,
e13: number,
e14: number,
e15: number,
e16: number
];
#### Mat2d
`ts`
/* A 2D affine transform matrix /
export type Mat2d = [
e1: number,
e2: number,
e3: number,
e4: number,
e5: number,
e6: number
];
#### Box3
`ts`
/* A box in 3D space /
export type Box3 = [
min: Vec3,
max: Vec3
];
#### OBB3
`ts`
/* A oriented bounding box in 3D space /
export type OBB3 = {
center: Vec3;
halfExtents: Vec3;
quaternion: Quat;
};
#### EulerOrder
`ts`
/* Euler orders /
export type EulerOrder = 'xyz' | 'xzy' | 'yxz' | 'yzx' | 'zxy' | 'zyx';
#### Euler
`ts`
/* A Euler in 3D space, with an optional order (default is 'xyz') /
export type Euler = [
x: number,
y: number,
z: number,
order?: EulerOrder
];
#### Plane3
`ts`
/**
* A plane in 3D space
* normal - a unit length vector defining the normal of the plane.
* constant - the signed distance from the origin to the plane.
*/
export type Plane3 = {
normal: Vec3;
constant: number;
};
#### Sphere
`ts`
/* A sphere in 3D space /
export type Sphere = {
center: Vec3;
radius: number;
};
#### Circle
`ts`
/* A circle in 2D space /
export type Circle = {
center: Vec2;
radius: number;
};
#### Ray3
`ts`
/* A ray in 3D space /
export type Ray3 = {
origin: Vec3;
direction: Vec3;
};
#### Raycast3
`ts`
/* A raycast in 3D space /
export type Raycast3 = {
origin: Vec3;
direction: Vec3;
length: number;
};
#### MutableArrayLike
`ts`
export type MutableArrayLike
[index: number]: T;
length: number;
};
#### vec2.create
`ts`
/**
* Creates a new, empty vec2
*
* @returns a new 2D vector
*/
export function create(): Vec2;
#### vec2.clone
`ts`
/**
* Creates a new vec2 initialized with values from an existing vector
*
* @param a vector to clone
* @returns a new 2D vector
*/
export function clone(a: Vec2): Vec2;
#### vec2.fromValues
`ts`
/**
* Creates a new vec2 initialized with the given values
*
* @param x X component
* @param y Y component
* @returns a new 2D vector
*/
export function fromValues(x: number, y: number): Vec2;
#### vec2.copy
`ts`
/**
* Copy the values from one vec2 to another
*
* @param out the receiving vector
* @param a the source vector
* @returns out
*/
export function copy(out: Vec2, a: Vec2): Vec2;
#### vec2.set
`ts`
/**
* Set the components of a vec2 to the given values
*
* @param out the receiving vector
* @param x X component
* @param y Y component
* @returns out
*/
export function set(out: Vec2, x: number, y: number): Vec2;
#### vec2.add
`ts`
/**
* Adds two vec2's
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @returns out
*/
export function add(out: Vec2, a: Vec2, b: Vec2): Vec2;
#### vec2.addScalar
`ts`
/**
* Adds a scalar value to all components of a vec2
*
* @param out the receiving vector
* @param a the source vector
* @param b the scalar value to add
* @returns out
*/
export function addScalar(out: Vec2, a: Vec2, b: number): Vec2;
#### vec2.subtract
`ts`
/**
* Subtracts vector b from vector a
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @returns out
*/
export function subtract(out: Vec2, a: Vec2, b: Vec2): Vec2;
#### vec2.subtractScalar
`ts`
/**
* Subtracts a scalar value from all components of a vec2
*
* @param out the receiving vector
* @param a the source vector
* @param b the scalar value to subtract
* @returns out
*/
export function subtractScalar(out: Vec2, a: Vec2, b: number): Vec2;
#### vec2.multiply
`ts`
/**
* Multiplies two vec2's
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @returns out
*/
export function multiply(out: Vec2, a: Vec2, b: Vec2): Vec2;
#### vec2.divide
`ts`
/**
* Divides two vec2's
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @returns out
*/
export function divide(out: Vec2, a: Vec2, b: Vec2): Vec2;
#### vec2.ceil
`ts`
/**
* Math.ceil the components of a vec2
*
* @param out the receiving vector
* @param a vector to ceil
* @returns out
*/
export function ceil(out: Vec2, a: Vec2): Vec2;
#### vec2.floor
`ts`
/**
* Math.floor the components of a vec2
*
* @param out the receiving vector
* @param a vector to floor
* @returns out
*/
export function floor(out: Vec2, a: Vec2): Vec2;
#### vec2.min
`ts`
/**
* Returns the minimum of two vec2's
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @returns out
*/
export function min(out: Vec2, a: Vec2, b: Vec2): Vec2;
#### vec2.max
`ts`
/**
* Returns the maximum of two vec2's
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @returns out
*/
export function max(out: Vec2, a: Vec2, b: Vec2): Vec2;
#### vec2.round
`ts`
/**
* symmetric round the components of a vec2
*
* @param out the receiving vector
* @param a vector to round
* @returns out
*/
export function round(out: Vec2, a: Vec2): Vec2;
#### vec2.scale
`ts`
/**
* Scales a vec2 by a scalar number
*
* @param out the receiving vector
* @param a the vector to scale
* @param b amount to scale the vector by
* @returns out
*/
export function scale(out: Vec2, a: Vec2, b: number): Vec2;
#### vec2.scaleAndAdd
`ts`
/**
* Adds two vec2's after scaling the second operand by a scalar value
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @param scale the amount to scale b by before adding
* @returns out
*/
export function scaleAndAdd(out: Vec2, a: Vec2, b: Vec2, scale: number): Vec2;
#### vec2.distance
`ts`
/**
* Calculates the euclidian distance between two vec2's
*
* @param a the first operand
* @param b the second operand
* @returns distance between a and b
*/
export function distance(a: Vec2, b: Vec2): number;
#### vec2.squaredDistance
`ts`
/**
* Calculates the squared euclidian distance between two vec2's
*
* @param a the first operand
* @param b the second operand
* @returns squared distance between a and b
*/
export function squaredDistance(a: Vec2, b: Vec2): number;
#### vec2.length
`ts`
/**
* Calculates the length of a vec2
*
* @param a vector to calculate length of
* @returns length of a
*/
export function length(a: Vec2): number;
#### vec2.squaredLength
`ts`
/**
* Calculates the squared length of a vec2
*
* @param a vector to calculate squared length of
* @returns squared length of a
*/
export function squaredLength(a: Vec2): number;
#### vec2.negate
`ts`
/**
* Negates the components of a vec2
*
* @param out the receiving vector
* @param a vector to negate
* @returns out
*/
export function negate(out: Vec2, a: Vec2): Vec2;
#### vec2.inverse
`ts`
/**
* Returns the inverse of the components of a vec2
*
* @param out the receiving vector
* @param a vector to invert
* @returns out
*/
export function inverse(out: Vec2, a: Vec2): Vec2;
#### vec2.normalize
`ts`
/**
* Normalize a vec2
*
* @param out the receiving vector
* @param a vector to normalize
* @returns out
*/
export function normalize(out: Vec2, a: Vec2): Vec2;
#### vec2.dot
`ts`
/**
* Calculates the dot product of two vec2's
*
* @param a the first operand
* @param b the second operand
* @returns dot product of a and b
*/
export function dot(a: Vec2, b: Vec2): number;
#### vec2.cross
`ts`
/**
* Computes the cross product of two vec2's
* Note that the cross product must by definition produce a 3D vector
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @returns out
*/
export function cross(out: Vec3, a: Vec2, b: Vec2): Vec3;
#### vec2.lerp
`ts`
/**
* Performs a linear interpolation between two vec2's
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @param t interpolation amount, in the range [0-1], between the two inputs
* @returns out
*/
export function lerp(out: Vec2, a: Vec2, b: Vec2, t: number): Vec2;
#### vec2.transformMat2
`ts`
/**
* Transforms the vec2 with a mat2
*
* @param out the receiving vector
* @param a the vector to transform
* @param m matrix to transform with
* @returns out
*/
export function transformMat2(out: Vec2, a: Vec2, m: Mat2): Vec2;
#### vec2.transformMat2d
`ts`
/**
* Transforms the vec2 with a mat2d
*
* @param out the receiving vector
* @param a the vector to transform
* @param m matrix to transform with
* @returns out
*/
export function transformMat2d(out: Vec2, a: Vec2, m: Mat2d): Vec2;
#### vec2.transformMat3
`ts`
/**
* Transforms the vec2 with a mat3
* 3rd vector component is implicitly '1'
*
* @param out the receiving vector
* @param a the vector to transform
* @param m matrix to transform with
* @returns out
*/
export function transformMat3(out: Vec2, a: Vec2, m: Mat3): Vec2;
#### vec2.transformMat4
`ts`
/**
* Transforms the vec2 with a mat4
* 3rd vector component is implicitly '0'
* 4th vector component is implicitly '1'
*
* @param out the receiving vector
* @param a the vector to transform
* @param m matrix to transform with
* @returns out
*/
export function transformMat4(out: Vec2, a: Vec2, m: Mat4): Vec2;
#### vec2.rotate
`ts`
/**
* Rotate a 2D vector
* @param out The receiving vec2
* @param a The vec2 point to rotate
* @param b The origin of the rotation
* @param rad The angle of rotation in radians
* @returns out
*/
export function rotate(out: Vec2, a: Vec2, b: Vec2, rad: number): Vec2;
#### vec2.angle
`ts`
/**
* Get the angle between two 2D vectors
* @param a The first operand
* @param b The second operand
* @returns The angle in radians
*/
export function angle(a: Vec2, b: Vec2): number;
#### vec2.zero
`ts`
/**
* Set the components of a vec2 to zero
*
* @param out the receiving vector
* @returns out
*/
export function zero(out: Vec2): Vec2;
#### vec2.str
`ts`
/**
* Returns a string representation of a vector
*
* @param a vector to represent as a string
* @returns string representation of the vector
*/
export function str(a: Vec2): string;
#### vec2.exactEquals
`ts`
/**
* Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)
*
* @param a The first vector.
* @param b The second vector.
* @returns True if the vectors are equal, false otherwise.
*/
export function exactEquals(a: Vec2, b: Vec2): boolean;
#### vec2.equals
`ts`
/**
* Returns whether or not the vectors have approximately the same elements in the same position.
*
* @param a The first vector.
* @param b The second vector.
* @returns True if the vectors are equal, false otherwise.
*/
export function equals(a: Vec2, b: Vec2): boolean;
#### vec2.finite
`ts`
/**
* Returns whether or not the vector is finite
* @param a vector to test
* @returns whether or not the vector is finite
*/
export function finite(a: Vec2): boolean;
#### vec2.len
`ts`
/**
* Alias for {@link length}
*/
export const len = length;
#### vec2.sub
`ts`
/**
* Alias for {@link subtract}
*/
export const sub = subtract;
#### vec2.mul
`ts`
/**
* Alias for {@link multiply}
*/
export const mul = multiply;
#### vec2.div
`ts`
/**
* Alias for {@link divide}
*/
export const div = divide;
#### vec2.dist
`ts`
/**
* Alias for {@link distance}
*/
export const dist = distance;
#### vec2.sqrDist
`ts`
/**
* Alias for {@link squaredDistance}
*/
export const sqrDist = squaredDistance;
#### vec2.sqrLen
`ts`
/**
* Alias for {@link squaredLength}
*/
export const sqrLen = squaredLength;
#### vec3.create
`ts`
/**
* Creates a new, empty vec3
*
* @returns a new 3D vector
*/
export function create(): Vec3;
#### vec3.clone
`ts`
/**
* Creates a new vec3 initialized with values from an existing vector
*
* @param a vector to clone
* @returns a new 3D vector
*/
export function clone(a: Vec3): Vec3;
#### vec3.length
`ts`
/**
* Calculates the length of a vec3
*
* @param a vector to calculate length of
* @returns length of a
*/
export function length(a: Vec3): number;
#### vec3.fromValues
`ts`
/**
* Creates a new vec3 initialized with the given values
*
* @param x X component
* @param y Y component
* @param z Z component
* @returns a new 3D vector
*/
export function fromValues(x: number, y: number, z: number): Vec3;
#### vec3.copy
`ts`
/**
* Copy the values from one vec3 to another
*
* @param out the receiving vector
* @param a the source vector
* @returns out
*/
export function copy(out: Vec3, a: Vec3): Vec3;
#### vec3.set
`ts`
/**
* Set the components of a vec3 to the given values
*
* @param out the receiving vector
* @param x X component
* @param y Y component
* @param z Z component
* @returns out
*/
export function set(out: Vec3, x: number, y: number, z: number): Vec3;
#### vec3.setScalar
`ts`
/**
* Sets all components of a vec3 to the given scalar value
*
* @param out the receiving vector
* @param s scalar value to set
* @returns out
*/
export function setScalar(out: Vec3, s: number): Vec3;
#### vec3.fromBuffer
`ts`
/**
* Sets the components of a vec3 from a buffer
* @param out the receiving vector
* @param buffer the source buffer
* @param startIndex the starting index in the buffer
* @returns out
*/
export function fromBuffer(out: Vec3, buffer: ArrayLike
#### vec3.toBuffer
`ts`
/**
* Writes the components of a vec3 to a buffer
* @param outBuffer The output buffer
* @param vec The source vector
* @param startIndex The starting index in the buffer
* @returns The output buffer
*/
export function toBuffer(outBuffer: MutableArrayLike
#### vec3.add
`ts`
/**
* Adds two vec3's
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @returns out
*/
export function add(out: Vec3, a: Vec3, b: Vec3): Vec3;
#### vec3.addScalar
`ts`
/**
* Adds a scalar value to all components of a vec3
*
* @param out the receiving vector
* @param a the source vector
* @param b the scalar value to add
* @returns out
*/
export function addScalar(out: Vec3, a: Vec3, b: number): Vec3;
#### vec3.subtract
`ts`
/**
* Subtracts vector b from vector a
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @returns out
*/
export function subtract(out: Vec3, a: Vec3, b: Vec3): Vec3;
#### vec3.subtractScalar
`ts`
/**
* Subtracts a scalar value from all components of a vec3
*
* @param out the receiving vector
* @param a the source vector
* @param b the scalar value to subtract
* @returns out
*/
export function subtractScalar(out: Vec3, a: Vec3, b: number): Vec3;
#### vec3.multiply
`ts`
/**
* Multiplies two vec3's
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @returns out
*/
export function multiply(out: Vec3, a: Vec3, b: Vec3): Vec3;
#### vec3.divide
`ts`
/**
* Divides two vec3's
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @returns out
*/
export function divide(out: Vec3, a: Vec3, b: Vec3): Vec3;
#### vec3.ceil
`ts`
/**
* Math.ceil the components of a vec3
*
* @param out the receiving vector
* @param a vector to ceil
* @returns out
*/
export function ceil(out: Vec3, a: Vec3): Vec3;
#### vec3.floor
`ts`
/**
* Math.floor the components of a vec3
*
* @param out the receiving vector
* @param a vector to floor
* @returns out
*/
export function floor(out: Vec3, a: Vec3): Vec3;
#### vec3.min
`ts`
/**
* Returns the minimum of two vec3's
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @returns out
*/
export function min(out: Vec3, a: Vec3, b: Vec3): Vec3;
#### vec3.max
`ts`
/**
* Returns the maximum of two vec3's
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @returns out
*/
export function max(out: Vec3, a: Vec3, b: Vec3): Vec3;
#### vec3.round
`ts`
/**
* symmetric round the components of a vec3
*
* @param out the receiving vector
* @param a vector to round
* @returns out
*/
export function round(out: Vec3, a: Vec3): Vec3;
#### vec3.scale
`ts`
/**
* Scales a vec3 by a scalar number
*
* @param out the receiving vector
* @param a the vector to scale
* @param b amount to scale the vector by
* @returns out
*/
export function scale(out: Vec3, a: Vec3, b: number): Vec3;
#### vec3.scaleAndAdd
`ts`
/**
* Adds two vec3's after scaling the second operand by a scalar value
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @param scale the amount to scale b by before adding
* @returns out
*/
export function scaleAndAdd(out: Vec3, a: Vec3, b: Vec3, scale: number): Vec3;
#### vec3.distance
`ts`
/**
* Calculates the euclidian distance between two vec3's
*
* @param a the first operand
* @param b the second operand
* @returns distance between a and b
*/
export function distance(a: Vec3, b: Vec3): number;
#### vec3.squaredDistance
`ts`
/**
* Calculates the squared euclidian distance between two vec3's
*
* @param a the first operand
* @param b the second operand
* @returns squared distance between a and b
*/
export function squaredDistance(a: Vec3, b: Vec3): number;
#### vec3.squaredLength
`ts`
/**
* Calculates the squared length of a vec3
*
* @param a vector to calculate squared length of
* @returns squared length of a
*/
export function squaredLength(a: Vec3): number;
#### vec3.negate
`ts`
/**
* Negates the components of a vec3
*
* @param out the receiving vector
* @param a vector to negate
* @returns out
*/
export function negate(out: Vec3, a: Vec3): Vec3;
#### vec3.inverse
`ts`
/**
* Returns the inverse of the components of a vec3
*
* @param out the receiving vector
* @param a vector to invert
* @returns out
*/
export function inverse(out: Vec3, a: Vec3): Vec3;
#### vec3.normalize
`ts`
/**
* Normalize a vec3
*
* @param out the receiving vector
* @param a vector to normalize
* @returns out
*/
export function normalize(out: Vec3, a: Vec3): Vec3;
#### vec3.dot
`ts`
/**
* Calculates the dot product of two vec3's
*
* @param a the first operand
* @param b the second operand
* @returns dot product of a and b
*/
export function dot(a: Vec3, b: Vec3): number;
#### vec3.cross
`ts`
/**
* Computes the cross product of two vec3's
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @returns out
*/
export function cross(out: Vec3, a: Vec3, b: Vec3): Vec3;
#### vec3.perpendicular
`ts`
/**
* Calculates a normalized perpendicular vector to the given vector.
* Useful for finding an arbitrary orthogonal basis vector.
*
* @param out the receiving vector
* @param a the source vector
* @returns the out vector
*/
export function perpendicular(out: Vec3, a: Vec3): Vec3;
#### vec3.lerp
`ts`
/**
* Performs a linear interpolation between two vec3's
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @param t interpolation amount, in the range [0-1], between the two inputs
* @returns out
*/
export function lerp(out: Vec3, a: Vec3, b: Vec3, t: number): Vec3;
#### vec3.slerp
`ts`
/**
* Performs a spherical linear interpolation between two vec3's
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @param t interpolation amount, in the range [0-1], between the two inputs
* @returns out
*/
export function slerp(out: Vec3, a: Vec3, b: Vec3, t: number): Vec3;
#### vec3.hermite
`ts`
/**
* Performs a hermite interpolation with two control points
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @param c the third operand
* @param d the fourth operand
* @param t interpolation amount, in the range [0-1], between the two inputs
* @returns out
*/
export function hermite(out: Vec3, a: Vec3, b: Vec3, c: Vec3, d: Vec3, t: number): Vec3;
#### vec3.bezier
`ts`
/**
* Performs a bezier interpolation with two control points
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @param c the third operand
* @param d the fourth operand
* @param t interpolation amount, in the range [0-1], between the two inputs
* @returns out
*/
export function bezier(out: Vec3, a: Vec3, b: Vec3, c: Vec3, d: Vec3, t: number): Vec3;
#### vec3.transformMat4
`ts`
/**
* Transforms the vec3 with a mat4.
* 4th vector component is implicitly '1'
*
* @param out the receiving vector
* @param a the vector to transform
* @param m matrix to transform with
* @returns out
*/
export function transformMat4(out: Vec3, a: Vec3, m: Mat4): Vec3;
#### vec3.transformMat3
`ts`
/**
* Transforms the vec3 with a mat3.
*
* @param out the receiving vector
* @param a the vector to transform
* @param m the 3x3 matrix to transform with
* @returns out
*/
export function transformMat3(out: Vec3, a: Vec3, m: Mat3): Vec3;
#### vec3.transformQuat
`ts`
/**
* Transforms the vec3 with a quat
* Can also be used for dual quaternions. (Multiply it with the real part)
*
* @param out the receiving vector
* @param a the vector to transform
* @param q quaternion to transform with
* @returns out
*/
export function transformQuat(out: Vec3, a: Vec3, q: Quat): Vec3;
#### vec3.rotateX
`ts`
/**
* Rotate a 3D vector around the x-axis
* @param out The receiving vec3
* @param a The vec3 point to rotate
* @param b The origin of the rotation
* @param rad The angle of rotation in radians
* @returns out
*/
export function rotateX(out: Vec3, a: Vec3, b: Vec3, rad: number): Vec3;
#### vec3.rotateY
`ts`
/**
* Rotate a 3D vector around the y-axis
* @param out The receiving vec3
* @param a The vec3 point to rotate
* @param b The origin of the rotation
* @param rad The angle of rotation in radians
* @returns out
*/
export function rotateY(out: Vec3, a: Vec3, b: Vec3, rad: number): Vec3;
#### vec3.rotateZ
`ts`
/**
* Rotate a 3D vector around the z-axis
* @param out The receiving vec3
* @param a The vec3 point to rotate
* @param b The origin of the rotation
* @param rad The angle of rotation in radians
* @returns out
*/
export function rotateZ(out: Vec3, a: Vec3, b: Vec3, rad: number): Vec3;
#### vec3.angle
`ts`
/**
* Get the angle between two 3D vectors
* @param a The first operand
* @param b The second operand
* @returns The angle in radians
*/
export function angle(a: Vec3, b: Vec3): number;
#### vec3.zero
`ts`
/**
* Set the components of a vec3 to zero
*
* @param out the receiving vector
* @returns out
*/
export function zero(out: Vec3): Vec3;
#### vec3.str
`ts`
/**
* Returns a string representation of a vector
*
* @param a vector to represent as a string
* @returns string representation of the vector
*/
export function str(a: Vec3): string;
#### vec3.exactEquals
`ts`
/**
* Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)
*
* @param a The first vector.
* @param b The second vector.
* @returns True if the vectors are equal, false otherwise.
*/
export function exactEquals(a: Vec3, b: Vec3): boolean;
#### vec3.equals
`ts`
/**
* Returns whether or not the vectors have approximately the same elements in the same position.
*
* @param a The first vector.
* @param b The second vector.
* @returns True if the vectors are equal, false otherwise.
*/
export function equals(a: Vec3, b: Vec3): boolean;
#### vec3.finite
`ts`
/**
* Returns whether or not the vector is finite
* @param a vector to test
* @returns whether or not the vector is finite
*/
export function finite(a: Vec3): boolean;
#### vec3.isScaleInsideOut
`ts`
/**
* Determines if a scale vector represents an inside-out transformation (reflection)
* Returns true if an odd number of scale components are negative
*
* @param scale The scale vector to test
* @returns true if the scale represents a reflection (odd number of negative components)
*/
export function isScaleInsideOut(scale: Vec3): boolean;
#### vec3.sub
`ts`
/**
* Alias for {@link subtract}
*/
export const sub = subtract;
#### vec3.mul
`ts`
/**
* Alias for {@link multiply}
*/
export const mul = multiply;
#### vec3.div
`ts`
/**
* Alias for {@link divide}
*/
export const div = divide;
#### vec3.dist
`ts`
/**
* Alias for {@link distance}
*/
export const dist = distance;
#### vec3.sqrDist
`ts`
/**
* Alias for {@link squaredDistance}
*/
export const sqrDist = squaredDistance;
#### vec3.len
`ts`
/**
* Alias for {@link length}
*/
export const len = length;
#### vec3.sqrLen
`ts`
/**
* Alias for {@link squaredLength}
*/
export const sqrLen = squaredLength;
#### vec4.create
`ts`
/**
* Creates a new, empty vec4
*
* @returns a new 4D vector
*/
export function create(): Vec4;
#### vec4.clone
`ts`
/**
* Creates a new vec4 initialized with values from an existing vector
*
* @param a vector to clone
* @returns a new 4D vector
*/
export function clone(a: Vec4): Vec4;
#### vec4.fromValues
`ts`
/**
* Creates a new vec4 initialized with the given values
*
* @param x X component
* @param y Y component
* @param z Z component
* @param w W component
* @returns a new 4D vector
*/
export function fromValues(x: number, y: number, z: number, w: number): Vec4;
#### vec4.copy
`ts`
/**
* Copy the values from one vec4 to another
*
* @param out the receiving vector
* @param a the source vector
* @returns out
*/
export function copy(out: Vec4, a: Vec4): Vec4;
#### vec4.set
`ts`
/**
* Set the components of a vec4 to the given values
*
* @param out the receiving vector
* @param x X component
* @param y Y component
* @param z Z component
* @param w W component
* @returns out
*/
export function set(out: Vec4, x: number, y: number, z: number, w: number): Vec4;
#### vec4.add
`ts`
/**
* Adds two vec4's
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @returns out
*/
export function add(out: Vec4, a: Vec4, b: Vec4): Vec4;
#### vec4.subtract
`ts`
/**
* Subtracts vector b from vector a
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @returns out
*/
export function subtract(out: Vec4, a: Vec4, b: Vec4): Vec4;
#### vec4.multiply
`ts`
/**
* Multiplies two vec4's
*
* @param out the receiving vector
* @param a the first operand
* @param b the second operand
* @returns out
*/
export function multiply(out: Vec4, a: Vec4, b: Vec4): Vec4;
#### vec4.divide
``ts
/**
* Divides two vec4's
*
* @param out the rec