Class 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 0pi and (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), where x is the location of the hyperplane. One way to visualize this is to picture the circle as a cake that has already been cut at 0pi. 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 0pi is 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
    • 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 hyperplane
        positiveFacing - if true, the hyperplane will point in a positive angular direction; otherwise, it will point in a negative direction
        precision - 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 to cutAngle.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 to cutAngle.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

        1. have equivalent point locations (points separated by multiples of 2pi are considered equivalent) and
        2. point in the same direction.
        Parameters:
        other - point to compare with
        precision - 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
      • 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 given Transform.
        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 a HyperplaneConvexSubset spanning 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 HyperplaneConvexSubset containing all points lying in this hyperplane
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object