Class Triangle


public class Triangle extends Polygon
A class defining a triangle
  • Constructor Details

    • Triangle

      public Triangle(Vertex v1, Vertex v2, Vertex v3)
      Construct a triangle given three vertices.
      Parameters:
      v1 - , v2, v3 the vertices
  • Method Details

    • 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
    • matches

      public boolean matches(Vector vec)
      Tests whether a triangle is present in a vector.
      Parameters:
      vec - vector of triangles to match
      Returns:
      true if the operation is successful, false otherwise
    • 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
    • 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
      v2 - the v2 parameter
      Returns:
      the third vertex or null if v1 and v2 are not vertices
    • edgeNeighbour

      public Triangle edgeNeighbour(Vector tris, Vertex v1, Vertex v2)
      Returns the triangle that shares a particular edge.
      Parameters:
      tris - the list of triangles to search v1 v2 the vertices that define the edge
      v1 - the v1 parameter
      v2 - the v2 parameter
      Returns:
      the neighbouring triangle or null if not found
    • 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
    • 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
      Returns:
      the resulting int