给定坐标系 A 中的 3 个点(x 和 y 坐标)和坐标系 B 中的 3 个对应点,我如何导出将从 A 转换为 B 的 AffineTransform。
我的问题与 Create transform to map from one rectangle to another? 类似,但该问题仅涉及 2 点 - 即,它假设没有轮换。
最佳答案
假设您的转换采用以下形式
x' = px + qy + r
y' = sx + ty + u
并将你的六个点写为(A1x, A1y), (A2x, A2y), (A3x, A3y), (B1x, B1y), (B2x, B2y), (B3x, B3y)
。以矩阵形式表达得出
/ \ / \ / \
| B1x B2x B3x | | p q r | | A1x A2x A3x |
| | = | | | |
| B1y B2y B3y | | s t u | | A1y A2y A3y |
\ / \ / | |
| 1 1 1 |
\ /
现在求右侧 3x3 矩阵的逆矩阵。您会在网上找到大量算法来告诉您如何做到这一点。有一个在http://www.econ.umn.edu/undergrad/math/An%20Algorithm%20for%20Finding%20the%20Inverse.pdf ,例如。
将上式两边分别后乘以 3x3 矩阵的逆矩阵,得到 p、q、r、s、t、u、v 的值
。
关于java - 从 3 个点生成 AffineTransform,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21270892/