AS3:获取Matrix对象的规模 [英] AS3: Getting the scale of a Matrix object
问题描述
大多数情况下,问题被问如何缩放的DisplayObject,答案通常是使用矩阵。
Most often, questions are asked about how to scale a DisplayObject, and the answer is usually to use a Matrix.
我的问题是,如何将你得到一个矩阵的规模(将scaleX和scaleY)?
My question is, how to you GET the scale of a Matrix (scaleX and scaleY)?
有一个Matrix.scale方法来设置的scaleX和scaleY,但它并没有返回值,且没有其他财产存在读回。
There's a Matrix.scale method to set the scaleX and scaleY, but it doesn't return a value, and no other properties exist to read it back.
我想问的原因,我使用的是埋在内心深处到显示列表对象,并且每个都可以进行转换。所以我用的子对象的sprite.transform.concatenatedMatrix消气,但我坚持在这一点上如何从中读出的规模。
The reason I ask, I'm using object burried deep down into a Display list, and each may be transformed. So I use the child object's sprite.transform.concatenatedMatrix getter, but am stuck at this point on how to read the scale from it.
任何数学奇才的房子?
Any Math Wiz in the house?
推荐答案
通常,一个可靠的方式来隔离缩放分量以矩阵是使用矩阵问题变换的单位向量沿轴,然后测量长度得到的载体
Generally, a reliable way to isolate the scaling component in a matrix is to use the matrix in question to transform the unit vectors along the axes, and then measure the length of the resulting vectors.
例如,考虑到转换
从DisplayObject和使用的Matrix3D时,的scaleX
将所获得如下:
For instance, given the transform
from a DisplayObject, and using the Matrix3D, the scaleX
would be obtained as follows:
transform.matrix3D.deltaTransformVector(Vector3D.X_AXIS).length
或者,如果你使用的级联2D矩阵,在的scaleY
是:
transform.concatenatedMatrix.deltaTransformPoint(new Point(0,1)).length
注意 deltaTransform *
函数忽略的矩阵,这对定标无影响的转换效果。
Note that the deltaTransform*
functions ignore the translation effects of the matrices, which have no effect on the scaling.
这篇关于AS3:获取Matrix对象的规模的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!