title: Minimum number of points in retrieval of affine transform?
body: <p>I am trying find a 2-D <a href="https://en.wikipedia.org/w/index.php?title=Affine_transformation#Representation" rel="nofollow">affine tranform</a> given two points using the solution given by <a href="http://ojs.pythonpapers.org/index.php/tppsc/article/view/86" rel="nofollow">Kloss, and Kloss in “N-Dimensional Linear Vector Field Regression with NumPy.” (2010, The Python Papers Source Codes 2).</a></p>
  
  <p><a href="http://ojs.pythonpapers.org/index.php/tppsc/article/view/86/187" rel="nofollow">Article source code</a>.</p>
  
  <p>They give an approach to finding the affine transform connecting two sets of points <strong>y</strong> and <strong>x</strong>  where the transform is represented by a matrix <strong>A</strong> and a vector <strong>b</strong> ( i.e. the matrix equation <strong>y = Ax+b</strong>).</p>
  
  <p>In two dimensions you have 6 unknowns, four defining the 2x2 <strong>A</strong> matrix and 2 defining <strong>b</strong>. </p>
  
  <p>However, in the example script  and in the paper describing it they have unknowns t=n^2+n where n is the number of points, which means you need six points, which for the 2D case is actually 12 known values (i.e. x and y values of each point on an image).</p>
  
  <p>they test this via:</p>
  
  <pre><code>def solve(point_list):
      """
      This function solves the linear equation system involved in the n
      dimensional linear extrapolation of a vector field to an arbitrary point.
  
      f(x) = x * A + b
  
      with:
         A - The "slope" of the affine function in an n x n matrix.
         b - The "offset" value for the n dimensional zero vector.
  
      The function takes a list of n+1 point-value tuples (x, f(x)) and returns
      the matrix A and the vector b. In case anything goes wrong, the function
      returns the tuple (None, None).
  
      These can then be used to compute directly any value in the linear
      vector field.
      """dimensions = len(point_list[0][0])
      unknowns = dimensions ** 2 + dimensions
      number_points = len(point_list[0]) 
      # Bail out if we do not have enough data.
      if number_points &lt; unknowns:
          print ’For a %d dimensional problem I need at least %d data points.’ \ % (dimensions, unknowns)  
          print ’Only %d data points were given.’ % number_points return None, None.
  </code></pre>
  
  <p>...</p>
  
  <p><strong>The question:</strong></p>
  
  <p><em>Why do they say you need 6 points to get a 2D affine transform?</em></p>
  
  <p>opencv <a href="http://docs.opencv.org/doc/tutorials/imgproc/imgtrans/warp_affine/warp_affine.html" rel="nofollow">getAffineTransform</a> only needs 3 data points to find a point in 2D, which is the intuitive number, since 3 points define a plane. And when I take the above conditional test out of the Kloss and Kloss code, it works for 3 points in 2D.</p>