代码之家  ›  专栏  ›  技术社区  ›  Todd Main

从XAML中菱形的倾斜因子创建倾斜角度

  •  3
  • Todd Main  · 技术社区  · 14 年前

    我不确定这是否可行,但基本上我有两个角度可以改变图像的宽度/大小和歪斜。在转换矩阵( <matrix3dprojection/> )中,它的工作方式如下:

    < PRE> M11: cos(x) m12: sin(y)*sin(x) m11:0 M21:0 M22: cos(y) M23:0 立方米1:0立方米2:0立方米3:1

    因此,如果我有 x=30_敓

    < PRE> M11: 0.866 m12: 0.321 m11:0 M21:0 M22: 0.766 M23:0 立方米1:0立方米2:0立方米3:1

    因此, 变为

    我想使用的是一个 transformGroup/> 但是不能很好地计算出??”/> 部分。 <scaleTransform/> 通过使用 m11 and m22 values above in scalex and scaley like <scaleTransform scalex=”.866“scaley=”.766“/>

    但我无法从一个 m12中找出 angley的部分我知道,通过手动操作,a value of angley=“20.3” 似乎非常准确。但我不知道这背后的数学原理。

    有人知道吗?<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 
    

    所以 normal 变成 30x40

    我想用的是 <TransformGroup/> 但不太清楚 <SkewTransform AngleY="???"/> 部分。这个 <ScaleTransform/> 使用起来很容易 M11 M22 值以上 ScaleX ScaleY 喜欢 <ScaleTransform ScaleX=".866" ScaleY=".766"/> .

    但我不知道 AngleY 部分 <SkewTransform/> 从一个 M12 价值 零点三二一 . 我知道,通过手动操作,值为 AngleY="20.3" 看起来很准确。但我想不出这背后的数学原理。

    有人知道吗?

    2 回复  |  直到 14 年前
        1
  •  3
  •   Quartermeister    14 年前

    您可以在歪斜变换类上使用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 degrees . 或者,回到原来的数字, skewY = atan(sin(y) * sin(x) / cos(y)) = atan(tan(y) * sin(x)) 它的产量 atan(tan(40 degrees) * sin(30 degrees)) = 22.7604763 degrees .

        2
  •  0
  •   AnthonyWJones    14 年前

    尝试在两行之间读一点你想避免使用 Projection 财产和使用权 RenderTransform 相反?

    如果是这样的话,而不是试图找出如何使用 ScaleTransform SkewTransform 只使用 MatrixTransform 渲染变换 .

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

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