netlogo - How to create turtles at intervals along links -



netlogo - How to create turtles at intervals along links -

i have network of links create turtles along @ equidistant intervals - much houses along road network.

i have played 2 implementations:

1 - create special builder turtle traverses network of links before main simulation run , hatches turtles i.e.

ask builders [ navigate 1 ;my network navigation function if count homes in-radius 2 = 0 [ hatch-homes 1 ] ]

2 - alternatively, can step through list of links , using position of ends, link-length , link-heading variables trig work out place home turtles. edit: have implemented trig version - not perfect job.

option 1 easy implement stymied the in-radius variable - on networks links may run parallel (our close to) , close 1 another. if case sec link traversed may not turtles (as within radius of first link's turtles - if see mean). alternative 2 involves trig.

can think of smarter/simpler way of doing this?

many looking - advice appreciated.

perhaps this? (assuming exclude end points.)

to-report convex-combinations [#pt1 #pt2 #npts] ;;report list of convex cominations (endpoints excluded) allow x1 item 0 #pt1 allow y1 item 1 #pt1 allow dx21 item 0 #pt2 - x1 allow dy21 item 1 #pt2 - y1 allow wts n-values #npts [(? + 1) / (#npts + 1)] study map [list (x1 + dx21 * ?) (y1 + dy21 * ?)] wts end to-report pts-along [#link #npts] allow locations [] inquire #link [ inquire both-ends [ set locations lput (list xcor ycor) locations ] ] study convex-combinations item 0 locations item 1 locations #npts end place-along [#link #nturtles] allow locations pts-along #link #nturtles foreach locations [ allow x item 0 ? allow y item 1 ? crt 1 [setxy x y] ] end

netlogo

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -