Namespace: mat2d
Table of contents
Type aliases
Functions
- add
- clone
- copy
- create
- determinant
- equals
- exactEquals
- frob
- fromRotation
- fromScaling
- fromTranslation
- fromValues
- identity
- invert
- multiply
- multiplyScalar
- multiplyScalarAndAdd
- rotate
- scale
- set
- str
- subtract
- translate
Type aliases
valueType
Ƭ valueType: mat2dtype
Functions
add
▸ add(out: mat2dtype, a: mat2dtype, b: mat2dtype): mat2dtype
Adds two mat2d's
Parameters
| Name | Type | Description |
|---|---|---|
out |
mat2dtype | the receiving matrix |
a |
mat2dtype | the first operand |
b |
mat2dtype | the second operand |
Returns: mat2dtype
out
clone
▸ clone(a: mat2dtype): mat2dtype
Creates a new mat2d initialized with values from an existing matrix
Parameters
| Name | Type | Description |
|---|---|---|
a |
mat2dtype | matrix to clone |
Returns: mat2dtype
a new 2x3 matrix
copy
▸ copy(out: mat2dtype, a: mat2dtype): mat2dtype
Copy the values from one mat2d to another
Parameters
Returns: mat2dtype
out
create
▸ create(): mat2dtype
Creates a new identity mat2d
Returns: mat2dtype
a new 2x3 matrix
determinant
▸ determinant(a: mat2dtype): number
Calculates the determinant of a mat2d
Parameters
| Name | Type | Description |
|---|---|---|
a |
mat2dtype | the source matrix |
Returns: number
determinant of a
equals
▸ equals(a: mat2dtype, b: mat2dtype): boolean
Returns whether or not the matrices have approximately the same elements in the same position.
Parameters
Returns: boolean
True if the matrices are equal, false otherwise.
exactEquals
▸ exactEquals(a: mat2dtype, b: mat2dtype): boolean
Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
Parameters
Returns: boolean
True if the matrices are equal, false otherwise.
frob
▸ frob(a: mat2dtype): number
Returns Frobenius norm of a mat2d
Parameters
| Name | Type | Description |
|---|---|---|
a |
mat2dtype | the matrix to calculate Frobenius norm of |
Returns: number
Frobenius norm
fromRotation
▸ fromRotation(out: mat2dtype, rad: number): mat2dtype
Creates a matrix from a given angle This is equivalent to (but much faster than):
mat2d.identity(dest);
mat2d.rotate(dest, dest, rad);
Parameters
| Name | Type | Description |
|---|---|---|
out |
mat2dtype | mat2d receiving operation result |
rad |
number | the angle to rotate the matrix by |
Returns: mat2dtype
out
fromScaling
▸ fromScaling(out: mat2dtype, v: mat2dtype): mat2dtype
Creates a matrix from a vector scaling This is equivalent to (but much faster than):
mat2d.identity(dest);
mat2d.scale(dest, dest, vec);
Parameters
Returns: mat2dtype
out
fromTranslation
▸ fromTranslation(out: mat2dtype, v: mat2dtype): mat2dtype
Creates a matrix from a vector translation This is equivalent to (but much faster than):
mat2d.identity(dest);
mat2d.translate(dest, dest, vec);
Parameters
Returns: mat2dtype
out
fromValues
▸ fromValues(a: number, b: number, c: number, d: number, tx: number, ty: number): mat2dtype
Create a new mat2d with the given values
Parameters
| Name | Type | Description |
|---|---|---|
a |
number | Component A (index 0) |
b |
number | Component B (index 1) |
c |
number | Component C (index 2) |
d |
number | Component D (index 3) |
tx |
number | Component TX (index 4) |
ty |
number | Component TY (index 5) |
Returns: mat2dtype
A new mat2d
identity
▸ identity(out: mat2dtype): mat2dtype
Set a mat2d to the identity matrix
Parameters
| Name | Type | Description |
|---|---|---|
out |
mat2dtype | the receiving matrix |
Returns: mat2dtype
out
invert
▸ invert(out: mat2dtype, a: mat2dtype): mat2dtype | null
Inverts a mat2d
Parameters
Returns: mat2dtype | null
out
multiply
▸ multiply(out: mat2dtype, a: mat2dtype, b: mat2dtype): mat2dtype
Multiplies two mat2d's
Parameters
| Name | Type | Description |
|---|---|---|
out |
mat2dtype | the receiving matrix |
a |
mat2dtype | the first operand |
b |
mat2dtype | the second operand |
Returns: mat2dtype
out
multiplyScalar
▸ multiplyScalar(out: mat2dtype, a: mat2dtype, b: number): mat2dtype
Multiply each element of the matrix by a scalar.
Parameters
| Name | Type | Description |
|---|---|---|
out |
mat2dtype | the receiving matrix |
a |
mat2dtype | the matrix to scale |
b |
number | amount to scale the matrix's elements by |
Returns: mat2dtype
out
multiplyScalarAndAdd
▸ multiplyScalarAndAdd(out: mat2dtype, a: mat2dtype, b: mat2dtype, scale: number): mat2dtype
Adds two mat2d's after multiplying each element of the second operand by a scalar value.
Parameters
| Name | Type | Description |
|---|---|---|
out |
mat2dtype | the receiving vector |
a |
mat2dtype | the first operand |
b |
mat2dtype | the second operand |
scale |
number | the amount to scale b's elements by before adding |
Returns: mat2dtype
out
rotate
▸ rotate(out: mat2dtype, a: mat2dtype, rad: number): mat2dtype
Rotates a mat2d by the given angle
Parameters
| Name | Type | Description |
|---|---|---|
out |
mat2dtype | the receiving matrix |
a |
mat2dtype | the matrix to rotate |
rad |
number | the angle to rotate the matrix by |
Returns: mat2dtype
out
scale
▸ scale(out: mat2dtype, a: mat2dtype, v: mat2dtype): mat2dtype
Scales the mat2d by the dimensions in the given vec2
Parameters
| Name | Type | Description |
|---|---|---|
out |
mat2dtype | the receiving matrix |
a |
mat2dtype | the matrix to translate |
v |
mat2dtype | the vec2 to scale the matrix by |
Returns: mat2dtype
out
set
▸ set(out: mat2dtype, a: number, b: number, c: number, d: number, tx: number, ty: number): mat2dtype
Set the components of a mat2d to the given values
Parameters
| Name | Type | Description |
|---|---|---|
out |
mat2dtype | the receiving matrix |
a |
number | Component A (index 0) |
b |
number | Component B (index 1) |
c |
number | Component C (index 2) |
d |
number | Component D (index 3) |
tx |
number | Component TX (index 4) |
ty |
number | Component TY (index 5) |
Returns: mat2dtype
out
str
▸ str(a: mat2dtype): string
Returns a string representation of a mat2d
Parameters
| Name | Type | Description |
|---|---|---|
a |
mat2dtype | matrix to represent as a string |
Returns: string
string representation of the matrix
subtract
▸ subtract(out: mat2dtype, a: mat2dtype, b: mat2dtype): mat2dtype
Subtracts matrix b from matrix a
Parameters
| Name | Type | Description |
|---|---|---|
out |
mat2dtype | the receiving matrix |
a |
mat2dtype | the first operand |
b |
mat2dtype | the second operand |
Returns: mat2dtype
out
translate
▸ translate(out: mat2dtype, a: mat2dtype, v: mat2dtype): mat2dtype
Translates the mat2d by the dimensions in the given vec2
Parameters
| Name | Type | Description |
|---|---|---|
out |
mat2dtype | the receiving matrix |
a |
mat2dtype | the matrix to translate |
v |
mat2dtype | the vec2 to translate the matrix by |
Returns: mat2dtype
out