We have an equilateral triangle $ABC$ in 3-dimensional space. The points are known, such as:
- $A = (x_1,y_1,z_1)$
- $B = (x_2,y_2,z_2)$
- $C = (x_3,y_3,z_3)$
Point $P$ is on triangle $ABC$.
If I know that $P = (x_4, y_4, ?)$ where $x_4$ and $y_4$ are given, how can I calculate the missing coordinate of that point?
Shift the triangle to the origin by A -> A - A = 0; B -> B - A; C -> C - A.
Points in the plane of the shifted triangle can be expressed with {B - A, C - A} as a basis, in other words you have a linear expression for the translated point P in the form $\alpha$ (B - A) + $\beta$ (C - A).
For the given $x_4$ and $y_4$, translate them in the same way (P -> P - A), solve the two simultaneous equations for $\alpha, \beta$ then compute $z_4$ and translate back to the actual position by P -> P + A.
Further explanation.
The x, y, z axes are a basis for 3D space: they actually represent unit vectors $\hat x = (1, 0, 0)$; $\hat y = (0, 1, 0)$; $\hat z = (0, 0, 1)$. Any point in the 3D space can be represented as a linear combination of these unit vectors. The point A = $(x_1, y_1, z_1) $ for example is equivalent to $ x_1 \hat x + y_1 \hat y + z_1 \hat z$. The x, y, z axes are at right angles to each other, but you can in fact represent a point in 3D space by a combination of any three (non-zero) vectors so long as no two of them point in the same direction.
The triangle ABC lies in a plane, defined by the points A, B, and C. Shifting it to the origin (I moved the point A, but you could move any of the vertices) makes it a proper 2D space which includes the origin, (0, 0). You can represent any point in a 2D space by a combination of any two (non-zero) vectors so long as they don't point in the same direction. The translated points B - A and C - A are two such vectors (so long as the triangle is not degenerate) , so any point in the plane of the translated triangle can be represented as $\alpha$ (B - A) + $\beta$ (C - A).
Translate P (P -> P - A) in the same way so that it is in the plane of the translated triangle, and then for some $\alpha$ and $\beta$, P - A = $\alpha$ (B - A) + $\beta$ (C - A). Expand this out in co-ordinates:
(1) $x_4 - x_1 = \alpha (x_2 - x_1) + \beta(x_3 - x_1)$
(2) $y_4 - y_1 = \alpha (y_2 - y_1) + \beta(y_3 - y_1)$
(3) $z_4 - z_1 = \alpha (z_2 - z_1) + \beta(z_3 - z_1)$
Equations (1) and (2) are two equations in two unknowns $\alpha$ and $\beta$, which you can solve. Then put $\alpha$ and $\beta$ into equation (3) to get $x_4$.
Point to note
You say that you know that P is in the triangle. The process above works for any point in the plane of the triangle, but does nothing to check that P is actually inside the triangle.