Advertisement

Relative Angle From Object To Point

Started by April 25, 2003 11:05 PM
0 comments, last by Extrarius 21 years, 9 months ago
Is this the proper way to get the relative angle from ''Object'' to ''Point'': v = (Point - Object.Poisition); angle = (atan2(v.y, v.x) - Facing); assuming Object.Poisition, Point, and v are points, and Facing is the facing of the object?
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
Some further details would be helpful. What do you mean by "Facing." Is that another angle? I don''t know what you mean by this term.

As for the answer to your question, I would have to say no, this is probably not the right way. While atan2(v.x, v.y) does give you an angle, it is measured relative to the world x axis within a plane parallel to the world xy plane, which may not be what you''re looking for. Plus, without knowing what Facing IS, it seems quite wrong to subtract Facing from that angle.

Keep in mind that the angle of vector v can be ANYTHING from -pi to pi depending on the reference axis and plane. To find the correct equation, you need to know where you want to measure the angle from. You can only measure an angle within a plane, and from a reference axis.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net

This topic is closed to new replies.

Advertisement