"David Williams" <david.williams@[EMAIL PROTECTED]
> wrote in message
news:1204646588.877.1204581661@[EMAIL PROTECTED]
>-> I'm trying to ****t some Zeno programs over to BASIC and I'm stuck on
the
> -> Zeno function ARCTANXY(x,y). According to the Zeno manual,
> -> it should be equal to ATN(y/x) when x and y are both non-zero.
> -> I created a BASIC function that does that but the results don't match
> -> the Zeno output. Does anyone here know exactly what calculation to
> -> use for ARCTANXY? TIA
>
> Here's how I usually code it in QBasic.
>
> FUNCTION Ang(X, Y)
> SELECT CASE SGN(X)
> CASE 1: Ang = ATN(Y / X)
> CASE -1: Ang = ATN(Y / X) + PI
> CASE ELSE: Ang = SGN(Y) * PI / 2
> END SELECT
> END FUNCTION
>
> Of course PI has to be pre-defined.
>
> The FUNCTION produces an angle in the range -PI/2 <= Ang < 3*PI/2.
> That's the complete circle, but if you want to adjust the range to,
> e.g., 0 to 2*PI, you'd have to add a bit of fiddling.
>
> Note that Ang is *not* equal to ATN(Y/X) if X is negative. ATN doesn't
> produce the complete circle of values.
Most implementations give
ATAN2(-5,-5) = -2.35619
but yours gives
Ang(-5,-5) = 3.926990
Any idea why?
Tom L


|