Search code examples
3dgeometryrectanglespointsperspectivecamera

Detect whether four points or four lines in 2D space can map to a flat right-angled rectangle rotated in 3D space


We are given either:

  1. 4 points in Cartesian coordinates
  2. 4 straight lines in Cartesian space

We assume this 2D Cartesian space is a perspective projection of a 2D space.

I may be wrong but I believe right-angled rectangles impose a constraint such that not every set of 4 such points or lines can fit a 2D perspective mapping of a rotated rectangle.

I'd like to know how to check whether the given inputs can map to a rectangle in 3D space.

If my assumption is wrong, then explaining why is also an acceptable answer.


Solution

  • All triplets of points should not be collinear.

    Points should form convex quadrangle. In some cases non-convexity might be solved by point order flipping (Z-form, and order is not fixed), in some cases - cannot be solved (spinner-form)

    Impossible cases for lines - when three of them intersect in the same point. They should provide four, five or six different intersection points (This issue includes case when three lines are parallel)