Difference between revisions of "Matrix"

From GiderosMobile
(remove language stuff)
(tried to fill missing methods short description)
Line 32: Line 32:
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== Methods ===
 
=== Methods ===
[[Matrix.new]] ''creates a new Matrix object''<br/><!-- GIDEROSMTD:Matrix.new(m11,m12,m21,m22,tx,ty) creates a new Matrix object -->
+
[[Matrix.new]] ''creates a new Matrix object''<br/><!--GIDEROSMTD:Matrix.new(m11,m12,m21,m22,tx,ty) creates a new Matrix object-->
[[Matrix:getAnchorPosition]] ''get anchor position from matrix transformation''<br/><!-- GIDEROSMTD:Matrix:getAnchorPosition() get anchor position from matrix transformation -->
+
[[Matrix:getAnchorPosition]] ''gets anchor position from matrix transformation''<br/><!--GIDEROSMTD:Matrix:getAnchorPosition() gets anchor position from matrix transformation-->
[[Matrix:getElements]] ''returns the elements of this matrix instance''<br/><!-- GIDEROSMTD:Matrix:getElements() returns the elements of this matrix instance -->
+
[[Matrix:getElements]] ''returns the elements of this matrix instance''<br/><!--GIDEROSMTD:Matrix:getElements() returns the elements of this matrix instance-->
[[Matrix:getM11]] ''returns the value of the m11 component''<br/><!-- GIDEROSMTD:Matrix:getM11() returns the value of the m11 component -->
+
[[Matrix:getM11]] ''returns the value of the m11 component''<br/><!--GIDEROSMTD:Matrix:getM11() returns the value of the m11 component-->
[[Matrix:getM12]] ''returns the value of the m12 component''<br/><!-- GIDEROSMTD:Matrix:getM12() returns the value of the m12 component -->
+
[[Matrix:getM12]] ''returns the value of the m12 component''<br/><!--GIDEROSMTD:Matrix:getM12() returns the value of the m12 component-->
[[Matrix:getM21]] ''returns the value of the m21 component''<br/><!-- GIDEROSMTD:Matrix:getM21() returns the value of the m21 component -->
+
[[Matrix:getM21]] ''returns the value of the m21 component''<br/><!--GIDEROSMTD:Matrix:getM21() returns the value of the m21 component-->
[[Matrix:getM22]] ''returns the value of the m22 component''<br/><!-- GIDEROSMTD:Matrix:getM22() returns the value of the m22 component -->
+
[[Matrix:getM22]] ''returns the value of the m22 component''<br/><!--GIDEROSMTD:Matrix:getM22() returns the value of the m22 component-->
[[Matrix:getMatrix]] ''get all 16 elements of 4x4 matrix''<br/><!-- GIDEROSMTD:Matrix:getMatrix() get all 16 elements of 4x4 matrix -->
+
[[Matrix:getMatrix]] ''gets all 16 elements of 4x4 matrix''<br/><!--GIDEROSMTD:Matrix:getMatrix() gets all 16 elements of 4x4 matrix-->
[[Matrix:getPosition]] ''get position from matrix transformation''<br/><!-- GIDEROSMTD:Matrix:getPosition() get position from matrix transformation -->
+
[[Matrix:getPosition]] ''gets position from matrix transformation''<br/><!--GIDEROSMTD:Matrix:getPosition() gets position from matrix transformation-->
[[Matrix:getRotationX]] ''get rotation for x axis''<br/><!-- GIDEROSMTD:Matrix:getRotationX() get rotation for x axis -->
+
[[Matrix:getRotationX]] ''gets rotation on x axis''<br/><!--GIDEROSMTD:Matrix:getRotationX() gets rotation on x axis-->
[[Matrix:getRotationY]] ''get rotation on y axis''<br/><!-- GIDEROSMTD:Matrix:getRotationY() get rotation on y axis -->
+
[[Matrix:getRotationY]] ''gets rotation on y axis''<br/><!--GIDEROSMTD:Matrix:getRotationY() get rotation on y axis-->
[[Matrix:getRotationZ]] ''get rotation for z axis''<br/><!-- GIDEROSMTD:Matrix:getRotationZ() get rotation for z axis -->
+
[[Matrix:getRotationZ]] ''get rotation on z axis''<br/><!--GIDEROSMTD:Matrix:getRotationZ() get rotation on z axis-->
[[Matrix:getScale]] ''get scale from matrix transformation''<br/><!-- GIDEROSMTD:Matrix:getScale() get scale from matrix transformation -->
+
[[Matrix:getScale]] ''gets scale from matrix transformation''<br/><!--GIDEROSMTD:Matrix:getScale() gets scale from matrix transformation-->
[[Matrix:getScaleX]] ''get scale on x axis''<br/><!-- GIDEROSMTD:Matrix:getScaleX() get scale on x axis -->
+
[[Matrix:getScaleX]] ''gets scale on x axis''<br/><!--GIDEROSMTD:Matrix:getScaleX() gets scale on x axis-->
[[Matrix:getScaleY]] ''get scale on y axis''<br/><!-- GIDEROSMTD:Matrix:getScaleY() get scale on y axis -->
+
[[Matrix:getScaleY]] ''gets scale on y axis''<br/><!--GIDEROSMTD:Matrix:getScaleY() gets scale on y axis-->
[[Matrix:getScaleZ]] ''get scale on z axis''<br/><!-- GIDEROSMTD:Matrix:getScaleZ() get scale on z axis -->
+
[[Matrix:getScaleZ]] ''gets scale on z axis''<br/><!--GIDEROSMTD:Matrix:getScaleZ() gets scale on z axis-->
[[Matrix:getTx]] ''returns the value of the tx component''<br/><!-- GIDEROSMTD:Matrix:getTx() returns the value of the tx component -->
+
[[Matrix:getTx]] ''returns the value of the tx component''<br/><!--GIDEROSMTD:Matrix:getTx() returns the value of the tx component-->
[[Matrix:getTy]] ''returns the value of the ty component''<br/><!-- GIDEROSMTD:Matrix:getTy() returns the value of the ty component -->
+
[[Matrix:getTy]] ''returns the value of the ty component''<br/><!--GIDEROSMTD:Matrix:getTy() returns the value of the ty component-->
[[Matrix:getTz]] ''returns the value of the tz component''<br/><!-- GIDEROSMTD:Matrix:getTz() returns the value of the tz component -->
+
[[Matrix:getTz]] ''returns the value of the tz component''<br/><!--GIDEROSMTD:Matrix:getTz() returns the value of the tz component-->
[[Matrix:getX]] ''get x position''<br/><!-- GIDEROSMTD:Matrix:getX() get x position -->
+
[[Matrix:getX]] ''gets x position''<br/><!--GIDEROSMTD:Matrix:getX() gets x position-->
[[Matrix:getY]] ''get y position''<br/><!-- GIDEROSMTD:Matrix:getY() get y position -->
+
[[Matrix:getY]] ''gets y position''<br/><!--GIDEROSMTD:Matrix:getY() gets y position-->
[[Matrix:getZ]] ''get z position''<br/><!-- GIDEROSMTD:Matrix:getZ() get z position -->
+
[[Matrix:getZ]] ''gets z position''<br/><!--GIDEROSMTD:Matrix:getZ() gets z position-->
[[Matrix:invert]] <br/><!-- GIDEROSMTD:Matrix:invert() -->
+
[[Matrix:invert]] ''inverts the matrix''<br/><!--GIDEROSMTD:Matrix:invert() inverts the matrix-->
[[Matrix:multiply]] ''Multiply current matrix with new one''<br/><!-- GIDEROSMTD:Matrix:multiply(matrix) Multiply current matrix with new one -->
+
[[Matrix:multiply]] ''multiplies current matrix with new one''<br/><!--GIDEROSMTD:Matrix:multiply(matrix) multiplies current matrix with new one-->
[[Matrix:orthographicProjection]] <br/><!-- GIDEROSMTD:Matrix:orthographicProjection(left,right,bottom,top,near,far) -->
+
[[Matrix:orthographicProjection]] ''replaces this matrix by an orthographic projection''<br/><!--GIDEROSMTD:Matrix:orthographicProjection(left,right,bottom,top,near,far) replaces this matrix by an orthographic projection-->
[[Matrix:perspectiveProjection]] <br/><!-- GIDEROSMTD:Matrix:perspectiveProjection(left,right,bottom,top,near,far) -->
+
[[Matrix:perspectiveProjection]] ''replaces this matrix by a perspective projection''<br/><!--GIDEROSMTD:Matrix:perspectiveProjection(left,right,bottom,top,near,far) replaces this matrix by a perspective projection-->
[[Matrix:perspectiveProjection]] <br/><!-- GIDEROSMTD:Matrix:perspectiveProjection(fov,aspect,near,far) -->
+
[[Matrix:perspectiveProjection]] ''replaces this matrix by a perspective projection''<br/><!--GIDEROSMTD:Matrix:perspectiveProjection(fov,aspect,near,far) replaces this matrix by a perspective projection-->
[[Matrix:rotate]] ''combine existing rotation with provided''<br/><!-- GIDEROSMTD:Matrix:rotate(angle,x vector,y vector,z vector) combine existing rotation with provided -->
+
[[Matrix:rotate]] ''combines existing rotation with provided rotation''<br/><!--GIDEROSMTD:Matrix:rotate(angle,x vector,y vector,z vector) combines existing rotation with provided rotation-->
[[Matrix:scale]] ''combine existing scale with provided scale''<br/><!-- GIDEROSMTD:Matrix:scale(x scale,y scale,z scale) combine existing scale with provided scale -->
+
[[Matrix:scale]] ''combines existing scale with provided scale''<br/><!--GIDEROSMTD:Matrix:scale(x scale,y scale,z scale) combines existing scale with provided scale-->
[[Matrix:setAnchorPosition]] ''transform matrix for setting anchor position''<br/><!-- GIDEROSMTD:Matrix:setAnchorPosition(x,y,z) transform matrix for setting anchor position -->
+
[[Matrix:setAnchorPosition]] ''transform matrix for setting anchor position''<br/><!--GIDEROSMTD:Matrix:setAnchorPosition(x,y,z) transform matrix for setting anchor position-->
[[Matrix:setElements]] ''sets all 6 elements of this matrix instance''<br/><!-- GIDEROSMTD:Matrix:setElements(m11,m12,m21,m22,tx,ty) sets all 6 elements of this matrix instance -->
+
[[Matrix:setElements]] ''sets all 6 elements of this matrix instance''<br/><!--GIDEROSMTD:Matrix:setElements(m11,m12,m21,m22,tx,ty) sets all 6 elements of this matrix instance-->
[[Matrix:setM11]] ''sets the value of the m11 component''<br/><!-- GIDEROSMTD:Matrix:setM11(m11) sets the value of the m11 component -->
+
[[Matrix:setM11]] ''sets the value of the m11 component''<br/><!--GIDEROSMTD:Matrix:setM11(m11) sets the value of the m11 component-->
[[Matrix:setM12]] ''sets the value of the m22 component''<br/><!-- GIDEROSMTD:Matrix:setM12(m12) sets the value of the m22 component -->
+
[[Matrix:setM12]] ''sets the value of the m12 component''<br/><!--GIDEROSMTD:Matrix:setM12(m12) sets the value of the m12 component-->
[[Matrix:setM21]] <br/><!-- GIDEROSMTD:Matrix:setM21(m21) -->
+
[[Matrix:setM21]] ''sets the value of the m21 component''<br/><!--GIDEROSMTD:Matrix:setM21(m21) sets the value of the m21 component-->
[[Matrix:setM22]] <br/><!-- GIDEROSMTD:Matrix:setM22(m22) -->
+
[[Matrix:setM22]] ''sets the value of the m22 component''<br/><!--GIDEROSMTD:Matrix:setM22(m22) sets the value of the m22 component-->
[[Matrix:setMatrix]] ''set all 16 elements of 4x4 matrix''<br/><!-- GIDEROSMTD:Matrix:setMatrix(m11,m12,m13,m14,m21,m22,m23,m24,m31,m32,m33,m34,m41,m42,m43,m44) set all 16 elements of 4x4 matrix -->
+
[[Matrix:setMatrix]] ''set all 16 elements of 4x4 matrix''<br/><!--GIDEROSMTD:Matrix:setMatrix(m11,m12,m13,m14,m21,m22,m23,m24,m31,m32,m33,m34,m41,m42,m43,m44) set all 16 elements of 4x4 matrix-->
[[Matrix:setPosition]] ''transform matrix for setting position''<br/><!-- GIDEROSMTD:Matrix:setPosition(x,y,z) transform matrix for setting position -->
+
[[Matrix:setPosition]] ''transform matrix for setting position''<br/><!--GIDEROSMTD:Matrix:setPosition(x,y,z) transform matrix for setting position-->
[[Matrix:setRotationX]] ''set rotation on x axis''<br/><!-- GIDEROSMTD:Matrix:setRotationX(x rotation) set rotation on x axis -->
+
[[Matrix:setRotationX]] ''sets rotation on x axis''<br/><!--GIDEROSMTD:Matrix:setRotationX(x rotation) sets rotation on x axis-->
[[Matrix:setRotationY]] ''set rotation on y axis''<br/><!-- GIDEROSMTD:Matrix:setRotationY(y rotation) set rotation on y axis -->
+
[[Matrix:setRotationY]] ''sets rotation on y axis''<br/><!--GIDEROSMTD:Matrix:setRotationY(y rotation) sets rotation on y axis-->
[[Matrix:setRotationZ]] ''set rotation on z axis''<br/><!-- GIDEROSMTD:Matrix:setRotationZ(z rotation) set rotation on z axis -->
+
[[Matrix:setRotationZ]] ''sets rotation on z axis''<br/><!--GIDEROSMTD:Matrix:setRotationZ(z rotation) sets rotation on z axis-->
[[Matrix:setScale]] ''transform matrix for setting scale''<br/><!-- GIDEROSMTD:Matrix:setScale(x,y,z) transform matrix for setting scale -->
+
[[Matrix:setScale]] ''transform matrix for setting scale''<br/><!--GIDEROSMTD:Matrix:setScale(x,y,z) transform matrix for setting scale-->
[[Matrix:setScaleX]] ''set scale on x axis''<br/><!-- GIDEROSMTD:Matrix:setScaleX(x scale) set scale on x axis -->
+
[[Matrix:setScaleX]] ''sets scale on x axis''<br/><!--GIDEROSMTD:Matrix:setScaleX(x scale) sets scale on x axis-->
[[Matrix:setScaleY]] ''set scale on y axis''<br/><!-- GIDEROSMTD:Matrix:setScaleY(y scale) set scale on y axis -->
+
[[Matrix:setScaleY]] ''sets scale on y axis''<br/><!--GIDEROSMTD:Matrix:setScaleY(y scale) sets scale on y axis-->
[[Matrix:setScaleZ]] ''set scale on z axis''<br/><!-- GIDEROSMTD:Matrix:setScaleZ(z scale) set scale on z axis -->
+
[[Matrix:setScaleZ]] ''sets scale on z axis''<br/><!--GIDEROSMTD:Matrix:setScaleZ(z scale) sets scale on z axis-->
[[Matrix:setTx]] ''sets the value of the tx component''<br/><!-- GIDEROSMTD:Matrix:setTx(tx) sets the value of the tx component -->
+
[[Matrix:setTx]] ''sets the value of the tx component''<br/><!--GIDEROSMTD:Matrix:setTx(tx) sets the value of the tx component-->
[[Matrix:setTy]] ''sets the value of the ty component''<br/><!-- GIDEROSMTD:Matrix:setTy(ty) sets the value of the ty component -->
+
[[Matrix:setTy]] ''sets the value of the ty component''<br/><!--GIDEROSMTD:Matrix:setTy(ty) sets the value of the ty component-->
[[Matrix:setTz]] ''sets the value of the tz component''<br/><!-- GIDEROSMTD:Matrix:setTz(tz) sets the value of the tz component -->
+
[[Matrix:setTz]] ''sets the value of the tz component''<br/><!--GIDEROSMTD:Matrix:setTz(tz) sets the value of the tz component-->
[[Matrix:setX]] ''set x position''<br/><!-- GIDEROSMTD:Matrix:setX(x) set x position -->
+
[[Matrix:setX]] ''sets x position''<br/><!--GIDEROSMTD:Matrix:setX(x) sets x position-->
[[Matrix:setY]] ''set y position''<br/><!-- GIDEROSMTD:Matrix:setY(y) set y position -->
+
[[Matrix:setY]] ''sets y position''<br/><!--GIDEROSMTD:Matrix:setY(y) sets y position-->
[[Matrix:setZ]] ''set z position''<br/><!-- GIDEROSMTD:Matrix:setZ(z) set z position -->
+
[[Matrix:setZ]] ''sets z position''<br/><!--GIDEROSMTD:Matrix:setZ(z) sets z position-->
[[Matrix:transformPoint]] <br/><!-- GIDEROSMTD:Matrix:transformPoint() -->
+
[[Matrix:transformPoint]] ''transforms the matrix''<br/><!--GIDEROSMTD:Matrix:transformPoint() transforms the matrix-->
[[Matrix:translate]] ''combine existing translation with provided translation''<br/><!-- GIDEROSMTD:Matrix:translate(x,y,z) combine existing translation with provided translation -->
+
[[Matrix:translate]] ''combines existing translation with provided translation''<br/><!--GIDEROSMTD:Matrix:translate(x,y,z) combines existing translation with provided translation-->
  
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|

Revision as of 08:44, 25 December 2020

Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform html5.pngPlatform winrt.pngPlatform win32.png
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:

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.

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