They're not equal and opposite -- they are synonyms for "pre" and
"post",
respectively -- both add to the output coordinate of the transformation,
but one ("offset") adds before the matrix multiplication and one
("shift")
adds after the matrix multiplication. In other words, "offset" works
in the
input plane, "shift" works in the output plane.
On Jan 18, 2008, at 9:44 AM, Matthew Kenworthy wrote:
I have a question about the behaviour of t_linear in PDL::Transform:
If you use t_linear a lot, you can use the Offset and Shift options to
rotate an image about any chosen point.
I'd naively expect Offset and Shift to be equal but opposite in
magnitude to get the desired effect, but this is not the case - I have
to add an additional 0.5 to the Shift coordinates to get it to perform
the way I'd expect it to.
I've attached a program that demonstrates this behaviour - remove the
"+0.5" values in t_linear to see the difference it makes.
Thanks,
Matt
#!/usr/bin/perl -w
use PDL;
use PDL::NiceSlice;
use PDL::Graphics::PGPLOT;
use PDL::Fit::Linfit;
use PDL::AutoLoader;
use PDL::Transform;
use strict;
dev("/xs",4,4,{Color=>1,AxisColour=>1,
Linewidth=>1, HardLw => 3,
HardCH=>1.6,
WindowWidth=>6, Aspect=>1.0});
# make a semicircle with center at 4,4
my $s = 9;
my $im = rvals($s,$s);
$im = ($im<($s/2));
$im(0:4,) .= 0;
my $x = 4; my $y = 4;
my $scale = 1;
for (my $rot = 0; $rot <= 180; $rot +=20) {
my $t =
t_linear(Offset=>[-$x,-$y],Rotation=>$rot,Scale=>$scale,Shift=>[$x
+0.5,$y+0.5]);
my $nim = $t->map($im,{pix=>1});
imag $nim;
}
--
Matthew Kenworthy / Instrument Scientist / CAAO / Steward Observatory
Room N414 / 933 N. Cherry Ave / Tucson AZ 85721 / vox 520 626 6720
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl