## ATAN2

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

### ATAN2

Posts: 813
Joined: February 22nd, 2007, 2:16 am
Location: United Kingdom

### Re: ATAN2

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' s10 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: 1216
Joined: February 10th, 2007, 7:33 am
Location: Rockville, MD