1

I'm looking at the Planarity model's "crossed?" method from the Models Library in order to determine if two lines are intersecting.

This model seems to be working for the most part; however, there is one issue that I think I found. I don't have the Math skills to solve this.

Essentially, consider a nodes A and B which are connected, and C and D which are connected.

The issue occurs when AB is perpendicular to CD when the intersection point is on one of the end points.

For example,

Node xcor ycor
A    0     0
B    0     10
C    -10   0
D    5     0

Any thoughts on how to extend the model to describe this boundary condition? I'm not that mathematically confident to describe when this condition occurs...I'd like an alternative to the intersecting lines example where it computes the equations for the lines and solves for the x's and checks if the x's are within the end points of one of the lines.

mattsap
  • 3,790
  • 1
  • 15
  • 36
  • 1
    given that you're calculating in floating point, roundoff error is liable to make it a coinflip whether you get a "yes" or "no" answer. in the presence of roundoff error, there isn't even a right answer. in your example there happens to be but only because everything's integers. – Seth Tisue Apr 18 '17 at 18:46

1 Answers1

2

Matt, planarity does not report a true cross for me with either of the coordinate sets in your example:

Case 1

Case 2

In both cases the model is considered "solved"; there are no intersections reported. For me to get the model be unsolved, I need to actually have the links cross, but it doesn't seem to matter if the crossing point is directly in the center:

Case 3 Case 4

Do you get similar behavior with the same setup as I have here? I'm not sure if I'm missing something. Modified code for the initial placements below, needs choosers as in the attached images.

to setup-level
  reset-ticks  ;; use tick counter as a move counter
  clear-turtles  ;; when the turtles die, the links connecting them die too
  ;; create nodes and position them randomly
  ( foreach xcors ycors [ "A" "B" "C" "D" ] [ [ x y n ] ->
    create-turtles 1 [
      setxy x y
      set size 2
      set color 88
      set node n
      set label node
      set label-color black 
    ]
  ]
  )

  ( foreach [ "A" "C" ] [ "B" "D" ] [  [ sp ep ] ->
    ask turtles with [ node = sp ] [
      ask turtles with [ node = ep ] [
        create-link-with myself ]
    ]
  ]
  )
  display
end
Luke C
  • 10,081
  • 1
  • 14
  • 21
  • 1
    You're right. I just went back into the original example, I was clicking the wrong link to check the cross. Whoops....Thanks. I updated my question to be a little more reasonable... – mattsap Apr 14 '17 at 19:00