mat2d

mat2d()

A mat2d contains six elements defined as:
[a, b, c,
 d, tx, ty]
This is a short form for the 3x3 matrix:
[a, b, 0,
 c, d, 0,
 tx, ty, 1]
The last column is ignored so the array is shorter and operations are faster.

Methods

inneradd$1(out, a, b)mat2d

Adds two mat2d's
Name Type Description
out mat2d the receiving matrix
a mat2d the first operand
b mat2d the second operand
Returns:
out

innerclone$1(a)mat2d

Creates a new mat2d initialized with values from an existing matrix
Name Type Description
a mat2d matrix to clone
Returns:
a new 2x3 matrix

innercopy$1(out, a)mat2d

Copy the values from one mat2d to another
Name Type Description
out mat2d the receiving matrix
a mat2d the source matrix
Returns:
out

innercreate$1()mat2d

Creates a new identity mat2d
Returns:
a new 2x3 matrix

innerdeterminant$1(a)Number

Calculates the determinant of a mat2d
Name Type Description
a mat2d the source matrix
Returns:
determinant of a

innerequals$2(a, b)Boolean

Returns whether or not the matrices have approximately the same elements in the same position.
Name Type Description
a mat2d The first matrix.
b mat2d The second matrix.
Returns:
True if the matrices are equal, false otherwise.

innerexactEquals$1(a, b)Boolean

Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
Name Type Description
a mat2d The first matrix.
b mat2d The second matrix.
Returns:
True if the matrices are equal, false otherwise.

innerfrob$1(a)Number

Returns Frobenius norm of a mat2d
Name Type Description
a mat2d the matrix to calculate Frobenius norm of
Returns:
Frobenius norm

innerfromRotation$1(out, rad)mat2d

Creates a matrix from a given angle This is equivalent to (but much faster than): mat2d.identity(dest); mat2d.rotate(dest, dest, rad);
Name Type Description
out mat2d mat2d receiving operation result
rad Number the angle to rotate the matrix by
Returns:
out

innerfromScaling$1(out, v)mat2d

Creates a matrix from a vector scaling This is equivalent to (but much faster than): mat2d.identity(dest); mat2d.scale(dest, dest, vec);
Name Type Description
out mat2d mat2d receiving operation result
v vec2 Scaling vector
Returns:
out

innerfromTranslation(out, v)mat2d

Creates a matrix from a vector translation This is equivalent to (but much faster than): mat2d.identity(dest); mat2d.translate(dest, dest, vec);
Name Type Description
out mat2d mat2d receiving operation result
v vec2 Translation vector
Returns:
out

innerfromValues$1(a, b, c, d, tx, ty)mat2d

Create a new mat2d with the given values
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:
A new mat2d

inneridentity$1(out)mat2d

Set a mat2d to the identity matrix
Name Type Description
out mat2d the receiving matrix
Returns:
out

innerinvert$1(out, a)mat2d

Inverts a mat2d
Name Type Description
out mat2d the receiving matrix
a mat2d the source matrix
Returns:
out

innermul$1()

Alias for mat2d.multiply

innermultiply$1(out, a, b)mat2d

Multiplies two mat2d's
Name Type Description
out mat2d the receiving matrix
a mat2d the first operand
b mat2d the second operand
Returns:
out

innermultiplyScalar$1(out, a, b)mat2d

Multiply each element of the matrix by a scalar.
Name Type Description
out mat2d the receiving matrix
a mat2d the matrix to scale
b Number amount to scale the matrix's elements by
Returns:
out

innermultiplyScalarAndAdd$1(out, a, b, scale)mat2d

Adds two mat2d's after multiplying each element of the second operand by a scalar value.
Name Type Description
out mat2d the receiving vector
a mat2d the first operand
b mat2d the second operand
scale Number the amount to scale b's elements by before adding
Returns:
out

innerrotate$1(out, a, rad)mat2d

Rotates a mat2d by the given angle
Name Type Description
out mat2d the receiving matrix
a mat2d the matrix to rotate
rad Number the angle to rotate the matrix by
Returns:
out

innerscale$1(out, a, v)mat2d

Scales the mat2d by the dimensions in the given vec2
Name Type Description
out mat2d the receiving matrix
a mat2d the matrix to translate
v vec2 the vec2 to scale the matrix by
Returns:
out

innerset$1(out, a, b, c, d, tx, ty)mat2d

Set the components of a mat2d to the given values
Name Type Description
out mat2d 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:
out

innerstr$1(a)String

Returns a string representation of a mat2d
Name Type Description
a mat2d matrix to represent as a string
Returns:
string representation of the matrix

innersub$1()

Alias for mat2d.subtract

innersubtract$1(out, a, b)mat2d

Subtracts matrix b from matrix a
Name Type Description
out mat2d the receiving matrix
a mat2d the first operand
b mat2d the second operand
Returns:
out

innertranslate(out, a, v)mat2d

Translates the mat2d by the dimensions in the given vec2
Name Type Description
out mat2d the receiving matrix
a mat2d the matrix to translate
v vec2 the vec2 to translate the matrix by
Returns:
out