我不确定这是否可行,但基本上我有两个度数可以改变图像的宽度/大小和倾斜度。在转换矩阵 ( <Matrix3DProjection/>
) 中,它是这样工作的:
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°
,我的矩阵是:
M11:0.866 M12:0.321 M11:0 M21:0 M22:0.766 M23:0 M31:0 M32:0 M33:1
所以 变成
我想改用 <TransformGroup/>
但不太明白 <SkewTransform AngleY="???"/>
部分。 <ScaleTransform/>
在 ScaleX
中使用上面的 M11 和 M22 值似乎很容易和 ScaleY
喜欢<ScaleTransform ScaleX=".866" ScaleY=".766"/>
.
但我无法弄清楚 AngleY
<SkewTransform/>
的一部分来自 M12
0.321 的值。我知道通过手动处理这个,值 AngleY="20.3"
似乎很准确。但我无法弄清楚这背后的数学原理。
有人知道吗?
最佳答案
您可以在 SkewTransform 类上使用 Reflector 来找出数学。它调用Matrix.Skew ,它使用矩阵:
1.0 tan(skewY) 0.0
tax(skewX) 1.0 0.0
因为您想要 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 degrees) * sin(30 degrees)) = 22.7604763 degrees
。
关于wpf - 在 XAML 中从菱形的偏斜因子创建偏斜 AngleY,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3226116/