Class OrientedPoint2d

    • Field Detail

      • dirZ

        public final double dirZ
        The counter-clockwise rotation around the point in radians.
    • Constructor Detail

      • OrientedPoint2d

        public OrientedPoint2d​(double x,
                               double y)
                        throws IllegalArgumentException
        Construct an oriented point with an x and y coordinate and a direction equal to 0.0.
        Parameters:
        x - double; the x coordinate
        y - double; the y coordinate
        Throws:
        IllegalArgumentException - when any coordinate is NaN
      • OrientedPoint2d

        public OrientedPoint2d​(double x,
                               double y,
                               double dirZ)
                        throws IllegalArgumentException
        Construct an oriented point with an x and y coordinate and a direction.
        Parameters:
        x - double; the x coordinate
        y - double; the y coordinate
        dirZ - double; the counter-clockwise rotation around the point in radians
        Throws:
        IllegalArgumentException - when any coordinate or dirZ is NaN
      • OrientedPoint2d

        public OrientedPoint2d​(double[] xy,
                               double dirZ)
                        throws IllegalArgumentException
        Construct an oriented point with an x and y coordinate and a direction.
        Parameters:
        xy - double[]; the x and y coordinate
        dirZ - double; the counter-clockwise rotation around the point in radians
        Throws:
        NullPointerException - when xy is null
        IllegalArgumentException - when the dimension of xy is not 2 or any value in xy is NaN or rotZ is NaN
      • OrientedPoint2d

        public OrientedPoint2d​(Point2D point,
                               double dirZ)
                        throws IllegalArgumentException
        Construct an oriented point from an AWT Point2D and a direction.
        Parameters:
        point - Point2D; an AWT Point2D
        dirZ - double; the counter-clockwise rotation around the point in radians
        Throws:
        IllegalArgumentException - when any coordinate in point is NaN, or rotZ is NaN
      • OrientedPoint2d

        public OrientedPoint2d​(Point2d point,
                               double dirZ)
                        throws IllegalArgumentException
        Construct an oriented point from a Point2d and a direction.
        Parameters:
        point - Point2d; a point (with or without orientation)
        dirZ - double; the counter-clockwise rotation around the point in radians
        Throws:
        IllegalArgumentException - when rotZ is NaN
    • Method Detail

      • translate

        public OrientedPoint2d translate​(double dx,
                                         double dy)
                                  throws IllegalArgumentException
        Return a new Point with a translation by the provided dx and dy.
        Overrides:
        translate in class Point2d
        Parameters:
        dx - double; the horizontal translation
        dy - double; the vertical translation
        Returns:
        P; a new point with the translated coordinates
        Throws:
        IllegalArgumentException - when dx, or dy is NaN
      • translate

        public OrientedPoint3d translate​(double dx,
                                         double dy,
                                         double z)
                                  throws IllegalArgumentException
        Return a new Point3d with a translation by the provided delta-x, delta-y and delta-z. If this is an OrientedPoint2d, then the result is an OrientedPoint3d with rotX copied from this and rotY and rotZ are set to 0.0.
        Overrides:
        translate in class Point2d
        Parameters:
        dx - double; the x translation
        dy - double; the y translation
        z - double; the z translation
        Returns:
        Point2d; a new point with the translated coordinates
        Throws:
        IllegalArgumentException - when dx, dy, or dz is NaN
      • abs

        public OrientedPoint2d abs()
        Return a new Point with absolute coordinate values.
        Specified by:
        abs in interface Point<Point2d>
        Overrides:
        abs in class Point2d
        Returns:
        Point; a new point with absolute coordinate values
      • interpolate

        public OrientedPoint2d interpolate​(OrientedPoint2d otherPoint,
                                           double fraction)
                                    throws NullPointerException,
                                           IllegalArgumentException
        Interpolate towards another Point with a fraction. It is allowed for fraction to be less than zero or larger than 1. In that case the interpolation turns into an extrapolation. DirZ is interpolated using the AngleUtil.interpolateShortest method.
        Parameters:
        otherPoint - OrientedPoint2d; the other point
        fraction - double; the factor for interpolation towards the other point. When <code>fraction</code> is between 0 and 1, it is an interpolation, otherwise an extrapolation. If fraction is 0; this Point is returned; if fraction is 1, the other point is returned
        Returns:
        OrientedPoint2d; a new OrientedPoint2d at the requested fraction
        Throws:
        NullPointerException - when otherPoint is null
        IllegalArgumentException - when fraction is NaN
      • rotate

        public OrientedPoint2d rotate​(double rotateZ)
                               throws IllegalArgumentException
        Return a new OrientedPoint2d with an in-place rotation around the z-axis by the provided delta. The resulting rotation is normalized between -π and π.
        Parameters:
        rotateZ - double; the rotation around the z-axis
        Returns:
        OrientedPoint; a new point with the same coordinates and applied rotation
        Throws:
        IllegalArgumentException - when deltaRotZ is NaN
      • getDirZ

        public double getDirZ()
        Return the rotation around the z-axis in radians.
        Specified by:
        getDirZ in interface Oriented<OrientedPoint2d>
        Returns:
        double; the rotation around the z-axis in radians
      • toString

        public String toString()
        Produce a string describing the Drawable using default conversion for the (double) coordinate values. Regrettably, it is not allowed to provide a default implementation here.
        Specified by:
        toString in interface Drawable<Point2d>
        Overrides:
        toString in class Point2d
        Returns:
        String; a string describing the Drawable
      • toString

        public String toString​(String doubleFormat,
                               boolean doNotIncludeClassName)
        Produce a String describing the Drawable.
        Specified by:
        toString in interface Drawable<Point2d>
        Overrides:
        toString in class Point2d
        Parameters:
        doubleFormat - String; a format string (something like "%6.3f") which will be used to render every coordinate value)
        doNotIncludeClassName - boolean; if true; the output of toString is not prefixed by the class name. This is useful for concatenating the textual representation of lots of Drawables (e.g. an array, or a List).
        Returns:
        String; textual representation of the Drawable
      • epsilonEquals

        public boolean epsilonEquals​(OrientedPoint2d other,
                                     double epsilonCoordinate,
                                     double epsilonRotation)
                              throws NullPointerException,
                                     IllegalArgumentException
        Compare this Oriented with another Oriented with specified tolerances in the coordinates and the angles.
        Specified by:
        epsilonEquals in interface Oriented<OrientedPoint2d>
        Parameters:
        other - O; the point to compare with
        epsilonCoordinate - double; the upper bound of difference for one of the coordinates; use Double.POSITIVE_INFINITY if you do not want to check the coordinates
        epsilonRotation - double; the upper bound of difference for the direction(s); use Double.POSITIVE_INFINITY if you do not want to check the angles
        Returns:
        boolean; true if x, y, and z are less than epsilonCoordinate apart, and rotX, rotY and rotZ are less than epsilonRotation apart, otherwise false
        Throws:
        NullPointerException - when other is null
        IllegalArgumentException - epsilonCoordinate or epsilonRotation is NaN or negative