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
  Formula for converting angle to vector? komirad 2 10,056 Jul 29, 2011 07:29 AM
Last Post: ThemsAllTook
  Direction of normal Miglu 3 3,638 Oct 4, 2010 05:08 PM
Last Post: Skorche
  Fast Distance formula? mikey 11 7,533 Nov 23, 2009 10:43 AM
Last Post: mikey
  Mathmatical formula for integer checking Jones 12 5,776 Jan 24, 2006 01:58 AM
Last Post: zKing