Package org.anchoranalysis.spatial.point
Class Point3d
- All Implemented Interfaces:
Serializable
A three-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:
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
double
The Euclidean distance between this point and anotherPoint3d
.double
distanceSquared
(Point3d point) The square of the Euclidean distance between this point and anotherPoint3d
.double
distanceSquared
(Point3i point) The square of the Euclidean distance between this point and anotherPoint3i
.dropZ()
Creates a new point with identical x and y values, but with z set to 0.boolean
boolean
equalsTolerance
(Point3d other, double delta) Checks if this point is equal to anotherPoint3d
accepting a tolerance between double values.int
hashCode()
static Point3d
immutableAdd
(Point3d point, int x, int y, int z) Adds values to a point immutably.static Point3d
immutableAdd
(Tuple3d tuple1, Tuple3d tuple2) Adds two tuples immutably.static Point3d
immutableScale
(Tuple3d tuple, int factor) Scales a tuple immutably.static Point3d
immutableSubtract
(Tuple3d tuple, Tuple3d toSubtract) static Point3d
immutableSubtract
(Tuple3i tuple, Tuple3d toSubtract) max
(double val) Element-wise maximum between this point and a scalar.Element-wise maximum between this point and another.min
(ReadableTuple3i point) Element-wise minimum between this point and another.Element-wise minimum between this point and another.double[]
toArray()
Converts the point to an array.double[]
Converts the X and Y dimensions of the point to an array.Methods inherited from class org.anchoranalysis.spatial.point.Tuple3d
absolute, add, add, add, divideBy, divideBy, dotProduct, increment, incrementX, incrementY, incrementZ, length, normalize, scale, scaleXY, setValueByDimension, setX, setX, setY, setY, setZ, setZ, subtract, toString, valueByDimension, valueByDimension, x, y, z
-
Constructor Details
-
Point3d
Creates with the same values as an existingPoint3d
.- Parameters:
point
- to copy values from.
-
Point3d
Creates with the same values as an existingTuple3d
.- Parameters:
point
- to copy values from.
-
Point3d
public Point3d(double x, double y, double z) Create with values for each dimension.- Parameters:
x
- the value for the X-dimension.y
- the value for the Y-dimension.z
- the value for the Z-dimension.
-
Point3d
public Point3d()
-
-
Method Details
-
distance
The Euclidean distance between this point and anotherPoint3d
.- Parameters:
point
- the other point to a measure a distance to.- Returns:
- the distance.
-
distanceSquared
The square of the Euclidean distance between this point and anotherPoint3d
.- 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 anotherPoint3i
.- Parameters:
point
- the other point to a measure a distance to.- Returns:
- the distance squared.
-
dropZ
Creates a new point with identical x and y values, but with z set to 0.This is an immutable operation that does not affect current state.
- Returns:
- the new point.
-
min
Element-wise minimum between this point and another.- Parameters:
point
- the other point.- Returns:
- a new point containing the minimum of the x, y, z components.
-
min
Element-wise minimum between this point and another.- Parameters:
point
- the other point.- Returns:
- a new point containing the minimum of the x, y, z components.
-
max
Element-wise maximum between this point and a scalar.- Parameters:
val
- the scalar.- Returns:
- a new point containing the minimum of the x, y, z components.
-
equalsTolerance
Checks if this point is equal to anotherPoint3d
accepting a tolerance between double values.- Parameters:
other
- the other point to check for equality with.delta
- the maximum difference before two double values are considered to be unequal.- Returns:
- true iff all dimensions of the point are equal (within the tolerance).
-
toArray
public double[] toArray()Converts the point to an array.- Returns:
- a newly created array with three elements, respectively for x, y and z components.
-
toArrayXY
public double[] toArrayXY()Converts the X and Y dimensions of the point to an array.- Returns:
- a newly created array with two elements, respectively for x and y components.
-
max
Element-wise maximum between this point and another.- Parameters:
point
- the other point.- Returns:
- a new point containing the minimum of the x, y, z components.
-
immutableAdd
Adds two tuples immutably.- Parameters:
tuple1
- the first tuple to add.tuple2
- the second tuple to add.- Returns:
- a newly created point, where each dimension is the sum of the corresponding dimensions in the points.
-
immutableAdd
Adds values to a point immutably.- Parameters:
point
- the point to add.x
- the value to add to the X-component.y
- the value to add to the Y-component.z
- the value to add to the Z-component.- Returns:
- a newly created point, where each dimension is the sum of the corresponding dimensions in the points.
-
immutableSubtract
- Parameters:
tuple
- the tuple to subtract from.toSubtract
- the tuple to subtract.- Returns:
- a newly created point, where each dimension is the subtraction of the corresponding dimensions in the points.
-
immutableSubtract
- Parameters:
tuple
- the tuple to subtract from.toSubtract
- the tuple to subtract.- Returns:
- a newly created point, where each dimension is the subtraction of the corresponding dimensions in the points.
-
immutableScale
Scales a tuple immutably.- Parameters:
tuple
- the tuple to scale.factor
- what to multiply each dimension by.- Returns:
- a newly created point, where each component is scaled by
factor
.
-
equals
-
canEqual
-
hashCode
public int hashCode()
-