Class SquareGraph


public class SquareGraph extends Object
Used for constructing a graph of squares that form a regular grid. Each square can have one edge per side.
  • Field Details

  • Constructor Details

    • SquareGraph

      public SquareGraph()
  • Method Details

    • reset

      public void reset()
    • computeNodeInfo

      public static void computeNodeInfo(SquareNode n)
    • detachEdge

      public void detachEdge(SquareEdge edge)
      Removes the edge from the two nodes and recycles the data structure
    • findSideIntersect

      public int findSideIntersect(SquareNode n, LineSegment2D_F64 line, Point2D_F64 intersection, LineSegment2D_F64 storage)
      Finds the side which intersects the line on the shape. The line is assumed to pass through the shape so if there is no intersection it is considered a bug
    • checkConnect

      public boolean checkConnect(SquareNode a, int indexA, SquareNode b, int indexB, double distance)
      Checks to see if the two nodes can be connected. If one of the nodes is already connected to another it then checks to see if the proposed connection is more desirable. If it is the old connection is removed and a new one created. Otherwise nothing happens.
      true if a connection is made
    • almostParallel

      public boolean almostParallel(SquareNode a, int sideA, SquareNode b, int sideB)
      Checks to see if the two sides are almost parallel to each other by looking at their acute angle.
    • acuteAngle

      public double acuteAngle(SquareNode a, int sideA, SquareNode b, int sideB)
      Returns an angle between 0 and PI/4 which describes the difference in slope between the two sides
    • getParallelThreshold

      public double getParallelThreshold()
    • setParallelThreshold

      public void setParallelThreshold(double parallelThreshold)