The quickest description of this answer is that I am trying to find the coordinates of the white dot
(Original answer updated. It may be a bit too verbose now, but I hope it helps.)
You're looking for the XY coordinates (called Cartesian coordinates), but these are difficult to calculate directly. The trick is to go through Polar coordinates first. Polar and Cartesian are two ways of expressing the same thing, namely a point in a grid and can be converted into eachother.
Polar coordinates consist of angle and distance from the center point. You can calculate the desired angle because you know the percentage of the circle that you need to cover and you can calculate the distance from the center because you know the radius of the circle.
Your covering arc is 225 degrees, so the remainder is 135 and half that is 67.5 degrees. The angle for the point you're looking for is therefore 225+67.5 = 292.5 degrees. The radius for that point is half the radius of the circle, so that's canvasWidth/4
.
Once you've determined the polar coordinate, (292.5, canvasWidth/4)
, you convert this to the XY coordinate using the conversion function. There's one thing that's a bit tricky: Math.cos(double)
and Math.sin(double)
expect their argument to be in radians, not in degrees. You express your 292.5/360 as x/2π before making the conversion, which you do by multiplying the value by π/180, giving 5.1051 in this case.
Assuming that canvasWidth
is 400:
double tdeg 292.5d; // Calculated from arc percentage
int r = 100; // Calculated from canvas width
double trad = tdeg * (Math.PI/180d); // = 5.1051
int x = (int) r * Math.cos(trad);
int y = (int) r * Math.sin(trad);