1

I have three points that lie on a plane $(p_{1x}, p_{1y}, h_1),\,(p_{2x},p_{2y},h_2),\,(p_{3x},p_{3y},h_3)$.

I know the $x$ and $y$ coordinates of a fourth point $(p_{4x}, p_{4y})$, but need to find the corresponding $z$ value (I.e. $h_4$) so that this point lies on the same plane as the first three points.

How do I find $h_4$?

sketch

Thanks for help.

Mostkaj
  • 119
  • 1
    Your question is unclear. Do you mean: I have three points that lie on a plane $(p_{1x}, p_{1y}, h_1),,(p_{2x},p_{2y},h_2),,(p_{3x},p_{3y},h_3)$. I know the $x$ and $y$ coordinates of a fourth point $(p_{4x}, p_{4y})$, but need to find the corresponding $z$ value (I.e. $h_4$) so that this point lies on the same plane as the first three points. How do I find $h_4$? – Daryl Oct 07 '16 at 20:51

1 Answers1

1

If you compute the barycentric coordinate of $p_4$ with respect to $p_1,p_2,p_3$.
i.e the three numbers $a_1, a_2, a_3$ such that $$a_1 + a_2 + a_3 = 1\quad\text{ and }\quad p_4 = a_1 p_1 + a_2 p_2 + a_3 p_3$$ $h_4$ will be equal to $a_1 h_1 + a_2 h_2 + a_3 h_3$.

To compute $a_1, a_2, a_3$, you can use the fact they are proportional to the area of triangles $\triangle p_4 p_2 p_3$, $\triangle p_4 p_3 p_1$ and $\triangle p_4 p_2 p_3$. More precisely, if $(x_i,y_i)$ are the coordinates for $p_i$ where $1 \le i \le 4$, we have

$$a_1 : a_2 : a_3\; = \; \left|\begin{matrix} x_4 & y_4 & 1\\ x_2 & y_2 & 1\\ x_3 & y_3 & 1\\ \end{matrix}\right| : \left|\begin{matrix} x_4 & y_4 & 1\\ x_3 & y_3 & 1\\ x_1 & y_1 & 1\\ \end{matrix}\right| : \left|\begin{matrix} x_4 & y_4 & 1\\ x_1 & y_1 & 1\\ x_2 & y_2 & 1\\ \end{matrix}\right| $$

achille hui
  • 122,701
  • Thanks. But im not good in math. Can you write simple formula which i can use in my program? – Mostkaj Oct 07 '16 at 21:40
  • 1
    @Tito100 I don't see anyway to have very simple formula, you could use following formula to implement a function to compute the determinant $$\left|\begin{matrix} x_1 & y_1 & 1\ x_2 & y_2 & 1\ x_3 & y_3 & 1\ \end{matrix}\right| = (x_1 y_2 - x_2 y_1) + (x_2 y_3 - x_3 y_2) + (x_3 y_1 - x_1 y_3)$$ – achille hui Oct 07 '16 at 22:57