1

Given two three dimensional points. find the z coordinate of a third point that has two known coordinates. I'm not entirely sure how to solve this system. I'll be implementing this into an algorithm so any additional pointers in that direction would be appreciated.

Example 1:

Point 1 = (1,1,5);
Point 2 = (2,2,10);
------------------
Point 3 = (3,3,?);

Example 2:

Point 1 = (2,6,5);
Point 2 = (4,40,10);
------------------
Point 3 = (3,23,?);

Example 3:

Point 1 = (0,6,5);
Point 2 = (0,40,10);
------------------
Point 3 = (0,20,?);

Ah, forgot to mention that these two points (and the subsequent third point) are on a line. I can also extend the sample size from 2 to N before runtime (where, in the above example, the 3rd point, is calculated).

  • How are the first two points determined? Are they on a line? Together on a plane? What do you want to do with the third point? – naslundx Apr 27 '15 at 15:53
  • @naslundx the first two points come from a dataset that i'm using to measure spatially related objects. The third point is generated at runtime. The expansion of these points is linear so, yes, all three points lie on a line. – hownowbrowncow Apr 27 '15 at 15:55
  • The $z$-coordinate of the first is $15$, and of the last is $120/17 = 7,1/17$, but I don't see how the second example could have all three points on a straight line. The $x$-coordinate there is halfway in between, but the $y$-coordinate is not. – Brian Tung Apr 27 '15 at 15:58
  • @BrianTung ah, some copy+paste errors in my calculations. They're just examples not entirely based upon actual data. – hownowbrowncow Apr 27 '15 at 16:00
  • Ahh, so now the point is halfway in between, and the $z$-coordinate is $15/2 = 7,1/2$. The answers below should give you the general method. – Brian Tung Apr 27 '15 at 16:01
  • Are you sure that all points are precisely on a common line? Measurement usually involves error and this would need some model fitting in contrast to the given answers which assume no errors. – mvw Apr 27 '15 at 17:29
  • @mvw some model fitting would probably need to occur. I can increase the number of sample points to any N before runtime.. Care to point me in a good direction? – hownowbrowncow Apr 27 '15 at 17:48
  • It would probably be some linear regression for a best fit line. It is not clear to me, which of your coordinates are exact and which might have measurement errors. – mvw Apr 27 '15 at 21:47
  • @mvw they're all resulting from sensor data so I assume they all carry slight errors in measurement (out of the total space these errors should be relatively slight), although I'm relatively sure if I take enough measurements a useable solution will arise (I could even scale to take multiple best fit lines and somehow average(?) that as well). – hownowbrowncow Apr 28 '15 at 12:24

3 Answers3

2

The line through two points $r_1=(x_1,y_1,z_1)$ and $r_2=(x_2,y_2,z_2)$ is parametrised as

$$r(t) = r_1 + t\cdot (r_2 - r_1)$$

That means, for the first example you provided, it's

$$(x(t),y(t),z(t)) = (1,1,5) + t\cdot ((2,2,10) - (1,1,5)) = (1,1,5) + t\cdot (1,1,5)$$

Now, knowing that at $t=t_3$, you will have $(x(t_3),y(t_3), z(t_3)) = (3,3,0)$, you can use the equation $1 + 1\cdot t_3 = 3$ to determine that $t_3=2$, meaning that $r(t_3) = (3,3,15)$

5xum
  • 123,496
  • 6
  • 128
  • 204
1

Find a vector $(a,b,c)$ going from the first point to the scond, then write the equation for the line on parametric form

$$(x_1, y_1, z_1) + t(a,b,c)$$

Where $(x_1, y_1, z_1)$ is the first point. Now, let this equal your third point:

$$(x_1, y_1, z_1) + t(a,b,c) = (x_3, y_3, z_3)$$

and solve for $t$. Then you will have the $z$ value as $z_3 = z_1 + tc$.

Example: For the first pair, we have $(a,b,c) = (2,2,10) - (1,1,5) = (1,1,5)$. This means the line has parametric form $(1,1,5) + t(1,1,5)$. Now, let this equal $(3,3,15)$. Solving for $t$, we get $t=2$, and so $z = 5 + 2\cdot 5 = 15$.

naslundx
  • 9,720
0

Try simultaneously 2 equations with 2 unknowns to find general equation like Z=ax+by

talmudist
  • 123