在 XAML 中根据菱形的倾斜因子创建倾斜角度Y
我不确定这是否可能,但基本上我有两个度数可以改变图像的宽度/大小和倾斜。在变换矩阵 (
) 中,它的工作原理如下:
M11:cos(x) M12:sin(y)*sin(x) M11:0 M21:0 M22:cos(y) M23:0 M31:0 M32:0 M33:1
因此,如果我有 X = 30°
和 Y=40°
code>,我的矩阵是:
M11:0.866 M12:0.321 M11:0 M21:0 M22:0.766 M23:0 M31:0 M32:0 M33:1
所以 变为
我想使用的是
部分。通过在 ScaleX
和 中使用上面的 M11 和 M22 值,
就像
看起来很简单>ScaleY
。
但我无法从 M12
值 0.321AngleY
部分>。我知道,通过手动处理,AngleY="20.3"
的值似乎非常准确。但我无法弄清楚这背后的数学原理。
有谁知道吗?
I'm not sure if this is possible, but basically I have two degrees that will change the width/size and skew of an image. In a tranformation matrix (<Matrix3DProjection/>
), it works like this:
M11:cos(x) M12:sin(y)*sin(x) M11:0 M21:0 M22:cos(y) M23:0 M31:0 M32:0 M33:1
So if I have X = 30°
and Y=40°
, my matrix is:
M11:0.866 M12:0.321 M11:0 M21:0 M22:0.766 M23:0 M31:0 M32:0 M33:1
So becomes
What I'd like to use instead is a <TransformGroup/>
but can't quite figure out the <SkewTransform AngleY="???"/>
portion. The <ScaleTransform/>
seems easy enough by using M11 and M22 values above in ScaleX
and ScaleY
like <ScaleTransform ScaleX=".866" ScaleY=".766"/>
.
But I can't figure out the AngleY
portion of <SkewTransform/>
from an M12
value of 0.321. I know that from doinking around with this manually, a value of AngleY="20.3"
seems very accurate. But I can't figure out the math behind this.
Does anyone know?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在 SkewTransform 类上使用 Reflector 来找出数学原理。它调用 Matrix.Skew,它使用矩阵:
由于您想要
tan(skewY) * 0.766 = 0.321
,因此您会得到skewY = atan(0.321 / 0.766) = 22.7366108 度
。或者,回到原来的数字,skewY = atan(sin(y) * sin(x) / cos(y)) = atan(tan(y) * sin(x))
,其中得出 atan(tan(40 度) * sin(30 度)) = 22.7604763 度。You can use Reflector on the SkewTransform class to find out the math. It calls Matrix.Skew, which uses the matrix:
Since you want
tan(skewY) * 0.766 = 0.321
, you getskewY = atan(0.321 / 0.766) = 22.7366108 degrees
. Or, going back to your original numbers,skewY = atan(sin(y) * sin(x) / cos(y)) = atan(tan(y) * sin(x))
, which yieldsatan(tan(40 degrees) * sin(30 degrees)) = 22.7604763 degrees
.尝试从字里行间解读一下您是否想避免使用
Projection
属性并改用RenderTransform
?如果是这样,而不是尝试弄清楚如何使用 ScaleTransform 和 SkewTransform ,只需使用 RenderTransform 中的 MatrixTransform 即可。
或者
Trying to read between the lines a little you want to avoid using the
Projection
property and use to theRenderTransform
instead?If so rather than trying to work out how to use
ScaleTransform
andSkewTransform
just use theMatrixTransform
in theRenderTransform
.OR