Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
695 views
in Technique[技术] by (71.8m points)

geometry - Transfer coordinates from one triangle to another triangle

I have two triangles , which can be in any sizes. The problem is that, how I can transfer coordinates from one triangle to another? I know both of triangle position in coordinate system and yes, they both are in one system.

Basically, i have point in triangle1 and I need to transfer it in triangle2.

Reading some posts, I found out that I could be calculated using affine transformation matrix, but I didn't undestand how to solve this with affine transformation matrix.

Thank you for any help.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Let you have unknown affine transformation matrix

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

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

Then affine transformation M that transforms the first triangle vertices to the second one vertices 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 (multiply M and (x,y,1) column matrix)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...