Package ffx.numerics.quickhull
Class Face
java.lang.Object
ffx.numerics.quickhull.Face
Basic triangular face used to form the hull.
The information stored for each face consists of a planar normal, a planar offset, and a doubly-linked list of three HalfEdges which surround the face in a counter-clockwise direction.
- Since:
- 1.0
- Author:
- John E. Lloyd, Fall 2004, Michael J. Schnieders
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble
areaSquared
(HalfEdge hedge0, HalfEdge hedge1) Computes the squared area of the triangle defined by hedge0 (tail->head) and the point at the head of hedge1.void
computeCentroid
(Point3d centroid) Computes the centroid (arithmetic mean of vertices) of this face into the provided point.void
computeNormal
(Vector3d normal) Computes a unit-length normal vector for this face using the vertex winding and writes it into the provided vector.void
computeNormal
(Vector3d normal, double minArea) Computes a unit-length normal for this face, and if the preliminary area is below the specified minArea, adjusts the normal to be more orthogonal to the longest edge to improve robustness.static Face
Creates a Face by linking the specified indices of a vertex array into a closed counter-clockwise half-edge loop and computing its normal and centroid.static Face
createTriangle
(Vertex v0, Vertex v1, Vertex v2) Convenience method to create a triangular Face from three vertices.static Face
createTriangle
(Vertex v0, Vertex v1, Vertex v2, double minArea) Constructs a triangular Face from vertices v0, v1, and v2 and computes its normal and centroid.double
Computes the distance from a point p to the plane of this face.Finds the half-edge within this face which has tailvt
and headvh
.Returns the centroid previously computed for this face.getEdge
(int i) Gets the i-th half-edge associated with the face.Returns the first half-edge of this face (the start of the circular list).Returns the normal of the plane associated with this face.void
getVertexIndices
(int[] idxs) Writes the vertex indices of this face into the provided array in CCW order.Returns a space-separated string of the vertex indices defining this face in counter-clockwise order.int
mergeAdjacentFace
(HalfEdge hedgeAdj, Face[] discarded) Merges this face with the adjacent face across the specified half-edge if possible.int
Returns the number of vertices (half-edges) bounding this face.void
triangulate
(FaceList newFaces, double minArea) Triangulates this (convex polygonal) face into a fan of triangles sharing the first vertex.
-
Field Details
-
DELETED
protected static final int DELETED- See Also:
-
NON_CONVEX
protected static final int NON_CONVEX- See Also:
-
VISIBLE
protected static final int VISIBLE- See Also:
-
area
protected double area -
he0
-
mark
protected int mark -
next
-
numVerts
protected int numVerts -
outside
-
planeOffset
protected double planeOffset
-
-
Constructor Details
-
Face
public Face()
-
-
Method Details
-
create
Creates a Face by linking the specified indices of a vertex array into a closed counter-clockwise half-edge loop and computing its normal and centroid.- Parameters:
vtxArray
- array of verticesindices
- indices into vtxArray specifying the face vertices in CCW order- Returns:
- the newly created Face
-
createTriangle
Convenience method to create a triangular Face from three vertices.- Parameters:
v0
- first vertexv1
- second vertexv2
- third vertex- Returns:
- the newly created triangular Face
-
createTriangle
Constructs a triangular Face from vertices v0, v1, and v2 and computes its normal and centroid. If the computed area is below minArea, the normal is adjusted for robustness against near-collinearity.- Parameters:
v0
- first vertexv1
- second vertexv2
- third vertexminArea
- minimum area threshold used to stabilize the normal- Returns:
- the newly created triangular Face
-
computeCentroid
Computes the centroid (arithmetic mean of vertices) of this face into the provided point.- Parameters:
centroid
- output parameter to receive the centroid
-
computeNormal
Computes a unit-length normal vector for this face using the vertex winding and writes it into the provided vector. Also updates the face area and number of vertices encountered.- Parameters:
normal
- output parameter to receive the unit normal
-
computeNormal
Computes a unit-length normal for this face, and if the preliminary area is below the specified minArea, adjusts the normal to be more orthogonal to the longest edge to improve robustness.- Parameters:
normal
- output parameter to receive the unit normalminArea
- minimum area threshold used to stabilize the normal computation
-
distanceToPlane
Computes the distance from a point p to the plane of this face.- Parameters:
p
- the point- Returns:
- distance from the point to the plane
-
findEdge
Finds the half-edge within this face which has tailvt
and headvh
.- Parameters:
vt
- tail pointvh
- head point- Returns:
- the half-edge, or null if none is found.
-
getCentroid
Returns the centroid previously computed for this face.- Returns:
- the centroid point
-
getEdge
Gets the i-th half-edge associated with the face.- Parameters:
i
- the half-edge index, in the range 0-2.- Returns:
- the half-edge
-
getFirstEdge
Returns the first half-edge of this face (the start of the circular list).- Returns:
- the first HalfEdge in the face
-
getNormal
Returns the normal of the plane associated with this face.- Returns:
- the planar normal
-
getVertexIndices
public void getVertexIndices(int[] idxs) Writes the vertex indices of this face into the provided array in CCW order. The array must be large enough to hold numVertices() entries.- Parameters:
idxs
- output array receiving the vertex indices
-
getVertexString
Returns a space-separated string of the vertex indices defining this face in counter-clockwise order.- Returns:
- string listing the vertex indices in CCW order
-
mergeAdjacentFace
Merges this face with the adjacent face across the specified half-edge if possible. Updates connectivity, recomputes normals/centroids, and records any faces that become redundant in the provided discarded array.- Parameters:
hedgeAdj
- the half-edge along which to merge with the adjacent facediscarded
- an output array to collect faces that are deleted by the merge- Returns:
- the number of faces recorded in discarded (0, 1, or 2)
-
numVertices
public int numVertices()Returns the number of vertices (half-edges) bounding this face.- Returns:
- the vertex count of this face
-
triangulate
Triangulates this (convex polygonal) face into a fan of triangles sharing the first vertex. Newly created faces are added to newFaces, and appropriate opposite links are established. Normals/centroids are updated using the given minArea for stability.- Parameters:
newFaces
- list that collects newly created triangular facesminArea
- minimum area threshold used when computing normals
-
areaSquared
Computes the squared area of the triangle defined by hedge0 (tail->head) and the point at the head of hedge1. Useful for robust comparisons without taking a square root.- Parameters:
hedge0
- the reference half-edge whose tail and head form two triangle verticeshedge1
- a half-edge providing the third vertex via its head- Returns:
- the squared area of the resulting triangle
-