Home Reference Source Test

References

summary
public

C Matrix

A class for storing values in rows and columns and for doing common matrix operations.

public

C Vector

Simple extension to js Array to allow function chaining when doing vector operations.

public

F add(to: number[], from: number[], target: number[]): number[]

Component-wise addition of two arrays/vectors.

public

F addAll(vectors: number[][], target: number[]): number[]

Component-wise addition of a set of arrays/vectors.

public

F addScaled(to: number[], from: number[], factor: number, target: number[]): number[]

Component-wise addition of one vector with a scaled version of another vector.

public

F angle(vector: number[], axis: number): number

Find the axis aligned angle of a 3d vector

public

F angle2(vector: number[]): number

Find the axis aligned angle of a 2d vector

public

F clamp(arg: number | number[], min: number, max: number, target: number[]): number | number[]

Clamps the argument according to min and max.

public

F clampArray(arr: number[], min: number, max: number, target: number[]): number[]

Clamps each value in array according to min and max.

public

F clampValue(value: number, min: number, max: number): number

Clamps the value to min or max if value is less than min or greater than max

public

F cross(v1: number[], v2: number[], target: number[]): number[]

Find the cross product between two 3d vectors

public

F cross2(v1: number[], v2: number[]): number

Find the psudo cross product between two 2d vectors

public

F deg(r: number): number

Convert radians to degrees

public

F descr(from: number[], to: number[], target: number[]): {vector: number[], sqr: number, distance: number, unit: number[]}

Describes relationships between two points.

public

F dir(from: number[], to: number[], target: number[]): number[]

Get a unit vector between two points/coordinates.

public

F dist(p1: number[], p2: number[]): number

Calculate the distance between two points/coordinates.

public

F dot(v1: number[], v2: number[]): number

Calculate the dot product between two vectors

public

F isNullVec(v: number[], epsilon: number): *

Test if a vector is a null vector

public

F lerp(a: number, b: number, t: number): number

Linear interpolation between two numbers

public

F mix(a: number[], b: number[], t: number | number[], target: number[]): number[]

Mix (interpolate) numbers or arrays (similar to glsl implementation).

public

F norm(vector: number[], target: number[]): number[]

Normalizes an array/vector

public

F nrad(r: number): number

Normalise an angle to be between -PI to +PI

public

F orth2(vector: number[], target: number[]): number[]

Get a unit vector that is perpendicular to the input vector.

public

F rad(d: number): number

Convert degrees to radians

public

F round(v: number | number[], digits: number): number

Rounds a number to the specific number of digits.

public

F scalar(vector: number[]): number

Computes the scalar value (length) of a vector

public

F scale(arr: number[], factor: number, target: number[]): number[]

Component-wise scaling of an array or vector

public

F seq(from: number | number[], to: number | number[], steps: number, start: number, end: number): *

Generates a list of interpolated values between from and to, where the number of elements returned are controlled by the steps argument.

public

F seqI(steps: number): *

Generates a list of interpolated values between 0 and 1, where the number of elements returned are controlled by the steps argument.

public

F smoothstep(edge0: number, edge1: number, x: number): *

Implementation of glsl smoothstep function

public

F step(edge: number | number[], x: number | number[], target: number[]): number | number[]

Implementation of glsl step function.

public

F stepArray(edges: number[], x: number | number[], target: number[]): number[]

As glsl step function for multiple numeric values

public

F stepValue(edge: number, x: number): number

As glsl step function for single numeric values

public

F sub(from: number[], vector: number[], target: number[]): number[]

Component-wise subtraction of two arrays/vectors.

public

F subAll(from: number[], vectors: number[][], target: number[]): number[]

Component-wise subtraction of array/vector and all elements in vectors.

public

F subScaled(from: number[], vector: number[], factor: number, target: number[]): number[]

Component-wise addition of one vector with a scaled version of another vector.

public

F sumsqr(arr: number[]): number

Computes the sum of squares

public

F triple(v1: number[], v2: number[], v3: number[]): number

Get the triple product between three 3d vectors

public

F vec(from: number[], to: number[], target: number[]): number[]

Create a vector from two points.

public

F mat(arr: ...number, cols: number, rowsFirst: boolean): Matrix

Factory function for creating and assigning a matrix from an array.

public

F mat2(args: ...number): Matrix

Factory function for creating and assigning a 2x2 matrix.

public

F mat3(args: ...number): Matrix

Factory function for creating and assigning a 3x3 matrix.

public

F mat4(args: ...number): Matrix

Factory function for creating and assigning a 4x4 matrix.

public

F flattenList(arg: number[], flattend: number[], max: number): *

Recursivly flattens a list of arguments to a 1 dimensional array

public

F rowsToColumns(arr: number[], cols: number, target: number[]): *

Transpose a single dimensional array, representing 2d data, from rows first to columns first.

public

F nvec(dim: number, values: Array<number>): Vector

Create a vector of specific dimension and optionally set its values.

public

F vec2(args: ...number): Vector

Factory function for creating and assigning a 2d vector.

public

F vec3(args: ...number): Vector

Factory function for creating and assigning a 3d vector.

public

F vec4(args: ...number): Vector

Factory function for creating and assigning a 4d vector.

public

V DEG2RAD: *

Constant for converting degrees to radians

public

V EPSILON: *

Epsilon

public

V PI: *

PI

public

V QPI: *

Quarter PI

public

V RAD2DEG: *

Constant for converting radians to degrees

public

V SPI: *

Semi PI

public

V TAU: *

Two times PI