I've found a two argument arctan indispensable and have always had these in my startup:

 atan2=: 13 : '2p1|((0>1{"1 y)*1p1)+2p1+_3&o. %/"1 y'    NB. arrays OK, 0<result<2p1 atan3=: 13 : '(_3&o. %/"1 y)+1p1*(0>{:"1 y)*(*{."1 y)'      NB. _1p1<result<1p1

For example:

(180%1p1)* atan2 1 1

45

(180%1p1)* atan2 _1 _1

225

(180%1p1)* atan3 1 1

45

(180%1p1)* atan3 _1 _1

_135

Patrick

On 3/20/23 8:15 PM, John Baker wrote:
While computing star rise, transit and set times I encountered a need for an 
atn2 verb. This is basically a tweaked arctan verb that handles ratios like 
(arctan a%b) when a and b might be 0. Atn2 is in FORTRAN libraries. I ended up 
rolling my own j verb but surely something so standard must be floating around. 
If anyone has any atn 2’s please post. I like to compare implementations for 
stuff like this.

Jdb

analyzethedatanotthedrivel.org
----------------------------------------------------------------------
For information about J forums seehttp://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to