Obtaining the size of a square from an angled view I have an image of a square that is randomly oriented in 3D space. That is, it is not parallel to the screen, and forms a parallelogram. I need to obtain the actual length of the sides of the square.
simple schematic
From the image I can obtain the coordinates of the four vertices of the parallelogram. Also, if it makes the process easier, I can obtain the lengths of the diagonals of the parallelogram and the angle between them. I'm assuming no image distortion (if that statement is nonsensical let me know).
Effectively looking for:
f(v1,v2,v3,v4) = length, where v1-v4 are (x,y) coordinates of the parallelogram vertices, OR
f(L1,L2,theta) = length, where L1 and 2 are diagonal lengths of parallelogram, and theta is the angle between them. Understanding that the "function" may be a process.
I understand that there is ambiguity to the orientation of the square based on the image (i.e. it represents two possible orientations). My hunch is that it doesn't matter for the purposes of this problem. That is, either orientation yields the same answer. If that's not the case, I can further specify details of the image to identify the specific orientation.
 A: Let the viewing plane be the $xy$ plane.  Take one of the vertices and place it at the origin $(0,0,0)$.  Take two adjacent sides of the tilted square, and let their coordinates be
$ A = (x_1, y_1, z_1 )$
$ B = (x_2, y_2, z_2 )$
Because we're projecting onto the $ xy $ plane, and the projection is known, then $x_1, y_1, x_2, y_2$ are known.
We have two conditions on $z_1, z_2$.  First $A $ and $B$ are perpendicular, hence
$ A \cdot B = x_1 x_2 + y_1 y_2 + z_1 z_2 = 0 $
Second, the length of $A$ is equal to the length of $B$, therefore,
$ x_1^2 + y_1^2 + z_1^2 = x_2^2 + y_2^2 + z_2^2 $
The above are two quadratic equations in $z_1 $ and $z_2$ which can be easily solved.  Once we have $z_1, z_2$ then we can solve for the length of the side of the square and therefore its area.
A: Another classical solution method uses complex arithmetic.
Your goal is to eventually construct three orthogonal vectors in space that have equal length. Call them $U,V,W$.
Working backwards from answer to statement of problem, suppose you already know  the three   vectors in space, written as say row vectors:
$U=(u_1, u_2, u_3)$,  $V=(v_1, v_2, v_3)$, and $W= (w_1, w_2, w_3)$.
From the first two rows  and all three columns you create the three complex quantities $ A= u_1 + i v_1, B= u_2+ i v_2$  and $C= u_3+i v_3$.
Their complex sum of squares satisfies $$0=A^2+ B^2+ C^2 \iff  (||U||^2 - ||V||^2) + 2i\  U \cdot V =0 \iff $$
$U$ and $V$ are orthogonal and of equal length. In your problem your given data in the plane tells you $A$ and $B$.  From that you can solve for $C$ and obtain two solutions $C= \pm \sqrt{-(A^2+B^2)}$. Once $C$ is determined you know the full 3D descriptions of $U$ and $V$. And then you can scale them to have the correct length you want. Finally, the cross product of these two orthogonal space vectors gives you the missing vector $W$.
