public final class Point2d extends Object implements Serializable
We consider a point to be a tuple representing a single physical point in space.
Constructor and Description |
---|
Point2d() |
Point2d(double x,
double y) |
Point2d(Point2d point)
Creates with the same values as an existing
Point2d . |
Modifier and Type | Method and Description |
---|---|
void |
add(double xToAdd,
double yToAdd)
Arithmetically adds two
double values, to the X- and Y- dimensions. |
void |
add(int xToAdd,
int yToAdd)
Arithmetically adds two
int values, to the X- and Y- dimensions. |
void |
add(Point2d toAdd)
Arithmetically adds a
Point2d 's values across each dimension. |
void |
add(Point2i toAdd)
Arithmetically adds a
Point2i 's values across each dimension. |
double |
distance(Point2d point)
The square of the Euclidean distance between this point and another
Point2d . |
double |
distanceSquared(Point2d point)
The square of the Euclidean distance between this point and another
Point2d . |
boolean |
equals(Object o) |
int |
hashCode() |
void |
scale(double factor)
Arithmetically multiplies each dimension's value by a factor.
|
String |
toString() |
double |
x()
X-axis component of point.
|
double |
y()
Y-axis component of point.
|
public Point2d(Point2d point)
Point2d
.point
- to copy values from.public Point2d(double x, double y)
public Point2d()
public void add(Point2i toAdd)
Point2i
's values across each dimension.toAdd
- tuple to add to current state.public void add(Point2d toAdd)
Point2d
's values across each dimension.toAdd
- tuple to add to current state.public void add(int xToAdd, int yToAdd)
int
values, to the X- and Y- dimensions.xToAdd
- x-value to add to current state.yToAdd
- y-value to add to current state.public void add(double xToAdd, double yToAdd)
double
values, to the X- and Y- dimensions.xToAdd
- x-value to add to current state.yToAdd
- y-value to add to current state.public void scale(double factor)
factor
- the factor to multiply by.public double distance(Point2d point)
Point2d
.point
- the other point to a measure a distance to.public double distanceSquared(Point2d point)
Point2d
.point
- the other point to a measure a distance to.public double x()
public double y()
Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.