Class InhomogeneousPoint3D

java.lang.Object
com.irurueta.geometry.Point3D
com.irurueta.geometry.InhomogeneousPoint3D
All Implemented Interfaces:
Point<Point3D>, Serializable

public class InhomogeneousPoint3D extends Point3D implements Serializable
Subclass of Point3D defining an inhomogeneous 3D point. An inhomogeneous 3D point is defined by three coordinates: (x, y, z), where x, y and z are the horizontal, vertical and depth coordinates, respectively. Homogeneous 3D points can be transformed into inhomogeneous ones by normalizing x, y and z coordinates by the w factor as follows: Homogeneous 3D point (x,y,z,w) -< Inhomogeneous 3D point (x/w,y/w,z/w). Note that if and homogeneous 3D point is at infinity (w=0), its corresponding inhomogeneous point will be at infinity by setting (x=inf,y=inf,z=inf). Because of this, and because of machine precision, usually Homogeneous points are better suited when working at far distances or for numerical purposes, and their inhomogeneous counterparts are better suited when computing Euclidean distances, etc.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private double
    Defines the X coordinate of an inhomogeneous 2D point.
    private double
    Defines the Y coordinate of an inhomogeneous 2D point.
    private double
    Defines the Z coordinate of an inhomogeneous 2D point.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Empty constructor.
    Constructor of this class.
    InhomogeneousPoint3D(double x, double y, double z)
    Constructor of this class.
    This constructor sets a new inhomogeneous 3D point using as initialization provided Point3D instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    double[]
    Returns an array containing the coordinates of this Point3D.
    void
    asArray(double[] array)
    Uses provided array to store the coordinates of this InhomogeneousPoint3D
    boolean
    Checks if the homogeneous 3D point described by this instance equals the input HomogeneousPoint3D (using a comparison threshold).
    boolean
    equals(HomogeneousPoint3D point, double threshold)
    Checks if the homogeneous 3D point described by this instance equals the input HomogeneousPoint3D (using a comparison threshold).
    boolean
    Checks if the homogeneous 3D point described by this instance equals the input InhomogeneousPoint3D (using a comparison threshold).
    boolean
    equals(InhomogeneousPoint3D point, double threshold)
    Checks if the homogeneous 3D point described by this instance equals the input InhomogeneousPoint3D (using a comparison threshold).
    boolean
    equals(Point3D point, double threshold)
    Checks if the homogeneous 3D point described by this instance equals the input Point3D (using a comparison threshold).
    boolean
    Checks if provided object equals current 2D point.
    double
    Returns W homogeneous coordinate of this 3D point.
    double
    Returns X homogeneous coordinate of this 3D point.
    double
    Returns Y homogeneous coordinate of this 3D point.
    double
    Returns Z homogeneous coordinate of this 3D point.
    double
    Returns X inhomogeneous coordinate of this 3D point.
    double
    Returns Y inhomogeneous coordinate of this 3D point.
    double
    Returns Z inhomogeneous coordinate of this 3D point.
    Returns the type of coordinates used to represent a Point3D.
    double
    Returns the X coordinate of the given homogeneous 3D point instance.
    double
    Returns the Y coordinate of the given homogeneous 3D point instance.
    double
    Returns the Z coordinate of the given homogeneous 3D point instance.
    int
    Returns hash code value.
    boolean
    Checks whether this Point3D is at infinity or not.
    final void
    setCoordinates(double[] v)
    Sets the coordinates of a 3D point using an array containing its coordinates.
    void
    setCoordinates(double x, double y, double z)
    Sets the coordinates of this inhomogeneous 3D point by using provided X, Y and Z coordinates.
    final void
    Sets coordinates of this instance using the coordinates of provided 3D point.
    void
    setHomogeneousCoordinates(double homX, double homY, double homZ, double homW)
    Sets coordinates of this 3D point instance using provided homogeneous coordinates.
    void
    setInhomogeneousCoordinates(double inhomX, double inhomY, double inhomZ)
    Sets coordinates of this 3D point instance using provided inhomogeneous coordinates.
    void
    setInhomX(double inhomX)
    Sets X inhomogeneous coordinate of this 3D point.
    void
    setInhomY(double inhomY)
    Sets Y inhomogeneous coordinate of this 3D point.
    void
    setInhomZ(double inhomZ)
    Sets Z inhomogeneous coordinate of this 3D point.
    void
    setX(double x)
    Sets the X coordinate of this homogeneous point.
    void
    setY(double y)
    Sets the Y coordinate of this homogeneous point.
    void
    setZ(double z)
    Sets the Z coordinate of this homogeneous point.
    Converts this instance into an homogeneous 3D point and returns the result as a new homogeneous 3D point instance.

    Methods inherited from class java.lang.Object

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

    • x

      private double x
      Defines the X coordinate of an inhomogeneous 2D point.
    • y

      private double y
      Defines the Y coordinate of an inhomogeneous 2D point.
    • z

      private double z
      Defines the Z coordinate of an inhomogeneous 2D point.
  • Constructor Details

    • InhomogeneousPoint3D

      public InhomogeneousPoint3D()
      Empty constructor.
    • InhomogeneousPoint3D

      public InhomogeneousPoint3D(double[] v)
      Constructor of this class. This constructor sets a new inhomogeneous v array containing the coordinates X, Y and Z of the given point.
      Parameters:
      v - Array of length 3 containing the 3D coordinates of an inhomogeneous point.
      Throws:
      IllegalArgumentException - Raised when the size of the array is not 2.
    • InhomogeneousPoint3D

      public InhomogeneousPoint3D(double x, double y, double z)
      Constructor of this class. This constructor sets a new inhomogeneous 3D point using the coordinates x, y and z of the given point.
      Parameters:
      x - X coordinate of the given 3D point.
      y - Y coordinate of the given 3D point.
      z - Z coordinate of the given 3D point.
    • InhomogeneousPoint3D

      public InhomogeneousPoint3D(Point3D point)
      This constructor sets a new inhomogeneous 3D point using as initialization provided Point3D instance.
      Parameters:
      point - Point to initialize new instance to.
  • Method Details

    • getX

      public double getX()
      Returns the X coordinate of the given homogeneous 3D point instance.
      Returns:
      X coordinate.
    • setX

      public void setX(double x)
      Sets the X coordinate of this homogeneous point.
      Parameters:
      x - X coordinate.
    • getY

      public double getY()
      Returns the Y coordinate of the given homogeneous 3D point instance.
      Returns:
      Y coordinate.
    • setY

      public void setY(double y)
      Sets the Y coordinate of this homogeneous point.
      Parameters:
      y - Y coordinate.
    • getZ

      public double getZ()
      Returns the Z coordinate of the given homogeneous 3D point instance.
      Returns:
      Z coordinate.
    • setZ

      public void setZ(double z)
      Sets the Z coordinate of this homogeneous point.
      Parameters:
      z - Z coordinate.
    • setCoordinates

      public void setCoordinates(double x, double y, double z)
      Sets the coordinates of this inhomogeneous 3D point by using provided X, Y and Z coordinates.
      Parameters:
      x - X coordinate.
      y - Y coordinate.
      z - Z coordinate.
    • setCoordinates

      public final void setCoordinates(double[] v)
      Sets the coordinates of a 3D point using an array containing its coordinates.
      Specified by:
      setCoordinates in class Point3D
      Parameters:
      v - Array containing the coordinates of the point.
      Throws:
      IllegalArgumentException - Raised if provided array does not have a valid size.
    • setCoordinates

      public final void setCoordinates(Point3D point)
      Sets coordinates of this instance using the coordinates of provided 3D point.
      Specified by:
      setCoordinates in class Point3D
      Parameters:
      point - Input point.
    • getHomX

      public double getHomX()
      Returns X homogeneous coordinate of this 3D point.
      Specified by:
      getHomX in class Point3D
      Returns:
      X homogeneous coordinate.
    • getHomY

      public double getHomY()
      Returns Y homogeneous coordinate of this 3D point.
      Specified by:
      getHomY in class Point3D
      Returns:
      Y homogeneous coordinate.
    • getHomZ

      public double getHomZ()
      Returns Z homogeneous coordinate of this 3D point.
      Specified by:
      getHomZ in class Point3D
      Returns:
      Z homogeneous coordinate.
    • getHomW

      public double getHomW()
      Returns W homogeneous coordinate of this 3D point.
      Specified by:
      getHomW in class Point3D
      Returns:
      W homogeneous coordinate.
    • setHomogeneousCoordinates

      public void setHomogeneousCoordinates(double homX, double homY, double homZ, double homW)
      Sets coordinates of this 3D point instance using provided homogeneous coordinates.
      Specified by:
      setHomogeneousCoordinates in class Point3D
      Parameters:
      homX - x homogeneous coordinate.
      homY - y homogeneous coordinate.
      homZ - z homogeneous coordinate.
      homW - w homogeneous coordinate.
    • getInhomX

      public double getInhomX()
      Returns X inhomogeneous coordinate of this 3D point.
      Specified by:
      getInhomX in class Point3D
      Returns:
      X inhomogeneous coordinate.
    • setInhomX

      public void setInhomX(double inhomX)
      Sets X inhomogeneous coordinate of this 3D point.
      Specified by:
      setInhomX in class Point3D
      Parameters:
      inhomX - inhomogeneous coordinate.
    • getInhomY

      public double getInhomY()
      Returns Y inhomogeneous coordinate of this 3D point.
      Specified by:
      getInhomY in class Point3D
      Returns:
      Y inhomogeneous coordinate.
    • setInhomY

      public void setInhomY(double inhomY)
      Sets Y inhomogeneous coordinate of this 3D point.
      Specified by:
      setInhomY in class Point3D
      Parameters:
      inhomY - Y inhomogeneous coordinate.
    • getInhomZ

      public double getInhomZ()
      Returns Z inhomogeneous coordinate of this 3D point.
      Specified by:
      getInhomZ in class Point3D
      Returns:
      Z inhomogeneous coordinate.
    • setInhomZ

      public void setInhomZ(double inhomZ)
      Sets Z inhomogeneous coordinate of this 3D point.
      Specified by:
      setInhomZ in class Point3D
      Parameters:
      inhomZ - Z inhomogeneous coordinate.
    • setInhomogeneousCoordinates

      public void setInhomogeneousCoordinates(double inhomX, double inhomY, double inhomZ)
      Sets coordinates of this 3D point instance using provided inhomogeneous coordinates.
      Specified by:
      setInhomogeneousCoordinates in class Point3D
      Parameters:
      inhomX - x inhomogeneous coordinate.
      inhomY - y inhomogeneous coordinate.
      inhomZ - z inhomogeneous coordinate.
    • equals

      public boolean equals(Object obj)
      Checks if provided object equals current 2D point.
      Overrides:
      equals in class Point3D
      Parameters:
      obj - Object to compare.
      Returns:
      True if both objects are considered to be equal, false otherwise.
    • hashCode

      public int hashCode()
      Returns hash code value.
      Specified by:
      hashCode in class Point3D
      Returns:
      Hash code value.
    • equals

      public boolean equals(Point3D point, double threshold)
      Checks if the homogeneous 3D point described by this instance equals the input Point3D (using a comparison threshold).
      Specified by:
      equals in class Point3D
      Parameters:
      point - Point that will be compared to.
      threshold - threshold grade of tolerance to determine whether the points are equal or not. It is used because due to machine precision, the values might not be exactly equal (if not provided DEFAULT_COMPARISON_THRESHOLD is used).
      Returns:
      True if current point and input point are the same, false otherwise.
      Throws:
      IllegalArgumentException - Raised if threshold is negative.
    • equals

      public boolean equals(HomogeneousPoint3D point, double threshold)
      Checks if the homogeneous 3D point described by this instance equals the input HomogeneousPoint3D (using a comparison threshold).
      Parameters:
      point - Point that will be compared to.
      threshold - threshold grade of tolerance to determine whether the points are equal or not. It is used because due to machine precision, the values might not be exactly equal (if not provided DEFAULT_COMPARISON_THRESHOLD is used).
      Returns:
      True if current point and input point are the same, false otherwise.
      Throws:
      IllegalArgumentException - Raised if threshold is negative.
    • equals

      public boolean equals(HomogeneousPoint3D point)
      Checks if the homogeneous 3D point described by this instance equals the input HomogeneousPoint3D (using a comparison threshold).
      Parameters:
      point - Point that will be compared to.
      Returns:
      True if current point and input point are the same, false otherwise
    • equals

      public boolean equals(InhomogeneousPoint3D point, double threshold)
      Checks if the homogeneous 3D point described by this instance equals the input InhomogeneousPoint3D (using a comparison threshold).
      Parameters:
      point - Point that will be compared to.
      threshold - threshold grade of tolerance to determine whether the points are equal or not. It is used because due to machine precision, the values might not be exactly equal (if not provided DEFAULT_COMPARISON_THRESHOLD is used).
      Returns:
      True if current point and input point are the same, false otherwise.
      Throws:
      IllegalArgumentException - Raised if threshold is negative.
    • equals

      public boolean equals(InhomogeneousPoint3D point)
      Checks if the homogeneous 3D point described by this instance equals the input InhomogeneousPoint3D (using a comparison threshold).
      Parameters:
      point - Point that will be compared to.
      Returns:
      True if current point and input point are the same, false otherwise.
    • isAtInfinity

      public boolean isAtInfinity()
      Checks whether this Point3D is at infinity or not.
      Specified by:
      isAtInfinity in class Point3D
      Returns:
      True if the point is at infinity. False otherwise.
    • getType

      public CoordinatesType getType()
      Returns the type of coordinates used to represent a Point3D.
      Specified by:
      getType in class Point3D
      Returns:
      Type of coordinates of this 3D point.
    • toHomogeneous

      public HomogeneousPoint3D toHomogeneous()
      Converts this instance into an homogeneous 3D point and returns the result as a new homogeneous 3D point instance.
      Returns:
      Converts and returns this point as an homogeneous 3D point.
    • asArray

      public double[] asArray()
      Returns an array containing the coordinates of this Point3D.
      Specified by:
      asArray in class Point3D
      Returns:
      Array containing coordinates of this Point3D.
    • asArray

      public void asArray(double[] array)
      Uses provided array to store the coordinates of this InhomogeneousPoint3D
      Specified by:
      asArray in class Point3D
      Parameters:
      array - Array where coordinates will be stored.
      Throws:
      IllegalArgumentException - Raised if length of array is not 2.