I have the centerX and centerY value of the circle and radius. And now i have (x1, y1) point that lie on the circle. I want to know the angle of circle for the point.
I tried the below formula to get the angle of (x1, y1). But it is not giving generic solution.
radian = Math.Atan2(y1 - Cy, x1 - Cx);
angle = radian * (180 / Math.PI);
Please refer the screenshot for my requirement.
Anyone please let me suggest what i did wrong.?
From the MSDN documentation page for Atan2, it returns a result between -180 and 180 degrees (-pi to pi radians). On the other hand, you require 0 to 360. To do this, simply add 360 to the final answer in degrees if it is negative.
radian = Math.Atan2(y1 - Cy, x1 - Cx);
angle = radian * (180 / Math.PI);
if (angle < 0.0)
angle += 360.0;
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