Projection matrix to project a point in a plane

2.8k Views Asked by At

enter image description here

How to determinate the 4x4 S matrix so that the P gets projected into Q, on the XZ (Y=0) plane?

Q = S P

2

There are 2 best solutions below

0
On BEST ANSWER

enter image description here

I've done done math and I have the solution now. This is simple similar triangles.

You have a light point L and a P point you want to project on the ground. If you draw the lines you find two triangles with the proportions. The red side divided by the green side is equivalent to the purple side divided by the pink side + green side like

$\frac{P_x - L_y}{P_y - L_y} = \frac{Q_x - L_x}{L_y}$

If you solve for $Q_x$ you have $Q_x = \frac{L_y \cdot P_x - L_x \cdot P_y}{P_y - L_y}$

The drawing is for 2D but don't forget we're on 3D so we need to solve for $Q_z$

$Q_z = \frac{-L_z \cdot P_y + L_y \cdot P_z}{P_y - L_y}$

We now want to find a matrix $M$ that gives the following result when multiplied by any point $P$ (The vertical axis is y and wee need a point on the floor so $y= 0$)

$ M *\begin{bmatrix}P_x\\P_y\\P_z\\1\\\end{bmatrix} = \begin{bmatrix}Q_x\\0\\Q_z\\1\\\end{bmatrix}$

The question here is to use homogeneous coordinates. If you look at $Q_x$ you have a division. There's no way to divide anything inside a matrix multiplication. So you use the homogeneous coordinate to get the result we want.

So we need a matrix $M$ multipled by any point $P$ that gives us $\begin{bmatrix} L_y \cdot P_x - L_x \cdot P_y\\ 0\\ -L_z \cdot P_y + L_y \cdot P_z\\ L_y-P_y\\ \end{bmatrix}$

and then we divide every row by $Py-Ly$ to get $\begin{bmatrix} \frac{L_y \cdot P_x - L_x \cdot P_y}{P_y-L_y}\\ 0\\ \frac{-L_z \cdot P_y + L_y \cdot P_z}{P_y-L_y}\\ 1\\ \end{bmatrix} $

$M = \begin{bmatrix} L_y & -L_x & 0 & 0\\ 0 & 0 & 0 & 0\\ 0 & -L_z & L_y & 0\\ 0 & -1 & 0 & L_y \end{bmatrix}$

Ps: I'm sorry if I'm not explaining the right way or if I'm making any mistake but the result is there.

3
On

There's no matrix with this property; if there were, what would it do when multiplied by the coordinates of the point $L$?

If you represent points with homogeneous coordinates (i.e., append a "1" at the end of each coordinate triple), then there's a $4 \times 4$ matrix that'll do what you want...almost. It'll send $(P_x, P_y, P_z, 1)$ to a point $(R_x, R_y, R_z, R_w)$, with $R_y = 0$, that has the property that when you divide through by $R_w$, you get $(Q_x, Q_y, Q_z, 1)$, except when $R_w$ happens to be zero, as it will when you multiply it by the point $(L_x, L_y, L_z, 1)$.

The introduction to 2D and 3D transformations section of any computer graphics book will explain this in considerable detail.