在 XAML 中根据菱形的倾斜因子创建倾斜角度Y

发布于 2024-09-09 04:58:17 字数 1304 浏览 13 评论 0原文

我不确定这是否可能,但基本上我有两个度数可以改变图像的宽度/大小和倾斜。在变换矩阵 () 中,它的工作原理如下:

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 

所以 normal 变为 30x40

我想使用的是 但无法完全弄清楚 部分。通过在 ScaleX中使用上面的 M11M22 值, 看起来很简单>ScaleY 就像

但我无法从 M120.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 normal becomes 30x40

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夏九 2024-09-16 04:58:17

您可以在 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 度) * 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:

1.0           tan(skewY)    0.0
tax(skewX)    1.0           0.0

Since you want tan(skewY) * 0.766 = 0.321, you get skewY = 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 yields atan(tan(40 degrees) * sin(30 degrees)) = 22.7604763 degrees.

拥抱没勇气 2024-09-16 04:58:17

尝试从字里行间解读一下您是否想避免使用 Projection 属性并改用 RenderTransform

如果是这样,而不是尝试弄清楚如何使用 ScaleTransform 和 SkewTransform ,只需使用 RenderTransform 中的 MatrixTransform 即可。

 <MatrixTransform Matrix=".866, .321, 0, .766, 0, 0" />

或者

 <MatrixTransform M11="0.866" M12="0.321", M22="0.766" />

Trying to read between the lines a little you want to avoid using the Projection property and use to the RenderTransform instead?

If so rather than trying to work out how to use ScaleTransform and SkewTransform just use the MatrixTransform in the RenderTransform.

 <MatrixTransform Matrix=".866, .321, 0, .766, 0, 0" />

OR

 <MatrixTransform M11="0.866" M12="0.321", M22="0.766" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文