ROT is ROTTEN [message #28083] |
Tue, 20 November 2001 20:56 |
Bhautik Jitendra Josh
Messages: 3 Registered: November 2001
|
Junior Member |
|
|
Hi all,
The question I put to you all today is this: is ROT completely and utterly
broken?
Lets take a nice and normal 5x5 float array:
MOO>a=findgen(5,5) & print, a
0.00000 1.00000 2.00000 3.00000 4.00000
5.00000 6.00000 7.00000 8.00000 9.00000
10.0000 11.0000 12.0000 13.0000 14.0000
15.0000 16.0000 17.0000 18.0000 19.0000
20.0000 21.0000 22.0000 23.0000 24.0000
Now, lets do a quick checksum:
MOO>print, total(a)
300.000
So any 90 degree rotations we perform should maintain this. Lets try it
out:
MOO>print, total(rot(a,90))
296.000
OMG! *world in crisis* How to fix? Use interpolation.
MOO>print, total(rot(a,90,/INTERP))
300.000
*phew* Lets do a clockwise rotation instead.
MOO>print, total(rot(a,-90,/interp))
300.000
So, for those who can remember their high school math, -90 degrees is the
same as a 270 degree rotation.
MOO>print, total(rot(a,270,/interp))
290.000
argh! 360 degrees - a complete rotation, no difference, right?
MOO>print, total(rot(a,360,/interp))
290.000
Perhaps its the interpolation thats stuffing it up. Lets leave it out.
MOO>print, total(rot(a,360))
262.000
*brain melts*
It doesn't make a difference whether you use the interp or cubic keywords,
nor if you shift it so that the centre of rotation is set to be the corner
of the pixel rather than the centre of the pixel. If it doesn't work for
multiples of 90 it certainly is going to have issues with arbitrary
angles.
ROT is bad. Can it be fixed? Is there a (fast) alternative?
Cheers,
Bhautik
________________________________________________________
/ \
|bjoshi@geocities.com | phone: 0404032617 |
|ICQ #: 2464537 | http://cow.mooh.org |
\~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(__)~~~~~~~/
(__) |..|--\
/--|^^| moo | |--|
|--| | \OO/||^
^||\oo/ moo
|
|
|