Class Triangle3D

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

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

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Default threshold value.
    static final int
    Constant defining number of coordinates
    static final double
    Minimum allowed threshold value
    static final int
    Constant defining number of vertices on a triangle
    private Point3D
    1st vertex of this triangle.
    private Point3D
    2nd vertex of this triangle.
    private Point3D
    3rd vertex of this triangle.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Triangle3D(Point3D vertex1, Point3D vertex2, Point3D vertex3)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    area(Point3D vertex1, Point3D vertex2, Point3D vertex3)
    Returns area of the triangle formed by provided vertices.
    static double
    area(Triangle3D triangle)
    Returns area of provided triangle.
    boolean
    Determines whether vertices of this triangle are considered to be co-linear.
    boolean
    areVerticesColinear(double threshold)
    Determines whether vertices of this triangle are considered to be co-linear up to certain threshold.
    void
    center(Point3D result)
    Computes the center of this triangle and stores the result in provided point.
    static Point3D
    center(Point3D vertex1, Point3D vertex2, Point3D vertex3)
    Computes the center of a triangle formed by provided vertices.
    static void
    center(Point3D vertex1, Point3D vertex2, Point3D vertex3, Point3D result)
    Computes the center of a triangle formed by provided vertices and stores the result in provided result point.
    static Point3D
    Computes the center of provided triangle.
    static void
    Computes the center of provided triangle and stores the result in provided result point.
    void
    closestPoint(Point3D point, Point3D result)
    Computes the point which is locus of this triangle closest to provided point and stores the result in provided result point.
    void
    closestPoint(Point3D point, Point3D result, double threshold)
    Computes the point which is locus of this triangle (up to a certain threshold) closest to provided point and stores the result in provided result point.
    private static double
    getAngleBetweenTriangles(double[] orientation1, double[] orientation2)
    Internal method to compute the angle between two triangles using the vectors containing the director vector of their corresponding planes (i.e. their orientations).
    static double
    Returns the angle formed by the two provided triangles, assuming that each triangle forms a plane.
    double
    Returns area of this triangle.
    Returns center of this triangle, which is the result of averaging its vertices.
    Returns the point which is locus of this triangle closest to provided point.
    getClosestPoint(Point3D point, double threshold)
    Returns the point which is locus of this triangle (up to a certain threshold) closest to provided point.
    double[]
    Returns array containing orientation of this 3D triangle.
    double[]
    getOrientation(double threshold)
    Returns array containing orientation of this 3D triangle.
    double
    Returns perimeter of this triangle.
    double
    Computes the shortest distance from a given point to the boundaries of this triangle, considering its boundaries as lines with a finite length Distance is computed up to triangle boundary, no matter if point lies inside the triangle or not.
    Returns 1st vertex of this triangle.
    Returns 2nd vertex of this triangle.
    Returns 3rd vertex of this triangle.
    Returns vertices of this triangle as a list of points.
    boolean
    Indicates whether provided point lies inside this triangle or not.
    boolean
    isInside(Point3D point, double threshold)
    Indicates whether provided point lies inside this triangle or not up to a certain threshold.
    static boolean
    isInside(Point3D vertex1, Point3D vertex2, Point3D vertex3, Point3D point)
    Indicates whether provided point lies inside a triangle formed by provided vertices or not.
    static boolean
    isInside(Point3D vertex1, Point3D vertex2, Point3D vertex3, Point3D point, double threshold)
    Indicates whether provided point lies inside a triangle formed by provided vertices or not up to a certain threshold.
    static boolean
    isInside(Triangle3D triangle, Point3D point)
    Indicates whether provided point lies inside provided triangle or not To lie inside point must be on the same plane formed by provided triangle and within triangle boundaries.
    static boolean
    isInside(Triangle3D triangle, Point3D point, double threshold)
    Indicates whether provided point lies inside provided triangle or not up to a certain threshold.
    boolean
    Returns boolean indicating if provided point is locus of this triangle (i.e. lies within this triangle boundaries).
    boolean
    isLocus(Point3D point, double threshold)
    Returns boolean indicating if provided point is locus of this triangle (i.e. lies within this triangle boundaries) up to a certain threshold.
    void
    orientation(double[] result)
    Computes orientation of this 3D triangle and stores the result in provided array.
    void
    orientation(double[] result, double threshold)
    Computes orientation of this 3D triangle and stores the result in provided array.
    static double[]
    orientation(Point3D vertex1, Point3D vertex2, Point3D vertex3)
    Returns orientation of 3D triangle formed by provided vertices.
    static double[]
    orientation(Point3D vertex1, Point3D vertex2, Point3D vertex3, double threshold)
    Returns orientation of 3D triangle formed by provided vertices.
    static void
    orientation(Point3D vertex1, Point3D vertex2, Point3D vertex3, double[] result)
    Computes orientation of 3D triangle formed by provided vertices and stores the result in provided array.
    static void
    orientation(Point3D vertex1, Point3D vertex2, Point3D vertex3, double[] result, double threshold)
    Computes orientation of 3D triangle formed by provided vertices and stores the result in provided array.
    static double[]
    Returns orientation of provided 3D triangle.
    static double[]
    orientation(Triangle3D triangle, double threshold)
    Returns orientation of provided 3D triangle.
    static void
    orientation(Triangle3D triangle, double[] result)
    Computes orientation of provided 3D triangle and stores the result in provided array.
    static void
    orientation(Triangle3D triangle, double[] result, double threshold)
    Computes orientation of provided 3D triangle and stores the result in provided array.
    static double
    perimeter(Point3D vertex1, Point3D vertex2, Point3D vertex3)
    Returns perimeter of triangle formed by provided vertices.
    static double
    Returns perimeter of provided triangle.
    void
    Sets 1st vertex of this triangle.
    void
    Sets 2nd vertex of this triangle.
    void
    Sets 3rd vertex of this triangle.
    final void
    setVertices(Point3D vertex1, Point3D vertex2, Point3D vertex3)
    Sets all vertices of this triangle.
    static double
    shortestDistance(Point3D vertex1, Point3D vertex2, Point3D vertex3, Point3D point)
    Computes the shortest distance from a given point to the boundaries of a triangle formed by provided vertices, where those boundaries are considered to be lines with a finite length.
    static double
    Computes the shortest distance from a given point to the boundaries of provided triangle, considering its boundaries as lines with a finite length.
    Returns the plane formed by the vertices of this triangle.
    void
    toPlane(Plane result)
    Computes the plane formed by the vertices of this triangle and stores the result into provided Plane instance.
    void
    Stores vertices of this triangle in provided list.

    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 triangle or not, or if its locus or not, etc.
      See Also:
    • MIN_THRESHOLD

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

      public static final int INHOM_COORDS
      Constant defining number of coordinates
      See Also:
    • NUM_VERTICES

      public static final int NUM_VERTICES
      Constant defining number of vertices on a triangle
      See Also:
    • vertex1

      private Point3D vertex1
      1st vertex of this triangle.
    • vertex2

      private Point3D vertex2
      2nd vertex of this triangle.
    • vertex3

      private Point3D vertex3
      3rd vertex of this triangle.
  • Constructor Details

    • Triangle3D

      public Triangle3D(Point3D vertex1, Point3D vertex2, Point3D vertex3)
      Constructor.
      Parameters:
      vertex1 - 1st vertex.
      vertex2 - 2nd vertex.
      vertex3 - 3rd vertex.
      Throws:
      NullPointerException - Raised if any of the vertices is null.
  • Method Details

    • getVertex1

      public Point3D getVertex1()
      Returns 1st vertex of this triangle.
      Returns:
      1st vertex.
    • setVertex1

      public void setVertex1(Point3D vertex1)
      Sets 1st vertex of this triangle.
      Parameters:
      vertex1 - 1st vertex.
      Throws:
      NullPointerException - Raised if provided vertex is null.
    • getVertex2

      public Point3D getVertex2()
      Returns 2nd vertex of this triangle.
      Returns:
      2nd vertex.
    • setVertex2

      public void setVertex2(Point3D vertex2)
      Sets 2nd vertex of this triangle.
      Parameters:
      vertex2 - 2nd vertex.
      Throws:
      NullPointerException - Raised if provided vertex is null.
    • getVertex3

      public Point3D getVertex3()
      Returns 3rd vertex of this triangle.
      Returns:
      3rd vertex.
    • setVertex3

      public void setVertex3(Point3D vertex3)
      Sets 3rd vertex of this triangle.
      Parameters:
      vertex3 - 3rd vertex.
      Throws:
      NullPointerException - Raised if provided vertex is null.
    • getVertices

      public List<Point3D> getVertices()
      Returns vertices of this triangle as a list of points.
      Returns:
      Vertices of this triangle.
    • vertices

      public void vertices(List<Point3D> result)
      Stores vertices of this triangle in provided list. Note that content of list will be cleared before storing this triangle's vertices.
      Parameters:
      result - list where vertices will be stored.
    • setVertices

      public final void setVertices(Point3D vertex1, Point3D vertex2, Point3D vertex3)
      Sets all vertices of this triangle.
      Parameters:
      vertex1 - 1st vertex.
      vertex2 - 2nd vertex.
      vertex3 - 3rd vertex.
      Throws:
      NullPointerException - Raised if any of the vertices is null.
    • area

      public static double area(Triangle3D triangle)
      Returns area of provided triangle.
      Parameters:
      triangle - Triangle to be evaluated.
      Returns:
      Area of triangle.
    • area

      public static double area(Point3D vertex1, Point3D vertex2, Point3D vertex3)
      Returns area of the triangle formed by provided vertices.
      Parameters:
      vertex1 - 1st vertex of a triangle.
      vertex2 - 2nd vertex of a triangle.
      vertex3 - 3rd vertex of a triangle.
      Returns:
      Area of a triangle.
    • getArea

      public double getArea()
      Returns area of this triangle.
      Returns:
      Area of this triangle.
    • areVerticesColinear

      public boolean areVerticesColinear()
      Determines whether vertices of this triangle are considered to be co-linear. Points are considered to be colinear when area of triangle is very small.
      Returns:
      True if vertices are colinear, false otherwise.
    • areVerticesColinear

      public boolean areVerticesColinear(double threshold)
      Determines whether vertices of this triangle are considered to be co-linear up to certain threshold. Points are considered to be colinear when are of triangle is very small.
      Parameters:
      threshold - Threshold to determine whether vertices are colinear. Vertices will be colinear when area of triangle is smaller than provided threshold.
      Returns:
      True if vertices are colinear, false otherwise.
      Throws:
      IllegalArgumentException - Raised if provided threshold is negative.
    • perimeter

      public static double perimeter(Triangle3D triangle)
      Returns perimeter of provided triangle.
      Parameters:
      triangle - Perimeter of provided triangle.
      Returns:
      Perimeter of provided triangle.
    • perimeter

      public static double perimeter(Point3D vertex1, Point3D vertex2, Point3D vertex3)
      Returns perimeter of triangle formed by provided vertices.
      Parameters:
      vertex1 - 1st vertex of a triangle.
      vertex2 - 2nd vertex of a triangle.
      vertex3 - 3rd vertex of a triangle.
      Returns:
      Perimeter of a triangle.
    • getPerimeter

      public double getPerimeter()
      Returns perimeter of this triangle.
      Returns:
      Perimeter of this triangle.
    • isInside

      public boolean isInside(Point3D point)
      Indicates whether provided point lies inside this triangle or not. To lie inside point must be on the same plane formed by this triangle and within triangle boundaries.
      Parameters:
      point - Point to be checked.
      Returns:
      True if point lies inside this triangle, false otherwise.
    • isInside

      public boolean isInside(Point3D point, double threshold)
      Indicates whether provided point lies inside this triangle or not up to a certain threshold. To lie inside point must be on the same plane formed by this triangle and within triangle boundaries up to a certain threshold.
      Parameters:
      point - Point to be checked.
      threshold - Threshold to determine whether point is inside this triangle, or not. This should usually be a small value.
      Returns:
      True if point lies inside this triangle, false otherwise.
      Throws:
      IllegalArgumentException - Raised if provided threshold is negative.
    • isInside

      public static boolean isInside(Triangle3D triangle, Point3D point)
      Indicates whether provided point lies inside provided triangle or not To lie inside point must be on the same plane formed by provided triangle and within triangle boundaries.
      Parameters:
      triangle - A triangle.
      point - Point to be checked.
      Returns:
      True if point lies inside provided triangle, false otherwise.
    • isInside

      public static boolean isInside(Triangle3D triangle, Point3D point, double threshold)
      Indicates whether provided point lies inside provided triangle or not up to a certain threshold. To lie inside point must be on the same plane formed by provided triangle and within triangle boundaries up to a certain threshold.
      Parameters:
      triangle - A triangle.
      point - Point to be checked.
      threshold - Threshold to determine whether point is inside this triangle, or not. This should usually be a small value.
      Returns:
      True if point lies inside this triangle, false otherwise.
      Throws:
      IllegalArgumentException - Raised if provided threshold is negative.
    • isInside

      public static boolean isInside(Point3D vertex1, Point3D vertex2, Point3D vertex3, Point3D point)
      Indicates whether provided point lies inside a triangle formed by provided vertices or not. To lie inside point must be on the same plane formed by that triangle and within its boundaries.
      Parameters:
      vertex1 - 1st vertex of a triangle.
      vertex2 - 2nd vertex of a triangle.
      vertex3 - 3rd vertex of a triangle.
      point - Point to be checked.
      Returns:
      True if point lies inside triangle formed by provided vertices, false otherwise.
    • isInside

      public static boolean isInside(Point3D vertex1, Point3D vertex2, Point3D vertex3, Point3D point, double threshold)
      Indicates whether provided point lies inside a triangle formed by provided vertices or not up to a certain threshold. To lie inside point must be on the same plane formed by that triangle and within its boundaries up to a certain threshold.
      Parameters:
      vertex1 - 1st vertex of a triangle.
      vertex2 - 2nd vertex of a triangle.
      vertex3 - 3rd vertex of a triangle.
      point - Point to be checked.
      threshold - Threshold to determine whether point is inside the triangle formed by provided vertices or not. This should usually be a small value.
      Returns:
      True if point lies inside triangle formed by provided vertices, false otherwise.
      Throws:
      IllegalArgumentException - Raised if provided threshold is negative.
    • toPlane

      public Plane toPlane() throws ColinearPointsException
      Returns the plane formed by the vertices of this triangle. The difference between a plane and a 3D triangle is that a triangle has its boundaries defined, whereas a plane extends up to the infinity.
      Returns:
      A plane.
      Throws:
      ColinearPointsException - Raised if vertices of this triangle are co-linear (triangle has area equal or very close to 0.0).
    • toPlane

      public void toPlane(Plane result) throws ColinearPointsException
      Computes the plane formed by the vertices of this triangle and stores the result into provided Plane instance. The difference between a plane and a 3D triangle is that a triangle has its boundaries defined, whereas a plane extends up to the infinity.
      Parameters:
      result - Instance where resulting plane will be stored.
      Throws:
      ColinearPointsException - Raised if vertices of this triangle are co-linear (triangle has area equal or very close to 0.0).
    • getCenter

      public Point3D getCenter()
      Returns center of this triangle, which is the result of averaging its vertices.
      Returns:
      Center of this triangle.
    • center

      public void center(Point3D result)
      Computes the center of this triangle and stores the result in provided point. The center of this triangle is computed as the average of its vertices.
      Parameters:
      result - Point instance where center will be stored.
    • center

      public static Point3D center(Point3D vertex1, Point3D vertex2, Point3D vertex3)
      Computes the center of a triangle formed by provided vertices. The center is computed as the average of the three vertices.
      Parameters:
      vertex1 - 1st vertex of a triangle.
      vertex2 - 2nd vertex of a triangle.
      vertex3 - 3rd vertex of a triangle.
      Returns:
      Center of a triangle formed by provided vertices.
    • center

      public static Point3D center(Triangle3D t)
      Computes the center of provided triangle. The center is computed as the average of the vertices of provided triangle.
      Parameters:
      t - A triangle.
      Returns:
      Center of provided triangle.
    • center

      public static void center(Point3D vertex1, Point3D vertex2, Point3D vertex3, Point3D result)
      Computes the center of a triangle formed by provided vertices and stores the result in provided result point. The center is computed as the average of provided vertices.
      Parameters:
      vertex1 - 1st vertex of a triangle.
      vertex2 - 2nd vertex of a triangle.
      vertex3 - 3rd vertex of a triangle.
      result - Point instance where center will be stored.
    • center

      public static void center(Triangle3D t, Point3D result)
      Computes the center of provided triangle and stores the result in provided result point. The center is computed as the average of the vertices of provided triangle.
      Parameters:
      t - A triangle.
      result - Point instance where center will be stored.
    • getShortestDistance

      public double getShortestDistance(Point3D point)
      Computes the shortest distance from a given point to the boundaries of this triangle, considering its boundaries as lines with a finite length Distance is computed up to triangle boundary, no matter if point lies inside the triangle or not.
      Parameters:
      point - Point to be checked.
      Returns:
      Shortest distance to this triangle.
    • shortestDistance

      public static double shortestDistance(Triangle3D triangle, Point3D point)
      Computes the shortest distance from a given point to the boundaries of provided triangle, considering its boundaries as lines with a finite length. Distance is computed up to triangle boundary, no matter if point lies inside the triangle or not.
      Parameters:
      triangle - A triangle.
      point - Point to be checked.
      Returns:
      Shortest distance to this triangle.
    • shortestDistance

      public static double shortestDistance(Point3D vertex1, Point3D vertex2, Point3D vertex3, Point3D point)
      Computes the shortest distance from a given point to the boundaries of a triangle formed by provided vertices, where those boundaries are considered to be lines with a finite length. Distance is computed up to triangle boundary, no matter if point lies inside the triangle or not.
      Parameters:
      vertex1 - 1st vertex of a triangle.
      vertex2 - 2nd vertex of a triangle.
      vertex3 - 3rd vertex of a triangle.
      point - Point to be checked.
      Returns:
      Shortest distance to the triangle formed by provided vertices.
    • getClosestPoint

      public Point3D getClosestPoint(Point3D point)
      Returns the point which is locus of this triangle closest to provided point.
      Parameters:
      point - Point to be checked.
      Returns:
      Closest point laying in this triangle boundaries.
    • getClosestPoint

      public Point3D getClosestPoint(Point3D point, double threshold)
      Returns the point which is locus of this triangle (up to a certain threshold) closest to provided point.
      Parameters:
      point - Point to be checked.
      threshold - Threshold to determine when a point is locus of this triangle or not.
      Returns:
      Closest point laying in this triangle boundaries.
      Throws:
      IllegalArgumentException - Raised if provided threshold is negative.
    • closestPoint

      public void closestPoint(Point3D point, Point3D result)
      Computes the point which is locus of this triangle closest to provided point and stores the result in provided result point.
      Parameters:
      point - Point to be checked.
      result - Point where result will be stored.
    • closestPoint

      public void closestPoint(Point3D point, Point3D result, double threshold)
      Computes the point which is locus of this triangle (up to a certain threshold) closest to provided point and stores the result in provided result point.
      Parameters:
      point - Point to be checked.
      result - Point where result will be stored.
      threshold - Threshold to determine when a point is locus of this triangle or not.
      Throws:
      IllegalArgumentException - Raised if provided threshold is negative.
    • isLocus

      public boolean isLocus(Point3D point, double threshold)
      Returns boolean indicating if provided point is locus of this triangle (i.e. lies within this triangle boundaries) up to a certain threshold.
      Parameters:
      point - Point to be checked.
      threshold - Threshold to determine if point is locus or not. This should usually be a small value.
      Returns:
      True if provided point is locus, false otherwise.
      Throws:
      IllegalArgumentException - Raised if provided threshold is negative.
    • isLocus

      public boolean isLocus(Point3D point)
      Returns boolean indicating if provided point is locus of this triangle (i.e. lies within this triangle boundaries).
      Parameters:
      point - Point to be checked.
      Returns:
      True if provided point is locus, false otherwise.
    • getOrientation

      public double[] getOrientation() throws CoincidentPointsException
      Returns array containing orientation of this 3D triangle.
      Returns:
      Array containing orientation of this 3D triangle.
      Throws:
      CoincidentPointsException - Raised if vertices of this triangle are too close to each other.
    • getOrientation

      public double[] getOrientation(double threshold) throws CoincidentPointsException
      Returns array containing orientation of this 3D triangle.
      Parameters:
      threshold - Threshold to determine whether vertices of this triangle are coincident or not.
      Returns:
      Array containing orientation of this 3D triangle.
      Throws:
      IllegalArgumentException - Raised if provided threshold is negative.
      CoincidentPointsException - Raised if vertices of this triangle are too close to each other.
    • orientation

      public void orientation(double[] result) throws CoincidentPointsException
      Computes orientation of this 3D triangle and stores the result in provided array.
      Parameters:
      result - Array where orientation is stored.
      Throws:
      IllegalArgumentException - Raised if provided array does not have length 3.
      CoincidentPointsException - Raised if vertices of this triangle are too close to each other.
    • orientation

      public void orientation(double[] result, double threshold) throws CoincidentPointsException
      Computes orientation of this 3D triangle and stores the result in provided array.
      Parameters:
      result - Array where orientation is stored.
      threshold - Threshold to determine whether vertices of this triangle are coincident or not.
      Throws:
      IllegalArgumentException - Raised if provided threshold is negative or if provided array does not have length 3.
      CoincidentPointsException - Raised if vertices of this triangle are too close to each other.
    • orientation

      public static double[] orientation(Triangle3D triangle) throws CoincidentPointsException
      Returns orientation of provided 3D triangle.
      Parameters:
      triangle - A triangle.
      Returns:
      Array containing orientation of provided 3D triangle.
      Throws:
      CoincidentPointsException - Raised if vertices of provided triangle are too close to each other.
    • orientation

      public static double[] orientation(Triangle3D triangle, double threshold) throws CoincidentPointsException
      Returns orientation of provided 3D triangle.
      Parameters:
      triangle - A triangle.
      threshold - Threshold to determine whether vertices of provided triangle are coincident or not.
      Returns:
      Array containing orientation of provided 3D triangle.
      Throws:
      IllegalArgumentException - Raised if provided threshold is negative.
      CoincidentPointsException - Raised if vertices of this triangle are too close to each other.
    • orientation

      public static void orientation(Triangle3D triangle, double[] result) throws CoincidentPointsException
      Computes orientation of provided 3D triangle and stores the result in provided array.
      Parameters:
      triangle - A triangle.
      result - Array where orientation is stored.
      Throws:
      IllegalArgumentException - Raised if provided array does not have length 3.
      CoincidentPointsException - Raised if vertices of provided triangle are too close to each other.
    • orientation

      public static void orientation(Triangle3D triangle, double[] result, double threshold) throws CoincidentPointsException
      Computes orientation of provided 3D triangle and stores the result in provided array.
      Parameters:
      triangle - A triangle.
      result - Array where orientation is stored.
      threshold - Threshold to determine whether vertices of provided triangle are coincident or not.
      Throws:
      IllegalArgumentException - Raised if provided threshold is negative or if array does not have length 3.
      CoincidentPointsException - Raised if vertices of provided triangle are too close to each other.
    • orientation

      public static double[] orientation(Point3D vertex1, Point3D vertex2, Point3D vertex3) throws CoincidentPointsException
      Returns orientation of 3D triangle formed by provided vertices.
      Parameters:
      vertex1 - 1st vertex.
      vertex2 - 2nd vertex.
      vertex3 - 3rd vertex.
      Returns:
      Array containing triangle orientation.
      Throws:
      CoincidentPointsException - Raised if provided vertices are too close to each other.
    • orientation

      public static double[] orientation(Point3D vertex1, Point3D vertex2, Point3D vertex3, double threshold) throws CoincidentPointsException
      Returns orientation of 3D triangle formed by provided vertices.
      Parameters:
      vertex1 - 1st vertex.
      vertex2 - 2nd vertex.
      vertex3 - 3rd vertex.
      threshold - Threshold to determine whether provided vertices are coincident or not.
      Returns:
      Array containing triangle orientation.
      Throws:
      IllegalArgumentException - Raised if provided threshold is negative.
      CoincidentPointsException - Raised if provided vertices are too close to each other.
    • orientation

      public static void orientation(Point3D vertex1, Point3D vertex2, Point3D vertex3, double[] result) throws CoincidentPointsException
      Computes orientation of 3D triangle formed by provided vertices and stores the result in provided array.
      Parameters:
      vertex1 - 1st vertex.
      vertex2 - 2nd vertex.
      vertex3 - 3rd vertex.
      result - Array where triangle orientation is stored.
      Throws:
      IllegalArgumentException - Raised if provided array does not have length 3.
      CoincidentPointsException - Raised if provided vertices are too close to each other.
    • orientation

      public static void orientation(Point3D vertex1, Point3D vertex2, Point3D vertex3, double[] result, double threshold) throws CoincidentPointsException
      Computes orientation of 3D triangle formed by provided vertices and stores the result in provided array.
      Parameters:
      vertex1 - 1st vertex.
      vertex2 - 2nd vertex.
      vertex3 - 3rd vertex.
      result - Array where triangle orientation is stored.
      threshold - Threshold to determine whether provided vertices are coincident or not.
      Throws:
      IllegalArgumentException - Raised if threshold is negative or if provided array does not have length 3.
      CoincidentPointsException - Raised if provided vertices are too close to each other.
    • getAngleBetweenTriangles

      public static double getAngleBetweenTriangles(Triangle3D triangle1, Triangle3D triangle2) throws CoincidentPointsException
      Returns the angle formed by the two provided triangles, assuming that each triangle forms a plane.
      Parameters:
      triangle1 - 1st triangle.
      triangle2 - 2nd triangle.
      Returns:
      Angle formed by the two provided triangles expressed in radians.
      Throws:
      CoincidentPointsException - Raised if vertices in a triangle are too close. This usually indicates numerical instability or triangle degeneracy.
    • getAngleBetweenTriangles

      private static double getAngleBetweenTriangles(double[] orientation1, double[] orientation2)
      Internal method to compute the angle between two triangles using the vectors containing the director vector of their corresponding planes (i.e. their orientations).
      Parameters:
      orientation1 - Orientation of 1st triangle.
      orientation2 - Orientation of 2nd triangle.
      Returns:
      Angle formed by the two triangles expressed in radians.
      Throws:
      IllegalArgumentException - Raised if provided orientation arrays don't have length 3.