getCircularPosition function

List<Point<num>> getCircularPosition(
  1. int numberOfElements,
  2. double radius,
  3. double scrollY
)

Formulas for calculate position x and y x= r x cos(θ); y= r x sin(θ);

1 round = 360° = 2π rad

Implementation

List<Point> getCircularPosition(
    int numberOfElements, double radius, double scrollY) {
  List<Point> points = [];

  for (var i = 0; i < numberOfElements; i++) {
    var angle = scrollY + (i * 2 * pi) / numberOfElements;
    var x = radius * cos(angle);
    var y = radius * sin(angle);

    points.add(Point(x, y));
  }

  return points;
}