For land surveying calculations, I usually need both distance and angle (or
direction), so I use something like:

NB. ============================================
  'd a'=. *. 147.23j523.78 
NB. real part is delta north and imaginary part is delta east
NB. then  2p1|a is azimuth (clockwise angle from north) in radians
   d
544.079
   a
1.29678
NB. ============================================

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Don Kelly
Sent: Wednesday, March 12, 2014 20:17
To: [email protected]
Subject: Re: [Jprogramming] atan2 ?

My typo   -----correction 12&0. not 13&o.
I agree with Bill Lam as typically one isn't making a table but finding an
angle from a given complex number (or array)
  12&0. @j./~ makes a table

Don

Using  13&o. as Tom suggested:

at=:13&o.
at  j./~i:100

gives the same result with both viewmat and plot as

atan2"0/~ i:100

Don

On 11/03/2014 4:59 PM, Raul Miller wrote:
> 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,
>

----------------------------------------------------------------------
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