Difference between revisions of "Matrix"
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
+ | <!-- GIDEROSOBJ:Matrix --> | ||
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]]<br/> | '''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]]<br/> | ||
'''<translate>Available since</translate>:''' Gideros 2011.6<br/> | '''<translate>Available since</translate>:''' Gideros 2011.6<br/> | ||
Line 28: | Line 29: | ||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
=== <translate>Methods</translate> === | === <translate>Methods</translate> === | ||
− | [[Special:MyLanguage/Matrix.new|Matrix.new]] ''<translate>creates a new Matrix object</translate>''<br/> | + | [[Special:MyLanguage/Matrix.new|Matrix.new]] ''<translate>creates a new Matrix object</translate>''<br/><!-- GIDEROSMTD:Matrix.new --> |
− | [[Special:MyLanguage/Matrix:getAnchorPosition|Matrix:getAnchorPosition]] ''<translate>get anchor position from matrix transformation</translate>''<br/> | + | [[Special:MyLanguage/Matrix:getAnchorPosition|Matrix:getAnchorPosition]] ''<translate>get anchor position from matrix transformation</translate>''<br/><!-- GIDEROSMTD:Matrix:getAnchorPosition --> |
− | [[Special:MyLanguage/Matrix:getElements|Matrix:getElements]] ''<translate>returns the elements of this matrix instance</translate>''<br/> | + | [[Special:MyLanguage/Matrix:getElements|Matrix:getElements]] ''<translate>returns the elements of this matrix instance</translate>''<br/><!-- GIDEROSMTD:Matrix:getElements --> |
− | [[Special:MyLanguage/Matrix:getM11|Matrix:getM11]] ''<translate>returns the value of the m11 component</translate>''<br/> | + | [[Special:MyLanguage/Matrix:getM11|Matrix:getM11]] ''<translate>returns the value of the m11 component</translate>''<br/><!-- GIDEROSMTD:Matrix:getM11 --> |
− | [[Special:MyLanguage/Matrix:getM12|Matrix:getM12]] ''<translate>returns the value of the m12 component</translate>''<br/> | + | [[Special:MyLanguage/Matrix:getM12|Matrix:getM12]] ''<translate>returns the value of the m12 component</translate>''<br/><!-- GIDEROSMTD:Matrix:getM12 --> |
− | [[Special:MyLanguage/Matrix:getM21|Matrix:getM21]] ''<translate>returns the value of the m21 component</translate>''<br/> | + | [[Special:MyLanguage/Matrix:getM21|Matrix:getM21]] ''<translate>returns the value of the m21 component</translate>''<br/><!-- GIDEROSMTD:Matrix:getM21 --> |
− | [[Special:MyLanguage/Matrix:getM22|Matrix:getM22]] ''<translate>returns the value of the m22 component</translate>''<br/> | + | [[Special:MyLanguage/Matrix:getM22|Matrix:getM22]] ''<translate>returns the value of the m22 component</translate>''<br/><!-- GIDEROSMTD:Matrix:getM22 --> |
− | [[Special:MyLanguage/Matrix:getMatrix|Matrix:getMatrix]] ''<translate>get all 16 elements of 4x4 matrix</translate>''<br/> | + | [[Special:MyLanguage/Matrix:getMatrix|Matrix:getMatrix]] ''<translate>get all 16 elements of 4x4 matrix</translate>''<br/><!-- GIDEROSMTD:Matrix:getMatrix --> |
− | [[Special:MyLanguage/Matrix:getPosition|Matrix:getPosition]] ''<translate>get position from matrix transformation</translate>''<br/> | + | [[Special:MyLanguage/Matrix:getPosition|Matrix:getPosition]] ''<translate>get position from matrix transformation</translate>''<br/><!-- GIDEROSMTD:Matrix:getPosition --> |
− | [[Special:MyLanguage/Matrix:getRotationX|Matrix:getRotationX]] ''<translate>get rotation for x axis</translate>''<br/> | + | [[Special:MyLanguage/Matrix:getRotationX|Matrix:getRotationX]] ''<translate>get rotation for x axis</translate>''<br/><!-- GIDEROSMTD:Matrix:getRotationX --> |
− | + | [[Special:MyLanguage/Matrix:getRotationY|Matrix:getRotationY]] ''<translate>get rotation on y axis</translate>''<br/><!-- GIDEROSMTD:Matrix:getRotationY --> | |
− | [[Special:MyLanguage/Matrix:getRotationZ|Matrix:getRotationZ]] ''<translate>get rotation for z axis</translate>''<br/> | + | [[Special:MyLanguage/Matrix:getRotationZ|Matrix:getRotationZ]] ''<translate>get rotation for z axis</translate>''<br/><!-- GIDEROSMTD:Matrix:getRotationZ --> |
− | [[Special:MyLanguage/Matrix:getScale|Matrix:getScale]] ''<translate>get scale from matrix transformation</translate>''<br/> | + | [[Special:MyLanguage/Matrix:getScale|Matrix:getScale]] ''<translate>get scale from matrix transformation</translate>''<br/><!-- GIDEROSMTD:Matrix:getScale --> |
− | [[Special:MyLanguage/Matrix:getScaleX|Matrix:getScaleX]] ''<translate>get scale on x axis</translate>''<br/> | + | [[Special:MyLanguage/Matrix:getScaleX|Matrix:getScaleX]] ''<translate>get scale on x axis</translate>''<br/><!-- GIDEROSMTD:Matrix:getScaleX --> |
− | [[Special:MyLanguage/Matrix:getScaleY|Matrix:getScaleY]] ''<translate>get scale on y axis</translate>''<br/> | + | [[Special:MyLanguage/Matrix:getScaleY|Matrix:getScaleY]] ''<translate>get scale on y axis</translate>''<br/><!-- GIDEROSMTD:Matrix:getScaleY --> |
− | [[Special:MyLanguage/Matrix:getScaleZ|Matrix:getScaleZ]] ''<translate>get scale on z axis</translate>''<br/> | + | [[Special:MyLanguage/Matrix:getScaleZ|Matrix:getScaleZ]] ''<translate>get scale on z axis</translate>''<br/><!-- GIDEROSMTD:Matrix:getScaleZ --> |
− | [[Special:MyLanguage/Matrix:getTx|Matrix:getTx]] ''<translate>returns the value of the tx component</translate>''<br/> | + | [[Special:MyLanguage/Matrix:getTx|Matrix:getTx]] ''<translate>returns the value of the tx component</translate>''<br/><!-- GIDEROSMTD:Matrix:getTx --> |
− | [[Special:MyLanguage/Matrix:getTy|Matrix:getTy]] ''<translate>returns the value of the ty component</translate>''<br/> | + | [[Special:MyLanguage/Matrix:getTy|Matrix:getTy]] ''<translate>returns the value of the ty component</translate>''<br/><!-- GIDEROSMTD:Matrix:getTy --> |
− | + | [[Special:MyLanguage/Matrix:getTz|Matrix:getTz]] ''<translate>returns the value of the tz component</translate>''<br/><!-- GIDEROSMTD:Matrix:getTz --> | |
− | [[Special:MyLanguage/Matrix:getX|Matrix:getX]] ''<translate>get x position</translate>''<br/> | + | [[Special:MyLanguage/Matrix:getX|Matrix:getX]] ''<translate>get x position</translate>''<br/><!-- GIDEROSMTD:Matrix:getX --> |
− | [[Special:MyLanguage/Matrix:getY|Matrix:getY]] ''<translate>get y position</translate>''<br/> | + | [[Special:MyLanguage/Matrix:getY|Matrix:getY]] ''<translate>get y position</translate>''<br/><!-- GIDEROSMTD:Matrix:getY --> |
− | [[Special:MyLanguage/Matrix:getZ|Matrix:getZ]] ''<translate>get z position</translate>''<br/> | + | [[Special:MyLanguage/Matrix:getZ|Matrix:getZ]] ''<translate>get z position</translate>''<br/><!-- GIDEROSMTD:Matrix:getZ --> |
− | [[Special:MyLanguage/Matrix:invert|Matrix:invert]] <br/> | + | [[Special:MyLanguage/Matrix:invert|Matrix:invert]] <br/><!-- GIDEROSMTD:Matrix:invert --> |
− | [[Special:MyLanguage/Matrix:multiply|Matrix:multiply]] ''<translate>Multiply current matrix with new one</translate>''<br/> | + | [[Special:MyLanguage/Matrix:multiply|Matrix:multiply]] ''<translate>Multiply current matrix with new one</translate>''<br/><!-- GIDEROSMTD:Matrix:multiply --> |
− | [[Special:MyLanguage/Matrix:orthographicProjection|Matrix:orthographicProjection]] <br/> | + | [[Special:MyLanguage/Matrix:orthographicProjection|Matrix:orthographicProjection]] <br/><!-- GIDEROSMTD:Matrix:orthographicProjection --> |
− | [[Special:MyLanguage/Matrix:perspectiveProjection|Matrix:perspectiveProjection]] <br/> | + | [[Special:MyLanguage/Matrix:perspectiveProjection|Matrix:perspectiveProjection]] <br/><!-- GIDEROSMTD:Matrix:perspectiveProjection --> |
− | + | [[Special:MyLanguage/Matrix:perspectiveProjection|Matrix:perspectiveProjection]] <br/><!-- GIDEROSMTD:Matrix:perspectiveProjection --> | |
− | [[Special:MyLanguage/Matrix:rotate|Matrix:rotate]] ''<translate>combine existing rotation with provided</translate>''<br/> | + | [[Special:MyLanguage/Matrix:rotate|Matrix:rotate]] ''<translate>combine existing rotation with provided</translate>''<br/><!-- GIDEROSMTD:Matrix:rotate --> |
− | [[Special:MyLanguage/Matrix:scale|Matrix:scale]] ''<translate>combine existing scale with provided scale</translate>''<br/> | + | [[Special:MyLanguage/Matrix:scale|Matrix:scale]] ''<translate>combine existing scale with provided scale</translate>''<br/><!-- GIDEROSMTD:Matrix:scale --> |
− | [[Special:MyLanguage/Matrix:setAnchorPosition|Matrix:setAnchorPosition]] ''<translate>transform matrix for setting anchor position</translate>''<br/> | + | [[Special:MyLanguage/Matrix:setAnchorPosition|Matrix:setAnchorPosition]] ''<translate>transform matrix for setting anchor position</translate>''<br/><!-- GIDEROSMTD:Matrix:setAnchorPosition --> |
− | [[Special:MyLanguage/Matrix:setElements|Matrix:setElements]] ''<translate>sets all 6 elements of this matrix instance</translate>''<br/> | + | [[Special:MyLanguage/Matrix:setElements|Matrix:setElements]] ''<translate>sets all 6 elements of this matrix instance</translate>''<br/><!-- GIDEROSMTD:Matrix:setElements --> |
− | [[Special:MyLanguage/Matrix:setM11|Matrix:setM11]] ''<translate>sets the value of the m11 component</translate>''<br/> | + | [[Special:MyLanguage/Matrix:setM11|Matrix:setM11]] ''<translate>sets the value of the m11 component</translate>''<br/><!-- GIDEROSMTD:Matrix:setM11 --> |
− | [[Special:MyLanguage/Matrix:setM12|Matrix:setM12]] ''<translate>sets the value of the m22 component</translate>''<br/> | + | [[Special:MyLanguage/Matrix:setM12|Matrix:setM12]] ''<translate>sets the value of the m22 component</translate>''<br/><!-- GIDEROSMTD:Matrix:setM12 --> |
− | [[Special:MyLanguage/Matrix:setM21|Matrix:setM21]] <br/> | + | [[Special:MyLanguage/Matrix:setM21|Matrix:setM21]] <br/><!-- GIDEROSMTD:Matrix:setM21 --> |
− | + | [[Special:MyLanguage/Matrix:setM22|Matrix:setM22]] <br/><!-- GIDEROSMTD:Matrix:setM22 --> | |
− | [[Special:MyLanguage/Matrix:setMatrix|Matrix:setMatrix]] ''<translate>set all 16 elements of 4x4 matrix</translate>''<br/> | + | [[Special:MyLanguage/Matrix:setMatrix|Matrix:setMatrix]] ''<translate>set all 16 elements of 4x4 matrix</translate>''<br/><!-- GIDEROSMTD:Matrix:setMatrix --> |
− | [[Special:MyLanguage/Matrix:setPosition|Matrix:setPosition]] ''<translate>transform matrix for setting position</translate>''<br/> | + | [[Special:MyLanguage/Matrix:setPosition|Matrix:setPosition]] ''<translate>transform matrix for setting position</translate>''<br/><!-- GIDEROSMTD:Matrix:setPosition --> |
− | [[Special:MyLanguage/Matrix:setRotationX|Matrix:setRotationX]] ''<translate>set rotation on x axis</translate>''<br/> | + | [[Special:MyLanguage/Matrix:setRotationX|Matrix:setRotationX]] ''<translate>set rotation on x axis</translate>''<br/><!-- GIDEROSMTD:Matrix:setRotationX --> |
− | [[Special:MyLanguage/Matrix:setRotationY|Matrix:setRotationY]] ''<translate>set rotation on y axis</translate>''<br/> | + | [[Special:MyLanguage/Matrix:setRotationY|Matrix:setRotationY]] ''<translate>set rotation on y axis</translate>''<br/><!-- GIDEROSMTD:Matrix:setRotationY --> |
− | [[Special:MyLanguage/Matrix:setRotationZ|Matrix:setRotationZ]] ''<translate>set rotation on z axis</translate>''<br/> | + | [[Special:MyLanguage/Matrix:setRotationZ|Matrix:setRotationZ]] ''<translate>set rotation on z axis</translate>''<br/><!-- GIDEROSMTD:Matrix:setRotationZ --> |
− | [[Special:MyLanguage/Matrix:setScale|Matrix:setScale]] ''<translate>transform matrix for setting scale</translate>''<br/> | + | [[Special:MyLanguage/Matrix:setScale|Matrix:setScale]] ''<translate>transform matrix for setting scale</translate>''<br/><!-- GIDEROSMTD:Matrix:setScale --> |
− | [[Special:MyLanguage/Matrix:setScaleX|Matrix:setScaleX]] ''<translate>set scale on x axis</translate>''<br/> | + | [[Special:MyLanguage/Matrix:setScaleX|Matrix:setScaleX]] ''<translate>set scale on x axis</translate>''<br/><!-- GIDEROSMTD:Matrix:setScaleX --> |
− | + | [[Special:MyLanguage/Matrix:setScaleY|Matrix:setScaleY]] ''<translate>set scale on y axis</translate>''<br/><!-- GIDEROSMTD:Matrix:setScaleY --> | |
− | [[Special:MyLanguage/Matrix:setScaleZ|Matrix:setScaleZ]] ''<translate>set scale on z axis</translate>''<br/> | + | [[Special:MyLanguage/Matrix:setScaleZ|Matrix:setScaleZ]] ''<translate>set scale on z axis</translate>''<br/><!-- GIDEROSMTD:Matrix:setScaleZ --> |
− | [[Special:MyLanguage/Matrix:setTx|Matrix:setTx]] ''<translate>sets the value of the tx component</translate>''<br/> | + | [[Special:MyLanguage/Matrix:setTx|Matrix:setTx]] ''<translate>sets the value of the tx component</translate>''<br/><!-- GIDEROSMTD:Matrix:setTx --> |
− | [[Special:MyLanguage/Matrix:setTy|Matrix:setTy]] ''<translate>sets the value of the ty component</translate>''<br/> | + | [[Special:MyLanguage/Matrix:setTy|Matrix:setTy]] ''<translate>sets the value of the ty component</translate>''<br/><!-- GIDEROSMTD:Matrix:setTy --> |
− | [[Special:MyLanguage/Matrix:setTz|Matrix:setTz]] ''<translate>sets the value of the tz component</translate>''<br/> | + | [[Special:MyLanguage/Matrix:setTz|Matrix:setTz]] ''<translate>sets the value of the tz component</translate>''<br/><!-- GIDEROSMTD:Matrix:setTz --> |
− | [[Special:MyLanguage/Matrix:setX|Matrix:setX]] ''<translate>set x position</translate>''<br/> | + | [[Special:MyLanguage/Matrix:setX|Matrix:setX]] ''<translate>set x position</translate>''<br/><!-- GIDEROSMTD:Matrix:setX --> |
− | [[Special:MyLanguage/Matrix:setY|Matrix:setY]] ''<translate>set y position</translate>''<br/> | + | [[Special:MyLanguage/Matrix:setY|Matrix:setY]] ''<translate>set y position</translate>''<br/><!-- GIDEROSMTD:Matrix:setY --> |
− | [[Special:MyLanguage/Matrix:setZ|Matrix:setZ]] ''<translate>set z position</translate>''<br/> | + | [[Special:MyLanguage/Matrix:setZ|Matrix:setZ]] ''<translate>set z position</translate>''<br/><!-- GIDEROSMTD:Matrix:setZ --> |
− | [[Special:MyLanguage/Matrix:transformPoint|Matrix:transformPoint]] <br/> | + | [[Special:MyLanguage/Matrix:transformPoint|Matrix:transformPoint]] <br/><!-- GIDEROSMTD:Matrix:transformPoint --> |
− | [[Special:MyLanguage/Matrix:translate|Matrix:translate]] ''<translate>combine existing translation with provided translation</translate>''<br/> | + | [[Special:MyLanguage/Matrix:translate|Matrix:translate]] ''<translate>combine existing translation with provided translation</translate>''<br/><!-- GIDEROSMTD:Matrix:translate --> |
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
=== <translate>Events</translate> === | === <translate>Events</translate> === | ||
=== <translate>Constants</translate> === | === <translate>Constants</translate> === | ||
|} | |} |
Revision as of 14:56, 31 August 2018
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 homogenous 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)
--aply to Sprite
local sprite = Sprite.new()
sprite:setMatrix(m)
MethodsMatrix.new creates a new Matrix object |
EventsConstants |