From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,9fe315ab08ea9576 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.68.231.202 with SMTP id ti10mr4924147pbc.5.1328922679895; Fri, 10 Feb 2012 17:11:19 -0800 (PST) Path: wr5ni10522pbc.0!nntp.google.com!news2.google.com!postnews.google.com!k10g2000yqk.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Arctan: to use with single or with double arguments? Date: Fri, 10 Feb 2012 17:11:19 -0800 (PST) Organization: http://groups.google.com Message-ID: <6e68502c-7ba3-43a5-9a3e-11ec3810c666@k10g2000yqk.googlegroups.com> References: <908e7aea-ed77-4dce-9f5d-e6341abc1303@s19g2000vbr.googlegroups.com> <53a2a6fa-9d48-4486-b5c7-aea81a026a82@x18g2000pro.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 X-Trace: posting.google.com 1328922679 28285 127.0.0.1 (11 Feb 2012 01:11:19 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 11 Feb 2012 01:11:19 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k10g2000yqk.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: ARLUEHNKC X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C),gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-02-10T17:11:19-08:00 List-Id: On Feb 10, 4:26=A0pm, Jack Mitchell wrote: > Am I missing something - surely :- > > =A0 =A0 =A0 =A0 z =3D Force * SIN(ATAN2(x,y)) > > Is the same as :- > > =A0 =A0 =A0 =A0 z =3D 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 :=3D Force * Sin(Arctan(Y, X)); is the same as z :=3D 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