-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefocal.pl
executable file
·55 lines (51 loc) · 1.34 KB
/
makefocal.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
#!/usr/bin/perl
#
# read the parameters
open(DAXIS, "daxis_params.dat") || die "Cannot open daxis_params.dat\n";
while(<DAXIS>)
{
@word = split /\s+/;
if($word[0] =~ /x_convert=/) {$x_convert = $word[1];}
if($word[0] =~ /z_convert=/) {$z_convert = $word[1];}
if($word[0] =~ /theta_convert=/) {$theta_convert = $word[1];}
if($word[0] =~ /sin_theta=/) {$sin_theta = $word[1];}
if($word[0] =~ /cos_theta=/) {$cos_theta = $word[1];}
}
#print "$x_convert $z_convert\n";
#rint "$theta_convert $sin_theta $cos_theta\n";
close(DAXIS);
$axislength = 50.;
open(OUT, ">daxis.dat") || die "cannot open for output\n";
$z = 0.; $x = $axislength;
printoutput($x, $z);
$z = 0.; $x = 0.;
printoutput($x, $z);
$z = $axislength; $x = 0.;
printoutput($x, $z);
close(OUT);
open(OUT, ">focalplane.dat") || die "cannot open for output\n";
open(FOCAL, "focaldaxis.dat") || die "cannot open focaldaxis.dat\n";
while(<FOCAL>)
{
@line = split(/\s+/);
$x = $line[1];
$z = $line[2];
printoutput($x, $z);
}
close(FOCAL);
close(OUT);
sub transinit {
my($x_in, $z_in) = @_;
my(@ret);
$ret[0] = $x_in*$cos_theta - $z_in*$sin_theta + $x_convert;
$ret[1] = $x_in*$sin_theta + $z_in*$cos_theta + $z_convert;
return(@ret);
}
sub printoutput {
my($x, $z) = @_;
my($x_out, $z_out) = transinit($x,$z);
my($xx,$yy);
$xx = -$x_out;
$yy = $z_out;
printf OUT "%.4f %.4f\n",$xx, $yy;
}