Yes you're right. To complete the outline you have to connect each point to the previous point. Something like this:
$prevdist = 0; foreach $ydist ( 0..$radius ) { # using the formula: # xdist*xdist + ydist*ydist = radius*radius $newxdist = int(sqrt( $radius*$radius - $ydist*$ydist)); # Take advantage of symmetry to plot 4 lines at once # (for circle outline, draw a line from the previous # point to the new one) foreach $xdist ($prevdist..$newxdist) { $circle{$x_center-$xdist}{$y_center-$ydist}++; $circle{$x_center+$xdist}{$y_center-$ydist}++; $circle{$x_center-$xdist}{$y_center+$ydist}++; $circle{$x_center+$xdist}{$y_center+$ydist}++; } $prevdist = $newxdist; }
In reply to Re^3: Creating a circle in a data structure
by Crackers2
in thread Creating a circle in a data structure
by AK108
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |