Search code examples
algorithmmatrixlanguage-agnosticgeometrytransformation

Transforming a 3D plane onto a 2D coordinate system


Say I have a set of points from a sensor which are all within a margin of error on a 2D plane somewhere in the 3D space. How would I go on about transforming the coordinates of the points onto a 2d coordinate system, so that for example the convex hulls of the points or the distances between the points don't change?


Solution

  • Assuming you know the equation of the plane (otherwise you can fit it by least-square or other), construct a new coordinate frame as follows:

    • get the normal vector,

    • form the cross product with an arbitrary vector having a different direction;

    • form the cross product of the normal and the second vector,

    • normalize all three and name the new axis z, x, y.

    This creates an orthonormal basis to which you will transform the points. This corresponds to a rigid transform, that preserves all distances. You can drop the z to get the orthogonal projections of the points to the plane.