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 #28073] Wed, 21 November 2001 05:02 Go to previous message
Heike Koch-Beuttenmue is currently offline  Heike Koch-Beuttenmue
Messages: 6
Registered: October 1999
Junior Member
Martin Downing wrote:
>
> Hi All,
>
> This was an interesting problem - I certainly hadn't noticed it before. The
> reason for the behaviour is precision error in the arithmatic which works
> out the poly2d coefficients. It can be corrected effectively by modifying
> 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)
>
> This does two things, firstly (-angle MOD 360) ensures that a precision
> error does not propagate due to large angles which contain multiple 360
> degree rotations,
> for instance that 390.45 degree rotation is treated exactly the same as
> 30.45 degrees [i.e. n*360+theta = = theta].
>
> Secondly, substituting (acos(0.0d)/90) for !radeg gives a full DOUBLE
> precision representation of theta in radians.
>
> This fixes it completely as far as I can see:
> IDL> a = findgen(5,5)
> IDL> for deg = -720, 720,90 do print, deg, total(rot(a, deg))
>
> -720 300.000
> -630 300.000
> -540 300.000
> -450 300.000
> -360 300.000
> -270 300.000
> -180 300.000
> -90 300.000
> 0 300.000
> 90 300.000
> 180 300.000
> 270 300.000
> 360 300.000
> 450 300.000
> 540 300.000
> 630 300.000
> 720 300.000
>
> compared this to previous output:
> IDL> for deg = -720, 720,90 do print, deg, total(rot(a, deg))
>
> -720 252.000
> -630 250.000
> -540 300.000
> -450 273.000
> -360 237.000
> -270 290.000
> -180 216.000
> -90 244.000
> 0 300.000
> 90 222.000
> 180 221.000
> 270 300.000
> 360 247.000
> 450 249.000
> 540 300.000
> 630 251.000
> 720 242.000
>
> Quite how RSI had left the code like that for so long who knows.....(but if
> they want to send me a copy of David's 2nd Ed. that would be nice!)
>
> cheers
>
> Martin
>
> ----------------------------------------
> Martin Downing,
> Clinical Research Physicist,
> Grampian Orthopaedic RSA Research Centre,
> Woodend Hospital, Aberdeen, AB15 6LS.
> Tel. 01224 556055 / 07903901612
> Fax. 01224 556662
>
Though there are some differences between the rot of pvwave and idl the
same correction helps pvwave to get the right result for rot (with
interp):

uncorrected: print, total(e1)
282.000
corrected:
print, total(e2)
300.000


Best regards

Heike Koch-Beuttenm�ller
[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 14:56:46 PDT 2025

Total time taken to generate the page: 0.00443 seconds