Given 4 known projected points on the screen, I need to calculate a 3D rectangle where the 4 projected points coincide with the rectangle corners from the o perspective.
Here you can visually see the problem:
The red points are known and I need to calculate the yellow points.
Assumptions:
o = (0,0,0)
I can calculate a point in the line from the projected points $(p_1,p_2,p_3,p_4)$ using a sphere with $radius = 1$ $(sp_1,sp_2,sp_3,sp_4)$.
The middle point in the rectangle can be known, calculating the sphere point as well with the intersection between the great arcs formed by the diagonals. Indeed, this point should be in the rectangle.
Using the line formula for the 4 points:
$p_1' = sp_1 + t_1*\vec{osp_1}$
$p_2' = sp_2 + t_2*\vec{osp_2}$
$p_3' = sp_3 + t_3*\vec{osp_3}$
$p_4' = sp_4 + t_4*\vec{osp_4}$
$t_1$, $t_2$, $t_3$ and $t_4$ are the variables to be calculated.
Some conditions I found:
- Adjacent sides must be 90 degrees
$\mathrm{\vec{p_1'p_2'}}\!\cdot\!\mathrm{\vec{p_1'p_4'}} = 0$
$\mathrm{\vec{p_2'p_1'}}\!\cdot\!\mathrm{\vec{p_2'p_3'}} = 0$
$\mathrm{\vec{p_3'p_2'}}\!\cdot\!\mathrm{\vec{p_3'p_4'}} = 0$
$\mathrm{\vec{p_4'p_1'}}\!\cdot\!\mathrm{\vec{p_4'p_3'}} = 0$
- Opposite sides must have the same length
$||\vec{p_1'p_2'}|| = ||\vec{p_4'p_3'}||$
$||\vec{p_2'p_3'}|| = ||\vec{p_1'p_4'}||$
- Opposite sides must be parallels
$\mathrm{\vec{p_1'p_2'}}\!\cdot\!\mathrm{\vec{p_4'p_3'}} = ||\vec{p_1'p_2'}||*||\vec{p_4'p_3'}||$
$\mathrm{\vec{p_3'p_2'}}\!\cdot\!\mathrm{\vec{p_4'p_1'}} = ||\vec{p_3'p_2'}||*||\vec{p_4'p_1'}||$
But there is something I'm missing. I have tried to solve in Mathematica (with the Solve command) but I didn't have luck. It gets stuck forever in "calculating...".
Can you help me?
Thanks in advance.
