Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 27 September 2008 - 12:14 PM
Posted 27 September 2008 - 12:54 PM
( a dot b )
theta = acos(---------)
( |a||b| )
Posted 29 September 2008 - 04:06 PM
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?
Posted 29 September 2008 - 04:39 PM
Quote: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.)
Original post by tKircher
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: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).
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.
Posted 29 September 2008 - 08:21 PM
Quote:
Original post by tKircher
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)
Posted 29 September 2008 - 08:44 PM
Posted 30 September 2008 - 01:13 PM
Quote:
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.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.