[SciPy-User] difference of angles - to be between -180 and + 180
Sebastian Haase
seb.haase@gmail....
Thu Nov 19 06:48:22 CST 2009
On Wed, Nov 18, 2009 at 5:19 PM, Jonathan Guyer <guyer@nist.gov> wrote:
> On Nov 18, 2009, at 11:14 AM, I wrote:
>
>> return np.fmod(d + 540, 360) - 180
>
> Actually, I think you can just write (d + 540) % 360 - 180
>
> I think we used fmod because of some automatic weave inlining we do
> that didn't play nice with '%'.
Hi Jonathan,
thanks for your answer. I might prefer your solution simply for its brevity.
However, there are also some sign "problems":
for the angle from -10 to 180 I was expecting +170, but your solution
returns -170.
and for (to:)'190' (from) '-10' expected: '160' , yours returns -160.
I have a list of 30 test cases, which these are the only 2 were yours
gave unexpected results regarding the sign -- besides the fact that
yours always returns -180 instead of +180, but that is obviously not
really wrong.
Thanks,
Sebastian
More information about the SciPy-User
mailing list