How do I calculate the slope of two points in three dimensions?
February 8, 2008 3:27 PM   Subscribe

How do I calculate the slope of two points in three dimensions? For example, what is the slope of the line that passes through points A(-5,-5,7) and B(3,0,5)? Please show your work. This is not a homework question.

I gave arbitrary points and asked that folks "show your work" so that

a) people would have an example of what I was asking
b) I could then follow along and actually learn how to solve it myself.

The answer to the arbitrary problem isn't what I seek, it's knowing how to solve for that answer.
posted by whatisish to Education (16 answers total)
 
I don't think that is conventionally defined. You could find the slope of the projection of that line onto an arbitrary plane, or more meaningfully you could find the slopes of the 3 projections onto the planes defined by the x, y, and z axes. Been a while since I did math in a classroom, though. It might be more interesting to generally find the function that defines a line, given any two points on it. It will be of the form z=ax+by, I would guess.
posted by mzurer at 6:08 PM on February 8, 2008 [1 favorite]


the problem is ill-defined: the slope of a line is only defined with respect to a coordinate system in a plane it is residing in. A line in 3 dimensional place lies in many different planes, you could establish a rule to pick one of those planes and then calculate the slope of the line wrt that plane i.e. project the line perpendicularly (this is now assuming euclidean geometry) to the horizontal coordinate plane and then take the plane of plane a projection with the coordinate lines given by the projection direction and the line of intersection... but honestly, this is only one scheme and doesn't mean anything.

again, slope is special to lines in two dimensions. the equivalent concept in three dimensions used to be called 'direction cosines' and there are three of them.

i don't get what you are trying to do...
posted by geos at 6:09 PM on February 8, 2008


Response by poster: Ok... A line passing through those points has an angle of inclination (something other than 0, a horizontal line) of X degrees. I'm trying to figure out X.
posted by whatisish at 6:15 PM on February 8, 2008


Best answer: The vector from A to B is (8,5,-2). The dot product of this with (8,5,0), which is the "shadow" of the original vector in the xy-plane, is 8*8 + 5*5 + (-2)*0= 89. Now the dot product of vectors a and b is |a| |b| cosθ, where &theta is the angle between the two. So we get

89 = sqrt(8*8+5*5 + (-2)(-2)) sqrt(8*8+5*5+0*0) cos θ

Evaluating all that and solving for cosθ gives 89/182 ∼ 0.489, so θ ∼ 60 degrees or so.
posted by gleuschk at 6:40 PM on February 8, 2008


Hm, now that I look at that answer, it doesn't make a lot of sense geometrically. (It should be negative, for one thing, and it's way too big, for another.) Sorry, I must be missing something that will make me feel dumb in the morning.
posted by gleuschk at 6:45 PM on February 8, 2008


Best answer: Aha! (Sorry for the repeated postings.) I forgot to take some square roots. If I'd remembered that, I'd have gotten 89/90.978 for cos θ, so θ is more like -11 degrees.
posted by gleuschk at 6:49 PM on February 8, 2008


Response by poster: Yes gleuschk, that's exactly what I'm trying to figure out. Not knowing what this kind of computation is even called, I couldn't find a "how-to" anywhere. If you see what's missing, please do follow up.
posted by whatisish at 7:02 PM on February 8, 2008


Response by poster: Excellent. Thanks so much.
posted by whatisish at 7:04 PM on February 8, 2008


We are given two vectors p and q.
Let v := p - q be their difference. Write v = (v_1, v_2, v_3).
Let v' = (v_1, v_2, 0) be the projection of v onto the x-y plane.
Similarly, let p' be the projection of p onto the x-y plane.
Let L = {v + tp, | t is a real number} be the line passing through p and q.
Assume we are not in the case when L is the z-axis.
Further assume L is not contained in the x-y plane.
Let L' = {v' + tp' | t is a real number} be the projection of L onto the x-y plane.

Claim: L and L' intersect in a unique point, hereafter denoted by X.
Proof. We set up an equation and solve for t.
v + tp = v' + tp'.
(v_1 + tp_1,v_2 + tp_2,v_3 + tp_3) = (v_1 + tp_1,v_2 + tp_2, 0)
Solution occurs when v_3 + tp_3 = 0.
t = -v_3/p_3.
The intersection point X is (v_1 -v_3p_1/p_3, v_2 -v_3p_2/p_3, 0).

Problem. Find the acute angle between L and L'.

Solution. Let a = p - X be the vector joining X and p.
Let b = q - X be the vector joining X and q.
Use the formula a.b = |a||b|cos theta, to solve for theta.
If theta is between 0 and pi/2, we are done.
If theta is between pi/2 and pi, the answer is pi - theta.
If theta is negative, multiply theta by -1, and refer to the previous cases.

If it turns out you're just using AskMe to do your homework, I'm gonna be kinda pissed. Oh well..
posted by proj08 at 8:20 PM on February 8, 2008


actually, i wouldn't be pissed- we need more questions like this on AskMe amirite?
posted by proj08 at 8:44 PM on February 8, 2008


Best answer: I get -12 degrees using the below procedure. I'd love to know what I'm doing wrong:

1) Normalize the vector by setting one to be the origin. Obvious it should'nt affect the slope.
So you get (0,0,0) and (8,5,-2)
2) The angle we want has a "x axis" (actually, projection onto the x-y plane) of sqrt(89)=9.43
3) The angle we want has a "y axis" of 2 (-2 actually)
4) So, the angle is TAN(angle)=2/9.43=0.212.
5) Solving for the angle: TAN-1(.212)=11.96 degrees. So, closer to 12 degrees.
posted by vacapinta at 9:02 PM on February 8, 2008


Best answer: In short, let x,y,z be the *differences* of each of the respective coordinates between the two points.

Then the angle it makes with the x-y plane is: TAN-1(z/sqrt(x*x+y*y))
posted by vacapinta at 9:06 PM on February 8, 2008


Response by poster: This is a task I sometimes, albeit rarely, have to perform for my job. I would normally just run a dowel or cord through the two points and take a measurement using an inclinometer. I've always thought it would be neat to verify the measurement mathematically but couldn't grasp how.

Thanks again everyone.
posted by whatisish at 10:50 PM on February 8, 2008


Just to be clarify what's happening here: as was mentioned earlier, there's no such thing as 'slope' in 3-d space.

If you're trying to find the angle between two arbitrary vectors in space, this angle can be found with the well-known dot-product.

The closest thing I can think of to slope is something like the gradient: the line connecting the two points: X = A - B, and normalized over one of the dimensions (divide all the quantities in X by A or B). Since slope is usually defined as y/x, this would be the line (1,y/x,z/x), with x,y,z representing the respective distances in the three coordinates of A and B.
posted by onalark at 8:34 AM on February 9, 2008


I understood the OP to be asking for the angle that the line connecting the two points makes with the x-y plane. More specifically the angle between the original line (x1y1z1 to x2y2z2) and the shadow on the xy plane (x1y10 to x2y20).

In physical reality, if z is height and the line defines a stick, the slope is the slope that an ant crawling up the stick would be walking at. The OP said above that a horizontal line has 0 degrees, which fits in with this definition.
posted by vacapinta at 4:17 PM on February 9, 2008


Whoops, I see what you mean vacapinta. I should have read the question more carefully.
posted by onalark at 11:13 AM on February 10, 2008


« Older Blue Cheese/Brie/Goat Cheese fondue?   |   Explain the ginger! Newer »
This thread is closed to new comments.