Difference between revisions of "Matrix"
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | |||
<languages /> | <languages /> | ||
− | |||
<!-- GIDEROSOBJ:Matrix --> | <!-- GIDEROSOBJ:Matrix --> | ||
− | '''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]] | + | '''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/> |
− | <br/> | + | '''<translate>Available since</translate>:''' Gideros 2011.6<br/> |
− | '''<translate>Available since</translate>:''' Gideros 2011.6 | + | '''<translate>Inherits from</translate>:''' [[Special:MyLanguage/Object|Object]]<br/> |
− | <br/> | ||
− | '''<translate>Inherits from</translate>:''' [[Special:MyLanguage/Object|Object]] | ||
− | <br/> | ||
=== <translate>Description</translate> === | === <translate>Description</translate> === | ||
− | |||
The Matrix class specifies transformation from one coordinate space to another. | The Matrix class specifies transformation from one coordinate space to another. | ||
− | + | ||
These transformations include translation, rotation, scaling and skewing. | These transformations include translation, rotation, scaling and skewing. | ||
+ | A 2D transformation matrix is a 3 x 3 matrix in homogeneous coordinate system: | ||
− | |||
− | |||
[[File:Matrix props.png]] | [[File:Matrix props.png]] | ||
− | + | ||
You can get and set the values of all six of the properties in a Matrix object: ''m11'', ''m12'', ''m21'', ''m22'', ''tx'', and ''ty''. | 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. | Since Gideros 2016.6, Matrix can also hold 3D (4x4) matrices. | ||
− | |||
=== <translate>Examples</translate> === | === <translate>Examples</translate> === | ||
'''Applying matrix to Sprite objects''' | '''Applying matrix to Sprite objects''' | ||
− | |||
<source lang="lua"> | <source lang="lua"> | ||
local angle = math.rad(30) | local angle = math.rad(30) | ||
Line 95: | Line 85: | ||
[[Special:MyLanguage/Matrix:transformPoint|Matrix:transformPoint]] <br/><!-- GIDEROSMTD:Matrix:transformPoint() --> | [[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/><!-- GIDEROSMTD:Matrix:translate(x,y,z) combine existing translation with provided translation --> | [[Special:MyLanguage/Matrix:translate|Matrix:translate]] ''<translate>combine existing translation with provided translation</translate>''<br/><!-- GIDEROSMTD:Matrix:translate(x,y,z) combine existing translation with provided translation --> | ||
+ | |||
| 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 23:35, 9 December 2019
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)
MethodsMatrix.new creates a new Matrix object |
EventsConstants |