Package micycle.pgs.commons
Class PEdge
java.lang.Object
micycle.pgs.commons.PEdge
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopy()
boolean
int
hashCode()
float
length()
Calculates the Euclidean distance of this PEdge.processing.core.PVector
midpoint()
round()
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.toString()
-
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
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
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 endb
).
-
hashCode
public int hashCode() -
equals
-
copy
- Returns:
- a deep copy of this PEdge
-
toString
-