I have two different images and with them an estimation of two planes ( defined in the same system). I would like to get the rotation matrix, quaternion or euler angles of a surface within this planes.
What I have is:
- an image of an object ( let's say a cuboid to simplify things a bit) taken from a fixed point.
- an estimation of the plane that I got from the measurement of the upper side of the cuboided form.
then the object is moved ( or even replaced by another one), so I would like to see how I would have to rotate the first measured object to get the position of the second measured object. In both planes I have a point relative to the origin (0,0,0), and the normal (unitary). Plane A and plane B are NOT identical, but the relative position of the surface should be close in area and length.
Please note that, despite I'm using the word "object" I don't really have a 3D representation or definition, but just a couple of points, and the plane.
My approach was the following one:
Get two points within plane A to define a vector, and normalize it. With this vector I would define the X or Y axis, as the Z axis is already given with the plane's normal. Calculate the cross product of vector "X-axis", normal to compute the vector "Y-axis". In other words, define coordinate system "A" with 3 unitary vectors. $\vec{AV_x},\vec{AV_y},\vec{AV_z}$.
Do the same with the second plane, plane "B". Get $\vec{BV_x}, \vec{BV_y}, \vec{BV_z}$.
Move the system B to the origin of system "A". ( By calculating Point 1 in plane A minus Point 1 in plane B). Calculate the new $\vec{AVx_2},\vec{AVy_2}$ and $\vec{AVz_2}$.
Compute the rotation matrix, to move B to A. For this, I was calculating a 3x3 matrix M where :
$M_{(1,1)} = \vec{AVx_2} \cdot \vec{BVx}$
$M_{(1,2)} = \vec{AVy_2} \cdot \vec{BVx}$
$M_{(1,3)} = \vec{AVz_2} \cdot \vec{BVx}$
$M_{(2,1)} = \vec{AVx_2} \cdot \vec{BVy}$
$M_{(2,2)} = \vec{AVy_2} \cdot \vec{BVy}$
$M_{(2,3)} = \vec{AVz_2} \cdot \vec{BVy}$
$M_{(3,1)} = \vec{AVx_2} \cdot \vec{BV_z}$
$M_{(3,2)} = \vec{AVy_2} \cdot \vec{BV_z}$
$M_{(3,3)} = \vec{AVz_2} \cdot \vec{BV_z}$
Unluckily, my test so far are showing that my results are not ok. Should I try a new approach to calculate this matrix? ( I just would like to know if this could be ok, or if not, why this should never be used by mankind :) ).