-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot.pl
executable file
·115 lines (93 loc) · 3.12 KB
/
plot.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/perl
#
# Lattice plotter
#
#
use Math::Trig;
open(DAT, $ARGV[0]) || die "Couldn't open input file: $!\n";
open(MAP, ">$ARGV[0].svg") || die "Couldn't open output file; $!\n";
$rads = deg2rad(60);
$size = 49;
$offset = 480;
#SVG HEAD STUFFS
print MAP "<?xml version=\"1.0\"?>";
print MAP " <svg width=\"20cm\" height=\"20cm\" viewBox=\"0 0 800 800\"";
print MAP " xmlns=\"http://www.w3.org/2000/svg\" version=\"1.2\" baseProfile=\"tiny\">";
print MAP " <desc>Example line01 - lines expressed in user coordinates</desc>";
print MAP " <!-- Show outline of canvas using rect element -->";
print MAP " <rect x=\"1\" y=\"1\" width=\"798\" height=\"798\" fill=\"white\" stroke=\"blue\" stroke-width=\"2\" />";
print MAP "<text x=\"125\" y=\"55\" font-family=\"Verdana\" font-size=\"22\" fill=\"blue\" > $ARGV[0] </text>";
while($line = readline(DAT)) {
@val = split(/\t/, $line);
$val[2] =~ s/\n//g;
push(@x, $val[0]);
push(@y, $val[1]);
push(@s, $val[2]);
$spins[$val[0]][$val[1]] = $val[2];
#print $val[2];
#print "$spins[$val[0]][$val[1]]";
}
#print MAP "<g>\n";
for ($i = 0; $i < 10; $i ++) {
for ($j=0; $j < 10; $j ++) {
if ($i < 9 && $j < 9) {
$sum = (($spins[$i+1][$j]>0)?1:-1) + (($spins[$i][$j+1]>0)?1:-1) + (($spins[$i][$j] >0)?1:-1);
if ($sum == 1) {
$colour = "red";
} elsif ($sum == -1) {
$colour = "blue";
} elsif($sum == 3) {
$colour = "green";
} elsif ($sum == -3) {
$colour = "yellow";
}
$xc1 = 20+$i*$size+$size*$j*cos($rads);
$xc2 = 20+$i*$size+($j+1)*$size*cos($rads);
$xc3 = 20+($i+1)*$size+$j*$size*cos($rads);
$yc1 = $offset - $j*$size*sin($rads);
$yc2 = $offset - ($j+1)*$size*sin($rads);
$yc3 = $offset - $j*$size*sin($rads);
print MAP "<polygon fill=\"$colour\" stroke=\"black\" stroke-width=\"2\"
points=\"$xc1,$yc1 $xc2,$yc2 $xc3,$yc3\" />";
}
if ($i < 9 && $j > 0) {
$sum = $spins[$i+1][$j-1] + $spins[$i+1][$j] + $spins[$i][$j];
if ($sum == 1) {
$colour = "red";
} elsif ($sum == -1) {
$colour = "blue";
} elsif($sum == 3) {
$colour = "green";
} elsif ($sum == -3) {
$colour = "yellow";
}
$xc1 = 20+$i*$size+$j*$size*cos($rads);
$xc2 = 20+($i+1)*$size+($j-1)*$size*cos($rads);
$xc3 = 20+($i+1)*$size+$j*$size*cos($rads);
$yc1 = $offset - $j*$size*sin($rads);
$yc2 = $offset - ($j-1)*$size*sin($rads);
$yc3 = $offset - $j*$size*sin($rads);
print MAP "<polygon fill=\"$colour\" stroke=\"black\" stroke-width=\"2\"
points=\"$xc1,$yc1 $xc2,$yc2 $xc3,$yc3\" />";
}
if ($spins[$i][$j] > 0) {
print MAP "<circle cx=\"$xc1\" cy=\"$yc1\" r=\"12\" fill=\"orange\" />";
} else {
print MAP "<circle cx=\"$xc1\" cy=\"$yc1\" r=\"12\" fill=\"magenta\" />";
}
if ($spins[$i+1][$j] > 0) {
print MAP "<circle cx=\"$xc3\" cy=\"$yc3\" r=\"12\" fill=\"orange\" />";
} else {
print MAP "<circle cx=\"$xc3\" cy=\"$yc3\" r=\"12\" fill=\"magenta\" />";
}
}
}
#print MAP" </g><g>\n";
for ($i = 0; $i < 10; $i ++) {
for ($j=0; $j < 10; $j ++) {
}
}
#print MAP "</g>\n";
print MAP "</svg>";
close(DATA);
close(MAP);