Difference between revisions of "Transform:getMatrix"
m |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | {{newin|[[ | + | {{newin|[[11.0]]|110|type=function}} |
Gets the internal 4x4 transformation matrix stored by this Transform. The matrix is returned in [[MatrixLayout|row-major]] order. | Gets the internal 4x4 transformation matrix stored by this Transform. The matrix is returned in [[MatrixLayout|row-major]] order. | ||
Line 8: | Line 8: | ||
</source> | </source> | ||
=== Arguments === | === Arguments === | ||
− | None | + | None. |
+ | |||
=== Returns === | === Returns === | ||
{{param|number|e1_1|The first column of the first row of the matrix.}} | {{param|number|e1_1|The first column of the first row of the matrix.}} | ||
Line 14: | Line 15: | ||
{{param|number|...|Additional matrix elements.}} | {{param|number|...|Additional matrix elements.}} | ||
{{param|number|e4_4|The fourth column of the fourth row of the matrix.}} | {{param|number|e4_4|The fourth column of the fourth row of the matrix.}} | ||
+ | |||
+ | |||
+ | === Examples === | ||
+ | Get "[[Transform:translate]]" transformations from the matrix: | ||
+ | <source lang="lua"> | ||
+ | local function getTranslate(transform) | ||
+ | -- get the matrix from the transform object | ||
+ | local matrix = transform:getMatrix() | ||
+ | -- extract X, Y translation values (4th and 8th elements) | ||
+ | local translateX, translateY = matrix[4], matrix[8] | ||
+ | return translateX, translateY | ||
+ | end | ||
+ | </source> | ||
+ | |||
+ | Get "[[Transform:scale]]" transformations from the matrix: | ||
+ | <source lang="lua"> | ||
+ | local function getScale(transform) | ||
+ | -- get the matrix from the transform object | ||
+ | local matrix = transform:getMatrix() | ||
+ | -- extract X, Y scale values | ||
+ | local scaleX, scaleY = matrix[1], matrix[6] | ||
+ | return scaleX, scaleY | ||
+ | end | ||
+ | </source> | ||
== See Also == | == See Also == |
Latest revision as of 15:55, 26 February 2025
Available since LÖVE 11.0 |
This function is not supported in earlier versions. |
Gets the internal 4x4 transformation matrix stored by this Transform. The matrix is returned in row-major order.
Contents
Function
Synopsis
e1_1, e1_2, ..., e4_4 = Transform:getMatrix( )
Arguments
None.
Returns
number e1_1
- The first column of the first row of the matrix.
number e1_2
- The second column of the first row of the matrix.
number ...
- Additional matrix elements.
number e4_4
- The fourth column of the fourth row of the matrix.
Examples
Get "Transform:translate" transformations from the matrix:
local function getTranslate(transform)
-- get the matrix from the transform object
local matrix = transform:getMatrix()
-- extract X, Y translation values (4th and 8th elements)
local translateX, translateY = matrix[4], matrix[8]
return translateX, translateY
end
Get "Transform:scale" transformations from the matrix:
local function getScale(transform)
-- get the matrix from the transform object
local matrix = transform:getMatrix()
-- extract X, Y scale values
local scaleX, scaleY = matrix[1], matrix[6]
return scaleX, scaleY
end
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info