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


Groups > comp.lang.postscript > #1566 > unrolled thread

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

Started byluser- -droog <mijoryx@yahoo.com>
First post2013-08-02 21:23 -0700
Last post2013-08-03 15:42 +0200
Articles 5 — 4 participants

Back to article view | Back to comp.lang.postscript


Contents

  -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

#1566 — -100 0 atan ==> 270 or -90?

Fromluser- -droog <mijoryx@yahoo.com>
Date2013-08-02 21:23 -0700
Subject-100 0 atan ==> 270 or -90?
Message-ID<fa9d6107-0deb-48c7-9744-6236e4f97bb0@googlegroups.com>
I've started writing up a test program for all operators, 
mostly using the example snippets from the manual.

And I've run into a difference between the Red Book (PLRM 1ed) 
and the GNU C library in the value returned by atan.

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?

[toc] | [next] | [standalone]


#1568

Fromluser- -droog <mijoryx@yahoo.com>
Date2013-08-02 23:59 -0700
Message-ID<578da34e-035d-44c2-ac04-04c3e1b3048a@googlegroups.com>
In reply to#1566
On Friday, August 2, 2013 11:23:37 PM UTC-5, luser- -droog wrote:
> I've started writing up a test program for all operators, 
> mostly using the example snippets from the manual.
> 
> 
> And I've run into a difference between the Red Book (PLRM 1ed) 
> and the GNU C library in the value returned by atan.
> 
> 
> 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.

[toc] | [prev] | [next] | [standalone]


#1575

FromJames Cloos <cloos@jhcloos.com>
Date2013-08-06 20:59 -0400
Message-ID<m3bo5a8ge0.fsf@carbon.jhcloos.org>
In reply to#1568
> 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

[toc] | [prev] | [next] | [standalone]


#1569

FromCecil Westerhof <Cecil@decebal.nl>
Date2013-08-03 10:04 +0200
Message-ID<874nb7dwt5.fsf@Aspire.decebal.nl>
In reply to#1566
Op zaterdag 3 aug 2013 06:23 CEST schreef luser:

> I've started writing up a test program for all operators, 
> mostly using the example snippets from the manual.
>
> And I've run into a difference between the Red Book (PLRM 1ed) 
> and the GNU C library in the value returned by atan.
>
> 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?

It looks like postscript does a modulo 360. Which in certain
definitions gives a value between 0 and modVal. The funny thing being
that mod gives a value between -modVal and modVal.

So I would say it is a bug.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

[toc] | [prev] | [next] | [standalone]


#1573

FromHelge Blischke <h.blischke@acm.org>
Date2013-08-03 15:42 +0200
Message-ID<b64flrFagvcU1@mid.individual.net>
In reply to#1569
Cecil Westerhof wrote:

> Op zaterdag 3 aug 2013 06:23 CEST schreef luser:
> 
>> I've started writing up a test program for all operators,
>> mostly using the example snippets from the manual.
>>
>> And I've run into a difference between the Red Book (PLRM 1ed)
>> and the GNU C library in the value returned by atan.
>>
>> 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?
> 
> It looks like postscript does a modulo 360. Which in certain
> definitions gives a value between 0 and modVal. The funny thing being
> that mod gives a value between -modVal and modVal.
> 
> So I would say it is a bug.
> 
The PLRM (3rd ed.) says:
atan num den atan angle
returns the angle (in degrees between 0 and 360) whose tangent is num 
divided by den.

So the positive value seems to be intentional.

Helge

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.postscript


csiph-web