Distribute items around circle with math - Flutter code

Viewed 202

I have a set of elements and I need to distribute them on a circular curve like the one in the picture below, so that the maximum possible number of elements is 10 and the minimum number is 3.

I need a mathematical equation or any other method in order to distribute these elements in a circular shape, with the Dart language.

Thank

enter image description here

1 Answers

I don't know anything about Dart, but this is how you can solve it mathematically:

(x,y): center of the circle
r: radius of the circle
a: start angle of the distribution in radians
b: end angle of the distribution in radians
n: number of elements

The element with index i should be positioned at:
x_new = x + r * cos(a + i * (b - a) / (max(2, n - 1)))
y_new = y + r * sin(a + i * (b - a) / (max(2, n - 1)))

Related