Difference between revisions of "Matrix"
| m (fixed some typo) | |||
| 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]]<br/> | + | '''<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>Available since</translate>:''' Gideros 2011.6<br/> | + | <br/> | 
| − | '''<translate>Inherits from</translate>:''' [[Special:MyLanguage/Object|Object]]<br/> | + | '''<translate>Available since</translate>:''' Gideros 2011.6 | 
| + | <br/> | ||
| + | '''<translate>Inherits from</translate>:''' [[Special:MyLanguage/Object|Object]] | ||
| + | <br/> | ||
| + | |||
| === <translate>Description</translate> === | === <translate>Description</translate> === | ||
| − | <translate | + | <translate> | 
| − | The Matrix class specifies transformation from one coordinate space to another.<br /> | + | The Matrix class specifies transformation from one coordinate space to another. | 
| − | These transformations include translation, rotation, scaling and skewing. | + | <br/> | 
| − | + | These transformations include translation, rotation, scaling and skewing. | |
| − | A 2D transformation matrix is a 3 x 3 matrix in  | + | |
| − | <br /> | + | |
| − | [[File:Matrix props.png]] | + | A 2D transformation matrix is a 3 x 3 matrix in homogeneous coordinate system: | 
| − | <br /> | + | <br/> | 
| − | You can get and set the values of all six of the properties in a | + | [[File:Matrix props.png]] | 
| − | Matrix object: ''m11'', ''m12'', ''m21'', ''m22'', ''tx'', and ''ty''. | + | <br/> | 
| − | < | + | 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. | ||
| + | </translate> | ||
| − | |||
| === <translate>Examples</translate> === | === <translate>Examples</translate> === | ||
| − | '''Applying matrix to Sprite objects'''<br/> | + | '''Applying matrix to Sprite objects''' | 
| − | <source lang="lua">local angle = math.rad(30) | + | <br/> | 
| + | <source lang="lua"> | ||
| + | local angle = math.rad(30) | ||
| -- create skew matrix | -- create skew matrix | ||
| local m = Matrix.new(1, math.tan(angle), math.tan(angle), 1, 0, 0) | local m = Matrix.new(1, math.tan(angle), math.tan(angle), 1, 0, 0) | ||
| − | -- | + | -- apply to Sprite | 
| local sprite = Sprite.new() | local sprite = Sprite.new() | ||
| − | sprite:setMatrix(m)</source> | + | sprite:setMatrix(m) | 
| + | </source> | ||
| + | |||
| {|- | {|- | ||
| | style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
Revision as of 02:43, 16 September 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 | 
