Transform a 3d point to a coordinate system relative to a viewing plane, and transform it back to its original coordinate system

101 Views Asked by At

For 3d software, in the code, I'm changing a 3d point from a stable coordinate system to a coordinate system that is relative to the screen view, using the following method:

$x, y, z$ = given point in the 3d system.

$(X_u, Y_u, Z_u)$ = The transform for the 2d view plane Y-direction/upwards vector relative to the 3d system.

$(X_r, Y_r, Z_r)$ = The transform for the 2d view plane X-direction/rightwards vector relative to the 3d system.

$(X_s, Y_s, Z_s)$ = The transform for the 2d view plane Z-direction/towards the viewing screen relative to the 3d system.

View plane values: $x_1, y_1, z_1$

Equations:

$$x_1 = X_r x + Y_r y + Z_r z$$

$$y_1 = X_u x + Y_u y + Z_u z$$

$$z_1 = X_s x + Y_s y + Z_s z$$

Note that the point is still in 3d space, it's just that its points are now measured relative to the viewing plane.

The problem I've come across is that I need to take $x_1, y_1, z_1$ and turn it back into $x, y, z$ without knowing the values of $x, y, z$, of course. I do have the transformations above and $x_1, y_1, z_1$.

What equations can I use to transform the point back?

1

There are 1 best solutions below

5
On BEST ANSWER

Write your equations as $$ \begin{pmatrix} x_1\\y_1\\z_1 \end{pmatrix}= \begin{pmatrix} X_r&Y_r&Z_r\\ X_u&Y_u&Z_u\\ X_s&Y_s&Z_s \end{pmatrix} \begin{pmatrix} x\\y\\z \end{pmatrix} $$ so, if the matrix is invertible, we have: $$ \begin{pmatrix} x\\y\\z \end{pmatrix}= \begin{pmatrix} X_r&Y_r&Z_r\\ X_u&Y_u&Z_u\\ X_s&Y_s&Z_s \end{pmatrix}^{-1} \begin{pmatrix} x_1\\y_1\\z_1 \end{pmatrix} $$