How can I improve this equation to work in all cases?

In summary, the linear formula for finding the X and Y values for a third point on a line in 3D space, whose Z value is 30, is given by:X = (((X1-X2) * (Z3-Z1)) / (Z1-Z2)) + X1Y = (((Y1-Y2) * (Z3-Z1)) / (Z1-Z2)) + Y1where (X1, Y1, Z1) and (X2, Y2, Z2) are two points on the line and (X, Y, 30) is the desired point.
  • #1
pjhphysics
16
0
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
 
Physics news on Phys.org
  • #2
Anyone? please.
 
  • #3
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
Hey, thanks for your help.

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
Any line can be written x= At+ B, y= Ct+ D, z= Et+ F. Also you are free to choose t= 0 at anyone 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
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:
  • #7
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...
 

Attachments

  • 1.jpg
    1.jpg
    6.1 KB · Views: 418
  • #8
pjhphysics said:
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

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

Please have a look:

Cx = (((Ax - Bx) * (Cz - Az)) / (Az - Bz)) + Ax
Cy = (((Ay - By) * (Cz - Az)) / (Az - Bz)) + Ay
 

What is "A Line in Three Dimensions"?

"A Line in Three Dimensions" refers to a geometric concept in which a line is represented in a three-dimensional space, as opposed to the traditional two-dimensional representation on a flat surface. It involves using three coordinates (x, y, and z) to define the position of a point on the line in three-dimensional space.

How is a line represented in three dimensions?

A line in three dimensions is typically represented using a parametric equation, which involves using a variable parameter to define points on the line. This allows for the line to be represented as a set of points rather than a single equation.

What is the equation for a line in three dimensions?

The equation for a line in three dimensions is typically written as:
x = x0 + at
y = y0 + bt
z = z0 + ct
where (x0, y0, z0) is a point on the line and (a, b, c) are direction vectors that determine the slope of the line in each direction.

What is the significance of a line in three dimensions?

A line in three dimensions has several practical applications in fields such as engineering, physics, and computer graphics. It is used to represent motion in three-dimensional space, as well as to define surfaces and curves in three-dimensional objects.

How does a line in three dimensions differ from a line in two dimensions?

In two dimensions, a line can be represented by a single equation of the form y = mx + b, where m is the slope and b is the y-intercept. In three dimensions, a line cannot be fully described by a single equation and requires the use of multiple parameters and equations to define its position and direction in three-dimensional space.

Similar threads

  • Linear and Abstract Algebra
Replies
10
Views
1K
Replies
17
Views
2K
  • Precalculus Mathematics Homework Help
Replies
17
Views
970
Replies
4
Views
2K
  • Linear and Abstract Algebra
Replies
1
Views
914
  • Linear and Abstract Algebra
Replies
6
Views
1K
Replies
5
Views
1K
  • General Math
Replies
4
Views
808
  • Precalculus Mathematics Homework Help
Replies
1
Views
1K
  • Linear and Abstract Algebra
Replies
2
Views
2K
Back
Top