Estimate a Rectangle from its Vertex Suppose i have estimated three points $\hat A$, $\hat B$ and $\hat C$ of a rectangle $ABCD$.
The fourth point can easily be: $\hat D=\hat A+(\hat C-\hat B)$.
But these points do not necessarily satisfy $\angle \hat A\hat B \hat C=90^\circ$ or the same for any other vertex. So $\hat A\hat B\hat C\hat D$ is not a rectangle.
Is there a proper way to correct those points in order $ABCD$ be a rectangle, under a minimal geometric error wrt the original points?.
We could assume the geometric error is: $$\sum_{X \in \{A,B,C,D\}} |X-\hat X|^2$$. Or any other metric.
 A: I don't know about "minimal geometric error", but one possible solution could be to draw a circle whose diameter is the diagonal of the rectangle, $AC$. Then project $B$ onto the circumference of this circle to obtain $\hat B$ (i.e.: draw a line through $B$ and the center of the circle and take $\hat B$ to be where the line intersects the circle). This guarantees that $\angle A \hat B C = 90^\circ$. The missing fourth point $\hat D$ would be the reflection of $\hat B$ across the diagonal $AC$.
A: I've finally set up this optimization problem with $x_i^0$ the original vertexs and $x_i$ the new vertex variable: 
$$
\mathscr{P}) \min \sum_{i=1}^4 |x_i-x_i^0|^2\\
(x_1-x_2)^T(x_2-x_3)=0\\
x_1-x_2+x_3-x_4=\mathbb{0}\\
x_i^0 \in \mathbb{R}^2
$$
Which is solved in Matlab as:
x0=[0 0;1 0;1.2 1;0 1.2];
x=fmincon(@(x)fmin(x,x0),x0,...
    [],[],[],[],[],[],@(x)con(x));

with the square error:
function y=fmin(x,x0)
y=sum((x(1,:)-x0(1,:)).^2+(x(2,:)-x0(2,:)).^2+...
    (x(3,:)-x0(3,:)).^2+(x(4,:)-x0(4,:)).^2);

And the rect angle constraint and fourth point constraint:
function [y,yeq]=con(x)
y=[];
yeq(1)=(x(1,:)-x(2,:))*(x(2,:)-x(3,:))';
yeq(2:3)=(x(1,:)-x(2,:)+x(3,:)-x(4,:))';

The result is depicted through:
line([x0(:,1);x0(1,1)],[x0(:,2);x0(1,2)]);
hold on;
line([x(:,1);x(1,1)],[x(:,2);x(1,2)]);
hold off;
axis square;

