View Full Version : Slope of a 3D line...HELP

I need some info on how to calculate a slope (I ultimately need the angle, but that's easy enough to calculate from the slop) of a two points in 3D space. This one has me stumped. I know how to calculate the slope of a 2D line. How do I calculate the slope of a 3D line? ANY info would be greatly appreciated.

Marjamaa

12-18-2002, 09:50 AM

m3d = dy / sqrt( dx * dx + dz * dz );

Assuming you want slope from the XZ plane. Swap the variables around for other planes.

-Marjamaa

edit: add plane stuff

[This message has been edited by Marjamaa (edited 12-18-2002).]

Coriolis

12-18-2002, 09:50 AM

This is not enough info. There is probably a really easy solution if you would tell us the entire problem, and what you actually want to do.

Angle of a line in isolation is meaningless, as is slope; there has to be a reference line or plane someplace else. Once you have that, it is easy to get the angle.

I am simply trying to determine the slope of a 3d line inside my view frustum. What info do you need?

lucidmm

12-18-2002, 10:20 AM

You've already been given the formula you need.

If you're trying to find the angle between the XZ plane, I think

sin^-1(dy/(sqrt(dx*dx+dy*dy+dz*dz))) will work.

I don't think this should be in an OpenGL forum and it's definitely not advanced.

Coriolis

12-18-2002, 11:32 AM

cru:

The meaning of the slope of a line only makes sense when it is in reference to a base plane or a base line. In different reference frames the slope is different, and with no reference frame there is no slope. So, what I need to know is what the reference frame is. You want to know the slope of the line with respect to what?

In 2D, the reference frame is typically the x axis, but you could just as easily call it the y axis or the line x = 2y.

Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.