Perl, 235 211 225 211 207 196 179 177 175 168 160 156 146 chars
<>=~/-d+/;for$y(@a=-$ ..$ ){print+(map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-$&/45==8|$t>=$`/45&$t<=-$&/45?qw(- / | \)[$t%4]:$":o,@a),$/}
www.un.org/Depts/DGACM/index_spanish.htm
Perl using say feature, 161 149 139 chars
$ echo -n <>=~/-d+/;for$y(@a=-$ " " ..$ " " ){say map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-$&/45==8|$t>=$`/45&$t<=-$&/45?qw(- / | \)[$t%4]:$":o,@a} | wc -c
139
$ perl -E <>=~/-d+/;for$y(@a=-$ " " ..$ " " ){say map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-$&/45==8|$t>=$`/45&$t<=-$&/45?qw(- / | \)[$t%4]:$":o,@a}
www.un.org/Depts/DGACM/index_spanish.htm
Perl without trailing newline, 153 143 chars
<>=~/-d+/;for$y(@a=-$ ..$ ){print$/,map$_|$y?!($t=8*($y>0)+atan2(-$y,$_)/atan2 1,1)&-$&/45==8|$t>=$`/45&$t<=-$&/45?qw(- / | \)[$t%4]:$":o,@a}
www.un.org/Depts/DGACM/index_spanish.htm
Original version commented:
$_=<>;m/(d+)-(d+) (d+)/;$e=$1/45;$f=$2/45; # parse angles and radius, angles are 0-8
for$y(-$3..$3){ # loop for each row and col
for$x(-$3..$3){
$t=atan2(-$y,$x)/atan2 1,1; # angle of this point
$t+=8if($t<0); # normalize negative angles
@w=split//,"-/|\"x2; # array of ASCII symbols for enclosing lines
$s.=!$x&&!$y?"o":$t==$e||$t==$f?$w[$t]:$t>$e&&$t<$f?"x":$";
# if it s origin -> "o", if it s enclosing line, get symbol from array
# if it s between enclosing angles "x", otherwise space
}
$s.=$/;
}
print$s;
www.un.org/Depts/DGACM/index_spanish.htm
EDIT 1: Inlined sub, relational and equality operators return 0 or 1.
www.un.org/Depts/DGACM/index_spanish.htm
EDIT 2: Added version with comments.
www.un.org/Depts/DGACM/index_spanish.htm
EDIT 3: Fixed enclosing line at 360º. Char count increased significantly.
www.un.org/Depts/DGACM/index_spanish.htm
EDIT 4: Added a shorter version, bending the rules.
www.un.org/Depts/DGACM/index_spanish.htm
EDIT 5: Smarter fix for the 360º enclosing line. Also, use a number as fill. Both things were obvious. Meh, I should sleep more :/
www.un.org/Depts/DGACM/index_spanish.htm
EDIT 6: Removed unneeded m
from match operator. Removed some semicolons.
www.un.org/Depts/DGACM/index_spanish.htm
EDIT 7: Smarter regexp. Under 200 chars!
www.un.org/Depts/DGACM/index_spanish.htm
EDIT 8: Lots of small improvements:
- Inner for loop -> map (1 char)
- symbol array from
split
string -> qw (3 chars)
- inlined symbol array (6 chars, together with the previous improvement 9 chars!)
- Logical or -> bitwise or (1 char)
- Regexp improvement (1 char)
- Use arithmethic for testing negative angles, inspired by Jacob s answer (5 chars)
www.un.org/Depts/DGACM/index_spanish.htm
EDIT 9: A little reordering in the conditional operators saves 2 chars.
www.un.org/Depts/DGACM/index_spanish.htm
EDIT 10: Use barewords for characters.
www.un.org/Depts/DGACM/index_spanish.htm
EDIT 11: Moved print inside of loop, inspired by Lowjacker s answer.
www.un.org/Depts/DGACM/index_spanish.htm
EDIT 12: Added version using say
.
www.un.org/Depts/DGACM/index_spanish.htm
EDIT 13: Reuse angles characters for fill character, as Gwell s answer does. Output isn t as nice as Gwell s though, that would require 5 additional chars :) Also, .. operator doen t need parentheses.
www.un.org/Depts/DGACM/index_spanish.htm
EDIT 14: Apply regex directly to <>. Assign range operator to a variable, as per Adrian s suggestion to bta s answer. Add version without the final newline. Updated say
version.
www.un.org/Depts/DGACM/index_spanish.htm
EDIT 15: More inlining. map{block}@a -> map expr,@a.