Interface OrientedRectangle2afp<ST extends Shape2afp<?,​?,​IE,​P,​V,​B>,​IT extends OrientedRectangle2afp<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2afp,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2afp<?,​?,​IE,​P,​V,​B>>

  • Type Parameters:
    ST - is the type of the general implementation.
    IT - is the type of the implementation of this shape.
    IE - is the type of the path elements.
    P - is the type of the points.
    V - is the type of the vectors.
    B - is the type of the bounding boxes.
    All Superinterfaces:
    Cloneable, JsonableObject, Parallelogram2afp<ST,​IT,​IE,​P,​V,​B>, Serializable, Shape2afp<ST,​IT,​IE,​P,​V,​B>, Shape2D<ST,​IT,​PathIterator2afp<IE>,​P,​V,​B>
    All Known Subinterfaces:
    Rectangle2afp<ST,​IT,​IE,​P,​V,​B>
    All Known Implementing Classes:
    OrientedRectangle2d, OrientedRectangle2dfx, Rectangle2d, Rectangle2dfx

    public interface OrientedRectangle2afp<ST extends Shape2afp<?,​?,​IE,​P,​V,​B>,​IT extends OrientedRectangle2afp<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2afp,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2afp<?,​?,​IE,​P,​V,​B>>
    extends Parallelogram2afp<ST,​IT,​IE,​P,​V,​B>
    Fonctional interface that represented a 2D oriented rectangle on a plane. An oriented rectangle is a parallelogram with orthogonal axes.
    Version:
    17.0 2020-01-04 14:41:43
    Author:
    Stéphane GALLAND, Nicolas GAUD
    Maven Group Id:
    org.arakhne.afc.core
    Maven Artifact Id:
    mathgeom
    • Method Detail

      • containsOrientedRectanglePoint

        @Pure
        static boolean containsOrientedRectanglePoint​(double centerX,
                                                      double centerY,
                                                      double axis1X,
                                                      double axis1Y,
                                                      double axis1Extent,
                                                      double axis2Extent,
                                                      double px,
                                                      double py)
        Replies if a point is inside in the oriented rectangle.
        Parameters:
        px - is the X coordinate of the point to test.
        py - is the Y coordinate of the point to test.
        centerX - is the X coordinate of the oriented rectangle center.
        centerY - is the Y coordinate of the oriented rectangle center.
        axis1X - is the X coordinate of the axis 1 unit vector.
        axis1Y - is the Y coordinate of the axis 1 unit vector.
        axis1Extent - is the extent of the axis 1 of the oriented rectangle.
        axis2Extent - is the extent of the axis 2 of the oriented rectangle.
        Returns:
        true if the given point is inside the oriented rectangle; otherwise false.
      • containsOrientedRectangleRectangle

        @Pure
        static boolean containsOrientedRectangleRectangle​(double centerX,
                                                          double centerY,
                                                          double axis1X,
                                                          double axis1Y,
                                                          double axis1Extent,
                                                          double axis2Extent,
                                                          double rx,
                                                          double ry,
                                                          double rwidth,
                                                          double rheight)
        Replies if a point is inside the oriented rectangle.
        Parameters:
        centerX - is the X coordinate of the oriented rectangle center.
        centerY - is the Y coordinate of the oriented rectangle center.
        axis1X - is the X coordinate of the axis 1 unit vector.
        axis1Y - is the Y coordinate of the axis 1 unit vector.
        axis1Extent - is the extent of the axis 1 of the oriented rectangle.
        axis2Extent - is the extent of the axis 2 of the oriented rectangle.
        rx - is the X coordinate of the lower point of the rectangle.
        ry - is the Y coordinate of the lower point of the rectangle.
        rwidth - is the width of the rectangle.
        rheight - is the height of the rectangle.
        Returns:
        true if the given rectangle is inside the oriented rectangle; otherwise false.
      • findsClosestFarthestPointsPointOrientedRectangle

        static void findsClosestFarthestPointsPointOrientedRectangle​(double px,
                                                                     double py,
                                                                     double centerX,
                                                                     double centerY,
                                                                     double axis1X,
                                                                     double axis1Y,
                                                                     double axis1Extent,
                                                                     double axis2Extent,
                                                                     Point2D<?,​?> closest,
                                                                     Point2D<?,​?> farthest)
        } Given a point p, this function computes the point q1 on (or in) this oriented rectangle, closest to p; and the point q2 on the oriented rectangle, farthest to p. If there are several points, the function will return one of those. Remember this function may return an approximate result when points remain on oriented rectangle plane of symmetry.
        Parameters:
        px - is the X coordinate of the point to test.
        py - is the Y coordinate of the point to test.
        centerX - is the X coordinate of the oriented rectangle center.
        centerY - is the Y coordinate of the oriented rectangle center.
        axis1X - is the X coordinate of the axis 1 vector.
        axis1Y - is the Y coordinate of the axis 1 vector.
        axis1Extent - is the extent of the axis 1 of the oriented rectangle.
        axis2Extent - is the extent of the axis 2 of the oriented rectangle.
        closest - the closest point. If null, the closest point is not computed.
        farthest - the farthest point. If null, the farthest point is not computed.
      • intersectsOrientedRectangleSegment

        @Pure
        static boolean intersectsOrientedRectangleSegment​(double centerX,
                                                          double centerY,
                                                          double axis1X,
                                                          double axis1Y,
                                                          double axis1Extent,
                                                          double axis2Extent,
                                                          double s1x,
                                                          double s1y,
                                                          double s2x,
                                                          double s2y)
        Replies if the specified rectangle intersects the specified segment.
        Parameters:
        centerX - is the X coordinate of the oriented rectangle center.
        centerY - is the Y coordinate of the oriented rectangle center.
        axis1X - is the X coordinate of the axis 1 unit vector.
        axis1Y - is the Y coordinate of the axis 1 unit vector.
        axis1Extent - is the extent of the axis 1 of the oriented rectangle.
        axis2Extent - is the extent of the axis 2 of the oriented rectangle.
        s1x - is the X coordinate of the first point of the segment.
        s1y - is the Y coordinate of the first point of the segment.
        s2x - is the X coordinate of the second point of the segment.
        s2y - is the Y coordinate of the second point of the segment.
        Returns:
        true if intersecting, otherwise false
      • intersectsOrientedRectangleTriangle

        @Pure
        static boolean intersectsOrientedRectangleTriangle​(double centerX,
                                                           double centerY,
                                                           double axis1X,
                                                           double axis1Y,
                                                           double axis1Extent,
                                                           double axis2Extent,
                                                           double s1x,
                                                           double s1y,
                                                           double s2x,
                                                           double s2y,
                                                           double s3x,
                                                           double s3y)
        Replies if the specified rectangle intersects the specified triangle.
        Parameters:
        centerX - is the X coordinate of the oriented rectangle center.
        centerY - is the Y coordinate of the oriented rectangle center.
        axis1X - is the X coordinate of the axis 1 unit vector.
        axis1Y - is the Y coordinate of the axis 1 unit vector.
        axis1Extent - is the extent of the axis 1 of the oriented rectangle.
        axis2Extent - is the extent of the axis 2 of the oriented rectangle.
        s1x - is the X coordinate of the first point of the triangle.
        s1y - is the Y coordinate of the first point of the triangle.
        s2x - is the X coordinate of the second point of the triangle.
        s2y - is the Y coordinate of the second point of the triangle.
        s3x - is the X coordinate of the third point of the triangle.
        s3y - is the Y coordinate of the third point of the triangle.
        Returns:
        true if intersecting, otherwise false
      • intersectsOrientedRectangleEllipse

        @Pure
        static boolean intersectsOrientedRectangleEllipse​(double centerX,
                                                          double centerY,
                                                          double axis1X,
                                                          double axis1Y,
                                                          double axis1Extent,
                                                          double axis2Extent,
                                                          double ex,
                                                          double ey,
                                                          double ewidth,
                                                          double eheight)
        Replies if the parallelogram intersects the given ellipse.
        Parameters:
        centerX - is the X coordinate of the parallelogram center.
        centerY - is the Y coordinate of the parallelogram center.
        axis1X - is the X coordinate of the axis 1 unit vector.
        axis1Y - is the Y coordinate of the axis 1 unit vector.
        axis1Extent - is the extent of the axis 1 of the parallelogram.
        axis2Extent - is the extent of the axis 2 of the parallelogram.
        ex - is the coordinate of the min point of the ellipse rectangle.
        ey - is the coordinate of the min point of the ellipse rectangle.
        ewidth - is the width of the ellipse.
        eheight - is the height of the ellipse.
        Returns:
        true if intersecting, otherwise false
      • intersectsOrientedRectangleCircle

        @Pure
        static boolean intersectsOrientedRectangleCircle​(double centerX,
                                                         double centerY,
                                                         double axis1X,
                                                         double axis1Y,
                                                         double axis1Extent,
                                                         double axis2Extent,
                                                         double circleX,
                                                         double circleY,
                                                         double circleRadius)
        Replies if the specified parallelogram intersects the specified circle.
        Parameters:
        centerX - is the X coordinate of the parallelogram center.
        centerY - is the Y coordinate of the parallelogram center.
        axis1X - is the X coordinate of the axis 1 unit vector.
        axis1Y - is the Y coordinate of the axis 1 unit vector.
        axis1Extent - is the extent of the axis 1 of the parallelogram.
        axis2Extent - is the extent of the axis 2 of the parallelogram.
        circleX - is the coordinate of the circle center.
        circleY - is the coordinate of the circle center.
        circleRadius - is the radius of the circle.
        Returns:
        true if intersecting, otherwise false
      • intersectsOrientedRectangleOrientedRectangle

        @Pure
        static boolean intersectsOrientedRectangleOrientedRectangle​(double centerX1,
                                                                    double centerY1,
                                                                    double axis1X1,
                                                                    double axis1Y1,
                                                                    double axis1Extent1,
                                                                    double axis2Extent1,
                                                                    double centerX2,
                                                                    double centerY2,
                                                                    double axis1X2,
                                                                    double axis1Y2,
                                                                    double axis1Extent2,
                                                                    double axis2Extent2)
        Replies if the specified rectangles intersect.

        The extents are assumed to be positive or zero. The lengths of the given arrays are assumed to be 2.

        This function uses the "separating axis theorem" which states that for any two oriented rectangles (AABB is a special case of oriented rectangle) that do not touch, a separating axis can be found.

        This function uses an general intersection test between two oriented rectangle. If the first box is expected to be an MBR, please use the optimized algorithm given by intersectsOrientedRectangleRectangle(double, double, double, double, double, double, double, double, double, double).

        Parameters:
        centerX1 - is the X coordinate of the oriented rectangle center.
        centerY1 - is the Y coordinate of the oriented rectangle center.
        axis1X1 - is the X coordinate of the axis 1 unit vector.
        axis1Y1 - is the Y coordinate of the axis 1 unit vector.
        axis1Extent1 - is the extent of the axis 1 of the oriented rectangle.
        axis2Extent1 - is the extent of the axis 2 of the oriented rectangle.
        centerX2 - is the X coordinate of the oriented rectangle center.
        centerY2 - is the Y coordinate of the oriented rectangle center.
        axis1X2 - is the X coordinate of the axis 1 unit vector.
        axis1Y2 - is the Y coordinate of the axis 1 unit vector.
        axis1Extent2 - is the extent of the axis 1 of the oriented rectangle.
        axis2Extent2 - is the extent of the axis 2 of the oriented rectangle.
        Returns:
        true if intersecting, otherwise false
        See Also:
        "RTCD pages 102-105", Intersection between two oriented boudning rectangles
      • intersectsOrientedRectangleRectangle

        @Pure
        static boolean intersectsOrientedRectangleRectangle​(double centerX,
                                                            double centerY,
                                                            double axis1X,
                                                            double axis1Y,
                                                            double axis1Extent,
                                                            double axis2Extent,
                                                            double rx,
                                                            double ry,
                                                            double rwidth,
                                                            double rheight)
        Replies if the specified rectangles intersect.

        This function is assuming that lx1 is lower or equal to ux1, and ly1 is lower or equal to uy1. The extents are assumed to be positive or zero. The lengths of the given arrays are assumed to be 2.

        This function uses the "separating axis theorem" which states that for any two oriented rectangles (AABB is a special case of oriented rectangle) that do not touch, a separating axis can be found.

        This function uses an optimized algorithm for AABB as first parameter. The general intersection type between two oriented rectangle is given by intersectsOrientedRectangleOrientedRectangle(double, double, double, double, double, double, double, double, double, double, double, double).

        Parameters:
        centerX - is the X coordinate of the oriented rectangle center.
        centerY - is the Y coordinate of the oriented rectangle center.
        axis1X - is the X coordinate of the axis 1 unit vector.
        axis1Y - is the Y coordinate of the axis 1 unit vector.
        axis1Extent - is the extent of the axis 1 of the oriented rectangle.
        axis2Extent - is the extent of the axis 2 of the oriented rectangle.
        rx - is the X coordinate of the lower point of the rectangle.
        ry - is the Y coordinate of the lower point of the rectangle.
        rwidth - is the width of the rectangle.
        rheight - is the height of the rectangle.
        Returns:
        true if intersecting, otherwise false
        See Also:
        "RTCD pages 102-105", OBB collision detection on Gamasutra.com
      • intersectsOrientedRectangleRoundRectangle

        @Pure
        static boolean intersectsOrientedRectangleRoundRectangle​(double centerX,
                                                                 double centerY,
                                                                 double axis1X,
                                                                 double axis1Y,
                                                                 double axis1Extent,
                                                                 double axis2Extent,
                                                                 double rx,
                                                                 double ry,
                                                                 double rwidth,
                                                                 double rheight,
                                                                 double rArcWidth,
                                                                 double rArcHeight)
        Replies if the oriented rectangle intersects the given rectangle.
        Parameters:
        centerX - is the X coordinate of the parallelogram center.
        centerY - is the Y coordinate of the parallelogram center.
        axis1X - is the X coordinate of the axis 1 unit vector.
        axis1Y - is the Y coordinate of the axis 1 unit vector.
        axis1Extent - is the extent of the axis 1 of the parallelogram.
        axis2Extent - is the extent of the axis 2 of the parallelogram.
        rx - is the X coordinate of the lower point of the rectangle.
        ry - is the Y coordinate of the lower point of the rectangle.
        rwidth - is the width of the rectangle.
        rheight - is the height of the rectangle.
        rArcWidth - is the width of the rectangle arcs.
        rArcHeight - is the height of the rectangle arcs.
        Returns:
        true if intersecting, otherwise false.
      • intersectsOrientedRectanglePathIterator

        static <T extends PathElement2afp> boolean intersectsOrientedRectanglePathIterator​(double centerX,
                                                                                           double centerY,
                                                                                           double axis1X,
                                                                                           double axis1Y,
                                                                                           double extent1,
                                                                                           double extent2,
                                                                                           PathIterator2afp<T> pathIterator)
        Tests if the interior of the specified PathIterator2afp intersects the interior of a specified set of oriented rectangular coordinates.
        Type Parameters:
        T - the type of the path elements to iterate on.
        Parameters:
        centerX - the specified X coordinate of the rectangle center.
        centerY - the specified Y coordinate of the rectangle center.
        axis1X - the X coordinate of the first axis of the rectangle.
        axis1Y - the Y coordinate of the first axis of the rectangle.
        extent1 - the extent the rectangle along the first axis.
        extent2 - the extent the rectangle along the second axis.
        pathIterator - the specified PathIterator2afp.
        Returns:
        true if the specified PathIterator2afp and the interior of the specified set of rectangular coordinates intersect each other; false otherwise.
      • set

        default void set​(double centerX,
                         double centerY,
                         double axis1x,
                         double axis1y,
                         double axis1Extent,
                         double axis2x,
                         double axis2y,
                         double axis2Extent)
        Set the oriented rectangle.

        For an oriented rectangle, the coordinates of the second axis are ignored. Indeed, they are automatically computed for being orthogonal to the first axis.

        Specified by:
        set in interface Parallelogram2afp<ST extends Shape2afp<?,​?,​IE,​P,​V,​B>,​IT extends OrientedRectangle2afp<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2afp,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2afp<?,​?,​IE,​P,​V,​B>>
        Parameters:
        centerX - is the X coordinate of the OBR center.
        centerY - is the Y coordinate of the OBR center.
        axis1x - is the X coordinate of first axis of the OBR.
        axis1y - is the Y coordinate of first axis of the OBR.
        axis1Extent - is the extent of the first axis.
        axis2x - is the X coordinate of second axis of the OBR.
        axis2y - is the Y coordinate of second axis of the OBR.
        axis2Extent - is the extent of the second axis.
      • set

        default void set​(Point2D<?,​?> center,
                         Vector2D<?,​?> axis1,
                         double axis1Extent,
                         double axis2Extent)
        Set the oriented rectangle. The second axis is automatically computed.
        Parameters:
        center - is the oriented rectangle center.
        axis1 - is the first axis of the oriented rectangle.
        axis1Extent - is the extent of the first axis.
        axis2Extent - is the extent of the second axis.
      • set

        void set​(double centerX,
                 double centerY,
                 double axis1X,
                 double axis1Y,
                 double axis1Extent,
                 double axis2Extent)
        Set the oriented rectangle. The second axis is automatically computed.
        Parameters:
        centerX - is the X coordinate of the oriented rectangle center.
        centerY - is the Y coordinate of the oriented rectangle center.
        axis1X - is the X coordinate of first axis of the oriented rectangle.
        axis1Y - is the Y coordinate of first axis of the oriented rectangle.
        axis1Extent - is the extent of the first axis.
        axis2Extent - is the extent of the second axis.