I'm attempting to get this randomly generated solar system code to display 'planets' randomly along the orbit arc. I'm struggling to find/use the right formula here (see picture for reference of what looks like now).
draw_orbit(cr, 4, width/2, sun_center, height - next_center - border_size, .6, .6, .6)
is the code for the orbit arc with height - next_center - border_size
being the radius of the arc.
Current array of points on circle... but formula is wrong and I can't seem to get it:
def points_on_circum(r,n=100):
points_positive = []
for x in range(0, n + 1):
xcoord = (math.cos(2 * math.pi / n * x) * r)
ycoord = (math.sin(2 * math.pi / n * x) * r)
if xcoord > 0 and ycoord > 0:
points_positive.append((xcoord, ycoord))
return points_positive
Current thought of how to get the random x, y coordinates of placement:
arc = height - next_center - border_size
placement = random.choice(points_on_circum(arc))
draw_circle_fill(cr, placement[0],placement[1], next_size, r, g, b)
Orbit function:
def draw_orbit(cr, line, x, y, radius, r, g, b):
cr.set_line_width(line)
cr.arc(x, y, radius, 0, 2*math.pi)
cr.stroke()
I'm trying to randomly generate the planets along the arc, but currently they are all at the same position: