6
$\begingroup$

so I have the x,y,z value for 3 points to define a plane in 3d space.

I need to find the z value of an arbitrary point given the x,y.

I can sort of see some ways to calculate this, but they seem like they might be doing a lot of extra steps.

I eventually need to encapsulate the process in a algorithm for a computer program, so the fewer steps the better.

$\endgroup$

2 Answers 2

9
$\begingroup$

The simplest way is to first find the equation of the plane.

So, suppose you are given three points, $$ (a_1,b_1,c_1),\quad (a_2,b_2,c_2),\quad (a_3,b_3,c_3).$$

I'm first going to assume everything will work out fine; I'll point out the possible problems later.

  1. First, construct two vectors determined by these three points: $$\begin{align*} \mathbf{v}_1 &= (a_1,b_1,c_1) - (a_2,b_2,c_2) = (a_1-a_2, b_1-b_2, c_1-c_2).\\ \mathbf{v}_2 &= (a_1,b_1,c_1) - (a_3,b_3,c_3) = (a_1-a_3, b_1-b_3, c_1-c_3). \end{align*}$$

  2. Then, compute their cross product: $$\mathbf{n} = \mathbf{v}_1\times\mathbf{v}_2 = (r,s,t).$$

  3. The plane you want has equation $rx + sy + tz = k$ for some $k$. To find $k$, plug in one of the points you have, say $(a_1,b_1,c_1)$, so you know that $$k = ra_1 + sb_1 + tc_1.$$

  4. Finally, given the $x$ and $y$ coordinate of a point, you can find the value of $z$ by solving: $$z = \frac{1}{t}\left( ra_1 + sb_1 + tc_1 - rx - sy\right).$$

What can go wrong?

  • For three points to determine a unique plane, you need the three points to not be collinear (not lie on the same line). You will find this when you compute the vector $\mathbf{n}$. If $\mathbf{n}=(0,0,0)$, then $\mathbf{v}_1$ and $\mathbf{v}_2$ are parallel, so that means that the three points are collinear and don't determine a unique plane. So you can just test $\mathbf{n}$ to see if it is nonzero before proceedings.

  • It's possible for there to not be a unique value of $z$ that goes with the given $x$ and $y$. This will happen if $\mathbf{n}$ has the form $\mathbf{n}=(r,s,0)$. Then either the given $x$ and $y$ satisfy the equation you get, in which case every value of $z$ works; or else the given $x$ and $y$ do not satisfy the equation you get and no value of $z$ works.

Example. Suppose you are given $(1,2,3)$, $(1,0,1)$, and $(-2,1,0)$. Then $$\begin{align*} \mathbf{v}_1 &= (1,2,3) - (1,0,1) = (0,2,2).\\ \mathbf{v}_2 &= (1,2,3) - (-2,1,0) = (3,1,3). \end{align*}$$ Then $$\begin{align*} \mathbf{n} &= \mathbf{v}_1\times\mathbf{v}_2 = \left|\begin{array}{rrr} \mathbf{i} & \mathbf{j} & \mathbf{k}\\ 0 & 2 & 2\\ 3 & 1 & 3 \end{array}\right|\\ &= ( 6-2, 6- 0, 0-6) \\ &= (4,6,-6). \end{align*}$$ So the plane has equation $4x + 6y - 6z = k$. To find $k$, we plug in $(1,2,3)$: $$ 4(1) + 6(2) - 6(3) = -2,$$ so the plane has equation $$4x + 6y - 6z = -2$$ or $$2x + 3y - 3z = -1.$$

Then, given two values of $x$ and $y$, say, $x=7$ and $y=-2$, you plug them in and solve for $z$: $$z = \frac{1}{-3}(-1 -2(7) -3(-2)) = \frac{1 + 14 - 6}{3} = 3,$$ so the point is $(7,-2,3)$.

$\endgroup$
1
  • $\begingroup$ Thank you so much. It worked perfectly. $\endgroup$ Commented Mar 20, 2011 at 16:28
2
$\begingroup$

If you have three points, you can represent the plane by finding vectors $z-x$ and $y-x$, and converting them into an equation (cross product produces a normal vector that defines the plane). Now given that equation, you plug in the $x$, $y$ values of a point, and tell the computer to solve for $z$ such that the equation of $Ax+By+Cz+D=0$ holds true, where $A$, $B$, and $C$ are coordinates of your normal vector. Alternatively, you can just tell the computer to solve the equation of $z=\frac{-D-Ax-By}{C}$.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .