Matrix Class
The Matrix class is now an object, which makes it a lot faster, here is a representation of it : | a | b | tx| | c | d | ty| | 0 | 0 | 1 |
Constructor
Matrix
()
Item Index
Methods
append
-
matrix
Appends the given Matrix to this Matrix.
Parameters:
-
matrix
Matrix
Returns:
This matrix. Good for chaining method calls.
apply
-
pos
-
[newPos]
Get a new position with the current transformation applied. Can be used to go from a child's coordinate space to the world coordinate space. (e.g. rendering)
Parameters:
Returns:
The new point, transformed through this matrix
applyInverse
-
pos
-
[newPos]
Get a new position with the inverse of the current transformation applied. Can be used to go from the world coordinate space to a child's coordinate space. (e.g. input)
Parameters:
Returns:
The new point, inverse-transformed through this matrix
fromArray
-
array
Creates a Matrix object based on the given array. The Element to Matrix mapping order is as follows:
a = array[0] b = array[1] c = array[3] d = array[4] tx = array[2] ty = array[5]
Parameters:
-
array
ArrayThe array that the matrix will be populated from.
identity
()
Matrix
Resets this Matix to an identity (default) matrix.
Returns:
This matrix. Good for chaining method calls.
rotate
-
angle
Applies a rotation transformation to the matrix.
Parameters:
-
angle
NumberThe angle in radians.
Returns:
This matrix. Good for chaining method calls.
scale
-
x
-
y
Applies a scale transformation to the matrix.
Parameters:
-
x
NumberThe amount to scale horizontally
-
y
NumberThe amount to scale vertically
Returns:
This matrix. Good for chaining method calls.
toArray
-
transpose
Creates an array from the current Matrix object.
Parameters:
-
transpose
BooleanWhether we need to transpose the matrix or not
Returns:
the newly created array which contains the matrix
Properties
a
Number
Default: 1
b
Number
Default: 0
c
Number
Default: 0
d
Number
Default: 1
tx
Number
Default: 0
ty
Number
Default: 0