NetLogo - find minimum angle between two patches in patchset -
i'd find set of patches constitute convex hull around set of patches belonging turtle's territory
. planning utilize "gift wrap" procedure calculate convex hull (related below picture).
i'm first finding territory patch lowest pxcor
start at. then, i'd find territory patch has smallest heading
(i.e., angle closest zero) starting patch, , on, until arrive @ starting patch. can't seem figure out how calculate headings between 2 patches. suggestions helpful. here have far. have create loop through each point along outer hull.
patches-own [ owner-animal ] turtles-own [ territory ] setup ca create-turtles 1 [ move-to patch-at (max-pxcor / 2) (max-pycor / 2) set territory patches in-radius (2 + random 8) inquire territory [ set owner-animal myself set pcolor [ color ] of myself - 2 ] ] end find-convex-hull inquire turtles [ allow start-patch min-one-of territory [pxcor] inquire start-patch [ allow next-patch min-one-of [territory] of myself [towards self] ] ] end
i think you're looking for. odd thing code [towards myself - heading] of myself]
in first myself refers next turtle , sec myself refers original, because myself of myself.
does create sense? allow me know if have questions.
to setup ca crt 10 [setxy random-xcor random-ycor] end start-connecting inquire min-one-of turtles [xcor][set heading 0 connect] end connect allow the-turtle min-one-of other turtles [[towards myself - heading] of myself > 0] [ [towards myself - heading] of myself] if the-turtle = nobody [stop] face the-turtle inquire the-turtle [set heading [heading] of myself] create-link-with the-turtle inquire the-turtle [connect] end
by way, if want particular agentsets, alter turtles connect in connect
procedure.
netlogo
No comments:
Post a Comment