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>
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
HyperplaneConvexSubset
implementation for Euclidean 1D space. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Vector1D
Hyperplane location as a point.private final boolean
Hyperplane direction. -
Constructor Summary
ConstructorsConstructorDescriptionOrientedPoint
(Vector1D point, boolean positiveFacing, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Simple constructor. -
Method Summary
Modifier and TypeMethodDescriptionclassify
(double location) Classify the number line location with respect to the instance.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
Get the direction of the hyperplane's plus side.double
Get the location of the hyperplane as a single value.getPoint()
Get the location of the hyperplane as a point.int
hashCode()
boolean
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
Get the offset (oriented distance) of a point with respect to this instance.Project a point onto this instance.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.span()
Return aHyperplaneConvexSubset
spanning this entire hyperplane.toString()
Transform this instance using the givenTransform
.Methods inherited from class org.apache.commons.geometry.core.partitioning.AbstractHyperplane
contains, getPrecision
-
Field Details
-
point
Hyperplane location as a point. -
positiveFacing
private final boolean positiveFacingHyperplane direction.
-
-
Constructor Details
-
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 Details
-
getPoint
Get the location of the hyperplane as a point.- Returns:
- the hyperplane location as a point
- See Also:
-
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:
-
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
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
Transform this instance using the givenTransform
.- Parameters:
transform
- object to transform this instance with- Returns:
- a new, transformed hyperplane
-
offset
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
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
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
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
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
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:
-
hashCode
public int hashCode() -
equals
-
toString
-