[Math] Projecting 3D points onto 2D coordinate system of a plane

coordinate systemslinear algebraprojectionvector-spaces

This is a rather basic question though I could not find a post with the answer.

I have a set of points in 3D. Let us define one of them $s$ as an observation point. we calculate the 3D Euclidean distances and choose the furthest point from $s$, denoted $r$. I want to span a 2D plane where the normal is $\overrightarrow{n}=\frac{\overrightarrow{sr}}{\left\|\overrightarrow{sr}\right\|}$. $\overrightarrow{sr}$ denotes the vector from point s to point r. I want to project the remaining points onto that plane and get their 2D values with the origin of the new system at $r$.

From all other projection answers I could find, I will get a 3D coordinate after the projection. My final goal is to calculate the 2D convex hull on the projected plane. How do I make the transition here?

Best Answer

To convert the projected 3D points into 2D coordinates you first need to define a 2D coordinate system which is contained in your plane. For this you need to define the base vectors $\overrightarrow{e_x}$ and $\overrightarrow{e_y}$ of your coordinate frame. I assume that you would want a right-handed orthonormal base.

First you need to define your base vector $\overrightarrow{e_x}$. For this you can choose any unit vector, which is contained in your plane (orthogonal to $\overrightarrow{n}$, length 1). One possibility would be to define your basis first basis vector $\overrightarrow{e_x}$ via $\overrightarrow{r}$:

$$\overrightarrow{e_x} = \frac{\overrightarrow{r} \times \overrightarrow{n}}{||\overrightarrow{r} \times \overrightarrow{n}||_2}$$

Where $\times$ denotes the vector cross product. This methods works unless $\overrightarrow{r}$ and $\overrightarrow{s}$ are parallel. Once you have found any possible basis vector $e_x$ you can derive the right hand basis vector $e_y$ by:

$$ \overrightarrow{e_y} = \frac{\overrightarrow{n} \times \overrightarrow{e_x}}{||\overrightarrow{n} \times \overrightarrow{e_x}||_2}$$

We now denote $p'$ as the projection of an arbitrary point p onto the defined plane in 3D coordinates. We can then define the 3d vector denoting the distance of point p' to the origin of the new coordinate system by:

$$\overrightarrow{rp'} = \overrightarrow{p'} - \overrightarrow{r}$$

To get the 2D coordinates of that point you simply project the 3D vector of $p'$ onto our derived 3D vectors for $e_x$ and $e_y$ using the scalar product:

$$ p'_{\ 2D} = \begin{pmatrix} \overrightarrow{rp'} \cdot \overrightarrow{e_x} \\ \overrightarrow{rp'} \cdot \overrightarrow{e_y} \end{pmatrix} $$

Finally you could reformulate the above equation into matrix form as follows:

$$ p'_{\ 2D} = K \ \overrightarrow{rp'} = \begin{pmatrix} \overrightarrow{e_x}^T \\ \overrightarrow{e_y}^T \end{pmatrix} \overrightarrow{rp'} = \begin{pmatrix} e_{x,1} & e_{x,2} & e_{x,3} \\ e_{y,1} & e_{y,2} & e_{y,3} \end{pmatrix} \overrightarrow{rp'} $$

Where K denotes the projection matrix which you can simply apply to any 3D point in the defined plane. With this the transition to a 2D coordinate for a projected point is complete.