Calculating the angle between two points

Posted by kingrichard2005 on Stack Overflow See other posts from Stack Overflow or by kingrichard2005
Published on 2010-04-20T16:12:05Z Indexed on 2010/04/20 16:23 UTC
Read the original article Hit count: 174

I'm currently developing a simple 2D game for Android. I have a stationary object that's situated in the center of the screen and I'm trying to get that object to rotate and point to the area on the screen that the user touches. I have the constant coordinates that represent the center of the screen and I can get the coordinates of the point that the user taps on. I'm using the formula outlined in this forum: How to get angle between two points?

-It says as follows "If you want the the angle between the line defined by these two points and the horizontal axis: double angle = atan2(y2 - y1, x2 - x1) * 180 / PI;".
-I implemented this, but I think the fact the I'm working in screen coordinates is causing a miscalculation, since the Y-coordinate is reversed. I'm not sure if this is the right way to go about it, any other thoughts or suggestions are appreciated.

© Stack Overflow or respective owner

Related posts about android

Related posts about game-development