Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Since my trigonometry skills suck (I mean they really suck) I need help into translating coordinates (X,Y) into degrees.

 

Ok, lets assume we have a circle on the screen. The circle has naturally its center located at some x,y pos. Now, what I want is to click anywhere on the screen a return its current degree value based on a 360º navigation system related to the center of the mentioned circle.

 

Therefore, if I click at the right side of the circle's position it should return 90º degrees, if I click directly bellow the center of the circle it should return 180º degrees. At the top of it it should return 360 / 0 degrees.

 

The clicking area can be anywhere, not necessary inside the circle, it simply needs to return the relative direction from the circle's center towards the mouse' clicking position.

What is the math formula to achieve this?

 

Thank you so very much!

Posted

I got this PERFECT formula :D!

 

"bearingInDegrees = (atan2( x - x0, y0 - y ) / PI * 180 + 360) % 360,

where (x0,y0) is the centre coordinate, (x,y) is the click point and % is the modulus operator"

 

submitted by d-glitch at Experts Exchange!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...