edge to edge distance between patches with netlogo

末鹿安然 提交于 2019-12-24 13:28:37

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!