Package com.irurueta.geometry
Class InhomogeneousPoint2D
java.lang.Object
com.irurueta.geometry.Point2D
com.irurueta.geometry.InhomogeneousPoint2D
- All Implemented Interfaces:
Point<Point2D>,Serializable
Subclass of Point2D defining an inhomogeneous 2D point.
An inhomogeneous 2D point is defined by two coordinates: (x, y), where x and
y are the horizontal and vertical coordinates, respectively.
Homogeneous 2D points can be transformed into inhomogeneous ones by
normalizing both x and y coordinates by the w factor as follows:
Homogeneous 2d point (x,y,w) -< Inhomogeneous 2D point (x/w,y/w).
Note that if and homogeneous 2D point is at infinity (w=0), its corresponding
inhomogeneous point will be at infinity by setting (x=inf,y=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
FieldsModifier and TypeFieldDescriptionprivate doubleDefines the X coordinate of an inhomogeneous 2D point.private doubleDefines the Y coordinate of an inhomogeneous 2D point.Fields inherited from class com.irurueta.geometry.Point2D
DEFAULT_COMPARISON_THRESHOLD, DEFAULT_COORDINATES_TYPE, MIN_THRESHOLD, POINT2D_HOMOGENEOUS_COORDINATES_LENGTH, POINT2D_INHOMOGENEOUS_COORDINATES_LENGTH -
Constructor Summary
ConstructorsConstructorDescriptionEmpty constructor.InhomogeneousPoint2D(double[] v) Constructor of this class.InhomogeneousPoint2D(double x, double y) Constructor of this class.InhomogeneousPoint2D(Point2D point) This constructor sets a new inhomogeneous 2D point using as initialization provided Point2D instance. -
Method Summary
Modifier and TypeMethodDescriptiondouble[]asArray()Returns an array containing the coordinates of this Point2D.voidasArray(double[] array) Uses provided array to store the coordinates of this InhomogeneousPoint2Dbooleanequals(HomogeneousPoint2D point) Checks if the homogeneous 2d point described by this instance equals the input HomogeneousPoint2d (using a comparison threshold).booleanequals(HomogeneousPoint2D point, double threshold) Checks if the homogeneous 2d point described by this instance equals the input HomogeneousPoint2d (using a comparison threshold).booleanequals(InhomogeneousPoint2D point) Checks if the homogeneous 2d point described by this instance equals the input InhomogeneousPoint2d (using a comparison threshold).booleanequals(InhomogeneousPoint2D point, double threshold) Checks if the homogeneous 2d point described by this instance equals the input InhomogeneousPoint2d (using a comparison threshold).booleanChecks if the homogeneous 2d point described by this instance equals the inputPoint2D(using a comparison threshold).booleanChecks if provided object equals current 2D point.doublegetHomW()Returns W homogeneous coordinate of this 2d point.doublegetHomX()Returns X homogeneous coordinate of this 2d point.doublegetHomY()Returns Y homogeneous coordinate of this 2d point.doubleReturns X inhomogeneous coordinate of this 2d point.doubleReturns Y inhomogeneous coordinate of this 2d point.getType()Returns the type of coordinates used to represent a Point2D.doublegetX()Returns the X coordinate of the given homogeneous 2D point instance.doublegetY()Returns the Y coordinate of the given homogeneous 2D point instance.inthashCode()Returns hash code value.booleanChecks whether this Point2D is at infinity or not.final voidsetCoordinates(double[] v) Sets the coordinates of a 2D point using an array containing its coordinates.voidsetCoordinates(double x, double y) Sets the coordinates of this inhomogeneous 2D point by using provided X and Y coordinates.final voidsetCoordinates(Point2D point) Sets coordinates of this instance using the coordinates of provided 2D point.voidsetHomogeneousCoordinates(double homX, double homY, double homW) Sets coordinates of this 2d point instance using provided homogeneous coordinates.voidsetInhomogeneousCoordinates(double inhomX, double inhomY) Sets coordinates of this 2d point instance using provided inhomogeneous coordinates.voidsetInhomX(double inhomX) Sets X inhomogeneous coordinate of this 2d point.voidsetInhomY(double inhomY) Sets Y inhomogeneous coordinate of this 2d point.voidsetX(double x) Sets the X coordinate of this homogeneous point.voidsetY(double y) Sets the Y coordinate of this homogeneous point.Converts this instance into an homogeneous 2D point and returns the result as a new homogeneous 2D point instance.Methods inherited from class com.irurueta.geometry.Point2D
create, create, create, create, distanceTo, dotProduct, equals, getDimensions, getInhomogeneousCoordinate, isBetween, isBetween, isNormalized, normalize, setInhomogeneousCoordinate, sqrDistanceTo
-
Field Details
-
x
private double xDefines the X coordinate of an inhomogeneous 2D point. -
y
private double yDefines the Y coordinate of an inhomogeneous 2D point.
-
-
Constructor Details
-
InhomogeneousPoint2D
public InhomogeneousPoint2D()Empty constructor. -
InhomogeneousPoint2D
public InhomogeneousPoint2D(double[] v) Constructor of this class. This constructor sets a new inhomogeneous v array containing the coordinates X and Y of the given point.- Parameters:
v- Array of length 2 containing the 2D coordinates of an inhomogeneous point.- Throws:
IllegalArgumentException- Raised when the size of the array is not 2.
-
InhomogeneousPoint2D
public InhomogeneousPoint2D(double x, double y) Constructor of this class. This constructor sets a new inhomogeneous 2D point using the coordinates x and y of the given point.- Parameters:
x- X coordinate of the given 2D point.y- Y coordinate of the given 2D point.
-
InhomogeneousPoint2D
This constructor sets a new inhomogeneous 2D point using as initialization provided Point2D instance.- Parameters:
point- Point to initialize new instance to.
-
-
Method Details
-
getX
public double getX()Returns the X coordinate of the given homogeneous 2D 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 2D point instance.- Returns:
- Y coordinate.
-
setY
public void setY(double y) Sets the Y coordinate of this homogeneous point.- Parameters:
y- Y coordinate.
-
setCoordinates
public void setCoordinates(double x, double y) Sets the coordinates of this inhomogeneous 2D point by using provided X and Y coordinates.- Parameters:
x- X coordinate.y- Y coordinate.
-
setCoordinates
public final void setCoordinates(double[] v) Sets the coordinates of a 2D point using an array containing its coordinates.- Specified by:
setCoordinatesin classPoint2D- Parameters:
v- Array containing the coordinates of the point.- Throws:
IllegalArgumentException- Raised if provided array does not have a valid size.
-
setCoordinates
Sets coordinates of this instance using the coordinates of provided 2D point.- Specified by:
setCoordinatesin classPoint2D- Parameters:
point- Input point.
-
getHomX
public double getHomX()Returns X homogeneous coordinate of this 2d point. -
getHomY
public double getHomY()Returns Y homogeneous coordinate of this 2d point. -
getHomW
public double getHomW()Returns W homogeneous coordinate of this 2d point. -
setHomogeneousCoordinates
public void setHomogeneousCoordinates(double homX, double homY, double homW) Sets coordinates of this 2d point instance using provided homogeneous coordinates.- Specified by:
setHomogeneousCoordinatesin classPoint2D- Parameters:
homX- x homogeneous coordinate.homY- y homogeneous coordinate.homW- w homogeneous coordinate.
-
getInhomX
public double getInhomX()Returns X inhomogeneous coordinate of this 2d point. -
setInhomX
public void setInhomX(double inhomX) Sets X inhomogeneous coordinate of this 2d point. -
getInhomY
public double getInhomY()Returns Y inhomogeneous coordinate of this 2d point. -
setInhomY
public void setInhomY(double inhomY) Sets Y inhomogeneous coordinate of this 2d point. -
setInhomogeneousCoordinates
public void setInhomogeneousCoordinates(double inhomX, double inhomY) Sets coordinates of this 2d point instance using provided inhomogeneous coordinates.- Specified by:
setInhomogeneousCoordinatesin classPoint2D- Parameters:
inhomX- x inhomogeneous coordinate.inhomY- y inhomogeneous coordinate.
-
equals
Checks if provided object equals current 2D point. -
hashCode
public int hashCode()Returns hash code value. -
equals
Checks if the homogeneous 2d point described by this instance equals the inputPoint2D(using a comparison threshold).- Specified by:
equalsin classPoint2D- 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
Checks if the homogeneous 2d point described by this instance equals the input HomogeneousPoint2d (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
Checks if the homogeneous 2d point described by this instance equals the input HomogeneousPoint2d (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
Checks if the homogeneous 2d point described by this instance equals the input InhomogeneousPoint2d (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
Checks if the homogeneous 2d point described by this instance equals the input InhomogeneousPoint2d (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 Point2D is at infinity or not.- Specified by:
isAtInfinityin classPoint2D- Returns:
- True if the point is at infinity. False otherwise.
-
getType
Returns the type of coordinates used to represent a Point2D. -
toHomogeneous
Converts this instance into an homogeneous 2D point and returns the result as a new homogeneous 2D point instance.- Returns:
- Converts and returns this point as an homogeneous 2D point.
-
asArray
public double[] asArray()Returns an array containing the coordinates of this Point2D. -
asArray
public void asArray(double[] array) Uses provided array to store the coordinates of this InhomogeneousPoint2D- Specified by:
asArrayin classPoint2D- Parameters:
array- Array where coordinates will be stored.- Throws:
IllegalArgumentException- Raised if length of array is not 2.
-