# A Line in Three Dimensions

1. Dec 21, 2008

### pjhphysics

Hi,

Let's say I have two points:

Pa = (0, 0, -30)

Pb = (-2.5, -2.5, 7.5)

and I want to find the X and Y values for a third point on this line whose Z value is 30:

Pc = (X, Y, 30)

How can I achieve this? My math is not very great and I'm applying this to a computer program. So if possible, a straightforward, programmable format would be so great!
Thanks

2. Dec 21, 2008

### pjhphysics

3. Dec 21, 2008

### mathwonk

parametrize the line through P,Q by t, as all points of form P + t(Q-P).

then you get a linear formula for each of the three coordinates.

set the formula for Z equal to whatever and solve for t.

then plug back into the formulas to get the other two coords.

this is precalculus. so you can look it up anywhere.

4. Dec 21, 2008

### pjhphysics

What exactly is the form of this linear formula?
I'm not sure I understand how to set this up. Could you provide a demonstration please (or point me to one)?
Thanks so much.

5. Dec 21, 2008

### HallsofIvy

Staff Emeritus
Any line can be written x= At+ B, y= Ct+ D, z= Et+ F. Also you are free to choose t= 0 at any one point on the line and t= 1 at any other point on the line. Knowing two points gives two equations for each pair of numbers, A and B, C and D, and E and F.

In your case, we can take t= 0 at Pa = (0, 0, -30) and have immediately x= A(0)+ B= 0 so B= 0, y= C(0)+ D= 0 so D= 0, and z= E(0)+ F= -30 so F= -30.

Now, take t= 1 at Pb = (-2.5, -2.5, 7.5) so x= A(1)+ 0= -2.5 which gives A= -2.5, y= C(1)+ 0= -2.5 so C= -2.5, and z= E(1)-30= 7.5 so E= 37.5.

You now have x= -2.5t, y= -2.5t, z= 37.5t- 30.

When z= 30, you have 37.5t- 30= 30. Solve that for t and use that t to find x and y.

6. Dec 21, 2008

### mathwonk

in vector form, if P = (0, 0, -30)

and Q = (-2.5, -2.5, 7.5), then Q-P = (-2.5, -2.5, 37.5), so P + t(Q-P)

= (-2.5 t, -2.5 t, -30 + 37.5 t), thus if the last coordinate = 30, i.e. if you want

Z = -30 + 37.5 t = 30, then t = 60/37.5. then plug that back in the other two entries to get X and Y.

Last edited: Dec 21, 2008
7. Dec 29, 2008

### haribrahma

Hi,

I tried the same problem but slightly different way, without involving any equation but doing it geometrically.

Pa and Pb are the two points of a line in 3D, just project this line on -XZ (negative X and Positive Z) axis, the point Pa will have x intercept 0 and Z intercept -30, like way Pb will have -X = 2.5 and Z=7.5. Now this forms a triangle with angle Θ with the Z axis as shown in the picture.

tan Θ = 2.5/37.5 = x/60

x is the x intercept of the line at Z=30

solving this simple equation we can get x, in the same way we can proceed for y.

But this method works easy for this given problem, it might be tedious for higher complex problem...

#### Attached Files:

• ###### 1.jpg
File size:
6.1 KB
Views:
28
8. Dec 30, 2008

### HallsofIvy

Staff Emeritus
If all you want is a simple, programmable formula, do this: determine what percentage of the way between -30 and 7.5 30 is (it will, of course, be larger than 100%). The distance from -30 to 7.5 is 7.5-(-30)= 37.5. The distance from -30 to 30 is 30-(-30)= 60. So 30 is 60/37.5= 1.6 or 160% of the way from -30 to 7.5. Now, what x is 160% of the way from 0 to -2.5? 1.6(-2.5- 0)= -4. And, of course, the same calculation for y. The point (-4, -4, 30) lies on the line through (0, 0, -30) and (-2.5, -2.5, 7.5).

9. Jan 3, 2009

### pjhphysics

Hi,
Thanks for the help.
I derived the following, which seems to work in some but not all cases.
In cases where it doesn't work, it seems that the signs of Cx and Cy are the opposite of what they should be, which makes me think I need to put in an absolute value notation somewhere in my equation.