I am making a WPF control (knob). I am trying to figure out the math to calculate the angle (0 to 360) based on a mouse click position inside the circle.
For instance, if I click where the X,Y is on the image, I would have a point X,Y. I have the centerpoint as well, and cannot figure out how to get the angle.

My code below:
internal double GetAngleFromPoint(Point point, Point centerPoint)
{
double dy = (point.Y - centerPoint.Y);
double dx = (point.X - centerPoint.X);
double theta = Math.Atan2(dy,dx);
double angle = (theta * 180) / Math.PI;
return angle;
}
You’ve got it almost right: