【问题标题】:How we get x and y from the transform matrix? [duplicate]我们如何从变换矩阵中得到 x 和 y? [复制]
【发布时间】:2012-07-18 06:41:31
【问题描述】:

可能重复:
How to get the actual x/y position of an element in SVG with transformations and matrices

我需要获取在 SVG 中这样编写的元素的 x/y 位置:

<image
   y="-421.28461"
   x="335.27295"
   id="image2991"
   xlink:href="file:///C:/Users/tom/Documents/t.jpg"
   height="369"
   width="360"
   transform="matrix(0.22297057,0.97482518,-0.97482518,0.22297057,0,0)" />

这里给出了xy 属性,但这并没有给出图像的实际位置。据我所知

变换矩阵 [a,b,c,d,e,f] e & f 分别给出 x 和 y 的平移轴。但是

问题是这里两个( e &amp; f ) 都是0。现在我可以得到这个图像的实际x 任何y 吗?

【问题讨论】:

  • 都写完了。 x="335.27295"y="-421.28461"
  • 但这不是元素的实际 x 和 y
  • 参见 SVG 文档中的 image element
  • 哦,您是在寻找应用变换矩阵后的 x、y 吗?
  • 好的,我会为你计算并发布一个带有解释的答案,给我几分钟..

标签: c# math matrix svg transform


【解决方案1】:

假设,

x="335.27295"
y="-421.28461"

给定变换矩阵

a              b          e
c              d          f
0              0          1

有价值观

0.22297057     0.97482518 0
-0.97482518    0.22297057 0
0              0          1

知道

  • a、d 分别负责缩放 x、y
  • e、f分别负责x、y的变换

你最终会得到

newX = x * a + e
newY = y * d + f

或者,

newX = 335.27295 * 0.22297057 + 0 = 74.75
newY = -421.28461 * 0.22297057 + 0 = -93.93

【讨论】:

猜你喜欢
  • 2019-06-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-28
  • 2017-08-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多