1

I have an array of 3D paired points in two different coordinate spaces (A and B).

Given points are not coplanar, how do I compute a non-affine transformation matrix which is able to transform a point from A into B?

I have managed to do this in 2D (using a homography), but can't work out how to make it work in 3D. A quick code example would be much appreciated if possible. :)

John
  • 405
  • 4
  • 19

1 Answers1

3

The approach described in this post will generalize to three dimensions: If you know the coordinates of five points in both coordinate systems, then you can use them to compute a 4×4 projective transformation matrix for this, which will be unique except for a scale factor which is without geometric relevance.

I've included variations of the required code for 2D in various posts, written for sage, and there is also the JavaScript example mentioned along with the description. Any of these could be adapted to the 3D case, but if you also want to change programming language, then you might be better off implementing the formula directly, keeping in mind that the adjoint may serve as alternative for the inverse of a matrix in several locations.

Here are some details on the generalization to 3D:

  1. Use a 4×4 system of linear equations, with the homogenous coordinates of four points on the left and a fifth point on the right hand side.
  2. Use the four solution variables to scale these four columns in order to obtain the transformation matrix.
  3. (as before)
  4. (as before)
  5. (as before)
  6. (as before)
  7. Divide the first three coordinates of the homogenous coordinate vector by the fourth coordinate to obtain dehomogenized coordinates.
Community
  • 1
  • 1
MvG
  • 57,380
  • 22
  • 148
  • 276
  • Thanks -- I know how to do it in 2D, but I'm not sure how to generalise to 3D, specifically in steps 1, 2 and 7. – John Oct 07 '13 at 11:23
  • Thanks for the update! In your post you mention that you use the adjugate matrix to solve. Can you explain that some more please? – John Oct 08 '13 at 17:28
  • In step 1 you have to solve a liner equation, which can be accomplished by multiplying the RHS vector with the inverse of the LHS matrix. In step 4 you need an inverse operation. In both these cases you can use the adjoint instead of the inverse, and the final result will only differ by a scalar multiple, which is of no geometriy consequence. – MvG Oct 09 '13 at 11:22