finding a third 3d point in a series

185 Views Asked by At

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).

3

There are 3 best solutions below

0
On BEST ANSWER

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)$

0
On

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$.

0
On

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