From: Adam Beneschan <adam@irvine.com>
Subject: Re: Arctan: to use with single or with double arguments?
Date: Fri, 10 Feb 2012 17:11:19 -0800 (PST)
Date: 2012-02-10T17:11:19-08:00 [thread overview]
Message-ID: <6e68502c-7ba3-43a5-9a3e-11ec3810c666@k10g2000yqk.googlegroups.com> (raw)
In-Reply-To: HZwQ6PESXbNPFw+6@plus.net
On Feb 10, 4:26 pm, Jack Mitchell <j...@home9999.plus.com> wrote:
> Am I missing something - surely :-
>
> z = Force * SIN(ATAN2(x,y))
>
> Is the same as :-
>
> z = Force * x / sqrt( x^2 + y^2 )
>
> This should be much faster (and probably more accurate)
> Perhaps I have got x & y swapped but you see my point.
Yep, the arguments to Arctan in Ada (and I believe the arguments to
ATAN2 in Fortran) are
(Y, X). So what you should have said (since this is an Ada newsgroup)
is
z := Force * Sin(Arctan(Y, X));
is the same as
z := Force * Y / Sqrt (X**2 + Y**2);
I did have to rewrite this so that I wouldn't go nuts trying to switch
the X and Y axes on a diagram. But it appears that you're right. The
sign is correct, i.e. Sin(Arctan(Y, X)) is negative when Y is negative
and positive when Y is positive. Similarly, Cos(Arctan(Y,X)) is the
same as X / Sqrt (X**2 + Y**2).
-- Adam
next prev parent reply other threads:[~2012-02-11 1:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-24 21:32 Arctan: to use with single or with double arguments? Ada novice
2010-09-24 21:55 ` Jeffrey Carter
2010-09-25 8:44 ` Ada novice
2010-09-25 17:31 ` Jeffrey Carter
2010-09-25 21:34 ` Ada novice
2010-09-26 4:02 ` jpwoodruff
2010-09-26 8:21 ` Ada novice
2010-09-26 7:31 ` Jeffrey Carter
2010-09-26 8:24 ` Ada novice
2012-02-11 0:26 ` Jack Mitchell
2012-02-11 1:11 ` Adam Beneschan [this message]
2012-02-11 8:53 ` Simon Wright
2012-02-11 10:46 ` AdaMagica
2012-02-11 15:29 ` Simon Wright
2012-02-11 16:21 ` Georg Bauhaus
2012-02-11 16:47 ` Simon Wright
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox