4

I'm not sure how to calculate the height of a point on a plane.

Plane {ABCD}, shown from above, with point E within the plane:

  :          :
··A----------B··
  |          |
  |       E  |
  |          |
  |          |
··D----------C··
  :          :

A: location (0,0), height 1
B: location (10,0), height 3
C: location (10,10), height 5
D: location (0,10), height 3
E: location (8,4), height ??

If E were at (5,5), then I'd just average the heights of {A,B,C,D} to obtain the height at E. How do I calculate the height at a given point on plane {A,B,C,D), given the height of each of those points?

I've looked at taking weighted averages—I could, say, calculate the weighted height: along AB, (0.2 × 0) + (0.8 × 3) = 2.4; along DC, (0.2 × 3) + (0.8 × 5) = 4.6; along AD, (0.6 × 0) + (0.4 × 3) = 1.2; along BC, (0.6 × 3) + (0.4 × 5) = 3.8. But the issue is that I don't really know what to do with these four. A simple average of them won't work. In this example, the average is 3, which seems reasonable at an estimate. But the average would be 1.9166666 at (0.33333, 0) – and my thinking is that the height at this location should be 1.

EDIT: Alrighty, thank you all, especially @amd. This is what I came up with, based on amd's post:

$$ let: Q_a = {D_y-E_y\over D_y-A_y}A_z + {E_y-A_y\over D_y-A_y}D_z $$ $$ Q_a = {10-4\over 10-0}1 + {4-0\over 10-0}3 = {9\over 5} $$

$$ let: Q_b = {C_y-E_y\over C_y-B_y}B_z + {E_y-B_y\over C_y-B_y}C_z $$ $$ Q_b = {10-4\over 10-0}3 + {4-0\over 10-0}5 = {19\over 5} $$

$$ E_z = {B_x-E_x\over B_x-A_x}Q_a + {E_x-A_x\over B_x-A_x}Q_b $$ $$ E_z = {10-8\over 10-0}·{9\over 5} + {8-0\over 10-0}·{19\over 5} = {17\over 5} $$

  • How about taking several averages, then? First along a pair of parallel sides, then along the segment through $E$ perpendicular to them. – amd Sep 09 '19 at 19:56
  • That's kinda what I'm thinking – but I'm not sure that actual averages, being 50% contribution from each point, would do it. Depending on where E is located within the rectangle, A, B, C and D would contribute differing amounts. I'm just not sure what the proper method of determining that is. – optimus_subprime Sep 09 '19 at 19:59
  • Use weighted averages, a.k.a. linear interpolation. Think about how you might find (in two dimensions) the $y$-coordinate of an arbitrary point on a line segment. – amd Sep 09 '19 at 20:01

3 Answers3

3

In two dimensions, you can find the height of a point on a line segment by computing a weighted average, a.k.a. linear interpolation: If the endpoints of the segment are $P_1=(x_1,y_1)$ and $P_2=(x_2,y_2)$, then the $y$-coordinate of the point on the segment at $x_0$ is $${x_2-x_0\over x_2-x_1}y_1+{x_0-x_1\over x_2-x_1}y_2.$$ A way to derive this expression is to substitute $x_0$ into the equation $$y={y_2-y_1\over x_2-x_1}(x-x_1)$$ of the line through $P_1$ and $P_2$ and then rearrange.

You can perform a similar interpolation in three dimensions over your rectangle: if you know the heights of the endpoints of either the horizontal or vertical line segment that passes through point $E$, then you can perform the above one-dimensional interpolation on that segment. To find the heights of the endpoints of, say, the horizontal segment, you just need to perform this same one-dimensional interpolation on the two vertical sides of the rectangle. To illustrate, the left end of this horizontal is at $(0,4)$, and interpolating along the vertical dimension produces $${10-4\over10-0}\cdot1+{4-0\over10-0}\cdot3 = \frac95.$$ Similarly, the right end is at $(10,4)$ with height $\frac{19}5$, and interpolating these in the $x$ direction, $${10-8\over10-0}\cdot\frac95+{8-0\over10-0}\cdot\frac{19}5 = \frac{17}5.$$ It might be a useful exercise to redo this calculation, but interpolating first in the $x$ direction instead.

