convexhull3d
Class Triangle

java.lang.Object
  |
  +--convexhull3d.Triangle

public class Triangle
extends java.lang.Object

Basic triangular face used to form the hull.

The information stored for each triangle consists of a planar normal, a planar offset, and a doubly-linked list of three HalfEdges which surround the triangle in a counter-clockwise direction.

Author:
John E. Lloyd, Winter 2003

Field Summary
static int COPLANAR
          Triangle is marked as coplanar (i.e., marginally visible) with respect to a particular point.
static int NO_MARK
          The triangle is not marked.
static int VISIBLE
          Triangle is marked as visible to a particular point.
 
Constructor Summary
Triangle(SpatialPoint p0, SpatialPoint p1, SpatialPoint p2)
          Constructs a Triangle from points p0, p1, and p2.
 
Method Summary
static void areaVector(SpatialVector v, SpatialPoint p0, SpatialPoint p1, SpatialPoint p2)
          Computes the cross product of the vectors formed from (p1-p0) and (p2-p0) and stores this in the vector v.
static double areaVectorDot(SpatialPoint p0, SpatialPoint p1, SpatialPoint p2, SpatialVector v)
          Computes the cross product of the vectors formed from (p1-p0) and (p2-p0), and then takes the dot product of this with the vector v.
 double distanceToPlane(SpatialPoint p)
          Computes the distance from a point p to the plane of this triangle.
 HalfEdge findEdge(SpatialPoint vt, SpatialPoint vh)
          Finds the half-edge within this triangle which has tail vt and head vh.
 HalfEdge getEdge(int i)
          Gets the i-th half-edge associated with the triangle.
 int getMark()
          Gets the marking associated with this triangle.
 SpatialVector getNormal()
          Returns the normal of the plane associated with this triangle.
static HalfEdge nextBoundaryEdge(HalfEdge edge0)
          Gets the next half-edge, adjacent to edge0 in a counter-clockwise direction, which lies along the boundary of a region of triangles marked VISIBLE or COPLANAR
static HalfEdge nextBoundaryEdge(HalfEdge edge0, int mark)
          Gets the next half-edge, adjacent to edge0 in a counter-clockwise direction, which lies along the boundary of a region of triangles marked with the value mark.
static HalfEdge prevBoundaryEdge(HalfEdge edge0)
          Gets the next half-edge, adjacent to edge0 in a clockwise direction, which lies along the boundary of a region of triangles which are marked VISIBLE or COPLANAR
 void setMark(int m)
          Sets the marking associated with this triangle.
 java.lang.String vertexString()
          Produces a string identifying this triangle by the point index values of its vertices.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_MARK

public static final int NO_MARK
The triangle is not marked.

See Also:
Constant Field Values

VISIBLE

public static final int VISIBLE
Triangle is marked as visible to a particular point.

See Also:
Constant Field Values

COPLANAR

public static final int COPLANAR
Triangle is marked as coplanar (i.e., marginally visible) with respect to a particular point.

See Also:
Constant Field Values
Constructor Detail

Triangle

public Triangle(SpatialPoint p0,
                SpatialPoint p1,
                SpatialPoint p2)
Constructs a Triangle from points p0, p1, and p2.

Parameters:
p0 - first point
p1 - second point
p2 - third point
Method Detail

areaVector

public static void areaVector(SpatialVector v,
                              SpatialPoint p0,
                              SpatialPoint p1,
                              SpatialPoint p2)
Computes the cross product of the vectors formed from (p1-p0) and (p2-p0) and stores this in the vector v. The length of v is then the area of the triangle formed by p0, p1, p2.

Parameters:
v - used to return the cross product
p0 - first point
p1 - second point
p2 - third point

areaVectorDot

public static double areaVectorDot(SpatialPoint p0,
                                   SpatialPoint p1,
                                   SpatialPoint p2,
                                   SpatialVector v)
Computes the cross product of the vectors formed from (p1-p0) and (p2-p0), and then takes the dot product of this with the vector v.

Parameters:
p0 - first point
p1 - second point
p2 - third point
v - used to form dot product
Returns:
[(p1-p0) X (p2-p0)] . v

setMark

public void setMark(int m)
Sets the marking associated with this triangle.

Parameters:
m - the mark value

getMark

public int getMark()
Gets the marking associated with this triangle.

Returns:
mark value

getEdge

public HalfEdge getEdge(int i)
Gets the i-th half-edge associated with the triangle.

Parameters:
i - the half-edge index, in the range 0-2.
Returns:
the half-edge

nextBoundaryEdge

public static HalfEdge nextBoundaryEdge(HalfEdge edge0)
Gets the next half-edge, adjacent to edge0 in a counter-clockwise direction, which lies along the boundary of a region of triangles marked VISIBLE or COPLANAR

Parameters:
edge0 - original edge
Returns:
adjacent half-edge

nextBoundaryEdge

public static HalfEdge nextBoundaryEdge(HalfEdge edge0,
                                        int mark)
Gets the next half-edge, adjacent to edge0 in a counter-clockwise direction, which lies along the boundary of a region of triangles marked with the value mark.

Parameters:
edge0 - original edge
mark - marking value for the region
Returns:
adjacent half-edge

prevBoundaryEdge

public static HalfEdge prevBoundaryEdge(HalfEdge edge0)
Gets the next half-edge, adjacent to edge0 in a clockwise direction, which lies along the boundary of a region of triangles which are marked VISIBLE or COPLANAR

Parameters:
edge0 - original edge
Returns:
adjacent half-edge

findEdge

public HalfEdge findEdge(SpatialPoint vt,
                         SpatialPoint vh)
Finds the half-edge within this triangle which has tail vt and head vh.

Parameters:
vt - tail point
vh - head point
Returns:
the half-edge, or null if none is found.

vertexString

public java.lang.String vertexString()
Produces a string identifying this triangle by the point index values of its vertices.

Returns:
identifying string

distanceToPlane

public double distanceToPlane(SpatialPoint p)
Computes the distance from a point p to the plane of this triangle.

Parameters:
p - the point
Returns:
distance from the point to the plane

getNormal

public SpatialVector getNormal()
Returns the normal of the plane associated with this triangle.

Returns:
the planar normal