On Wed, Jul 27, 2011 at 11:24 AM, Tom Arneson <[email protected]> wrote:
> I use *. Which returns length/angle. If you only want the angle just drop
> length.

Yes.

Here's an example use:

atan2=: {:@*.@j.~

haversine=:4 :0
  r=. 3959  NB. average radius of earth, in miles
  rad=. *&1r180p1
  d=. y-x
  sin=. 1&o.
  cos=. 2&o.
  a=. +/(*: sin rad d%2)*1,x *&cos&rad&{. y
  r* 2* (atan2&%: -.) a
)

x and y are (latitude,longitude) pairs for two points

The result is the great circle distance, in miles, between those two points.

Hypothetically speaking, I could replace atan2 with the expression
using *. which is its definition, but the concept gets used enough
that I like having a word for it.

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

Reply via email to