builtin-programs/intersect.folk


When /someone/ wishes /p/ has neighbors & /p/ has region /r/ & /p2/ has region /r2/ {
  if {$p eq $p2} { return }
  lassign [regionToBbox $r] bMinX bMinY bMaxX bMaxY
  lassign [regionToBbox $r2] b2MinX b2MinY b2MaxX b2MaxY
  
  set hasIntersections [rectanglesOverlap [list $bMinX $bMinY] \
              [list $bMaxX $bMaxY]\
              [list $b2MinX $b2MinY]\
              [list $b2MaxX $b2MaxY]\
  false ]
  #Display::stroke [list [list $bMinX $bMinY] {500 500}] 3 blue
  #Display::stroke [list [list $bMaxX $bMaxY] {500 500}] 3 red

  if {$hasIntersections} {
    Claim $p has neighbor $p2
    #Display::stroke [list [list $b2MinX $b2MinY] {500 500}] 3 red
    #Display::stroke [list [list $b2MaxX $b2MaxY] {500 500}] 3 white
    #Display::stroke [list [list $b2MinX $b2MinY] [list $b2MaxX $b2MaxY]] 10 blue
  }
}

When when /p/ has neighbor /n/ /lambda/ with environment /e/ {
  Wish $p has neighbors
}