If I have an image 720, 720 that looks like this..
How do I work out the angle of the touched x,y given that the center x and y are 360, 360 A lot of calculations I see for this assume the origin is 0,0 (which is top left) so I get incorrect results. I am assuming 0 is always to the top and not rotated.
May be clearer this way:
(Math.toDegrees( Math.atan2(fromLeft - 360.0, 360.0 - fromTop) ) + 360.0) % 360.0
Adding a 360 degree turn and applying the modulo operator gives you the positive angle, which atan2 does not.
Here is the general formula:
angle = atan2(mouseY - cirleCenterY, mouseX - circleCenterX);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With