Class Triangle

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

public class Triangle
extends Polygon
A class defining a triangle


Constructor Index

 o Triangle(Vertex, Vertex, Vertex)
Construct a triangle given three vertices.

Method Index

 o edgeNeighbour(Vector, Vertex, Vertex)
Returns the triangle that shares a particular edge.
 o matches(Vector)
Tests whether a triangle is present in a vector.
 o matchIndex(Vector)
Returns the index of a triangle in a vector.
 o sameTriangle(Triangle, Triangle)
Tests whether two triangles are the same.
 o thirdVertex(Vertex, Vertex)
Returns the third vertex of a triangle given the other two.
 o volume6(Vertex)
Returns six times the volume of the tetrahedron formed by a triangle and vertex.
 o volumeSign(Vertex)
Returns the sign of the volume of the tetrahedron formed by a triangle and a vertex.

Constructors

 o Triangle
 public Triangle(Vertex v1,
                 Vertex v2,
                 Vertex v3)
Construct a triangle given three vertices.

Parameters:
v1, - v2, v3 the vertices

Methods

 o sameTriangle
 public static boolean sameTriangle(Triangle t1,
                                    Triangle t2)
Tests whether two triangles are the same. Order of vertices is ignored.

Parameters:
t1, - t2 The triangles to compare
 o matches
 public boolean matches(Vector vec)
Tests whether a triangle is present in a vector.

Parameters:
vec - vector of triangles to match
 o matchIndex
 public int matchIndex(Vector vec)
Returns the index of a triangle in a vector.

Parameters:
vec - vector of triangles to match
Returns:
index of the match or -1 if no match
 o thirdVertex
 public Vertex thirdVertex(Vertex v1,
                           Vertex v2)
Returns the third vertex of a triangle given the other two.

Parameters:
v1, - v2 the other two vertices
Returns:
the third vertex or null if v1 and v2 are not vertices
 o edgeNeighbour
 public Triangle edgeNeighbour(Vector tris,
                               Vertex v1,
                               Vertex v2)
Returns the triangle that shares a particular edge.

Parameters:
s - tris the list of triangles to search v1 v2 the vertices that define the edge
Returns:
the neighbouring triangle or null if not found
 o volumeSign
 public int volumeSign(Vertex v)
Returns the sign of the volume of the tetrahedron formed by a triangle and a vertex. VolumeSign is positive iff the vertex is on the negative side of the triangle, where the positive side is determined by the rh-rule. So the volume is positive if the ccw normal to points outside the tetrahedron. The final fewer-multiplications form is due to Bob Williamson.

Parameters:
v - vertex to test
Returns:
-1/0/1 if vertex is on the negative/coplanar/positive side of the triangle according to the rh-rule
 o volume6
 public int volume6(Vertex v)
Returns six times the volume of the tetrahedron formed by a triangle and vertex. The volume is positive iff the vertex is on the negative side of the triangle, where the positive side is determined by the rh-rule.

Parameters:
v - the vertex