How we get x and y from the transform matrix? [duplicate]

故事扮演 提交于 2019-12-25 05:18:22

问题


Possible Duplicate:
How to get the actual x/y position of an element in SVG with transformations and matrices

I need to get the x/y positions of an element that is written like this in SVG:

<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)" />

Here x & y attributes are given but this not gives the image actual position. As much as i know in the

transform matrix [a,b,c,d,e,f] e & f gives the translated axis in the x and y respectively. But the

problem is that here both ( e & f ) are 0. Now i can i get the actual x any y for this image?


回答1:


Assuming,

x="335.27295"
y="-421.28461"

Given the transformation matrix

a              b          e
c              d          f
0              0          1

Having the values

0.22297057     0.97482518 0
-0.97482518    0.22297057 0
0              0          1

Knowing

  • a, d are responsible for scaling x, y respectivly
  • e, f are responsible for transforming x, y respectivly

You`ll eventually get

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

Or,

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


来源:https://stackoverflow.com/questions/11535621/how-we-get-x-and-y-from-the-transform-matrix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!