Transfer coordinates from one triangle to another triangle

↘锁芯ラ 提交于 2019-11-29 07:57:42

Let's you have unknown affine transformation matrix

   | a c e |
M =| b d f |
   | 0 0 1 |

first triangle vertices are (xa1, ya1), (xa2, ya2), (xa3, ya3), and second triangle vertices have coordinates (xb1, yb1), (xb2, yb2), (xb3, yb3)

Then affine transformation that transforms first triangle to second one is

M * A = B

where

   | xa1 xa2 xa3 |
A =| ya1 ya2 ya3 |
   |  1   1   1  |

   | xb1 xb2 xb3 |
B =| yb1 yb2 yb3 |
   |  1   1   1  |

To find unknown M, we can multiply both sides of the expression by inverse of A matrix

M * A * Inv(A) = B * Inv(A)
M = B * Inv(A)

Inversion of A is rather simple (calculated by Maple, may contain errors due to my typos):

| (ya2-ya3)    -(xa2-xa3)    (xa2*ya3-xa3*ya2)  |
| -(-ya3+ya1)  (-xa3+xa1)    -(xa1*ya3-ya1*xa3) | * 1/Det
| (-ya2+ya1)   -(-xa2+xa1)   (xa1*ya2-ya1*xa2)  |

where determinant value is

Det = xa2*ya3-xa3*ya2-ya1*xa2+ya1*xa3+xa1*ya2-xa1*ya3

So you can find affine matrix for needed transformation and apply it to coordinates

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