Kiwi.Geom.Matrix Class
Represents a 2d transformation matrix. This can be used to map points between different coordinate spaces. Matrices are used by Transform objects to represent translation, scale and rotation transformations, and to determine where objects are in world space or camera space. Objects such as entities and groups may be nested, and their associated transforms may represent how they are scaled, translated and rotated relative to a parent transform. By concatenating an object's transformation matrix with it's ancestors matrices, it is possible to determine the absolute position of the object in world space. See http://en.wikipedia.org/wiki/Transformation_matrix#Examples_in_2D_graphics for an in depth discussion of 2d tranformation matrices.
Constructor
Kiwi.Geom.Matrix
-
[a
-
[b
-
[c
-
[d
-
[tx
-
[ty
Parameters:
-
[a
Number= 1] position 0,0 of the matrix, affects scaling and rotation.
-
[b
Number= 0] position 0,1 of the matrix, affects scaling and rotation.
-
[c
Number= 0] position 1,0 of the matrix, affects scaling and rotation.
-
[d
Number= 1] position 1,1 of the matrix, affects scaling and rotation.
-
[tx
Number= 0] position 2,0 of the matrix, affects translation on x axis.
-
[ty
Number= 0] position 2,1 of the matrix, affects translation on y axis.
Returns:
(Object) This object.
Item Index
Methods
append
-
[a
-
[b
-
[c
-
[d
-
[tx
-
[ty
Append values to this matrix, paramters supplied individually.
Parameters:
-
[a
Number= 1] position 0,0 of the matrix, affects scaling and rotation.
-
[b
Number= 0] position 0,1 of the matrix, affects scaling and rotation.
-
[c
Number= 0] position 1,0 of the matrix, affects scaling and rotation.
-
[d
Number= 1] position 1,1 of the matrix, affects scaling and rotation.
-
[tx
Number= 0] position 2,0 of the matrix, affects translation on x axis.
-
[ty
Number= 0] position 2,1 of the matrix, affects translation on y axis.
Returns:
This object.
appendMatrix
-
m
Append a matrix to this matrix.
Parameters:
-
m
ObjectThe matrix to append.
Returns:
This object.
clone
()
Object
Clone this matrix
Returns:
The new clone of this matrix.
copyFrom
-
m
Copy another matrix to this matrix.
Parameters:
-
m
ObjectThe matrixto be copied from.
Returns:
This object.
copyTo
-
m
Copy this matrix to another matrix.
Parameters:
-
m
ObjectThe matrix to copy to.
Returns:
This object.
identity
()
Object
Set the matrix to the identity matrix - when appending or prepending this matrix to another there will be no change in the resulting matrix
Returns:
This object.
prepend
-
[a
-
[b
-
[c
-
[d
-
[tx
-
[ty
Prepend values to this matrix, paramters supplied individually.
Parameters:
-
[a
Number= 1] position 0,0 of the matrix, affects scaling and rotation.
-
[b
Number= 0] position 0,1 of the matrix, affects scaling and rotation.
-
[c
Number= 0] position 1,0 of the matrix, affects scaling and rotation.
-
[d
Number= 0] position 1,1 of the matrix, affects scaling and rotation.
-
[tx
Number= 0] position 2,0 of the matrix, affects translation on x axis.
-
[ty
Number= 0] position 2,1 of the matrix, affects translation on y axis.
Returns:
This object.
prependMatrix
-
m.
Prepend a matrix to this matrix.
Parameters:
-
m.
ObjectThe matrix to prepend.
Returns:
This object.
rotate
-
radians
Rotate the matrix by "radians" degrees
Parameters:
-
radians
Numberradians.
Returns:
This object.
scale
-
scaleX.
-
scaleY.
Scale the matrix
Parameters:
-
scaleX.
NumberThe amount to scale on the x axis.
-
scaleY.
NumberThe amount to scale on the y axis.
Returns:
This object.
setFromTransform
-
tx
-
ty
-
scaleX
-
scaleY
-
rotation
Set matrix values from transform values
Parameters:
-
tx
Numbertx. Translation on x axis.
-
ty
Numberty. Translation on y axis.
-
scaleX
NumberscaleX. Scale on x axis.
-
scaleY
NumberscaleY. Scale on y axis.
-
rotation
Numberrotation.
Returns:
This object.
setPosition
-
x
-
y
Set the tx and ty elements of the matrix
Parameters:
-
x
NumberTranslation on x axis.
-
y
NumberTranslation on y axis.
Returns:
This object.
setPositionVector
-
p
Set the tx and ty elements of the matrix from an object with x and y properties.
Parameters:
-
p
NumberThe object from which to copy the x and y properties from.
Returns:
This object.
setPositionVector
()
Object
Get the x and y position of the matrix as an object with x and y properties
Returns:
An object constructed from a literal with x and y properties.
setTo
-
[a
-
[b
-
[c
-
[d
-
[tx
-
[ty
Set all matrix values
Parameters:
-
[a
Number= 1] position 0,0 of the matrix, affects scaling and rotation.
-
[b
Number= 0] position 0,1 of the matrix, affects scaling and rotation.
-
[c
Number= 0] position 1,0 of the matrix, affects scaling and rotation.
-
[d
Number= 1] position 1,1 of the matrix, affects scaling and rotation.
-
[tx
Number= 0] position 2,0 of the matrix, affects translation on x axis.
-
[ty
Number= 0] position 2,1 of the matrix, affects translation on y axis.
Returns:
(Object) This object.
toString
()
String
Returns a string representation of this object.
Returns:
a string representation of the instance.
transalte
-
tx
-
ty
Translate the matrix
Parameters:
-
tx
Numbertx. The amount to translate on the x axis.
-
ty
Numberty. The amount to translate on the y axis.
Returns:
This object.
transformPoint
()
Object
Invert this matrix so that it represents the opposite of it's orginal tranformaation.
Returns:
This object.
transformPoint
-
pt
Apply this matrix to a an object with x and y properties representing a point and return the transformed point.
Parameters:
-
pt
ObjectThe point to be translated.
Returns:
The translated point.