Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #1575

Re: -100 0 atan ==> 270 or -90?

From James Cloos <cloos@jhcloos.com>
Newsgroups comp.lang.postscript
Subject Re: -100 0 atan ==> 270 or -90?
Date 2013-08-06 20:59 -0400
Organization A noiseless patient Spider
Message-ID <m3bo5a8ge0.fsf@carbon.jhcloos.org> (permalink)
References <fa9d6107-0deb-48c7-9744-6236e4f97bb0@googlegroups.com> <578da34e-035d-44c2-ac04-04c3e1b3048a@googlegroups.com>

Show all headers | View raw


> The Red Book says:
> 
> -100 0 atan => 270.0
> 
> But atan2(3) (after suitable conversions) gives me -90.0
> 
> Is this serious? And, if so, what (if anything) should I do about it?

> For now, I'm just going to add 360.0 if the result is < 0.0.

As you wrote, the PS spec says atan returns values in degrees in the
range [0,360].

As you discovered, the C89, C99 and POSIX specs specify that atan2(3)
returns values in radians in the range [-pi,+pi].

So multiplying by 180*M_1_PI and adding 360 when the result is <0 is the
right thing to do.

Something like:

	out = atan2(n,d) * 180. * M_1_PI;
	if (out < 0.)
            out += 360.;


-JimC
-- 
James Cloos <cloos@jhcloos.com>         OpenPGP: 1024D/ED7DAEA6

Back to comp.lang.postscript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

-100 0 atan ==> 270 or -90? luser- -droog <mijoryx@yahoo.com> - 2013-08-02 21:23 -0700
  Re: -100 0 atan ==> 270 or -90? luser- -droog <mijoryx@yahoo.com> - 2013-08-02 23:59 -0700
    Re: -100 0 atan ==> 270 or -90? James Cloos <cloos@jhcloos.com> - 2013-08-06 20:59 -0400
  Re: -100 0 atan ==> 270 or -90? Cecil Westerhof <Cecil@decebal.nl> - 2013-08-03 10:04 +0200
    Re: -100 0 atan ==> 270 or -90? Helge Blischke <h.blischke@acm.org> - 2013-08-03 15:42 +0200

csiph-web