Search code examples
javarotationlibgdxgeometryspinning

How to create a circle out of smaller circles in libgdx?


I am creating a ring that will spin made out of circles and I don't want to have to manually place each circle and then spin them all at once. Isn't there some mathematical way to create this circle? Each circle is an object.

It would look like this: https://i.sstatic.net/wgpbf.jpg


Solution

  • Not sure if I understood it correct,but propably you want something like this

    int numOfCircles=40;
    float rad=10;
    List<Point> points=new ArrayList<Point>();
    for(float a=0;a<360;a+=(360/numOfCircles)){
        points.add(new Point(Math.cos((a) * 0.0174532925f) * rad), Math.sin((a) * 0.0174532925f) * rad));
    }