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
|
#!/usr/local/bin/perl -w
# (C) Copyright 2009 Stijn van Dongen
#
# This file is part of MCL. You can redistribute and/or modify MCL under the
# terms of the GNU General Public License; either version 3 of the License or
# (at your option) any later version. You should have received a copy of the
# GPL along with MCL, in the file COPYING.
sub explain {
print <<EOH;
to be written
EOH
}
use strict;
use Getopt::Long;
my $mul = 1;
my $div = 1;
my $mov = 0;
my $xmul = 1;
my $xdiv = 1;
my $xmov = 0;
my $ymul = 1;
my $ydiv = 1;
my $ymov = 0;
my $wmul = 1;
my $wdiv = 1;
my $wmov = 0;
my $help = 0;
if
(! GetOptions
( "mov=i" => \$mov
, "div=i" => \$div
, "mul=i" => \$mul
, "wmov=f" => \$wmov
, "wdiv=f" => \$wdiv
, "wmul=f" => \$wmul
, "xmov=f" => \$xmov
, "xdiv=f" => \$xdiv
, "xmul=f" => \$xdiv
, "ymov=f" => \$ymov
, "ydiv=f" => \$ydiv
, "ymul=f" => \$ydiv
)
)
{ print STDERR "option processing failed\n";
exit(1);
}
&explain && exit(0) if $help;
my $x_apart = $xmov != 0 || $xmul != 1 || $xdiv != 1;
my $y_apart = $ymov != 0 || $ymul != 1 || $ydiv != 1;
sub mov {
my ($n, $mov, $mul, $div) = @_;
$n += $mov;
$n *= $mul if $mul != 1;
$n /= $div if $div != 1;
return $n;
}
sub rescale {
my ($w, $mov, $mul, $div) = shift;
$w += $wmov;
$w *= $wmul if $wmul != 1;
$w /= $wdiv if $wdiv != 1;
return $w;
}
while (<>) {
chomp;
my ($x, $y, $w) = split;
$x = $x_apart ? mov($x, $xmov, $xmul, $xdiv) : mov($x, $mov, $mul, $div);
$y = $y_apart ? mov($y, $ymov, $ymul, $ydiv) : mov($y, $mov, $mul, $div);
$w = rescale($w);
print "$x\t$y\t$w\n";
}
|