Root/
| Source at commit 30c683effd7ab362d1517950700c96cfa09e45e8 created 11 years 17 days ago. By Werner Almesberger, tornado/fw/sim/p: pass arguments to "alg"; label graphs; better separate "up" | |
|---|---|
| 1 | #!/usr/bin/perl |
| 2 | $I = 50; # inner radius (50 cm) |
| 3 | $O = 80; # outer radius (80 cm) |
| 4 | #$Y = 64; # image heights (pixels) |
| 5 | #$X = 256; # image width (pixels) |
| 6 | |
| 7 | |
| 8 | sub ang |
| 9 | { |
| 10 | local ($r) = @_; |
| 11 | |
| 12 | # (O-I)/Y = r*arc(a) |
| 13 | # arc |
| 14 | return ($O-$I)/$Y/$r; |
| 15 | } |
| 16 | |
| 17 | |
| 18 | if ($ARGV[0] eq "-r") { |
| 19 | shift @ARGV; |
| 20 | $rect = 1; |
| 21 | } |
| 22 | |
| 23 | while (<>) { |
| 24 | chop; |
| 25 | if (/#define\s+\S+_width\s+(\d+)/) { |
| 26 | $X = $1; |
| 27 | next; |
| 28 | } |
| 29 | if (/#define\s+\S+_height\s+(\d+)/) { |
| 30 | $Y = $1; |
| 31 | next; |
| 32 | } |
| 33 | next unless /\s*0x/; |
| 34 | s/^\s*//; |
| 35 | s/(,|};)$//; |
| 36 | push(@p, split /,/); |
| 37 | } |
| 38 | |
| 39 | for ($x = 0; $x != $X; $x++) { |
| 40 | for ($y = 0; $y != $Y; $y++) { |
| 41 | $i = $x+$y*$X; |
| 42 | $p = ((hex $p[$i >> 3]) >> ($i & 7)) & 1; |
| 43 | next unless $p; |
| 44 | if ($rect) { |
| 45 | print "$x ", $Y-$y-1, "\n"; |
| 46 | } else { |
| 47 | $r = ($Y-$y-1)/$Y*($O-$I)+$I; |
| 48 | $a = &ang($O)*($x-$X/2); |
| 49 | print $r*sin($a), " ", $r*cos($a), "\n"; |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | |
Branches:
master
tornado-v1