You could also compute a weighted average of the vertices directly using the barycentric coordinates of $E$ relative to this rectangle, but that’s at least as much work, I think.

amd
  • 53,693
  • @optimus_subprime You’re interpolating heights (i.e., $z$-coordinates in 3-D), so that $1$ is the height at point $A$ and the $3$ is the height at point $B$. – amd Sep 09 '19 at 23:07
  • P.S. If you combine the three interpolations into a single expression, you get the bilinear interpolation in Ethan Bolker’s answer. – amd Sep 09 '19 at 23:09
2

A plane is defined from three points ABC using the following algorithm. How you handle the 4th point is up to you.

  1. Plane normal direction $$\vec{n} = (B-A) \times (C-B)$$

$$ \vec{n} = (B_x-A_x,B_y-A_y,B_z-A_z)\times(C_x-B_x,C_y-B_y,C_z-B_z) $$

you can read more about the cross product of two vectors, but the generic answer from above would be:

$$ \vec{n} = [(B_y-A_y)(C_z-B_z)-(c_y-B_y)(B_z-A_z)]\mathbf{\hat{x}} \\ -[(B_x-A_x)(C_z-B_z)-(C_x-B_x)(B_z-A_z)]\mathbf{\hat{y}} \\ - [(B_x-A_x)(C_y-B_y)-(C_x-B_x)(B_y-A_y)]\mathbf{\hat{z}} $$

  1. Scalar Component $$d=-\vec{n} \cdot A$$

$$ d = n_xA_x+n_yA_y+n_zA_z $$ You can read more about the dot product here

  1. Equation of plane $$ \mathbf{n}_x \hat{x}+\mathbf{n}_y \hat{y}+\mathbf{n}_z \hat{z} = d $$

Using your points, you can get the following:

$$\vec{n} = (10,0,2) \times (0,10,2)$$

getting a final equation for the plane to be:

$$ -20\hat{x}-20\hat{y}+100\hat{z} = 100 $$

or

$$ -\hat{x}-\hat{y}+5\hat{z} = 5 $$

NOTE: You can see how your point D actually fits within this equation.

Now you can find the $\mathbf{z}$ coordinate of your point $E$ by doing:

$$ -8-4+5\hat{z} = 5 $$

thus getting a $\mathbf{z}$ coordinate of $\frac{17}{5}$. Hence your final $E$ coordinates should be: $(8,4,\frac{17}{5})$

Dashi
  • 791
  • 5
  • 12
  • @optimus_subprime I apologize, I saw your "If E were at (5,5), then I'd just average the heights of {A,B,C,D}..." and did not see the rest. I edited for the correct values – Dashi Sep 09 '19 at 20:40
  • To be honest, I don't really follow. If I say that A_x, A_y and A_z, are the x, y and z coordinates of A, and B_x, etc. the same for B, C, and D, could you possibly help me reform this like, for E such that E is within ABCD, the coordinates of E are (E_x, E_y, ???), using A_x, E_x, etc.? – optimus_subprime Sep 09 '19 at 20:53
  • @optimus_subprime, after you construct the plane equation from the points you already know, namely $-\hat{x}-\hat{y}+5\hat{z} = 5 $, then just put in $E_x, E_y$ for $x,y$ and then solve for $z$ which would be $E_z$ – Dashi Sep 09 '19 at 21:16
  • Honestly, I don't follow. I appreciate your help very much. I understand some math, but multiplying "(10,0,2)" by something is beyond me. I'm not asking for a math lesson, or even a link - I just know there's a non-matrix related solution that I can digest more easily. – optimus_subprime Sep 09 '19 at 21:27
  • Oh I see what you mean, That is relatively easy to do. I will edit and maybe it will be clearer – Dashi Sep 09 '19 at 21:28
  • This looks like the correct answer, but there appears to be an error. If you calculate out the scalar component from the values provided, you should get -100. Somehow this value becomes 100 in the comment above, which turns out to be correct. So somewhere there's a missing "-" sign. – Vijchti May 11 '20 at 22:56
