Class 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
    • 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 hyperplane
        positiveFacing - 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 to pt.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 given Transform.
        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 of offset(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​(double location)
        Classify the number line location with respect to the instance. This is a convenience overload of classify(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 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 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

        1. have equivalent locations and
        2. point in the same direction.
        Parameters:
        other - the 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:
        Vector1D.eq(Vector1D, Precision.DoubleEquivalence)
      • 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