Does a point quadrilateral form a rect in 3D space?

305 Views Asked by At

I have 4 points with x and y coordinate and would like to find out a way to check if given quadrilateral would be a rectangle in 3D space.

I tried a bunch of conditions, but there was always and edge case where it would reject a real one or it wouldn't be strict enough.

Is there a mathematical formula to achieve this or are there any simple/obvious conditions that I missed?

Example: First three quadrilaterals on the image below would all be correct. Top one has upper edge pushed away, middle one is orthogonal to the view point and the third is similar to the first one, only that left edge is farther from the view point. Last, the red one would be incorrect as no matter how it would be turned in 3D space, it wouldn't be rectangle.

Quads