1
$\begingroup$

I have the coordinates of two points in an initial 2d coordinate system and the corresponding coordinates in a target system. Is is possible to determine the affine transform matrix from these values?

Since there are 6 unknowns, I would assume 2 points are not enough.

$ \begin{bmatrix}x' & y' & 1\end{bmatrix} = \begin{bmatrix}x & y & 1\end{bmatrix} \begin{bmatrix}a & b & 0 \\ c & d & 0 \\ t_x & t_y & 1\end{bmatrix} $

But intuitively I don't quite understand why 2 points would not be enough.

Consider the 2 finger "pinch to zoom" gesture you can use on touch screens. Isn't that exactly this case? You have the coordinates of the fingers when they first touched the screen and you have their current coordinates. And seemingly it's possible to transform the content in a way that always maps the originally touched locations to the current finger positions and scales, translates, rotates the rest accordingly.

$\endgroup$
  • $\begingroup$ What you really need here are two vectors and a single point. That will give you your $6$ unknowns. $\endgroup$ – Omnomnomnom Mar 17 '14 at 23:17
1
$\begingroup$

Two points is not enough information. There is a flaw in your argument about the pinch gesture. You could scale by whatever value you wanted in the direction perpendicular to the pinch, and the transform would still work. So, the transform is not fully determined by the two pairs of points.

The transform used in the pinch gesture is a translation+rotation+scaling, where the scaling is uniform. So, there are only four unknowns -- the x and y translations, the rotation angle, and the scale. You can determine these four quantities from the two pairs of points you get from the gesture.

Saying it another way, the "pinch" transform does not involve any secondary scaling (where one direction is scaled differently from the other), and it doesn't involve any skewing of axes. So, compared to a general 2D affine transform, two parameters are missing, and only four are left.

$\endgroup$
  • $\begingroup$ That's exactly what I overlooked. Thanks a lot! $\endgroup$ – Jawap Mar 18 '14 at 1:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.