ewoksndreg.transformation.lstsq.calc_affine#
- ewoksndreg.transformation.lstsq.calc_affine(from_coord, to_coord)[source]#
Coordinate array shape is (ndim, ncoord).
Find the affine transformation between two sets of coordinates by solving this system of equations:
\[\begin{split}\begin{align*} x' &= a.x + b.y + t_0\\ y' &= c.x + d.y + t_1\\ \mathrm{sol} &= [a, b, t_0, c, d, t_1] \end{align*}\end{split}\]\[\begin{split}\begin{equation*} \begin{bmatrix} x_1 & y1 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & x_1 & y1 & 1 \\ x_2 & y_2 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & x_2 & y_2 & 1 \\ \vdots \end{bmatrix}. \mathrm{sol} = \begin{bmatrix} x_1' \\ y1' \\ x_2' \\ y_2' \\ \vdots \end{bmatrix} \end{equation*}\end{split}\]The resulting transformation matrix is
\[\begin{split}\begin{equation*} \mathrm{sol}=\begin{bmatrix} a & b & t_0\\ c & d & t_1\\ 0 & 0 & 1 \end{bmatrix} \end{equation*}\end{split}\]- Parameters:
from_coord (
Sequence
[ndarray
])to_coord (
Sequence
[ndarray
])
- Return type:
ndarray