21 oct 2009

Random walk on a hexagonal grid

randomwalk.png

To indicate the direction, the verb arrow is used to generate the arrow heads in the right direction:

arrow=: 3 : 0
NB. y is sequence of points; 2={:$y 
lay=. *.j./"(1) 2-~/\y  NB. gives length/angle
NB. standard arrow head
t=.0.1 % 3      NB. base is 3*t, widt 1.4*t
head=. 0,hd=.(,:1 _1 * ])(0-3*t),0+1.4*t 
lah=. *.j./"1 hd
heads=. (}.y) (+"1"_1) 0,"2 +.*.^:_1"1 lah ({."1@[ ,. +&({:"1))"_ _1 lay
)

RE Boss/J-blog/Arrow (last edited 2009-10-21 17:40:27 by RE Boss)