The edge crossing algorithm is called by one edge with a second edge as an input parameter. We assume an instance of Edge knows its first and second vertices. So we simply ask: are the first and second vertices inside the argument edge. If both are inside or both or outside, the edges do not cross. Put differently, if one vertex is inside and the other outside, then the edges cross.

<Edge crossing algorithm>=
 public boolean crosses(Edge edge) {
   boolean isFirstInside = firstvertex.inside(edge);
   boolean isSecondInside = secondvertex.inside(edge);
   if ((isFirstInside && !isSecondInside) || (!isFirstInside && isSecondInside)) {
     return true;
   }
   else {
     return false;
   }
 }