Class CutAngle
- java.lang.Object
-
- org.apache.commons.geometry.core.partitioning.AbstractHyperplane<Point1S>
-
- org.apache.commons.geometry.spherical.oned.CutAngle
-
- All Implemented Interfaces:
Hyperplane<Point1S>
public final class CutAngle extends AbstractHyperplane<Point1S>
Class representing an oriented point in 1-dimensional spherical space, meaning an azimuth angle and a direction (increasing or decreasing angles) along the circle.Hyperplanes split the spaces they are embedded in into three distinct parts: the hyperplane itself, a plus side and a minus side. However, since spherical space wraps around, a single oriented point is not sufficient to partition the space; any point could be classified as being on the plus or minus side of a hyperplane depending on the direction that the circle is traversed. The approach taken in this class to address this issue is to (1) define a second, implicit cut point at
0piand (2) define the domain of hyperplane points (for partitioning purposes) to be the range[0, 2pi). Each hyperplane then splits the space into the intervals[0, x]and[x, 2pi), wherexis the location of the hyperplane. One way to visualize this is to picture the circle as a cake that has already been cut at0pi. Each hyperplane then specifies the location of the second cut of the cake, with the plus and minus sides being the pieces thus cut.Note that with the hyperplane partitioning rules described above, the hyperplane at
0piis unique in that it has the entire space on one side (minus the hyperplane itself) and no points whatsoever on the other. This is very different from hyperplanes in Euclidean space, which always have infinitely many points on both sides.Instances of this class are guaranteed to be immutable.
- See Also:
CutAngles
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classCutAngle.CutAngleConvexSubsetHyperplaneConvexSubsetimplementation for spherical 1D space.
-
Field Summary
Fields Modifier and Type Field Description private Point1SpointHyperplane location as a point.private booleanpositiveFacingHyperplane direction.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HyperplaneLocationclassify(Point1S pt)Classify a point with respect to this hyperplane.booleaneq(CutAngle 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.booleanequals(java.lang.Object obj)doublegetAzimuth()Get the location of the hyperplane as a single value.doublegetNormalizedAzimuth()Get the location of the hyperplane as a single value, normalized to the range[0, 2pi).Point1SgetPoint()Get the location of the hyperplane as a point.inthashCode()booleanisPositiveFacing()Return true if the hyperplane is oriented with its plus side pointing toward increasing angles.doubleoffset(Point1S pt)Get the offset (oriented distance) of a point with respect to this instance.Point1Sproject(Point1S pt)Project a point onto this instance.CutAnglereverse()Return a hyperplane that has the opposite orientation as this instance.booleansimilarOrientation(Hyperplane<Point1S> other)Return true if this instance has a similar orientation to the given hyperplane, meaning that they point in generally the same direction.HyperplaneConvexSubset<Point1S>span()Return aHyperplaneConvexSubsetspanning this entire hyperplane.java.lang.StringtoString()CutAngletransform(Transform<Point1S> 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 Point1S point
Hyperplane location as a point.
-
positiveFacing
private final boolean positiveFacing
Hyperplane direction.
-
-
Constructor Detail
-
CutAngle
CutAngle(Point1S point, boolean positiveFacing, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision)
Simple constructor.- Parameters:
point- location of the hyperplanepositiveFacing- if true, the hyperplane will point in a positive angular direction; otherwise, it will point in a negative directionprecision- precision context used to compare floating point values
-
-
Method Detail
-
getPoint
public Point1S getPoint()
Get the location of the hyperplane as a point.- Returns:
- the hyperplane location as a point
- See Also:
getAzimuth()
-
getAzimuth
public double getAzimuth()
Get the location of the hyperplane as a single value. This is equivalent tocutAngle.getPoint().getAzimuth().- Returns:
- the location of the hyperplane as a single value.
- See Also:
getPoint(),Point1S.getAzimuth()
-
getNormalizedAzimuth
public double getNormalizedAzimuth()
Get the location of the hyperplane as a single value, normalized to the range[0, 2pi). This is equivalent tocutAngle.getPoint().getNormalizedAzimuth().- Returns:
- the location of the hyperplane, normalized to the range
[0, 2pi) - See Also:
getPoint(),Point1S.getNormalizedAzimuth()
-
isPositiveFacing
public boolean isPositiveFacing()
Return true if the hyperplane is oriented with its plus side pointing toward increasing angles.- Returns:
- true if the hyperplane is facing in the direction of increasing angles
-
eq
public boolean eq(CutAngle 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.The instances are considered equivalent if they
- have equivalent point locations (points separated by multiples of 2pi are considered equivalent) and
- point in the same direction.
- Parameters:
other- 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:
Point1S.eq(Point1S, Precision.DoubleEquivalence)
-
offset
public double offset(Point1S 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
-
classify
public HyperplaneLocation classify(Point1S pt)
Classify a point with respect to this hyperplane.- Specified by:
classifyin interfaceHyperplane<Point1S>- Overrides:
classifyin classAbstractHyperplane<Point1S>- Parameters:
pt- the point to classify- Returns:
- the relative location of the point with respect to this instance
-
project
public Point1S project(Point1S 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.
-
reverse
public CutAngle 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 CutAngle transform(Transform<Point1S> transform)
Transform this instance using the givenTransform.- Parameters:
transform- object to transform this instance with- Returns:
- a new, transformed hyperplane
-
similarOrientation
public boolean similarOrientation(Hyperplane<Point1S> 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
-
span
public HyperplaneConvexSubset<Point1S> span()
Return aHyperplaneConvexSubsetspanning this entire hyperplane. The returned subset contains all points lying in this hyperplane and no more.Since there are no subspaces in spherical 1D space, 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
HyperplaneConvexSubsetcontaining all points lying in this hyperplane
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-