问题
How can I compute edge to edge distance between patches with netlogo ? With the function "distance", distance between patches is calculated from center of patches.
Thank you very much for your help. Have a good day Marine
回答1:
If you want to measure the distance between the edges of your patches, you can create temporary turtles on the edges of your patches and measure the distance between these turtles. I assume that you want the shortest distance between any two points located on the edges of your two patches. In this case, you can create 8 turtles on each patch (the four corners and the four mid-edge points) and take the minimum distance between any pair of turtles.
to-report create-edge-turtles [ p ]
let edge-turtles nobody
ask p [
foreach sort neighbors [
sprout 1 [
face ?
fd distance ? / 2
set edge-turtles (turtle-set edge-turtles self)
]
]
]
report edge-turtles
end
to-report edge-distance [ patch-a patch-b ]
let edges-a create-edge-turtles patch-a
let edges-b create-edge-turtles patch-b
let result min [ min [ distance myself ] of edges-b ] of edges-a
ask edges-a [ die ]
ask edges-b [ die ]
report result
end
来源:https://stackoverflow.com/questions/18935142/edge-to-edge-distance-between-patches-with-netlogo