Class Line3D

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

public class Line3D extends Object implements Serializable
This class defines a lines in 3D space. A line in 3D space is defined as the intersection of two non-parallel planes.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Positive threshold determine whether points lay inside (is locus) of a given line or not.
    private static final int
    Constant defining the size of vector that define the direction of a line
    static final double
    Minimum allowed threshold
    private Plane
    1st plane forming this 3D line.
    private Plane
    2nd plane forming this 3D line.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Line3D(Plane plane1, Plane plane2)
    Constructor.
    Line3D(Point3D point1, Point3D point2)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    areCoincidentPlanes(Plane plane1, Plane plane2)
    Determines whether provided planes are coincident.
    void
    closestPoint(Point3D point, Point3D result)
    Computes closest point belonging to this 3D line respect provided point and stores the result in provided instance.
    void
    closestPoint(Point3D point, Point3D result, double threshold)
    Computes closest point belonging to this 3D line respect provided point up to provided threshold and stores the result in provided instance.
    Returns closest point belonging to this 3D line respect provided point.
    getClosestPoint(Point3D point, double threshold)
    Returns closest point belonging to this 3D line respect provided point up to provided threshold.
    double[]
    Returns array containing vector that indicates the direction of this 3D line.
    double
    Returns shortest distance of provided point to this 3D line.
    Returns point where provided point intersects this 3D line.
    Returns 1st plane determining this 3D line.
    Returns 2nd plane determining this 3D line.
    void
    intersection(Plane plane, Point3D result)
    Computes point where provided point intersects this 3D line and stores the result in provided instance.
    boolean
    Raised if provided point is locus of this 3D line.
    boolean
    isLocus(Point3D point, double threshold)
    Determines if provided point is locus of this 3D line up to provided threshold.
    boolean
    Determines whether the planes forming this 3D line are normalized or not.
    void
    Normalize the planes forming this 3D line.
    final void
    setPlanes(Plane plane1, Plane plane2)
    Sets intersecting planes for this 3D line.
    final void
    Sets planes of this 3D line so that it passes through provided points.

    Methods inherited from class java.lang.Object

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

    • DEFAULT_LOCUS_THRESHOLD

      public static final double DEFAULT_LOCUS_THRESHOLD
      Positive threshold determine whether points lay inside (is locus) of a given line or not.
      See Also:
    • MIN_THRESHOLD

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

      private static final int INHOM_VECTOR_SIZE
      Constant defining the size of vector that define the direction of a line
      See Also:
    • plane1

      private Plane plane1
      1st plane forming this 3D line.
    • plane2

      private Plane plane2
      2nd plane forming this 3D line.
  • Constructor Details

    • Line3D

      public Line3D(Plane plane1, Plane plane2) throws CoincidentPlanesException
      Constructor. Sets planes intersecting into this 3D line.
      Parameters:
      plane1 - 1st plane.
      plane2 - 2nd plane.
      Throws:
      CoincidentPlanesException - Raised if provided planes are coincident and hence never intersect. Notice that parallel planes are not coincident and they intersect at infinity.
    • Line3D

      public Line3D(Point3D point1, Point3D point2) throws CoincidentPointsException
      Constructor. Builds a 3D line passing through provided 2 points.
      Parameters:
      point1 - 1st point.
      point2 - 2nd point.
      Throws:
      CoincidentPointsException - Raised if provided points are considered to be equal.
  • Method Details

    • areCoincidentPlanes

      public static boolean areCoincidentPlanes(Plane plane1, Plane plane2)
      Determines whether provided planes are coincident. Two planes are considered coincident if they are equal up to scale.
      Parameters:
      plane1 - 1st plane.
      plane2 - 2nd plane.
      Returns:
      True if planes are coincident, false otherwise.
    • setPlanes

      public final void setPlanes(Plane plane1, Plane plane2) throws CoincidentPlanesException
      Sets intersecting planes for this 3D line. The intersection of provided planes will determine this 3D line.
      Parameters:
      plane1 - 1st plane.
      plane2 - 2nd plane.
      Throws:
      CoincidentPlanesException - Raised if provided planes are coincident. Notice that parallel planes are not coincident and they intersect at infinity.
    • setPlanesFromPoints

      public final void setPlanesFromPoints(Point3D point1, Point3D point2) throws CoincidentPointsException
      Sets planes of this 3D line so that it passes through provided points.
      Parameters:
      point1 - 1st point.
      point2 - 2nd point.
      Throws:
      CoincidentPointsException - Raised if provided points are equal and hence a line cannot be determined.
    • getPlane1

      public Plane getPlane1()
      Returns 1st plane determining this 3D line. The intersection of plane1 and plane2 determines this 3D line.
      Returns:
      1st plane.
    • getPlane2

      public Plane getPlane2()
      Returns 2nd plane determining this 3D line. The intersection of plane1 and plane2 determines this 3D line.
      Returns:
      2nd plane.
    • isLocus

      public boolean isLocus(Point3D point, double threshold)
      Determines if provided point is locus of this 3D line up to provided threshold.
      Parameters:
      point - Point to be checked.
      threshold - Threshold to determine if provided point is locus or not. This should usually be a small value.
      Returns:
      True if provided point belongs to this 3D line, false otherwise.
      Throws:
      IllegalArgumentException - Raised if provided threshold is negative.
    • isLocus

      public boolean isLocus(Point3D point)
      Raised if provided point is locus of this 3D line.
      Parameters:
      point - Point to be checked.
      Returns:
      True if provided point belongs to this 3D line, false otherwise.
    • getDistance

      public double getDistance(Point3D point)
      Returns shortest distance of provided point to this 3D line. The shortest distance is obtained in perpendicular direction of this line.
      Parameters:
      point - Point to be checked.
      Returns:
      Shortest distance of provided point to this 3D line.
    • getClosestPoint

      public Point3D getClosestPoint(Point3D point)
      Returns closest point belonging to this 3D line respect provided point.
      Parameters:
      point - Point to be checked.
      Returns:
      Closest point belonging to this 3D line respect provided point.
    • getClosestPoint

      public Point3D getClosestPoint(Point3D point, double threshold)
      Returns closest point belonging to this 3D line respect provided point up to provided threshold.
      Parameters:
      point - Point to be checked.
      threshold - Threshold to determine the closest point.
      Returns:
      Closest point belonging to this 3D line respect provided point.
      Throws:
      IllegalArgumentException - Raised if provided threshold is negative.
    • closestPoint

      public void closestPoint(Point3D point, Point3D result)
      Computes closest point belonging to this 3D line respect provided point and stores the result in provided instance.
      Parameters:
      point - Point to be checked.
      result - Instance where computed point will be stored.
    • closestPoint

      public void closestPoint(Point3D point, Point3D result, double threshold)
      Computes closest point belonging to this 3D line respect provided point up to provided threshold and stores the result in provided instance.
      Parameters:
      point - Point to be checked.
      result - Instance where computed point will be stored.
      threshold - Threshold to determine the closest point.
      Throws:
      IllegalArgumentException - Raised if provided threshold is negative.
    • normalize

      public void normalize()
      Normalize the planes forming this 3D line.
    • isNormalized

      public boolean isNormalized()
      Determines whether the planes forming this 3D line are normalized or not.
      Returns:
      True if planes forming this 3D line are normalized, false otherwise.
    • getDirection

      public double[] getDirection()
      Returns array containing vector that indicates the direction of this 3D line.
      Returns:
      Returns vector indicating the direction of this 3D line.
    • getIntersection

      public Point3D getIntersection(Plane plane) throws NoIntersectionException
      Returns point where provided point intersects this 3D line.
      Parameters:
      plane - Plane to intersect this 3D line.
      Returns:
      Point where provided point intersects this 3D line.
      Throws:
      NoIntersectionException - Raised if provided plane does not intersect this 3D line.
    • intersection

      public void intersection(Plane plane, Point3D result) throws NoIntersectionException
      Computes point where provided point intersects this 3D line and stores the result in provided instance.
      Parameters:
      plane - Plane to intersect this 3D line.
      result - Instance where computes point will be stored.
      Throws:
      NoIntersectionException - Raised if provided plane does not intersect this 3D line.