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?
Quote this message in a reply
Sage
Posts: 1,482
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.
Quote this message in a reply
Member
Posts: 43
Joined: 2009.02
Post: #3
Thank you very much!
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Smooth acceleration in every direction. Honey Sharma 1 4,867 Aug 16, 2011 01:37 AM
Last Post: PoseMotion
  Formula for converting angle to vector? komirad 2 11,401 Jul 29, 2011 07:29 AM
Last Post: ThemsAllTook
  newbie request direction Teehee 3 6,473 Jul 27, 2011 09:57 AM
Last Post: AndyKorth
  give direction to sprite termitis 9 10,818 Mar 11, 2011 02:38 PM
Last Post: compiler
  Direction of normal Miglu 3 4,022 Oct 4, 2010 05:08 PM
Last Post: Skorche