Package org.anchoranalysis.spatial.point
Class Point2d
Object
Point2d
- All Implemented Interfaces:
Serializable
A two-dimensional point of double values.
We consider a point to be a tuple representing a single physical point in space.
- Author:
- Owen Feehan
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(double xToAdd, double yToAdd) Arithmetically adds twodoublevalues, to the X- and Y- dimensions.voidadd(int xToAdd, int yToAdd) Arithmetically adds twointvalues, to the X- and Y- dimensions.voidArithmetically adds aPoint2d's values across each dimension.voidArithmetically adds aPoint2i's values across each dimension.doubleThe square of the Euclidean distance between this point and anotherPoint2d.doubledistanceSquared(Point2d point) The square of the Euclidean distance between this point and anotherPoint2d.booleaninthashCode()voidscale(double factor) Arithmetically multiplies each dimension's value by a factor.toString()doublex()X-axis component of point.doubley()Y-axis component of point.
-
Constructor Details
-
Point2d
Creates with the same values as an existingPoint2d.- Parameters:
point- to copy values from.
-
Point2d
public Point2d(double x, double y) Creates a newPoint2dinstance.- Parameters:
x- X-axis component of point.y- Y-axis component of point.
-
Point2d
public Point2d()
-
-
Method Details
-
add
Arithmetically adds aPoint2i's values across each dimension.- Parameters:
toAdd- tuple to add to current state.
-
add
Arithmetically adds aPoint2d's values across each dimension.- Parameters:
toAdd- tuple to add to current state.
-
add
public void add(int xToAdd, int yToAdd) Arithmetically adds twointvalues, to the X- and Y- dimensions.- Parameters:
xToAdd- x-value to add to current state.yToAdd- y-value to add to current state.
-
add
public void add(double xToAdd, double yToAdd) Arithmetically adds twodoublevalues, to the X- and Y- dimensions.- Parameters:
xToAdd- x-value to add to current state.yToAdd- y-value to add to current state.
-
scale
public void scale(double factor) Arithmetically multiplies each dimension's value by a factor.- Parameters:
factor- the factor to multiply by.
-
distance
The square of the Euclidean distance between this point and anotherPoint2d.- Parameters:
point- the other point to a measure a distance to.- Returns:
- the distance squared.
-
distanceSquared
The square of the Euclidean distance between this point and anotherPoint2d.- Parameters:
point- the other point to a measure a distance to.- Returns:
- the distance squared.
-
toString
-
equals
-
hashCode
public int hashCode() -
x
public double x()X-axis component of point. -
y
public double y()Y-axis component of point.
-