Page 1 of 1

ATAN2

PostPosted: June 9th, 2014, 5:16 pm
by Ajay Askoolum
Please include ATAN2(radian(longitude),radian(latitude)) in the list of trigonometric functions.

Re: ATAN2

PostPosted: June 12th, 2014, 11:14 am
by Tech Support
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."