comp.lang.ada
 help / color / mirror / Atom feed
* Ada 95 ARCTAN function
@ 2007-03-01 18:58 saag
  2007-03-01 19:38 ` Jacob Sparre Andersen
  2007-03-01 19:43 ` Dmitry A. Kazakov
  0 siblings, 2 replies; 6+ messages in thread
From: saag @ 2007-03-01 18:58 UTC (permalink / raw)


Does the ARCTAN(y,x) function in the ADA.NUMERICS package provide the
same results an atan2 function call in c?  I'm trying to find out if
Ada supplies an atan2 function (that gives an appropriate answer based
on the quadrant the original point lies in)

thanks




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Ada 95 ARCTAN function
  2007-03-01 18:58 Ada 95 ARCTAN function saag
@ 2007-03-01 19:38 ` Jacob Sparre Andersen
  2007-03-01 20:03   ` Adam Beneschan
  2007-03-01 19:43 ` Dmitry A. Kazakov
  1 sibling, 1 reply; 6+ messages in thread
From: Jacob Sparre Andersen @ 2007-03-01 19:38 UTC (permalink / raw)


"saag" <saag37@yahoo.com> writes:

> Does the ARCTAN(y,x) function in the ADA.NUMERICS package provide the
> same results an atan2 function call in c?  I'm trying to find out if
> Ada supplies an atan2 function (that gives an appropriate answer based
> on the quadrant the original point lies in)

You can find the specification of how function Arctan works on
<http://www.cs.fsu.edu/~baker/ada/arm_95/RM-A-5-1.html>.

I don't know where I can find the corresponding specification for the
C function atan2(), so I can't give you a proper comparison.

Greetings,

Jacob
-- 
I'm giving a short talk at Game Developers Conference (Mobile
Game Innovation Hunt) Monday afternoon:
          http://www.gdconf.com/conference/gdcmobile_hunt.htm



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Ada 95 ARCTAN function
  2007-03-01 18:58 Ada 95 ARCTAN function saag
  2007-03-01 19:38 ` Jacob Sparre Andersen
@ 2007-03-01 19:43 ` Dmitry A. Kazakov
  2007-03-01 21:39   ` saag
  1 sibling, 1 reply; 6+ messages in thread
From: Dmitry A. Kazakov @ 2007-03-01 19:43 UTC (permalink / raw)


On 1 Mar 2007 10:58:25 -0800, saag wrote:

> Does the ARCTAN(y,x) function in the ADA.NUMERICS package provide the
> same results an atan2 function call in c?  I'm trying to find out if
> Ada supplies an atan2 function (that gives an appropriate answer based
> on the quadrant the original point lies in)

A.5.1 (11) states that arctan (y, x) yields the result in the quadrant of
the point (x,y). I.e. (with circle=2pi)

       |    y>0    |    y<0
-------+-----------+----------
x>0    |  0..pi/2  | -pi/2..0
       |           |
x<0    |  pi/2..pi | -pi..-pi/2

When x is negative and y is approaches 0 changing its sign, it gets
instable (either pi or -pi). Argument_Error is propagated when x and y are
0.

(I cannot tell how this corresponds to the semantics of atan2)

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Ada 95 ARCTAN function
  2007-03-01 19:38 ` Jacob Sparre Andersen
@ 2007-03-01 20:03   ` Adam Beneschan
  2007-03-04 21:16     ` Keith Thompson
  0 siblings, 1 reply; 6+ messages in thread
From: Adam Beneschan @ 2007-03-01 20:03 UTC (permalink / raw)


On Mar 1, 11:38 am, Jacob Sparre Andersen <spa...@nbi.dk> wrote:

> I don't know where I can find the corresponding specification for the
> C function atan2(), so I can't give you a proper comparison.

The Unix "man" page for atan2 has some information.  It's not as
detailed as the Ada manual, because after all this is C and providing
specific details would infringe on the inalienable right of C
programmers to shoot themselves in the foot.  However, the man page
I'm looking at does say:

(1) that the result is between -pi and pi (inclusive), and

(2) the signs of both arguments are used to determine the quadrant of
the result.

So I'd guess that the semantics are probably the same.

                            -- Adam






^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Ada 95 ARCTAN function
  2007-03-01 19:43 ` Dmitry A. Kazakov
@ 2007-03-01 21:39   ` saag
  0 siblings, 0 replies; 6+ messages in thread
From: saag @ 2007-03-01 21:39 UTC (permalink / raw)



thanks for the quick responses.
Didn't exactly phrase my question properly as I'm really interested in
whether the Ada arctan function returns a value based on the quadrant
-
and according to both that diagram & the link in the other post the
results in the range (-pi, pi) are what I was hoping for.

thanks again


On Mar 1, 2:43 pm, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:
> On 1 Mar 2007 10:58:25 -0800, saag wrote:
>
> > Does the ARCTAN(y,x) function in the ADA.NUMERICS package provide the
> > same results an atan2 function call in c?  I'm trying to find out if
> > Ada supplies an atan2 function (that gives an appropriate answer based
> > on the quadrant the original point lies in)
>
> A.5.1 (11) states that arctan (y, x) yields the result in the quadrant of
> the point (x,y). I.e. (with circle=2pi)
>
>        |    y>0    |    y<0
> -------+-----------+----------
> x>0    |  0..pi/2  | -pi/2..0
>        |           |
> x<0    |  pi/2..pi | -pi..-pi/2
>
> When x is negative and y is approaches 0 changing its sign, it gets
> instable (either pi or -pi). Argument_Error is propagated when x and y are
> 0.
>
> (I cannot tell how this corresponds to the semantics of atan2)
>
> --
> Regards,
> Dmitry A. Kazakovhttp://www.dmitry-kazakov.de





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Ada 95 ARCTAN function
  2007-03-01 20:03   ` Adam Beneschan
@ 2007-03-04 21:16     ` Keith Thompson
  0 siblings, 0 replies; 6+ messages in thread
From: Keith Thompson @ 2007-03-04 21:16 UTC (permalink / raw)


"Adam Beneschan" <adam@irvine.com> writes:
> On Mar 1, 11:38 am, Jacob Sparre Andersen <spa...@nbi.dk> wrote:
>> I don't know where I can find the corresponding specification for the
>> C function atan2(), so I can't give you a proper comparison.
>
> The Unix "man" page for atan2 has some information.  It's not as
> detailed as the Ada manual, because after all this is C and providing
> specific details would infringe on the inalienable right of C
> programmers to shoot themselves in the foot.  However, the man page
> I'm looking at does say:
>
> (1) that the result is between -pi and pi (inclusive), and
>
> (2) the signs of both arguments are used to determine the quadrant of
> the result.
>
> So I'd guess that the semantics are probably the same.

The C99 standard says:

    The atan2 functions compute the value of the arc tangent of y/x,
    using the signs of both arguments to determine the quadrant of the
    return value. A domain error may occur if both arguments are zero.

    The atan2 functions return arctan y/x in the interval [-pi, +pi]
    radians.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-03-04 21:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-01 18:58 Ada 95 ARCTAN function saag
2007-03-01 19:38 ` Jacob Sparre Andersen
2007-03-01 20:03   ` Adam Beneschan
2007-03-04 21:16     ` Keith Thompson
2007-03-01 19:43 ` Dmitry A. Kazakov
2007-03-01 21:39   ` saag

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox