I have been trying to figure out how to write a simple program to compute the x,y points for creating a regular polygon of n sides. Can someone give me some code examples th
angle = start_angle
angle_increment = 360 / n_sides
for n_sides:
x = x_centre + radius * cos(angle)
y = y_centre + radius * sin(angle)
angle += angle_increment
in practice, when drawing lines instead of just calculating the corner points, you also need to "join up" the polygon by repeating the first point.
also, if sin() and cos() work in radians rather than degrees, you want 2 * PI instead of 360.