Class Polygon3D

java.lang.Object
com.irurueta.geometry.Polygon3D
All Implemented Interfaces:
Serializable

public class Polygon3D extends Object implements Serializable
This class defines a polygon in 3D space.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Default threshold value.
    static final TriangulatorMethod
    Default method for triangulation.
    static final int
    Constant defining inhomogeneous coordinates.
    static final double
    Minimum allowed threshold value.
    static final int
    Minimum number of vertices that a polygon is allowed to have.
    private List<Triangle3D>
    List containing triangles found after triangulating this polygon.
    private boolean
    Boolean indicating whether polygon has already been triangulated.
    Method to do triangulation.
    private List<Point3D>
    List containing vertices of this polygon.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Polygon3D(List<Point3D> vertices)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    center(Point3D result)
    Computes the center of this polygon.
    void
    closestPoint(Point3D point, Point3D result)
    Computes the closes point to provided point that is locus of this polygon (i.e. lies on a border of this polygon).
    private static double
    getAngleBetweenOrientations(double[] orientation1, double[] orientation2)
    Internal method to compute polygon orientation from their respective orientation vectors.
    static double
    Returns the angle between two polygons, assuming that all vertices of each polygon lie on a given plane.
    static double
    getAngleBetweenPolygons(Polygon3D polygon1, Polygon3D polygon2, double threshold)
    Returns the angle between two polygons, assuming that all vertices of each polygon lie on a given plane.
    static double
    getAngleBetweenPolygons(List<Point3D> vertices1, List<Point3D> vertices2)
    Returns the angle between two polygons formed each of them by the corresponding list of provided vertices and assuming that all vertices of each polygon lie on a given plane.
    static double
    getAngleBetweenPolygons(List<Point3D> vertices1, List<Point3D> vertices2, double threshold)
    Returns the angle between two polygons formed each of them by the corresponding list of provided vertices and assuming that all vertices of each polygon lie on a given plane.
    double
    Returns signed area of this polygon.
    Returns the center of this polygon.
    Returns the closest point to provided point that is locus of this polygon (i.e. lies on a border of this polygon).
    double[]
    Returns the average orientation of provided 3D polygon as an array containing the vector coordinates of the orientation.
    double[]
    getOrientation(double threshold)
    Returns the average orientation of provided 3D polygon as an array containing the vector coordinates of the orientation.
    double
    Returns perimeter of this polygon.
    double
    Returns the shortest distance from provided point to a border of this polygon.
    Returns a list of triangles forming this polygon.
    Returns triangulator method.
    Returns the list of vertices forming this polygon.
    boolean
    Determines if provided point lies within the region defined by this polygon.
    boolean
    isInside(Point3D point, double threshold)
    Determines if provided point lies within the region defined by this polygon.
    boolean
    Determines whether provided point is locus of the borders defined by the vertices of this polygon.
    boolean
    isLocus(Point3D point, double threshold)
    Determines whether provided point is locus of the borders defined by the vertices of this polygon.
    boolean
    Determines whether this polygon has already been triangulated.
    void
    orientation(double[] result)
    Computes the average orientation of provided 3D polygon as an array containing the vector coordinates of the orientation.
    void
    orientation(double[] result, double threshold)
    Computes the average orientation of this polygon as an array containing the vector coordinates of the orientation.
    static double[]
    Returns the average orientation of provided 3D polygon as an array containing the vector coordinates of the orientation.
    static double[]
    orientation(Polygon3D polygon, double threshold)
    Returns the average orientation of provided 3D polygon as an array containing the vector coordinates of the orientation.
    static void
    orientation(Polygon3D polygon, double[] result)
    Computes the average orientation of provided 3D polygon as an array containing the vector coordinates of the orientation.
    static void
    orientation(Polygon3D polygon, double[] result, double threshold)
    Computes the average orientation of provided 3D polygon as an array containing the vector coordinates of the orientation.
    static double[]
    Returns the average orientation of a 3D polygon as an array containing the vector coordinates of the orientation.
    static double[]
    orientation(List<Point3D> vertices, double threshold)
    Returns the average orientation of a 3D polygon as an array containing the vector coordinates of the orientation.
    static void
    orientation(List<Point3D> vertices, double[] result)
    Computes the average orientation of a 3D polygon as an array containing the vector coordinates of the orientation.
    static void
    orientation(List<Point3D> vertices, double[] result, double threshold)
    Computes the average orientation of a 3D polygon as an array containing the vector coordinates of the orientation.
    void
    Sets triangulator method.
    final void
    Sets list of vertices forming this polygon.
    void
    Triangulates this polygon using this polygon's triangulator method.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_THRESHOLD

      public static final double DEFAULT_THRESHOLD
      Default threshold value. Thresholds are used to determine whether a point lies inside the polygon or not, or if it's locus or not, etc.
      See Also:
    • MIN_THRESHOLD

      public static final double MIN_THRESHOLD
      Minimum allowed threshold value.
      See Also:
    • MIN_VERTICES

      public static final int MIN_VERTICES
      Minimum number of vertices that a polygon is allowed to have.
      See Also:
    • INHOM_COORDS

      public static final int INHOM_COORDS
      Constant defining inhomogeneous coordinates.
      See Also:
    • DEFAULT_TRIANGULATOR_METHOD

      public static final TriangulatorMethod DEFAULT_TRIANGULATOR_METHOD
      Default method for triangulation.
    • vertices

      private List<Point3D> vertices
      List containing vertices of this polygon. Each vertex is a 3D point.
    • triangulated

      private boolean triangulated
      Boolean indicating whether polygon has already been triangulated.
    • triangles

      private List<Triangle3D> triangles
      List containing triangles found after triangulating this polygon. Initially this list will be null until triangulation is done.
    • triangulatorMethod

      private TriangulatorMethod triangulatorMethod
      Method to do triangulation.
  • Constructor Details

  • Method Details

    • getTriangulatorMethod

      public TriangulatorMethod getTriangulatorMethod()
      Returns triangulator method. Triangulator method determines the way a polygon is divided into triangles. If none has been provided DEFAULT_TRIANGULATOR_METHOD will be returned.
      Returns:
      Triangulator method.
    • setTriangulatorMethod

      public void setTriangulatorMethod(TriangulatorMethod triangulatorMethod)
      Sets triangulator method. A triangulator method determines the way a polygon is divided into triangles.
      Parameters:
      triangulatorMethod - A triangulator method.
    • getVertices

      public List<Point3D> getVertices()
      Returns the list of vertices forming this polygon.
      Returns:
      List of vertices.
    • setVertices

      public final void setVertices(List<Point3D> vertices) throws NotEnoughVerticesException
      Sets list of vertices forming this polygon.
      Parameters:
      vertices - List of vertices.
      Throws:
      NotEnoughVerticesException - Raised if provided list does not have enough vertices.
      See Also:
    • isTriangulated

      public boolean isTriangulated()
      Determines whether this polygon has already been triangulated. A polygon will only need to be triangulated once, unless the list of vertices is reset.
      Returns:
      True if polygon has already been triangulated, false otherwise.
    • getTriangles

      public List<Triangle3D> getTriangles() throws TriangulatorException
      Returns a list of triangles forming this polygon. This method checks whether this polygon has already been triangulated, if not, it performs triangulation first.
      Returns:
      A list of triangles forming this polygon.
      Throws:
      TriangulatorException - Raised if triangulation was needed and failed.
    • getArea

      public double getArea()
      Returns signed area of this polygon. The sign of the area determines whether vertices of the polygon are provided in clockwise (negative sign) or clockwise (positive sign) order.
      Returns:
      Signed area of this polygon.
    • getPerimeter

      public double getPerimeter()
      Returns perimeter of this polygon. The perimeter is computed as the sum of the distances between consecutive pairs of vertices.
      Returns:
      Perimeter of this polygon.
    • isInside

      public boolean isInside(Point3D point) throws TriangulatorException
      Determines if provided point lies within the region defined by this polygon. Notice that this method is only ensured to work for polygons having no holes or crossing borders. It will safely work on any other polygon, no matter if it is regular, non-regular, convex or concave.
      Parameters:
      point - Point to be checked.
      Returns:
      True if point lies within the area defined by this polygon, false otherwise.
      Throws:
      TriangulatorException - Raised if triangulation was required but failed.
    • isInside

      public boolean isInside(Point3D point, double threshold) throws TriangulatorException
      Determines if provided point lies within the region defined by this polygon. Notice that this method is only ensured to work for polygons having no holes or crossing borders. It will safely work on any other polygon, no matter if it is regular, non-regular, convex or concave.
      Parameters:
      point - Point to be checked.
      threshold - Threshold to determine whether point lies inside this polygon. Usually this value should be small.
      Returns:
      True if point lies within the area defined by this polygon, false otherwise.
      Throws:
      IllegalArgumentException - Raised if provided threshold is negative.
      TriangulatorException - Raised if triangulation was required but failed.
    • getCenter

      public Point3D getCenter()
      Returns the center of this polygon. The center is the average point among all the vertices of this polygon. The center is not ensure to lie within the area formed by this polygon.
      Returns:
      Center of this polygon.
    • center

      public void center(Point3D result)
      Computes the center of this polygon. The center is the average point among all the vertices of this polygon. The center is not ensured to lie within the area formed by this polygon.
      Parameters:
      result - Instance where the computed center will be stored.
    • isLocus

      public boolean isLocus(Point3D point, double threshold)
      Determines whether provided point is locus of the borders defined by the vertices of this polygon. A point will be locus if it lies in the line defined by two consecutive vertices up to a certain threshold of error.
      Parameters:
      point - Point to be checked.
      threshold - Threshold of allowed error. This should usually be a small value.
      Returns:
      True if provided point lies in a border of this polygon, false otherwise.
      Throws:
      IllegalArgumentException - Raised if provided threshold is negative.
    • isLocus

      public boolean isLocus(Point3D point)
      Determines whether provided point is locus of the borders defined by the vertices of this polygon. A point will be locus if it lies in the line defined by two consecutive vertices.
      Parameters:
      point - Point to be checked.
      Returns:
      True if provided point lies in a border of this polygon, false otherwise.
    • getShortestDistance

      public double getShortestDistance(Point3D point) throws CoincidentPointsException
      Returns the shortest distance from provided point to a border of this polygon. Note that borders are segments defined by consecutive vertices
      Parameters:
      point - Point to be checked.
      Returns:
      Shortest distance from provided point to this polygon.
      Throws:
      CoincidentPointsException - Raised if points in a polygon are too close. This usually indicates numerical instability or polygon degeneracy.
    • getClosestPoint

      public Point3D getClosestPoint(Point3D point) throws CoincidentPointsException
      Returns the closest point to provided point that is locus of this polygon (i.e. lies on a border of this polygon).
      Parameters:
      point - Point to be checked.
      Returns:
      Closest point being locus of this polygon.
      Throws:
      CoincidentPointsException - Raised if points in a polygon are too close. This usually indicates numerical instability or polygon degeneracy.
    • closestPoint

      public void closestPoint(Point3D point, Point3D result) throws CoincidentPointsException
      Computes the closes point to provided point that is locus of this polygon (i.e. lies on a border of this polygon).
      Parameters:
      point - Point to be checked.
      result - Instance where the closest point will be stored.
      Throws:
      CoincidentPointsException - Raised if points in a polygon are too close. This usually indicates numerical instability or polygon degeneracy.
    • triangulate

      public void triangulate() throws TriangulatorException
      Triangulates this polygon using this polygon's triangulator method. A polygon only will be triangulated once when required or this method is called. This method will make no action if a polygon is already triangulated unless it's vertices are reset.
      Throws:
      TriangulatorException - Raised if triangulation failed.
      See Also:
    • orientation

      public static void orientation(List<Point3D> vertices, double[] result, double threshold) throws CoincidentPointsException
      Computes the average orientation of a 3D polygon as an array containing the vector coordinates of the orientation. Notice that if all the vertices of the polygon lie in the same plane, then the estimated orientation will be exact, otherwise an average orientation will be estimated. Estimated orientation will be normalized (the norm of the estimated vector will be 1).
      Parameters:
      vertices - List of vertices forming a polygon in 3D.
      result - Array where the estimated orientation will be stored.
      threshold - Threshold to determine whether the orientation can be estimated or not. Because the estimated orientation needs to be normalized, it will only be possible to do so when norm has a reasonable value. If estimated norm happens to be smaller than provided value, then it will be assumed that polygon contains a degeneracy or that a consecutive pair of vertices are coincident.
      Throws:
      IllegalArgumentException - Raised if provided result array does not have length 3, or if the list of provided vertices does not contain at least three vertices, or if provided threshold is negative.
      CoincidentPointsException - Raised usually when it is determined that consecutive vertices of the polygon are too close (i.e. coincident) or when there are polygon degeneracies or numerical instabilities.
    • orientation

      public static void orientation(List<Point3D> vertices, double[] result) throws CoincidentPointsException
      Computes the average orientation of a 3D polygon as an array containing the vector coordinates of the orientation. Notice that if all the vertices of the polygon lie in the same plane, then the estimated orientation will be exact, otherwise an average orientation will be estimated. Estimated orientation will be normalized (the norm of the estimated vector will be 1).
      Parameters:
      vertices - List of vertices forming a polygon in 3D.
      result - Array where the estimated orientation will be stored.
      Throws:
      IllegalArgumentException - Raised if provided result array does not have length 3, or if the list of provided vertices does not contain at least three vertices.
      CoincidentPointsException - Raised usually when it is determined that consecutive vertices of the polygon are too close (i.e. coincident) or when there are polygon degeneracies or numerical instabilities.
    • orientation

      public static double[] orientation(List<Point3D> vertices, double threshold) throws CoincidentPointsException
      Returns the average orientation of a 3D polygon as an array containing the vector coordinates of the orientation. Notice that if all the vertices of the polygon lie in the same plane, then the estimated orientation will be exact, otherwise an average orientation will be estimated. Estimated orientation will be normalized (the norm of the estimated vector will be 1).
      Parameters:
      vertices - List of vertices forming a polygon in 3D.
      threshold - Threshold to determine whether the orientation can be estimated or not. Because the estimated orientation needs to be normalized, it will only be possible to do so when norm has a reasonable value. If estimated norm happens to be smaller than provided value, then it will be assumed that polygon contains a degeneracy or that a consecutive pair of vertices are coincident.
      Returns:
      Array containing estimated orientation.
      Throws:
      IllegalArgumentException - Raised if the list of provided vertices does not contain at least three vertices, or if provided threshold is negative.
      CoincidentPointsException - Raised usually when it is determined that consecutive vertices of the polygon are too close (i.e. coincident) or when there are polygon degeneracies or numerical instabilities.
    • orientation

      public static double[] orientation(List<Point3D> vertices) throws CoincidentPointsException
      Returns the average orientation of a 3D polygon as an array containing the vector coordinates of the orientation. Notice that if all the vertices of the polygon lie in the same plane, then the estimated orientation will be exact, otherwise an average orientation will be estimated. Estimated orientation will be normalized (the norm of the estimated vector will be 1).
      Parameters:
      vertices - List of vertices forming a polygon in 3D
      Returns:
      Array containing estimated orientation.
      Throws:
      IllegalArgumentException - Raised if the list of provided vertices does not contain at least three vertices.
      CoincidentPointsException - Raised usually when it is determined that consecutive vertices of the polygon are too close (i.e. coincident) or when there are polygon degeneracies or numerical instabilities.
    • orientation

      public static void orientation(Polygon3D polygon, double[] result, double threshold) throws CoincidentPointsException
      Computes the average orientation of provided 3D polygon as an array containing the vector coordinates of the orientation. Notice that if all the vertices of the polygon lie in the same plane, then the estimated orientation will be exact, otherwise an average orientation will be estimated. Estimated orientation will be normalized (the norm of the estimated vector will be 1).
      Parameters:
      polygon - A polygon in 3D.
      result - Array where the estimated orientation will be stored.
      threshold - Threshold to determine whether the orientation can be estimated or not. Because the estimated orientation needs to be normalized, it will only be possible to do so when norm has a reasonable value. If estimated norm happens to be smaller than provided value, then it will be assumed that polygon contains a degeneracy or that a consecutive pair of vertices are coincident.
      Throws:
      IllegalArgumentException - Raised if provided result array does not have length 3 or if provided threshold is negative.
      CoincidentPointsException - Raised usually when it is determined that consecutive vertices of the polygon are too close (i.e. coincident) or when there are polygon degeneracies or numerical instabilities.
    • orientation

      public static void orientation(Polygon3D polygon, double[] result) throws CoincidentPointsException
      Computes the average orientation of provided 3D polygon as an array containing the vector coordinates of the orientation. Notice that if all the vertices of the polygon lie in the same plane, then the estimated orientation will be exact, otherwise an average orientation will be estimated. Estimated orientation will be normalized (the norm of the estimated vector will be 1).
      Parameters:
      polygon - A polygon in 3D.
      result - Array where the estimated orientation will be stored.
      Throws:
      IllegalArgumentException - Raised if provided result array does not have length 3.
      CoincidentPointsException - Raised usually when it is determined that consecutive vertices of the polygon are too close (i.e. coincident) or when there are polygon degeneracies or numerical instabilities.
    • orientation

      public static double[] orientation(Polygon3D polygon, double threshold) throws CoincidentPointsException
      Returns the average orientation of provided 3D polygon as an array containing the vector coordinates of the orientation. Notice that if all the vertices of the polygon lie in the same plane, then the estimated orientation will be exact, otherwise an average orientation will be estimated. Estimated orientation will be normalized (the norm of the estimated vector will be 1).
      Parameters:
      polygon - A polygon in 3D.
      threshold - Threshold to determine whether the orientation can be estimated or not. Because the estimated orientation needs to be normalized, it will only be possible to do so when norm has a reasonable value. If estimated norm happens to be smaller than provided value, then it will be assumed that polygon contains a degeneracy or that a consecutive pair of vertices are coincident.
      Returns:
      Array containing estimated orientation.
      Throws:
      IllegalArgumentException - Raised if provided threshold is negative.
      CoincidentPointsException - Raised usually when it is determined that consecutive vertices of the polygon are too close (i.e. coincident) or when there are polygon degeneracies or numerical instabilities.
    • orientation

      public static double[] orientation(Polygon3D polygon) throws CoincidentPointsException
      Returns the average orientation of provided 3D polygon as an array containing the vector coordinates of the orientation. Notice that if all the vertices of the polygon lie in the same plane, then the estimated orientation will be exact, otherwise an average orientation will be estimated. Estimated orientation will be normalized (the norm of the estimated vector will be 1).
      Parameters:
      polygon - A polygon in 3D.
      Returns:
      Array containing estimated orientation.
      Throws:
      CoincidentPointsException - Raised usually when it is determined that consecutive vertices of the polygon are too close (i.e. coincident) or when there are polygon degeneracies or numerical instabilities.
    • orientation

      public void orientation(double[] result, double threshold) throws CoincidentPointsException
      Computes the average orientation of this polygon as an array containing the vector coordinates of the orientation. Notice that if all the vertices of the polygon lie in the same plane, then the estimated orientation will be exact, otherwise an average orientation will be estimated. Estimated orientation will be normalized (the norm of the estimated vector will be 1).
      Parameters:
      result - Array where the estimated orientation will be stored.
      threshold - Threshold to determine whether the orientation can be estimated or not. Because the estimated orientation needs to be normalized, it will only be possible to do so when norm has a reasonable value. If estimated norm happens to be smaller than provided value, then it will be assumed that polygon contains a degeneracy or that a consecutive pair of vertices are coincident.
      Throws:
      IllegalArgumentException - Raised if provided result array does not have length 3 or if provided threshold is negative.
      CoincidentPointsException - Raised usually when it is determined that consecutive vertices of the polygon are too close (i.e. coincident) or when there are polygon degeneracies or numerical instabilities.
    • orientation

      public void orientation(double[] result) throws CoincidentPointsException
      Computes the average orientation of provided 3D polygon as an array containing the vector coordinates of the orientation. Notice that if all the vertices of the polygon lie in the same plane, then the estimated orientation will be exact, otherwise an average orientation will be estimated. Estimated orientation will be normalized (the norm of the estimated vector will be 1).
      Parameters:
      result - Array where the estimated orientation will be stored.
      Throws:
      IllegalArgumentException - Raised if provided result array does not have length 3.
      CoincidentPointsException - Raised usually when it is determined that consecutive vertices of the polygon are too close (i.e. coincident) or when there are polygon degeneracies or numerical instabilities.
    • getOrientation

      public double[] getOrientation(double threshold) throws CoincidentPointsException
      Returns the average orientation of provided 3D polygon as an array containing the vector coordinates of the orientation. Notice that if all the vertices of the polygon lie in the same plane, then the estimated orientation will be exact, otherwise an average orientation will be estimated. Estimated orientation will be normalized (the norm of the estimated vector will be 1).
      Parameters:
      threshold - Threshold to determine whether the orientation can be estimated or not. Because the estimated orientation needs to be normalized, it will only be possible to do so when norm has a reasonable value. If estimated norm happens to be smaller than provided value, then it will be assumed that polygon contains a degeneracy or that a consecutive pair of vertices are coincident.
      Returns:
      Array containing estimated orientation.
      Throws:
      IllegalArgumentException - Raised if provided threshold is negative.
      CoincidentPointsException - Raised usually when it is determined that consecutive vertices of the polygon are too close (i.e. coincident) or when there are polygon degeneracies or numerical instabilities.
    • getOrientation

      public double[] getOrientation() throws CoincidentPointsException
      Returns the average orientation of provided 3D polygon as an array containing the vector coordinates of the orientation. Notice that if all the vertices of the polygon lie in the same plane, then the estimated orientation will be exact, otherwise an average orientation will be estimated. Estimated orientation will be normalized (the norm of the estimated vector will be 1).
      Returns:
      Array containing estimated orientation.
      Throws:
      CoincidentPointsException - Raised usually when it is determined that consecutive vertices of the polygon are too close (i.e. coincident) or when there are polygon degeneracies or numerical instabilities.
    • getAngleBetweenPolygons

      public static double getAngleBetweenPolygons(Polygon3D polygon1, Polygon3D polygon2, double threshold) throws CoincidentPointsException
      Returns the angle between two polygons, assuming that all vertices of each polygon lie on a given plane. Hence, this is equivalent to estimating the angle between the planes formed by two polygons. The angle between two polygons is estimated by first estimating their orientation.
      Parameters:
      polygon1 - 1st polygon.
      polygon2 - 2nd polygon.
      threshold - Threshold to determine when polygon orientation can be estimated.
      Returns:
      Angle between two polygons in radians.
      Throws:
      IllegalArgumentException - Raised if provided threshold is negative.
      CoincidentPointsException - Raised usually when it is determined that consecutive vertices of the polygon are too close (i.e. coincident) or when there are polygon degeneracies or numerical instabilities.
      See Also:
    • getAngleBetweenPolygons

      public static double getAngleBetweenPolygons(Polygon3D polygon1, Polygon3D polygon2) throws CoincidentPointsException
      Returns the angle between two polygons, assuming that all vertices of each polygon lie on a given plane. Hence, this is equivalent to estimating the angle between the planes formed by two polygons. The angle between two polygons is estimated by first estimating their orientation.
      Parameters:
      polygon1 - 1st polygon.
      polygon2 - 2nd polygon.
      Returns:
      Angle between two polygons in radians.
      Throws:
      CoincidentPointsException - Raised usually when it is determined that consecutive vertices of the polygon are too close (i.e. coincident) or when there are polygon degeneracies or numerical instabilities.
      See Also:
    • getAngleBetweenPolygons

      public static double getAngleBetweenPolygons(List<Point3D> vertices1, List<Point3D> vertices2, double threshold) throws CoincidentPointsException
      Returns the angle between two polygons formed each of them by the corresponding list of provided vertices and assuming that all vertices of each polygon lie on a given plane. Hence, this is equivalent to estimating the angle between the planes formed by two polygons. The angle between two polygons is estimated by first estimating their orientation.
      Parameters:
      vertices1 - Vertices of 1st polygon.
      vertices2 - 2nd polygon.
      threshold - Threshold to determine when polygon orientation can be estimated.
      Returns:
      Angle between two polygons in radians.
      Throws:
      IllegalArgumentException - Raised if provided threshold is negative or if list of vertices do not contain at least 3 vertices for each polygon.
      CoincidentPointsException - Raised usually when it is determined that consecutive vertices of the polygon are too close (i.e. coincident) or when there are polygon degeneracies or numerical instabilities.
      See Also:
    • getAngleBetweenPolygons

      public static double getAngleBetweenPolygons(List<Point3D> vertices1, List<Point3D> vertices2) throws CoincidentPointsException
      Returns the angle between two polygons formed each of them by the corresponding list of provided vertices and assuming that all vertices of each polygon lie on a given plane. Hence, this is equivalent to estimating the angle between the planes formed by two polygons. The angle between two polygons is estimated by first estimating their orientation.
      Parameters:
      vertices1 - Vertices of 1st polygon.
      vertices2 - 2nd polygon.
      Returns:
      Angle between two polygons in radians.
      Throws:
      IllegalArgumentException - Raised if list of vertices do not contain at least 3 vertices for each polygon.
      CoincidentPointsException - Raised usually when it is determined that consecutive vertices of the polygon are too close (i.e. coincident) or when there are polygon degeneracies or numerical instabilities.
      See Also:
    • getAngleBetweenOrientations

      private static double getAngleBetweenOrientations(double[] orientation1, double[] orientation2)
      Internal method to compute polygon orientation from their respective orientation vectors. Orientation vectors are provided as arrays and can be obtained by calling orientation(Polygon3D, double[]) among other methods.
      Parameters:
      orientation1 - Orientation of 1st polygon.
      orientation2 - Orientation of 2nd polygon.
      Returns:
      Angle between two polygons in radians.
      Throws:
      IllegalArgumentException - Raised if any of the orientation arrays do not have length 3.