Here's another way to look at it:

   at2=:    13 :'([:{:"1 *.) j./"1 y'
   at2
[: ([: {:"1 *.) j./"1
   
   ]A=:(1,%:3)%2
0.5 0.866025
   at2 A
1.0472
   o.%3
1.0472
   
   ]B=:(_1,%:3)%2
_0.5 0.866025
   at2 B
2.0944
   o.2%3
2.0944
   
   ]C=:(-1,%:3)%2
_0.5 _0.866025
   at2 C
_2.0944
   -o.2%3
_2.0944
   
   ]D=:(1,-%:3)%2
0.5 _0.866025
   at2 D
_1.0472
   -o.%3
_1.0472
   
Linda

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Tom Arneson
Sent: Tuesday, March 11, 2014 10:08 PM
To: [email protected]
Subject: Re: [Jprogramming] atan2 ?

The circle verb o. with 12 as the left argument

   NB. radian to degree
   r2d=: 180p_1*[
   
   atan2=: 12&o.
   
   [r=. atan2 0j0 1j1 0j1 _1j1 _1j0 _1j_1 0j_1 1j_1 1j0
0 0.785398 1.5708 2.35619 3.14159 _2.35619 _1.5708 _0.785398 0
   
   r2d r
0 45 90 135 180 _135 _90 _45 0
   
   360|r2d r
0 45 90 135 180 225 270 315 0

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Raul Miller
Sent: Tuesday, March 11, 2014 19:00
To: Programming forum
Subject: Re: [Jprogramming] atan2 ?

This might be what you are looking for?
   atan2trivial=: _3 o. %~
   atan2=: 0 { [: +. [: r.^:_1 j.

For the principal domain, atan2trivial matches atan2
   1 (atan2trivial -: atan2) 2
1

However, atan2 can distinguish direction when x=0
   0 atan2 1
1.5708
   0 atan2 _1
_1.5708

I'd like more test cases, though. I've not been doing much trig recently,
and it's possible I made a mistake.

Maybe someone who has been working with this kind of math can judge from
what viewmat displays?

   require 'viewmat'
   viewmat atan2"0/~ i:100

Thanks,

--
Raul




On Tue, Mar 11, 2014 at 7:05 PM, EelVex <[email protected]> wrote:

> Is there an atan2 anywhere in some library?
>
> If not maybe we could add it?
>
> A simple start could be:
> atan2 =: +:@(_3&o.)@([ %~ ] -~ +/&.:*:)
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

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

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

Reply via email to