Class PEdge

java.lang.Object
micycle.pgs.commons.PEdge

public class PEdge extends Object
An undirected edge / line segment joining 2 PVectors.

Note: PEdges PEdge(a, b) and PEdge(b, a) are considered equal.

Author:
Michael Carleton
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final processing.core.PVector
     
    final processing.core.PVector
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    PEdge(double x1, double y1, double x2, double y2)
     
    PEdge(processing.core.PVector a, processing.core.PVector b)
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    boolean
     
    int
     
    float
    Calculates the Euclidean distance of this PEdge.
    processing.core.PVector
     
    Rounds (mutates) the vertex coordinates of this PEdge to their closest ints.
    slice(double from, double to)
    Calculates the subsection of this PEdge as a new PEdge.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • a

      public final processing.core.PVector a
    • b

      public final processing.core.PVector b
  • Constructor Details

    • PEdge

      public PEdge(processing.core.PVector a, processing.core.PVector b)
    • PEdge

      public PEdge(double x1, double y1, double x2, double y2)
  • Method Details

    • round

      public PEdge round()
      Rounds (mutates) the vertex coordinates of this PEdge to their closest ints.
      Returns:
      this PEdge
    • midpoint

      public processing.core.PVector midpoint()
    • length

      public float length()
      Calculates the Euclidean distance of this PEdge.
      Returns:
    • slice

      public PEdge slice(double from, double to)
      Calculates the subsection of this PEdge as a new PEdge.
      Parameters:
      from - the start of the subsection as a normalized value along the length of this PEdge. 'from' should be less than or equal to 'to'.
      to - the end of the subsection as a normalized value along the length of this PEdge. 'to' should be greater than or equal to 'from'.
      Returns:
      A new PEdge representing the subsection of this PEdge between 'from' (from end a) and 'to' (towards end b).
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • copy

      public PEdge copy()
      Returns:
      a deep copy of this PEdge
    • toString

      public String toString()
      Overrides:
      toString in class Object