Class TriangularFacet

  • All Implemented Interfaces:
    Facet

    public class TriangularFacet
    extends Object
    implements Facet
    This is the triangle implementation of Facet Interface. A facet consists of three vertices. The triangles orientation is counter clock wise.
    Author:
    Tim-Oliver Buchholz (University of Konstanz)
    • Field Detail

      • vertices

        protected List<Vertex> vertices
        The vertices of this facet in counter clock wise orientation.
      • neighbors

        protected List<T> neighbors
        The neighboring facets of this facet.

        Neighbor 0 is the neighbor which is adjacent to this facet at the edge from UpdateablePointSet.getLastVertex() to TriangularFacet#getVertex(0).

    • Constructor Detail

      • TriangularFacet

        public TriangularFacet()
        Creates a new empty facet.
      • TriangularFacet

        public TriangularFacet​(Vertex v0,
                               Vertex v1,
                               Vertex v2)
        Creates a new facet of three vertices.
        Parameters:
        v0 - the first vertex
        v1 - the second vertex
        v2 - the third vertex
    • Method Detail

      • getArea

        public double getArea()
        Get the area of this facet.
        Returns:
        the area
      • getCentroid

        public Vector3D getCentroid()
        Get the centroid of this facet.
        Returns:
        the centroid
      • getNormal

        public Vector3D getNormal()
        Get the normal of this facet.
        Returns:
        the normal
      • getPlaneOffset

        public double getPlaneOffset()
        Computes the offset of this facet
        Returns:
        the offset
      • distanceToPlane

        public double distanceToPlane​(Vector3D p)
        Computes the distance from a point to this facet
        Parameters:
        p - the point
        Returns:
        the distance
      • setVertexInFront

        public void setVertexInFront​(Vertex v,
                                     double distanceToPlane)
        Adds a vertex to the points in front of this facet.
        Parameters:
        v - the vertex
        distanceToPlane - of this vertex
      • getVerticesInFront

        public List<Vertex> getVerticesInFront()
        All points which are in front of this plane.
        Returns:
        points which are in front
      • getMaximumDistanceVertex

        public Vertex getMaximumDistanceVertex()
        The vertex which is in front and farthest apart of the plane
        Returns:
        vertex with maximum distance to the plane
      • getP0

        public Vertex getP0()
      • getP1

        public Vertex getP1()
      • getP2

        public Vertex getP2()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getVertices

        public List<Vertex> getVertices()
        The list of vertices.
        Returns:
        all vertices
      • indexOfVertex

        public int indexOfVertex​(Vertex vertex)
        Returns the index of the first occurrence of vertex.
        Parameters:
        vertex - the vertex
        Returns:
        index of vertex or -1 if this vertex is not contained
      • getVertex

        public Vertex getVertex​(int i)
        Get the vertex at index i.
        Parameters:
        i - the position
        Returns:
        the vertex
      • size

        public int size()
        Get the number of vertices.
        Returns:
        number of vertices
      • getLastVertex

        public Vertex getLastVertex()
        Get the last vertex.
        Returns:
        the last vertex
      • containsAll

        public boolean containsAll​(List<Vertex> vertexList)
        Returns true if all vertices are part of this polygon
        Parameters:
        vertexList - to check
        Returns:
        true if all vertices are contained
      • hasEdge

        public boolean hasEdge​(Vertex tail,
                               Vertex head)
        Returns true if this facet has the edge from tail to head.
        Parameters:
        tail - vertex of the edge
        head - vertex of the edge
        Returns:
        has edge tail to head
      • setNeighbor

        public void setNeighbor​(int position,
                                T n)
        Sets the n-th neighbor of this facet.
        Parameters:
        position - of the neighbor
        n - the neighbor
      • getNeighbor

        public T getNeighbor​(int position)
        Get the neighbor at position.
        Parameters:
        position - the position
        Returns:
        the neighbor
      • getNeighbors

        public List<T> getNeighbors()
        Get all neighbors.
        Returns:
        all neighbors
      • replaceNeighbor

        public void replaceNeighbor​(int i,
                                    T f)
        Replaces a neighbor.
        Parameters:
        i - index of the neighbor to replace
        f - the new neighbor
      • indexOfNeighbor

        public int indexOfNeighbor​(T facet)
        Get index of a neighbor.
        Parameters:
        facet - the neighboring facet
        Returns:
        the index or -1 if facet is not a neighbor