Pergunta

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. :)

Foi útil?

Solução

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.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top