Interface Segment2ai<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​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, Serializable, Shape2ai<ST,​IT,​IE,​P,​V,​B>, Shape2D<ST,​IT,​PathIterator2ai<IE>,​P,​V,​B>
    All Known Implementing Classes:
    Segment2i, Segment2ifx, SegmentPoint2i

    public interface Segment2ai<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​IE,​P,​V,​B>>
    extends Shape2ai<ST,​IT,​IE,​P,​V,​B>
    Fonctional interface that represented a 2D segment/line on a plane.
    Since:
    13.0
    Version:
    17.0 2020-01-04 14:41:43
    Author:
    Stéphane GALLAND
    Maven Group Id:
    org.arakhne.afc.core
    Maven Artifact Id:
    mathgeom
    • Method Detail

      • findsClosestPointSegmentPoint

        static void findsClosestPointSegmentPoint​(int ax,
                                                  int ay,
                                                  int bx,
                                                  int by,
                                                  int px,
                                                  int py,
                                                  Point2D<?,​?> result)
        Replies the closest point in a circle to a point.
        Parameters:
        ax - is the x-coordinate of the first point of the segment
        ay - is the y-coordinate of the first point of the segment
        bx - is the x-coordinate of the second point of the segment
        by - is the y-coordinate of the second point of the segment
        px - is the x-coordinate of the point
        py - is the x-coordinate of the point
        result - the closest point in the segment to the point.
      • findsClosestPointSegmentRectangle

        static double findsClosestPointSegmentRectangle​(int sx1,
                                                        int sy1,
                                                        int sx2,
                                                        int sy2,
                                                        int rx,
                                                        int ry,
                                                        int rwidth,
                                                        int rheight,
                                                        Point2D<?,​?> result)
        Replies the point on the segment that is closest to the rectangle.
        Parameters:
        sx1 - is the x coordinate of the first point of the segment.
        sy1 - is the y coordinate of the first point of the segment.
        sx2 - is the x coordinate of the second point of the segment.
        sy2 - is the y coordinate of the second point of the segment.
        rx - is the x coordinate of the rectangle.
        ry - is the y coordinate of the rectangle.
        rwidth - is the width of the rectangle.
        rheight - is the height of the rectangle.
        result - the is point on the segment.
        Returns:
        the square distance between the segments.
      • findsClosestPointSegmentSegment

        static double findsClosestPointSegmentSegment​(int s1x1,
                                                      int s1y1,
                                                      int s1x2,
                                                      int s1y2,
                                                      int s2x1,
                                                      int s2y1,
                                                      int s2x2,
                                                      int s2y2,
                                                      Point2D<?,​?> result)
        Replies the point on the first segment that is closest to the second segment.
        Parameters:
        s1x1 - is the x coordinate of the first point of the first segment.
        s1y1 - is the y coordinate of the first point of the first segment.
        s1x2 - is the x coordinate of the second point of the first segment.
        s1y2 - is the y coordinate of the second point of the first segment.
        s2x1 - is the x coordinate of the first point of the second segment.
        s2y1 - is the y coordinate of the first point of the second segment.
        s2x2 - is the x coordinate of the second point of the second segment.
        s2y2 - is the y coordinate of the second point of the second segment.
        result - the is point on the shape.
        Returns:
        the square distance between the segments.
      • findsClosestPointsSegmentSegment

        static double findsClosestPointsSegmentSegment​(int s1x1,
                                                       int s1y1,
                                                       int s1x2,
                                                       int s1y2,
                                                       int s2x1,
                                                       int s2y1,
                                                       int s2x2,
                                                       int s2y2,
                                                       Point2D<?,​?> resultOnFirstSegment,
                                                       Point2D<?,​?> resultOnSecondSegment)
        Replies the point on the first segment that is closest to the second segment.
        Parameters:
        s1x1 - is the x coordinate of the first point of the first segment.
        s1y1 - is the y coordinate of the first point of the first segment.
        s1x2 - is the x coordinate of the second point of the first segment.
        s1y2 - is the y coordinate of the second point of the first segment.
        s2x1 - is the x coordinate of the first point of the second segment.
        s2y1 - is the y coordinate of the first point of the second segment.
        s2x2 - is the x coordinate of the second point of the second segment.
        s2y2 - is the y coordinate of the second point of the second segment.
        resultOnFirstSegment - the point on the first segment.
        resultOnSecondSegment - the point on the second segment.
        Returns:
        the square distance between the segments.
      • findsFarthestPointSegmentPoint

        static void findsFarthestPointSegmentPoint​(int ax,
                                                   int ay,
                                                   int bx,
                                                   int by,
                                                   int px,
                                                   int py,
                                                   Point2D<?,​?> result)
        Replies the farthest point on a segment to a point.
        Parameters:
        ax - is the x-coordinate of the first point of the segment
        ay - is the y-coordinate of the first point of the segment
        bx - is the x-coordinate of the second point of the segment
        by - is the y-coordinate of the second point of the segment
        px - is the x-coordinate of the point
        py - is the x-coordinate of the point
        result - the farthest point in the segment to the point.
      • findsSideLinePoint

        @Pure
        static int findsSideLinePoint​(int x1,
                                      int y1,
                                      int x2,
                                      int y2,
                                      int px,
                                      int py)
        Replies on which side of a line the given point is located.

        A return value of 1 indicates that the line segment must turn in the direction that takes the positive X axis towards the negative Y axis. In the default coordinate system used by Java 2D, this direction is counterclockwise.

        A return value of -1 indicates that the line segment must turn in the direction that takes the positive X axis towards the positive Y axis. In the default coordinate system by Java 2D, this direction is clockwise.

        A return value of 0 indicates that the point lies exactly on the line segment.

        Parameters:
        x1 - the X coordinate of the start point of the specified line segment
        y1 - the Y coordinate of the start point of the specified line segment
        x2 - the X coordinate of the end point of the specified line segment
        y2 - the Y coordinate of the end point of the specified line segment
        px - the X coordinate of the specified point to be compared with the specified line segment
        py - the Y coordinate of the specified point to be compared with the specified line segment
        Returns:
        an integer that indicates the position of the third specified coordinates with respect to the line segment formed by the first two specified coordinates.
        See Also:
        MathUtil.isEpsilonZero(double)
      • calculatesCrossingsCircleShadowSegment

        @Pure
        static int calculatesCrossingsCircleShadowSegment​(int crossings,
                                                          int cx,
                                                          int cy,
                                                          int radius,
                                                          int x0,
                                                          int y0,
                                                          int x1,
                                                          int y1)
        Calculates the number of times the line from (x0, y0) to (x1, y1) crosses the ellipse (ex0, ey0) to (ex1, ey1) extending to the right.

        When the line (x0;y0) to (x1;y1) is crossing one of the up or bottom borders of the shadow of the circle, the crossings count is increased or decreased, depending if the line is going down or up, respectively. In the following figure, the circle is represented. The "shadow" is the projection of the circle on the right. The red lines represent the up and bottom borders.

        Parameters:
        crossings - is the initial value for the number of crossings.
        cx - is the center of the circle to extend.
        cy - is the center of the circle to extend.
        radius - is the radius of the circle to extend.
        x0 - is the first point of the line.
        y0 - is the first point of the line.
        x1 - is the second point of the line.
        y1 - is the secondpoint of the line.
        Returns:
        the crossing, or GeomConstants.SHAPE_INTERSECTS.
      • calculatesCrossingsSegmentShadowSegment

        @Pure
        static int calculatesCrossingsSegmentShadowSegment​(int crossings,
                                                           int sx1,
                                                           int sy1,
                                                           int sx2,
                                                           int sy2,
                                                           int x0,
                                                           int y0,
                                                           int x1,
                                                           int y1)
        Calculates the number of times the line from (x0, y0) to (x1, y1) crosses the segment (sx0, sy0) to (sx1, sy1) extending to the right.

        When the line (x0;y0) to (x1;y1) is crossing one of the up or bottom borders of the shadow of the segment, the crossings count is increased or decreased, depending if the line is going down or up, respectively. In the following figure, the segment is represented. The "shadow" is the projection of the segment on the right. The red lines represent the up and bottom borders.

        Parameters:
        crossings - is the initial value for the number of crossings.
        sx1 - is the first point of the segment to extend.
        sy1 - is the first point of the segment to extend.
        sx2 - is the second point of the segment to extend.
        sy2 - is the second point of the segment to extend.
        x0 - is the first point of the line.
        y0 - is the first point of the line.
        x1 - is the second point of the line.
        y1 - is the secondpoint of the line.
        Returns:
        the crossing, or GeomConstants.SHAPE_INTERSECTS.
      • calculatesCrossingsRectangleShadowSegment

        @Pure
        static int calculatesCrossingsRectangleShadowSegment​(int crossings,
                                                             int rxmin,
                                                             int rymin,
                                                             int rxmax,
                                                             int rymax,
                                                             int x0,
                                                             int y0,
                                                             int x1,
                                                             int y1)
        Accumulate the number of times the line crosses the shadow extending to the right of the rectangle.

        When the line (x0;y0) to (x1;y1) is intersecting the rectangle, the value GeomConstants.SHAPE_INTERSECTS is returned. When the line (x0;y0) to (x1;y1) is crossing one of the up or bottom borders of the shadow of the rectangle, the crossings count is increased or decreased, depending if the line is going down or up, respectively. In the following figure, the rectangle is represented. The "shadow" is the projection of the rectangle on the right. The red lines represent the up and bottom borders.

        Parameters:
        crossings - is the initial value for the number of crossings.
        rxmin - is the first corner of the rectangle.
        rymin - is the first corner of the rectangle.
        rxmax - is the second corner of the rectangle.
        rymax - is the second corner of the rectangle.
        x0 - is the first point of the line.
        y0 - is the first point of the line.
        x1 - is the second point of the line.
        y1 - is the secondpoint of the line.
        Returns:
        the crossing, or GeomConstants.SHAPE_INTERSECTS.
      • calculatesCrossingsPointShadowSegment

        @Pure
        static int calculatesCrossingsPointShadowSegment​(int crossing,
                                                         int px,
                                                         int py,
                                                         int x0,
                                                         int y0,
                                                         int x1,
                                                         int y1)
        Calculates the number of times the line from (x0, y0) to (x1, y1) crosses the up/bottom borders of the ray extending to the right from (px, py). +x is returned for a crossing where the Y coordinate is increasing. -x is returned for a crossing where the Y coordinate is decreasing. x is the number of border crossed by the lines.

        The borders of the segment are the two side limits between the cells covered by the segment and the adjacents cells (not covered by the segment). In the following figure, the point (px;py) is represented. The "shadow line" is the projection of (px;py) on the right. The red lines represent the up and bottom borders.

        Parameters:
        crossing - is the initial value of the crossing.
        px - is the reference point to test.
        py - is the reference point to test.
        x0 - is the first point of the line.
        y0 - is the first point of the line.
        x1 - is the second point of the line.
        y1 - is the secondpoint of the line.
        Returns:
        the crossing, GeomConstants.SHAPE_INTERSECTS
      • calculatesCrossingsAndXPointShadowSegment

        static int calculatesCrossingsAndXPointShadowSegment​(int crossing,
                                                             int px,
                                                             int py,
                                                             int x0,
                                                             int y0,
                                                             int x1,
                                                             int y1,
                                                             boolean enableTopBorder,
                                                             boolean enableBottomBorder,
                                                             OutputParameter<Integer> xCoordinate)
        Calculates the number of times the line from (x0, y0) to (x1, y1) crosses the up/bottom borders of the ray extending to the right from (px, py). +x is returned for a crossing where the Y coordinate is increasing. -x is returned for a crossing where the Y coordinate is decreasing. x is the number of border crossed by the lines.

        The borders of the segment are the two side limits between the cells covered by the segment and the adjacents cells (not covered by the segment). In the following figure, the point (px;py) is represented. The "shadow line" is the projection of (px;py) on the right. The red lines represent the up and bottom borders.

        Parameters:
        crossing - is the initial value of the crossing.
        px - is the reference point to test.
        py - is the reference point to test.
        x0 - is the first point of the line.
        y0 - is the first point of the line.
        x1 - is the second point of the line.
        y1 - is the secondpoint of the line.
        enableTopBorder - indicates if the top border must be enabled in the crossing computation.
        enableBottomBorder - indicates if the bottom border must be enabled in the crossing computation.
        xCoordinate - output parameter for the x coordinate that is intersecting.
        Returns:
        the crossing; or GeomConstants.SHAPE_INTERSECTS if the segment is on the point.
      • intersectsSegmentSegment

        @Pure
        static boolean intersectsSegmentSegment​(int x1,
                                                int y1,
                                                int x2,
                                                int y2,
                                                int x3,
                                                int y3,
                                                int x4,
                                                int y4)
        Replies if two segments are intersecting. This function determines if the segments' lines are intersecting because using the pixel-based test. This function uses the pixels of the segments that are computed according to a Bresenham line algorithm.
        Parameters:
        x1 - is the first point of the first segment.
        y1 - is the first point of the first segment.
        x2 - is the second point of the first segment.
        y2 - is the second point of the first segment.
        x3 - is the first point of the second segment.
        y3 - is the first point of the second segment.
        x4 - is the second point of the second segment.
        y4 - is the second point of the second segment.
        Returns:
        true if the two shapes are intersecting; otherwise false
      • intersectsSegmentSegment

        static boolean intersectsSegmentSegment​(int x1,
                                                int y1,
                                                int x2,
                                                int y2,
                                                int x3,
                                                int y3,
                                                int x4,
                                                int y4,
                                                boolean enableThirdPoint,
                                                boolean enableFourthPoint,
                                                Point2D<?,​?> intersectionPoint)
        Replies if two segments are intersecting pixel per pixel. This function does not determine if the segments' lines are intersecting because using the pixel-based test. This function uses the pixels of the segments that are computed according to a Bresenham line algorithm.
        Parameters:
        x1 - is the first point of the first segment.
        y1 - is the first point of the first segment.
        x2 - is the second point of the first segment.
        y2 - is the second point of the first segment.
        x3 - is the first point of the second segment.
        y3 - is the first point of the second segment.
        x4 - is the second point of the second segment.
        y4 - is the second point of the second segment.
        enableThirdPoint - indicates if the intersection on the third point is computed.
        enableFourthPoint - indicates if the intersection on the fourth point is computed.
        intersectionPoint - are the coordinates of the intersection, if exist.
        Returns:
        true if the two segments are intersecting; otherwise false
      • findsIntersectionTypeSegmentSegment

        static int findsIntersectionTypeSegmentSegment​(int x1,
                                                       int y1,
                                                       int x2,
                                                       int y2,
                                                       int x3,
                                                       int y3,
                                                       int x4,
                                                       int y4,
                                                       boolean enableThirdPoint,
                                                       boolean enableFourthPoint,
                                                       Point2D<?,​?> intersectionPoint)
        Replies if two segments are intersecting pixel per pixel. This function does not determine if the segments' lines are intersecting because using the pixel-based test. This function uses the pixels of the segments that are computed according to a Bresenham line algorithm.
        Parameters:
        x1 - is the first point of the first segment.
        y1 - is the first point of the first segment.
        x2 - is the second point of the first segment.
        y2 - is the second point of the first segment.
        x3 - is the first point of the second segment.
        y3 - is the first point of the second segment.
        x4 - is the second point of the second segment.
        y4 - is the second point of the second segment.
        enableThirdPoint - indicates if the intersection on the third point is computed.
        enableFourthPoint - indicates if the intersection on the fourth point is computed.
        intersectionPoint - are the coordinates of the intersection, if exist.
        Returns:
        an integer value; if 0 the two segments are not intersecting; 1 if the two segments are intersecting and the segment 2 has pixels on both sides of the segment 1; 2 if the segments are intersecting and the segment 2 is only in one side of the segment 1.
      • equalsToShape

        @Pure
        default boolean equalsToShape​(IT shape)
        Description copied from interface: Shape2D
        Replies this shape is equal to the given shape.
        Specified by:
        equalsToShape in interface Shape2D<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        shape - the shape to compare to.
        Returns:
        true if this shape is equal is equal to the given path.
      • isEmpty

        @Pure
        default boolean isEmpty()
        Description copied from interface: Shape2D
        Replies if this shape is empty. The semantic associated to the state "empty" depends on the implemented shape. See the subclasses for details.
        Specified by:
        isEmpty in interface Shape2D<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​IE,​P,​V,​B>>
        Returns:
        true if the shape is empty; false otherwise.
      • set

        void set​(int x1,
                 int y1,
                 int x2,
                 int y2)
        Change the line.
        Parameters:
        x1 - x coordinate of the first point.
        y1 - y coordinate of the first point.
        x2 - x coordinate of the second point.
        y2 - y coordinate of the second point.
      • set

        default void set​(Point2D<?,​?> firstPoint,
                         Point2D<?,​?> secondPoint)
        Change the line.
        Parameters:
        firstPoint - the first point.
        secondPoint - the second point.
      • getX1

        @Pure
        int getX1()
        Replies the X of the first point.
        Returns:
        the x of the first point.
      • getY1

        @Pure
        int getY1()
        Replies the Y of the first point.
        Returns:
        the y of the first point.
      • getX2

        @Pure
        int getX2()
        Replies the X of the second point.
        Returns:
        the x of the second point.
      • getY2

        @Pure
        int getY2()
        Replies the Y of the second point.
        Returns:
        the y of the second point.
      • setX1

        @Pure
        void setX1​(int x)
        Change the X of the first point.
        Parameters:
        x - the x of the first point.
      • setY1

        @Pure
        void setY1​(int y)
        Change the Y of the first point.
        Parameters:
        y - the y of the first point.
      • setX2

        @Pure
        void setX2​(int x)
        Change the X of the second point.
        Parameters:
        x - the x of the second point.
      • setY2

        @Pure
        void setY2​(int y)
        Change the Y of the second point.
        Parameters:
        y - the y of the second point.
      • getP1

        @Pure
        default P getP1()
        Replies the first point.
        Returns:
        the first point.
      • getP2

        @Pure
        default P getP2()
        Replies the second point.
        Returns:
        the second point.
      • setP1

        @Pure
        default void setP1​(Point2D<?,​?> point)
        Change the first point.
        Parameters:
        point - the first point.
      • setP1

        @Pure
        default void setP1​(int x,
                           int y)
        Change the first point.
        Parameters:
        x - x coordinate of the first point.
        y - y coordinate of the first point.
      • setP2

        @Pure
        default void setP2​(Point2D<?,​?> point)
        Change the second point.
        Parameters:
        point - the second point.
      • setP2

        @Pure
        default void setP2​(int x,
                           int y)
        Change the second point.
        Parameters:
        x - x coordinate the second point.
        y - y coordinate the second point.
      • getDistanceSquared

        @Pure
        default double getDistanceSquared​(Segment2ai<?,​?,​?,​?,​?,​?> segment)
        Description copied from interface: Shape2ai
        Replies the minimum distance between this shape and the given segment.
        Specified by:
        getDistanceSquared in interface Shape2ai<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        segment - the segment.
        Returns:
        the minimum distance between the two shapes.
      • getDistanceSquared

        @Pure
        default double getDistanceSquared​(Rectangle2ai<?,​?,​?,​?,​?,​?> rectangle)
        Description copied from interface: Shape2ai
        Replies the minimum distance between this shape and the given rectangle.
        Specified by:
        getDistanceSquared in interface Shape2ai<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        rectangle - the rectangle.
        Returns:
        the minimum distance between the two shapes.
      • getDistanceSquared

        @Pure
        default double getDistanceSquared​(Point2D<?,​?> pt)
        Description copied from interface: Shape2D
        Replies the squared value of the minimal distance from this shape to the given point.
        Specified by:
        getDistanceSquared in interface Shape2D<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        pt - the point.
        Returns:
        squared value of the minimal distance between this shape and the point.
      • getDistanceL1

        @Pure
        default double getDistanceL1​(Point2D<?,​?> pt)
        Description copied from interface: Shape2D
        Computes the L-1 (Manhattan) distance between this shape and point p1. The L-1 distance is equal to abs(x1-x2) + abs(y1-y2).
        Specified by:
        getDistanceL1 in interface Shape2D<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        pt - the point
        Returns:
        the distance.
      • getDistanceLinf

        @Pure
        default double getDistanceLinf​(Point2D<?,​?> pt)
        Description copied from interface: Shape2D
        Computes the L-infinite distance between this shape and point p1. The L-infinite distance is equal to MAX[abs(x1-x2), abs(y1-y2)].
        Specified by:
        getDistanceLinf in interface Shape2D<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        pt - the point
        Returns:
        the distance.
      • contains

        @Pure
        default boolean contains​(int x,
                                 int y)
        Description copied from interface: Shape2ai
        Replies if the given point is inside this shape.
        Specified by:
        contains in interface Shape2ai<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        x - x coordinate of the point to test.
        y - y coordinate of the point to test.
        Returns:
        true if the given point is inside this shape, otherwise false.
      • contains

        @Pure
        default boolean contains​(Rectangle2ai<?,​?,​?,​?,​?,​?> rectangle)
        Description copied from interface: Shape2ai
        Replies if the given rectangle is inside this shape.
        Specified by:
        contains in interface Shape2ai<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        rectangle - the rectangle to test.
        Returns:
        true if the given box is inside the shape.
      • contains

        @Pure
        default boolean contains​(Shape2D<?,​?,​?,​?,​?,​?> shape)
        Description copied from interface: Shape2D
        Replies if this shape is inside the given shape.

        You must use the containing functions with a specific parameter type in place of this general function. Indeed, the implementation of this function is unefficient due to the tests against the types of the given shape, and the cast operators.

        Specified by:
        contains in interface Shape2ai<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​IE,​P,​V,​B>>
        Specified by:
        contains in interface Shape2D<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        shape - the shape to compare to.
        Returns:
        true if the given shape is inside this shape; false otherwise.
      • getClosestPointTo

        @Pure
        default P getClosestPointTo​(Point2D<?,​?> pt)
        Description copied from interface: Shape2D
        Replies the point on the shape that is closest to the given point.
        Specified by:
        getClosestPointTo in interface Shape2D<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        pt - the point.
        Returns:
        the closest point on the shape; or the point itself if it is inside the shape.
      • getClosestPointTo

        default P getClosestPointTo​(Circle2ai<?,​?,​?,​?,​?,​?> circle)
        Description copied from interface: Shape2ai
        Replies the closest point on this shape to the given rectangle.
        Specified by:
        getClosestPointTo in interface Shape2ai<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        circle - the circle.
        Returns:
        the closest point on this shape to the given shape; or the point if the point is in this shape.
      • getClosestPointTo

        default P getClosestPointTo​(Segment2ai<?,​?,​?,​?,​?,​?> segment)
        Description copied from interface: Shape2ai
        Replies the closest point on this shape to the given rectangle.
        Specified by:
        getClosestPointTo in interface Shape2ai<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        segment - the segment.
        Returns:
        the closest point on this shape to the given shape; or the point if the point is in this shape.
      • getClosestPointTo

        default P getClosestPointTo​(Rectangle2ai<?,​?,​?,​?,​?,​?> rectangle)
        Description copied from interface: Shape2ai
        Replies the closest point on this shape to the given rectangle.
        Specified by:
        getClosestPointTo in interface Shape2ai<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        rectangle - the rectangle.
        Returns:
        the closest point on this shape to the given shape; or the point if the point is in this shape.
      • getClosestPointTo

        default P getClosestPointTo​(Path2ai<?,​?,​?,​?,​?,​?> path)
        Description copied from interface: Shape2ai
        Replies the closest point on this shape to the given rectangle.
        Specified by:
        getClosestPointTo in interface Shape2ai<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        path - the path.
        Returns:
        the closest point on this shape to the given shape; or the point if the point is in this shape.
      • getPointIterator

        @Pure
        default Iterator<P> getPointIterator()
        Replies an iterator on the points of the segment.

        The Bresenham line algorithm is an algorithm which determines which points in an n-dimensional raster should be plotted in order to form a close approximation to a straight line between two given points. It is commonly used to draw lines on a computer screen, as it uses only integer addition, subtraction and bit shifting, all of which are very cheap operations in standard computer architectures. It is one of the earliest algorithms developed in the field of computer graphics. A minor extension to the original algorithm also deals with drawing circles.

        While algorithms such as Wu's algorithm are also frequently used in modern computer graphics because they can support antialiasing, the speed and simplicity of Bresenham's line algorithm mean that it is still important. The algorithm is used in hardware such as plotters and in the graphics chips of modern graphics cards. It can also be found in many software graphics libraries. Because the algorithm is very simple, it is often implemented in either the firmware or the hardware of modern graphics cards.

        Specified by:
        getPointIterator in interface Shape2ai<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​IE,​P,​V,​B>>
        Returns:
        an iterator on the points along the Bresenham line.
      • clipToRectangle

        default boolean clipToRectangle​(int rxmin,
                                        int rymin,
                                        int rxmax,
                                        int rymax)
        Clip the segment against the clipping rectangle according to the Cohen-Sutherland algorithm.
        Parameters:
        rxmin - is the min of the coordinates of the rectangle.
        rymin - is the min of the coordinates of the rectangle.
        rxmax - is the max of the coordinates of the rectangle.
        rymax - is the max of the coordinates of the rectangle.
        Returns:
        true if the segment has an intersection with the rectangle and the segment was clipped; false if the segment does not intersect the rectangle.
      • intersects

        @Pure
        default boolean intersects​(Rectangle2ai<?,​?,​?,​?,​?,​?> rectangle)
        Description copied from interface: Shape2ai
        Replies if this shape is intersecting the given rectangle.
        Specified by:
        intersects in interface Shape2ai<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        rectangle - the rectangle.
        Returns:
        true if this shape is intersecting the given shape; false if there is no intersection.
      • intersects

        @Pure
        default boolean intersects​(Circle2ai<?,​?,​?,​?,​?,​?> circle)
        Description copied from interface: Shape2ai
        Replies if this shape is intersecting the given circle.
        Specified by:
        intersects in interface Shape2ai<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        circle - the circle.
        Returns:
        true if this shape is intersecting the given shape; false if there is no intersection.
      • intersects

        @Pure
        default boolean intersects​(Segment2ai<?,​?,​?,​?,​?,​?> segment)
        Description copied from interface: Shape2ai
        Replies if this shape is intersecting the given segment.
        Specified by:
        intersects in interface Shape2ai<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        segment - the segment.
        Returns:
        true if this shape is intersecting the given shape; false if there is no intersection.
      • intersects

        @Pure
        default boolean intersects​(PathIterator2ai<?> iterator)
        Description copied from interface: Shape2ai
        Replies if this shape is intersecting the path described by the given iterator.
        Specified by:
        intersects in interface Shape2ai<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        iterator - the path iterator.
        Returns:
        true if this shape is intersecting the given shape; false if there is no intersection.
      • intersects

        @Pure
        default boolean intersects​(MultiShape2ai<?,​?,​?,​?,​?,​?,​?> multishape)
        Description copied from interface: Shape2ai
        Replies if this shape is intersecting the given multishape.
        Specified by:
        intersects in interface Shape2ai<ST extends Shape2ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment2ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement2ai,​P extends Point2D<? super P,​? super V>,​V extends Vector2D<? super V,​? super P>,​B extends Rectangle2ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        multishape - the multishape.
        Returns:
        true if this shape is intersecting the given shape; false if there is no intersection.