As the title suggests, i'm trying to find a way to extrapolate the pitch, yaw, and roll between two 3D points.
I know how to do this in 2D (atan2 etc), but i'm striking out trying to find a way to do this at all in 3d, let alone in an efficient way.
Any help's appreciated.

Ok well, my routine isn't working, and since all the other calculations are taken line-for-line from code that everyone reports as working, i assume it's this.

All i'm doing is taking the dot product of the two points (taking the x, y, z of each point as vectors and dotting those), then using sin, cos, and tan on the dot to get the three values i'm after. I figured an implicit magnitude of 1 would simplify the equation (divide by 1 is sorta redundant)

However, it doesn't seem to be working. The angles aren't correct, it -always- returns 90 degrees when using the arc-tan/cos/sin, and when using normal cos/tan/sin, it constantly returns a 57.29 degree. This isn't correct, as the angle between the two points is, in fact, exactly 180 degrees.

Quote:

Computing the pitch, yaw, and roll 'between two 3D points' doesn't really make any sense. Could you perhaps clarify what it is you're trying to do?

Well, how about this. I have two points. I want to know the angles that point from one point to the other one. Or, another way of thinking, if i have an entity at one point who isn't rotated at all, how many degrees would such an entity have to rotate to be facing -exactly- at that second point.

Original post by tKircherOk well, my routine isn't working, and since all the other calculations are taken line-for-line from code that everyone reports as working, i assume it's this.

All i'm doing is taking the dot product of the two points (taking the x, y, z of each point as vectors and dotting those), then using sin, cos, and tan on the dot to get the three values i'm after. I figured an implicit magnitude of 1 would simplify the equation (divide by 1 is sorta redundant)

However, it doesn't seem to be working. The angles aren't correct, it -always- returns 90 degrees when using the arc-tan/cos/sin, and when using normal cos/tan/sin, it constantly returns a 57.29 degree. This isn't correct, as the angle between the two points is, in fact, exactly 180 degrees.

Sounds like you might be missing a degrees/radians conversion somewhere. (That's just a guess though - maybe you could post the code where you perform these calculations.)

Quote:

Well, how about this. I have two points. I want to know the angles that point from one point to the other one. Or, another way of thinking, if i have an entity at one point who isn't rotated at all, how many degrees would such an entity have to rotate to be facing -exactly- at that second point.

Ok, to rotate an entity to aim at a target, you only need to compute two angles. What you're looking for is a cartesian-to-spherical coordinate conversion, which, given the target position, will return two angles (pitch and yaw, azimuth and elevation - whatever you want to call them).

Unfortunately it can be kind of tricky to get the conversion right, due to the various differing conventions that are used. Note that there are other options as well that don't involve angles or trig - if this is for billboarding, for example, you can usually construct a suitable orientation directly using only vector math. Finally, if this is for AI, and if you want the entity to turn gradually toward the target rather than snapping to it, it would probably be better to transform the target point into the local space of the entity and then apply pitch and yaw deltas based on the local-space position of the target.

So what, ultimately, are you trying to do? With a little more info, we can probably steer you toward a suitable solution.

Original post by tKircherAll i'm doing is taking the dot product of the two points (taking the x, y, z of each point as vectors and dotting those), then using sin, cos, and tan on the dot to get the three values i'm after. I figured an implicit magnitude of 1 would simplify the equation (divide by 1 is sorta redundant)

Well, there are a few problems here :).

First, the formula does not generalize to plug in sin/cos/tan/asin/atan, it only works with acos. Second, unless you are using normalized vectors, dividing by the magnitude is actually very important.

The most serious problem, is I misread your question (went off the title of the post, not the content ;)). The formula I gave you will certainly compute the angle between two vectors. However, that's all it will do.

As far as i know u can't calculate an angle between two points ... U can calculate an angle between two vectors (or lines)... I calculate an angle between one static line and a ray pointing from a model that i can drag with mouse...