Direction formula?

Member
Posts: 43
Joined: 2009.02
Post: #1
I was wondering if anyone has any information on how to calculate the angle at which to rotate an object based on an x,y set of information?
Ie:
A circle has a point on it that I want to face the mouse. I have the x,y of the circle, and the x,y of the mouse. How can I figure the angle at which to rotate the circle?
Sage
Posts: 1,487
Joined: 2002.09
Post: #2
Code:
`atan2(mousey - circley, mousex - circlex)`
Result is in Radians. Multiply by 180/PI to convert to degres.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Member
Posts: 43
Joined: 2009.02
Post: #3
Thank you very much!

Possibly Related Threads...
 Thread: Author Replies: Views: Last Post Formula for converting angle to vector? komirad 2 14,338 Jul 29, 2011 07:29 AM Last Post: ThemsAllTook Direction of normal Miglu 3 5,367 Oct 4, 2010 05:08 PM Last Post: Skorche Fast Distance formula? mikey 11 13,247 Nov 23, 2009 10:43 AM Last Post: mikey Mathmatical formula for integer checking Jones 12 10,514 Jan 24, 2006 01:58 AM Last Post: zKing