1

I think what you want is the bilinear interpolation that produces a hyperbolic paraboloid as $E$ varies.

In order not to post a link only example I've pasted in this from wikipedia. You can substitute the coordinates for $A,B,C,D$.

e) Hyperbolic paraboloid:

If the two directrices are the lines

$$ c(u)=(1-u) a_{1}+u a_{2},\quad d(v)=(1-u)b_{1}+v b_{2} $$

one gets

$$ x ( u , v ) = ( 1 − v ) ( ( 1 − u ) a_1 + u a_2 ) + v ( ( 1 − u ) b_1 + u b_2 ) $$

which is the hyperbolic paraboloid that interpolates the 4 points
$a_1 , a_2 , b_1 , b_2$ bilinearly.

Edit to work the OP's example.

This is much easier than the general case above since $ABCD$ is a very nicely situated square in the $xy$-plane.

To find the height above $E$ we first have to find $u$ and $v$, which tell us where $E$ lives relative to the corners along the $x$ and $y$ axes.

Since the $x$-coordinate of $E$ is $8$ and the side of the square is $10$ the point $E$ is $u= 0.8$ of the way from $A$ to $B$ (or, equivalently, from $D$ to $C$). Similarly, $v = 0.4$. (The sketch in the question is pretty accurate.)

Now $u$ and $v$ tell us how to average the heights at the corners using the second equation from wikipedia. The four values $a_1, a_2, b_1, b_2$ in that equation are the heights of $A, B, C, D$. Then the left side of that equation will be the height of $E$.

Warning: I haven't checked the order in which you match $a_1, a_2, b_1, b_2$ to $A, B, C, D$. You can figure it out by making sure you get the right answers when you substitute $0$ and $1$ for $u$ and $v$ since those will be the heights of the corners.

To make a final check, draw a picture with all four points in space and make sure it looks right.

Ethan Bolker
  • 95,224
  • 7
  • 108
  • 199
  • Given the hyperbolic paraboloid that can be obtained with this method, which is in fact simply the plane itself (already given), how does one obtain the height of a point on it? This answer provides a 2-dimensional surface, not a coordinate of a point in 3-dimensional space. – optimus_subprime Sep 09 '19 at 20:59
  • @optimus_subprime I did not check to see if the heights you specified for the corners do in fact lead to four points that lie on a plane in three space (I think they do). If they do then this surface will be that plane - the hyperboloid will be "flat". In any case this interpolation formula will give you the height over any point $E$ in the square. That height together with the location of $E$ in the $ABCD$ plane defines a point in three dimensions - it lies on the surface. – Ethan Bolker Sep 09 '19 at 21:13
  • Okay, I want to make sure I follow. If I use "A_x" and "A_y" for the coordinates of A, and "A_z" for the height at A, and similar for B,C,D,E... would this be correct? E_z = (1 - E_y) · ((1 - E_x) · A_z + E_x · B_z) + E_y · ((1 - E_x) · D_z + E_x · C_z) – optimus_subprime Sep 09 '19 at 21:35
  • @optimus_subprime No. It's more subtle. I did most of the work in an edit. Spend some time working with that. – Ethan Bolker Sep 09 '19 at 22:15
  • I've tried assigning b1 and b2 to C and D, and vice versa, but I get 3.28 with b1=D and b2=C, and 2.8 with the opposite. :( – optimus_subprime Sep 09 '19 at 22:36
  • Do you have an assignment that gets the corners right? Note: I believe the answer from @amd is the same as mine. I've done all I can to help. – Ethan Bolker Sep 09 '19 at 22:47
  • @EthanBolker Yes, it is. If you combine the three interpolations that I describe into a single expression, you get the bilinear interpolation described here. – amd Sep 09 '19 at 23:12