Find Affine transformation matrix between two Shapes(SVG Paths)

孤人 提交于 2019-12-23 23:01:07

问题


I have two Shapes, each defined as a single SVG Path. I want to find if Shape A is an Affine Transform of Shape B and also compute/find the Affine transform matrix. My current approach computes the consecutive Angles between off curve and on curve points to find if they are transformed shapes. This works for translate,scale,rotate operations. But does not work for sheared Shapes.

Any proper mathematical approaches are available?


回答1:


You can find matrix of affine transform between any triplet of non-collinear points P1,P2,P3 and their translated twins P1',P2',P3'

A * P = P'

   |x1  x2  x3|    |x1' x2' x3'|
A *|y1  y2  y3| =  |y1' y2' y3'|  
   |1   1   1 |    |1   1    1 |

To calculate A, it is needed to multiply both sides by inverse of P matrix

A * P * P-1 = P' * P-1

A * E = P' * P-1

A = P' * P-1

Then check that the same A works for other triplets of points (for random subset or for all points, if possible)

There are sophisticated methods to evaluate affine transform for the whole point cloud, but they are more complex.



来源:https://stackoverflow.com/questions/33590244/find-affine-transformation-matrix-between-two-shapessvg-paths

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