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 TypeMethodDescriptionvoid
add
(double xToAdd, double yToAdd) Arithmetically adds twodouble
values, to the X- and Y- dimensions.void
add
(int xToAdd, int yToAdd) Arithmetically adds twoint
values, to the X- and Y- dimensions.void
Arithmetically adds aPoint2d
's values across each dimension.void
Arithmetically adds aPoint2i
's values across each dimension.double
The square of the Euclidean distance between this point and anotherPoint2d
.double
distanceSquared
(Point2d point) The square of the Euclidean distance between this point and anotherPoint2d
.boolean
int
hashCode()
void
scale
(double factor) Arithmetically multiplies each dimension's value by a factor.toString()
double
x()
X-axis component of point.double
y()
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 newPoint2d
instance.- 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 twoint
values, 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 twodouble
values, 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.
-