问题
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