#### Archived

This topic is now archived and is closed to further replies.

# Fast angle calculation between two points

This topic is 5884 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''ve been trying to find a fast way of getting the angle between two points. What I have is this one object in the game who is supposed to chase after another object (straight line). The game is basically 2d (uses 3d models for graphics but the gameplay is all 2d). I was wondering if maybe I should use vectors but I really am not sure where to go. I''d search the forums but the search thing is broken right now.

##### Share on other sites
y2 - y1
---------
x2 - x1

Won''t that work?

##### Share on other sites
You should use vectors, but in the mean time:
x1 * x2 + y1 * y2 = sqrt(x1² + y1²) * sqrt(x2² + y2²) * cos(angle)

This is the definition of the dot product. If you have two vectors (x1, y1) and (x2, y2), then you can use this formula to find the angle.

There are some introductions to vectors here on GameDev, if you don''t know how to use them.

Cédric

1. 1
2. 2
3. 3
Rutin
22
4. 4
5. 5

• 13
• 19
• 14
• 9
• 9
• ### Forum Statistics

• Total Topics
632936
• Total Posts
3009312
• ### Who's Online (See full list)

There are no registered users currently online

×