Module org.dyn4j

Class SweepLineEdge

  • All Implemented Interfaces:
    java.lang.Comparable<SweepLineEdge>

    final class SweepLineEdge
    extends java.lang.Object
    implements java.lang.Comparable<SweepLineEdge>
    Represents an edge of a polygon storing the next and previous edges and the vertices that make up this edge.

    The edge also stores a helper vertex which is used during y-monotone decomposition.

    Since:
    2.2.0
    Version:
    3.2.0
    Author:
    William Bittle
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) SweepLineVertex helper
      The helper vertex of this edge
      (package private) Reference<java.lang.Double> referenceY
      The current state of the sweep; a reference value shared between all edges (for context when sorting)
      (package private) double slope
      The inverted slope of the edge (run/rise); This will be Double.POSITIVE_INFINITY if its a horizontal edge
      (package private) SweepLineVertex v0
      The first vertex of the edge in Counter-Clockwise order
      (package private) SweepLineVertex v1
      The second vertex of the edge in Counter-Clockwise order
    • Constructor Summary

      Constructors 
      Constructor Description
      SweepLineEdge​(Reference<java.lang.Double> referenceY)
      Minimal constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(SweepLineEdge o)  
      double getSortValue​(double y)
      Returns the intersection point of the given y value (horizontal sweep line) with this edge.
      boolean isInteriorRight()
      Returns true if the interior of the polygon is to the right of this edge.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • referenceY

        final Reference<java.lang.Double> referenceY
        The current state of the sweep; a reference value shared between all edges (for context when sorting)
      • v0

        SweepLineVertex v0
        The first vertex of the edge in Counter-Clockwise order
      • v1

        SweepLineVertex v1
        The second vertex of the edge in Counter-Clockwise order
      • slope

        double slope
        The inverted slope of the edge (run/rise); This will be Double.POSITIVE_INFINITY if its a horizontal edge
    • Constructor Detail

      • SweepLineEdge

        public SweepLineEdge​(Reference<java.lang.Double> referenceY)
        Minimal constructor.
        Parameters:
        referenceY - the current sweep position
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • compareTo

        public int compareTo​(SweepLineEdge o)
        Specified by:
        compareTo in interface java.lang.Comparable<SweepLineEdge>
      • getSortValue

        public double getSortValue​(double y)
        Returns the intersection point of the given y value (horizontal sweep line) with this edge.

        Returns the x value of the corresponding intersection point.

        Parameters:
        y - the horizontal line y value
        Returns:
        double
      • isInteriorRight

        public boolean isInteriorRight()
        Returns true if the interior of the polygon is to the right of this edge.

        Given that the polygon's vertex winding is Counter- Clockwise, if the vertices that make this edge decrease along the y axis then the interior of the polygon is to the right, otherwise its to the left.

        Returns:
        boolean