View Single Post
  #6  
Old July 6th, 2009, 12:33 PM
alunw's Avatar
alunw alunw is offline
Member
 
Join Date: May 2009
Posts: 185
Country:
Thanks: 9
Thanked 48 Times in 43 Posts
alunw will become famous soon enough
Default

Say A",B",C",D" are the values I said before. Now we put the first three values into a matrix
in columns
Code:
ax bx cx = 0 1 1
ay by cy   0 0 1
az bz cz   1 1 1

Invert this matrix:
-1 0  1     
 1 -1 0     
 0 1  0     

Multiply D'' by this
-1 0 1  0 =  1
1 -1 0 *1    -1
0 1  0  1     1
Make this into a diagonal matrix but making the third value 1 and dividing the first two coordinates by the third and multiply on the left by the first matrix we wrote down:
Code:
0 1 1   1  0  0  0 -1  1   
0 0 1 * 0 -1 0 = 0  0   1   
1 1 1   0 0  1   1  -1  1
This transformation maps the projective reference points to A''B''C''D''
which we can check by writing all four vectors in one matrix and multiplying
Code:
0 -1  1     1 0 0 1    0 -1 1 0
0  0  1  *  0 1 0 1 =  0 0 1 1
1 -1  1     0 0 1 1    1 -1 1 1
Note that although we seemed to map 0 1 0 to -1 0 -1 this is the same
as 1 0 1 (we divide the first two coordinates by the third and replace the third by 1). If you ever find yourself dividing by 0 it means that the point is an ideal point and not visible in the projected image.

Now you do all the same things but with A' B' C' D'. Finally you have to invert one of the matrices and multiply them together to get the matrix that moves
A'B'C'D' to A''B''C''D'' or vice versa.
There are probably other ways to calculate these transformations but this one is fairly robust and quite easy to program.
Reply With Quote