Draw n-gon problem

BlitzMax Forums/BlitzMax Programming/Draw n-gon problem

Ok I'm trying to writ my own draw polygon command.
It takes the sidelength as a parameter and the number of sides and SHOULD produce a ngon of the correct number of sides.

It works great with numbers like 5,6 but when I use the number 16, the angles are off and they are a missing side.
it makes use of this command which findsthe radius of the polygone:
Function poly_radius#(sidelength:Float,num_sides:Float)
		Local r:Float = sidelength /(2*Sin(180°/num_sides))
		Return r
End Function

Function draw_ngon(x#,y#,numsides%,sidelength#)
	Local small_angle# =360/numsides
	Local radius#=poly_radius(sidelength,numsides)
	
		For Local i=0 To numsides
		DrawLine x+Sin(i*small_angle)*radius,y-Cos(i*small_angle)*radius,x+Sin(i*small_angle+small_angle)*radius,y-Cos(i*small_angle+small_angle)*radius 
		Next
End Function