Class SquareGridTools


public class SquareGridTools
extends Object
A class for manipulating SquareGrid
  • Constructor Details

    • SquareGridTools

      public SquareGridTools()
  • Method Details

    • putIntoCanonical

      public void putIntoCanonical​(SquareGrid grid)
      There can be 2 or 4 possible orientations which are equally valid solutions. For sake of consistency it will make the (0,0) coordinate be closest to the origin of the image coordinate system.
    • rotateCCW

      public void rotateCCW​(SquareGrid grid)
    • reverse

      public void reverse​(SquareGrid grid)
    • checkFlip

      public boolean checkFlip​(SquareGrid grid)
      Checks to see if it needs to be flipped. Flipping is required if X and Y axis in 2D grid are not CCW.
    • computeSize

      public double computeSize​(SquareGrid grid)
    • transpose

      public void transpose​(SquareGrid grid)
      Transposes the grid
    • flipRows

      public void flipRows​(SquareGrid grid)
      Flips the order of rows
    • flipColumns

      public void flipColumns​(SquareGrid grid)
      Flips the order of columns
    • boundingPolygonCCW

      public void boundingPolygonCCW​(SquareGrid grid, Polygon2D_F64 bounding)
      Get outside corner polygon around the grid. The grid is assumed to be in CCW orientation.
    • orderNodeGrid

      protected void orderNodeGrid​(SquareGrid grid, int row, int col)
      Given the grid coordinate, order the corners for the node at that location. Takes in handles situations where there are no neighbors.
    • orderNode

      protected void orderNode​(SquareNode target, SquareNode node, boolean pointingX)
      Fills the ordered list with the corners in target node in canonical order.
      pointingX - true if 'node' is pointing along the x-axis from target. false for point along y-axis
    • findIntersection

      protected int findIntersection​(SquareNode target, SquareNode node)
      Finds the side which intersects the line segment from the center of target to center of node
    • orderSquareCorners

      public boolean orderSquareCorners​(SquareGrid grid)
      Adjust the corners in the square's polygon so that they are aligned along the grids overall length
      true if valid grid or false if not
    • sign

      public static int sign​(LineGeneral2D_F64 line, Point2D_F64 p)