Find a Circle Point on Android

Everything seemed so simple and simple until I had to program it.

What I have

I uploaded an image to better explain it.

  • I have a circle and I know

    • its radius
    • coordinates of the center point
    • the initial coordinate of each button (red circles).

I want to be able when I rotate the image of the gray circle with 10 degrees to calculate the red buttons with the new coordinates (x1y1, x2y2).

This should not be difficult to achieve for those who know math, but I have not been able to find a suitable solution. I also searched here and did not find a working solution. Any help is appreciated. Thanks you

enter image description here

Working solution as below:

- first take care of the rotation angle, at each redraw just increase it

   angle = angle+mainRotationAngle;

    float x =  (float) (center.X + Math.cos(angle*Math.PI / 180F) * radius 
    float y =  (float) (center.Y + Math.sin(angle*Math.PI / 180F) * radius

    button.setX(x);
    button.setY(y);
+5
2

, , , . :

newAngle = Angle+rot;
xbutton = center.x+cos(newAngle)*radius;
ybutton = center.y+sin(newAngle)*radius;

, atan2, :

buttonAngle = atan2(button.y-center.y,button.x-center.x);
+5

x1 = x + r sin 10

y1 = y + r cos 10

x2 = x - r sin 10

y2 = y - r cos 10

+1

All Articles