[Math] Transform from global coordinate system to a local

coordinate systemsgeometrylinear algebra

I have a plane in $\mathbb R^3$, defined by a direction vector $$\vec n= \langle n_x,n_y,n_z\rangle$$ and a point $C(X_1,Y_1,Z_1)$. The direction of the normal unit vector $\vec n$ is described from plane's altitude and azimuth angles $\alpha, A$ respectively as: $$\vec n = \langle\cos(\alpha) \sin(A), \cos(\alpha)\cos(A), \sin(\alpha)\rangle.$$
Assume a point $P(X_P, Y_P, Z_P)$ which lies on the plane (e.g intersection point between a line and plane).

How can I convert point $P(X_P,Y_P,Z_P)$ from the global coordinate system to plane's local coordinate system and finally get $p(x_p, y_p, 0)$?

All uppercase $X,Y,Z$ refer to global coordinate system.

All lowercase $x,y,z$ to plane's local coordinate system.

Best Answer

If $n = \pm\langle 0, 0, 1\rangle$, then $Z_{P} = 0$ and your point is already in the desired form.

Otherwise, $u_{1} = \langle -\cos(A), \sin(A), 0\rangle$ and $u_{2} = n \times u_{1} = \langle -\sin(\alpha) \sin(A), -\sin(\alpha) \cos(A), \cos(\alpha)\rangle$ are an orthonormal basis for your plane, and \begin{align*} x_{P} &= (P - C) \cdot u_{1} = -(X_{P} - X_{1}) \cos(A) + (Y_{P} - Y_{1}) \sin(A), \\ y_{P} &= (P - C) \cdot u_{2} = -(X_{P} - X_{1})\sin(\alpha) \sin(A) - (Y_{P} - Y_{1})\sin(\alpha) \cos(A) + (Z_{P} - Z_{1})\cos(\alpha). \end{align*}

Related Question