in reply to how to calculate polygon vertex coordinates

Hi!
I'm copying right from my SWF module with some changes; you will have to do some analyzing and reformating.
It draws a polygon, given radius and number of sides. No GD by the way, but the algorithm should be applicable elsewhere.

AGAIN: Just to illustrate one way to draw a polygon. The code below will not run!!
sub polygon { my $r = shift; my $sides = shift; #Angles: my $theta = &rad(360/$sides); my $theta_half = &rad(180/$sides); #my $phase = &rad(0) ; my $beta = &rad ( (180-360/$sides) /2 ) ; my $s = $r * sin($theta)/sin($beta); my( $beginX,$beginY) = @M; my($sX,$sY); #Drawing: for ( 1..$sides ) { $sX = $s * cos(($_* $theta + $theta_half )); $sY = $s * sin(($_* $theta + $theta_half )); $shapeSWF->drawLineTo($beginX+$sX,$beginY+$sY); $beginX = $beginX+$sX; $beginY = $beginY+$sY; } }