Class BorderLine
java.lang.Object
eu.svjatoslav.sixth.e3d.renderer.raster.slicer.BorderLine
- All Implemented Interfaces:
Comparator<BorderLine>
Represents an edge (border line) of a triangle in the polygon slicing pipeline.
A BorderLine connects two Vertex endpoints and carries an
identification count used by the Slicer to determine which edge
of the original triangle this line corresponds to (1, 2, or 3). This identification
is essential for correct recursive subdivision -- when the longest edge is split,
the slicer uses the count to decide how to partition the triangle into two
smaller triangles.
Implements Comparator so that an array of border lines can be sorted
by edge length, allowing the Slicer to identify the longest edge for subdivision.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal intThe edge identifier (1, 2, or 3) indicating which edge of the original triangle this border line represents. -
Constructor Summary
ConstructorsConstructorDescriptionBorderLine(Vertex c1, Vertex c2, int count) Creates a border line between two vertices with the given edge identifier. -
Method Summary
Modifier and TypeMethodDescriptionintcompare(BorderLine o1, BorderLine o2) Compares two border lines by their 3D edge length in ascending order.doubleComputes the 3D Euclidean distance between the two endpoint vertices.Computes the midpoint vertex of this edge by averaging both the 3D coordinates and the 2D texture coordinates of the two endpoints.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
count
public final int countThe edge identifier (1, 2, or 3) indicating which edge of the original triangle this border line represents. Used bySlicerduring recursive subdivision.
-
-
Constructor Details
-
BorderLine
Creates a border line between two vertices with the given edge identifier.- Parameters:
c1- the first vertex endpointc2- the second vertex endpointcount- the edge identifier (1, 2, or 3)
-
-
Method Details
-
compare
Compares two border lines by their 3D edge length in ascending order.- Specified by:
comparein interfaceComparator<BorderLine>- Parameters:
o1- the first border lineo2- the second border line- Returns:
- a negative value if
o1is shorter, positive if longer, zero if equal
-
getLength
public double getLength()Computes the 3D Euclidean distance between the two endpoint vertices.- Returns:
- the length of this edge in world-space units
-
getMiddlePoint
Computes the midpoint vertex of this edge by averaging both the 3D coordinates and the 2D texture coordinates of the two endpoints.- Returns:
- a new
Vertexat the midpoint, with interpolated texture coordinates
-