ATAN2

General discussions on potential enhancements to the APL+Win system.

ATAN2

Postby Ajay Askoolum » June 9th, 2014, 5:16 pm

Please include ATAN2(radian(longitude),radian(latitude)) in the list of trigonometric functions.
Ajay Askoolum
 
Posts: 650
Joined: February 22nd, 2007, 2:16 am
Location: United Kingdom

Re: ATAN2

Postby Tech Support » June 12th, 2014, 11:14 am

Had you considered using the CSE to accomplish this? If no, below is solution using the CSE:

Code: Select all
⍙output←x atan2 y;s1;⍙atan2;⍙radians;⍙degrees
⍝ Calculate the arctangent of an angle
⍝ x is x-coordinate of a point
⍝ y is y-coordinate of a point
⍝ Material and example sourced from http://msdn.microsoft.com/en-us/library/system.math.atan2.aspx

⍝ 2014 APLNow LLC

⍙atan2←'c' ⎕cse 'Init' 'System'
s1←⊃'using System;' 'double x;' 'double y;' 'double angle;' 'double radians;'
0 0⍴⍙atan2 ⎕cse 'Exec' s1
0 0⍴⍙atan2 ⎕cse 'ExecStmt' 'radians = Math.Atan2({0},{1});' y x
⍙radians←⍙atan2 ⎕cse 'GetValue' 'radians'
0 0⍴⍙atan2 ⎕cse 'ExecStmt' 'angle = {0}*(180/Math.PI);' ⍙radians
⍙degrees←⍙atan2 ⎕cse 'GetValue' 'angle'
⍙atan2 ⎕cse 'Close'

⍙output←"The arctangent of the angle formed by the x-axis",⎕tcnl
⍙output←⍙output," and a vector to point (",(⍕x),",",(⍕y),") is ",(⍕⍙radians),⎕tcnl
⍙output←⍙output"which is equivalent to",(⍕⍙degrees)," degrees."
Tech Support
 
Posts: 1136
Joined: February 10th, 2007, 7:33 am
Location: Rockville, MD


Return to APL+Win Wish-List

Who is online

Users browsing this forum: No registered users and 1 guest