Class OrientedPoint
- java.lang.Object
-
- org.apache.commons.geometry.core.partitioning.AbstractHyperplane<Vector1D>
-
- org.apache.commons.geometry.euclidean.oned.OrientedPoint
-
- All Implemented Interfaces:
Hyperplane<Vector1D>
public final class OrientedPoint extends AbstractHyperplane<Vector1D>
This class represents a 1D oriented hyperplane.A hyperplane in 1D is a simple point, its orientation being a boolean indicating if the direction is positive or negative.
Instances of this class are guaranteed to be immutable.
- See Also:
OrientedPoints
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
OrientedPoint.OrientedPointConvexSubset
HyperplaneConvexSubset
implementation for Euclidean 1D space.
-
Field Summary
Fields Modifier and Type Field Description private Vector1D
point
Hyperplane location as a point.private boolean
positiveFacing
Hyperplane direction.
-
Constructor Summary
Constructors Constructor Description OrientedPoint(Vector1D point, boolean positiveFacing, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)
Simple constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HyperplaneLocation
classify(double location)
Classify the number line location with respect to the instance.HyperplaneLocation
classify(Vector1D pt)
Classify a point with respect to this hyperplane.boolean
eq(OrientedPoint other, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)
Return true if this instance should be considered equivalent to the argument, using the given precision context for comparison.boolean
equals(java.lang.Object obj)
Vector1D.Unit
getDirection()
Get the direction of the hyperplane's plus side.double
getLocation()
Get the location of the hyperplane as a single value.Vector1D
getPoint()
Get the location of the hyperplane as a point.int
hashCode()
boolean
isPositiveFacing()
Return true if the hyperplane is oriented with its plus side in the direction of positive infinity.double
offset(double location)
Compute the offset of the given number line location.double
offset(Vector1D pt)
Get the offset (oriented distance) of a point with respect to this instance.Vector1D
project(Vector1D pt)
Project a point onto this instance.OrientedPoint
reverse()
Return a hyperplane that has the opposite orientation as this instance.boolean
similarOrientation(Hyperplane<Vector1D> other)
Return true if this instance has a similar orientation to the given hyperplane, meaning that they point in generally the same direction.HyperplaneConvexSubset<Vector1D>
span()
Return aHyperplaneConvexSubset
spanning this entire hyperplane.java.lang.String
toString()
OrientedPoint
transform(Transform<Vector1D> transform)
Transform this instance using the givenTransform
.-
Methods inherited from class org.apache.commons.geometry.core.partitioning.AbstractHyperplane
contains, getPrecision
-
-
-
-
Field Detail
-
point
private final Vector1D point
Hyperplane location as a point.
-
positiveFacing
private final boolean positiveFacing
Hyperplane direction.
-
-
Constructor Detail
-
OrientedPoint
OrientedPoint(Vector1D point, boolean positiveFacing, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)
Simple constructor.- Parameters:
point
- location of the hyperplanepositiveFacing
- if true, the hyperplane will face toward positive infinity; otherwise, it will point toward negative infinity.precision
- precision context used to compare floating point values
-
-
Method Detail
-
getPoint
public Vector1D getPoint()
Get the location of the hyperplane as a point.- Returns:
- the hyperplane location as a point
- See Also:
getLocation()
-
getLocation
public double getLocation()
Get the location of the hyperplane as a single value. This is equivalent topt.getPoint().getX()
.- Returns:
- the location of the hyperplane as a single value.
- See Also:
getPoint()
-
getDirection
public Vector1D.Unit getDirection()
Get the direction of the hyperplane's plus side.- Returns:
- the hyperplane direction
-
isPositiveFacing
public boolean isPositiveFacing()
Return true if the hyperplane is oriented with its plus side in the direction of positive infinity.- Returns:
- true if the hyperplane is facing toward positive infinity
-
reverse
public OrientedPoint reverse()
Return a hyperplane that has the opposite orientation as this instance. That is, the plus side of this instance is the minus side of the returned instance and vice versa.- Returns:
- a hyperplane with the opposite orientation
-
transform
public OrientedPoint transform(Transform<Vector1D> transform)
Transform this instance using the givenTransform
.- Parameters:
transform
- object to transform this instance with- Returns:
- a new, transformed hyperplane
-
offset
public double offset(Vector1D pt)
Get the offset (oriented distance) of a point with respect to this instance. Points with an offset of zero lie on the hyperplane itself.- Parameters:
pt
- the point to compute the offset for- Returns:
- the offset of the point
-
offset
public double offset(double location)
Compute the offset of the given number line location. This is a convenience overload ofoffset(Vector1D)
for use in one dimension.- Parameters:
location
- the number line location to compute the offset for- Returns:
- the offset of the location from the instance
-
classify
public HyperplaneLocation classify(Vector1D pt)
Classify a point with respect to this hyperplane.- Specified by:
classify
in interfaceHyperplane<Vector1D>
- Overrides:
classify
in classAbstractHyperplane<Vector1D>
- Parameters:
pt
- the point to classify- Returns:
- the relative location of the point with respect to this instance
-
classify
public HyperplaneLocation classify(double location)
Classify the number line location with respect to the instance. This is a convenience overload ofclassify(Vector1D)
for use in one dimension.- Parameters:
location
- the number line location to classify- Returns:
- the classification of the number line location with respect to this instance
-
similarOrientation
public boolean similarOrientation(Hyperplane<Vector1D> other)
Return true if this instance has a similar orientation to the given hyperplane, meaning that they point in generally the same direction. This method is not used to determine exact equality of hyperplanes, but rather to determine whether two hyperplanes that contain the same points are parallel (point in the same direction) or anti-parallel (point in opposite directions).- Parameters:
other
- the hyperplane to compare with- Returns:
- true if the hyperplanes point in generally the same direction and could possibly be parallel
-
project
public Vector1D project(Vector1D pt)
Project a point onto this instance.- Parameters:
pt
- the point to project- Returns:
- the projection of the point onto this instance. The returned point lies on the hyperplane.
-
span
public HyperplaneConvexSubset<Vector1D> span()
Return aHyperplaneConvexSubset
spanning this entire hyperplane. The returned subset contains all points lying in this hyperplane and no more.Since there are no subspaces in 1D, this method effectively returns a stub implementation of
HyperplaneConvexSubset
, the main purpose of which is to support the proper functioning of the partitioning code.- Returns:
- a
HyperplaneConvexSubset
containing all points lying in this hyperplane
-
eq
public boolean eq(OrientedPoint other, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)
Return true if this instance should be considered equivalent to the argument, using the given precision context for comparison.Instances are considered equivalent if they
- have equivalent locations and
- point in the same direction.
- Parameters:
other
- the point to compare withprecision
- precision context to use for the comparison- Returns:
- true if this instance should be considered equivalent to the argument
- See Also:
Vector1D.eq(Vector1D, Precision.DoubleEquivalence)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-