从一个三角形转移坐标到另一个三角形 [英] Transfer coordinates from one triangle to another triangle

查看:205
本文介绍了从一个三角形转移坐标到另一个三角形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个三角形,可以是任意大小。问题是,我如何将坐标从一个三角形转移到另一个三角形?我知道坐标系中的三角形位置和是的,它们都在一个系统中。

基本上,我有点在triangle1,我需要将它转换为triangle2。



阅读一些文章后,我发现我可以使用仿射变换矩阵进行计算,但我没有想到如何解决这个问题。仿射变换矩阵。



感谢您的任何帮助。

解决方案

让我们来看看你的未知仿射变换矩阵

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

第一个三角形顶点是(xa1,ya1),(xa2,ya2),(xa3,ya3) ,第二个三角形顶点的坐标为(xb1,yb1),(xb2,yb2),(xb3,yb3),然后将第一个三角形转换为第二个三角形的仿射变换为

  M * A = B 

其中

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

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

为了找到未知的M,我们可以将表达式的两边乘以矩阵的逆

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

A的倒置相当简单(由Maple计算,可能包含由于我的拼写错误而导致的错误):

  | (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)|

其中行列式值为

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

因此,您可以找到所需转换的仿射矩阵,并将其应用于坐标。

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.

解决方案

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

这篇关于从一个三角形转移坐标到另一个三角形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