comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: ROT is ROTTEN (a solution)
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: ROT is ROTTEN (a solution) [message #28159 is a reply to message #28075] Wed, 21 November 2001 13:06 Go to previous messageGo to previous message
Martin Downing is currently offline  Martin Downing
Messages: 136
Registered: September 1998
Senior Member
Wayne,
Sure, if you are doing 90-degree rotations, call ROTATE. Whether there
should be a wrapper to do it for you I don't know - I think you are better
being aware of what is going on. This was an issue of general rotations
which was just well illustrated by 90 degree examples.

Regarding the accuracy issue, I can not reproduce your result:
IDL> print, !version

{ x86 Win32 Windows Microsoft Windows 5.5 Beta Jun 20 2001 32 64}

IDL> a = dist(2048)

IDL> print,total(rot(a,90)) - total(a)

0.000000

Martin

"Wayne Landsman" <landsman@mpb.gsfc.nasa.gov> wrote in message
news:3BFBF563.2E32668E@mpb.gsfc.nasa.gov...
> Martin Downing wrote:
>
>> line 128 of rot.pro:
>>
>> from:
>>
>> theta = -angle/!radeg ;angle in degrees CLOCKWISE.
>>
>> to:
>>
>> theta = (-angle MOD 360) *acos(0.0d)/90 ;angle in degrees CLOCKWISE.
(mod
>> MRD 21/11/2001 to correct for precision error)
>>
>
> That's neat how the double precision improves things. But I 'd still
> emphasize that if you are rotating by a multiple of 90 degrees then you
should
> be using ROTATE() and not ROT() for two reasons:
>
> (1) ROTATE() is much faster (almost a factor of 4 on my Solaris machine)
> (2) Using ROTATE() will ensure that you have the exactly correct numbers
in the
> output array (since it simply moves elements within the array and performs
no
> arithmetic operations). The improved ROT() is much better but it is not
> perfect. For example
>
> { sparc sunos unix 5.3 Nov 11 1999}
> IDL>a = dist(2048)
> IDL>print,total(a)
> 3.28828e+09
> IDL>print,total(rot(a,90)) ;use improved ROT with double precision
!RADEG
> 3.28830e+09
> IDL>print,total(rotate(a,1))
> 3.28828e+09
>
> So possibly one could add to the beginning of ROT() something like:
>
> theta = angle mod 90
> if theta EQ 0 then return, rotate(a, theta/90)
>
> although one needs to also worry if the user has also set the
magnification or
> pivot keywords
>
>
> --Wayne Landsman landsman@mpb.gsfc.nasa.gov
>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Time on My Hands
Next Topic: Event Handling

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:00:17 PDT 2025

Total time taken to generate the page: 0.00636 seconds