Supported platforms:
Available since: Gideros 2011.6
Inherits from: Object
Description
The Matrix class specifies transformation from one coordinate space to another.
These transformations include translation, rotation, scaling and skewing.
A 2D transformation matrix is a 3 x 3 matrix in homogeneous coordinate system:
You can get and set the values of all six of the properties in a Matrix object: m11, m12, m21, m22, tx, and ty.
Since Gideros 2016.6, Matrix can also hold 3D (4x4) matrices.
Examples
Applying matrix to Sprite objects
local angle = math.rad(30)
-- create skew matrix
local m = Matrix.new(1, math.tan(angle), math.tan(angle), 1, 0, 0)
-- apply to Sprite
local sprite = Sprite.new()
sprite:setMatrix(m)
Methods
Matrix.new creates a new Matrix object
[[1]] gets anchor position from matrix transformation
[[2]] returns the elements of this matrix instance
[[3]] returns the value of the m11 component
[[4]] returns the value of the m12 component
[[5]] returns the value of the m21 component
[[6]] returns the value of the m22 component
[[7]] gets all 16 elements of 4x4 matrix
[[8]] gets position from matrix transformation
[[9]] gets rotation on x axis
[[10]] gets rotation on y axis
[[11]] get rotation on z axis
[[12]] gets scale from matrix transformation
[[13]] gets scale on x axis
[[14]] gets scale on y axis
[[15]] gets scale on z axis
[[16]] returns the value of the tx component
[[17]] returns the value of the ty component
[[18]] returns the value of the tz component
[[19]] gets x position
[[20]] gets y position
[[21]] gets z position
[[22]] inverts the matrix
[[23]] multiplies current matrix with new one
[[24]] replaces this matrix by an orthographic projection
[[25]] replaces this matrix by a perspective projection
[[26]] replaces this matrix by a perspective projection
[[27]] combines existing rotation with provided rotation
[[28]] combines existing scale with provided scale
[[29]] transform matrix for setting anchor position
[[30]] sets all 6 elements of this matrix instance
[[31]] sets the value of the m11 component
[[32]] sets the value of the m12 component
[[33]] sets the value of the m21 component
[[34]] sets the value of the m22 component
[[35]] set all 16 elements of 4x4 matrix
[[36]] transform matrix for setting position
[[37]] sets rotation on x axis
[[38]] sets rotation on y axis
[[39]] sets rotation on z axis
[[40]] transform matrix for setting scale
[[41]] sets scale on x axis
[[42]] sets scale on y axis
[[43]] sets scale on z axis
[[44]] sets the value of the tx component
[[45]] sets the value of the ty component
[[46]] sets the value of the tz component
[[47]] sets x position
[[48]] sets y position
[[49]] sets z position
[[50]] transforms the matrix
[[51]] combines existing translation with provided translation
|
Events
Constants
|