Finding the $z$ coordinate for a point within a triangle in three dimensions.

3dcoordinate systemsgeometrytriangles

Suppose I know the coordinates $(x,y,z)$ for three vertices of a triangle and the x and y coordinates of a fourth point within the triangle. How do I calculate the $z$ for that fourth point?

I've seen a couple other questions with answers but they did not clear anything up for me, such as this one: Triangle in 3D space point X and Y coordinate know find Z

A little clarification would be very appreciated, thank you.

Best Answer

There is a simple technique using determinants (see there).

Consider for example points $$\begin{cases}A&=&(x_A,y_A,z_A)&=&(0,2,2)\\ B&=&(x_B,y_B,z_B)&=&(2,0,2)\\ C&=&(x_C,y_C,z_C)&=&(2,2,0)\end{cases}$$

which can be considered as vertices of a cube.

Let $M(1,1,z)$ belonging to plane $ABC$ for which we desire coordinate $z$.

The coplanarity of 4 points is equivalent to the fact that the following determinant is zero:

$$\begin{vmatrix}x_A&y_A&z_A&1\\ x_B&y_B&z_B&1\\ x_C&y_C&z_C&1\\ x_M&y_M&z_M&1 \end{vmatrix}=0 \ \text{giving here} \ \begin{vmatrix}0&1&1&1\\ 1&0&1&1\\ 1&1&0&1\\ 1&1&z&1 \end{vmatrix}=0 $$

giving a first degree equation for $z$. Technicaly: subtract the last column to the two first columns, one gets an easy expansion giving, as expected, the value $z=0$.