Interface Segment3ai<ST extends Shape3ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment3ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement3ai,​P extends Point3D<? super P,​? super V>,​V extends Vector3D<? super V,​? super P>,​B extends RectangularPrism3ai<?,​?,​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, Shape3ai<ST,​IT,​IE,​P,​V,​B>, Shape3D<ST,​IT,​PathIterator3ai<IE>,​P,​V,​B>
    All Known Implementing Classes:
    Segment3i, Segment3ifx, SegmentPoint3i

    public interface Segment3ai<ST extends Shape3ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment3ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement3ai,​P extends Point3D<? super P,​? super V>,​V extends Vector3D<? super V,​? super P>,​B extends RectangularPrism3ai<?,​?,​IE,​P,​V,​B>>
    extends Shape3ai<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 Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default void clear()
      Reset this shape to be equivalent to an just-created instance of this shape type.
      default boolean clipToRectangle​(int rxmin, int rymin, int rzmin, int rxmax, int rymax, int rzmax)
      Clip the segment against the clipping rectangle according to the Cohen-Sutherland algorithm.
      static void computeClosestPointToPoint​(int ax, int ay, int az, int bx, int by, int bz, int px, int py, int pz, Point3D<?,​?> result)
      Replies the closest point in a circle to a point.
      static double computeClosestPointToRectangle​(int sx1, int sy1, int sz1, int sx2, int sy2, int sz2, int rx, int ry, int rz, int rwidth, int rheight, int rdepth, Point3D<?,​?> result)
      Replies the point on the segment that is closest to the rectangle.
      static double computeClosestPointToSegment​(int s1x1, int s1y1, int s1z1, int s1x2, int s1y2, int s1z2, int s2x1, int s2y1, int s2z1, int s2x2, int s2y2, int s2z2, Point3D<?,​?> result)
      Replies the point on the first segment that is closest to the second segment.
      static double computeClosestPointToSegment​(int s1x1, int s1y1, int s1z1, int s1x2, int s1y2, int s1z2, int s2x1, int s2y1, int s2z1, int s2x2, int s2y2, int s2z2, Point3D<?,​?> resultOnFirstSegment, Point3D<?,​?> resultOnSecondSegment)
      Replies the point on the first segment that is closest to the second segment.
      static int computeCrossingsFromPoint​(int crossing, int px, int py, int pz, int x0, int y0, int z0, int x1, int y1, int z1)
      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).
      static int computeCrossingsFromPoint​(int crossing, int px, int py, int pz, int x0, int y0, int z0, int x1, int y1, int z1, boolean enableTopBorder, boolean enableBottomBorder)
      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).
      static int computeCrossingsFromRect​(int crossings, int rxmin, int rymin, int rzmin, int rxmax, int rymax, int rzmax, int x0, int y0, int z0, int x1, int y1, int z1)
      Accumulate the number of times the line crosses the shadow extending to the right of the rectangle.
      static int computeCrossingsFromSegment​(int crossings, int sx1, int sy1, int sz1, int sx2, int sy2, int sz2, int x0, int y0, int z0, int x1, int y1, int z1)
      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.
      static int computeCrossingsFromSphere​(int crossings, int cx, int cy, int cz, int radius, int x0, int y0, int z0, int x1, int y1, int z1)
      Calculates the number of times the line from (x0,y0,z0) to (x1,y1,z1) crosses the sphere (ex0,ey0,ez0,rad) extending to the right.
      static void computeFarthestPointTo​(int ax, int ay, int az, int bx, int by, int bz, int px, int py, int pz, Point3D<?,​?> result)
      Replies the farthest point in a circle to a point.
      static int computeIntersectionTypeSegmentSegment​(int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3, int x4, int y4, int z4, boolean enableThirdPoint, boolean enableFourthPoint, Point3D<?,​?> intersectionPoint)
      Replies if two segments are intersecting pixel per pixel.
      static int computeSideLinePoint​(int x1, int y1, int z1, int x2, int y2, int z2, int px, int py, int pz)
      Replies on which side of a line the given point is located.
      default boolean contains​(int x, int y, int z)
      Replies if the given point is inside this shape.
      default boolean contains​(RectangularPrism3ai<?,​?,​?,​?,​?,​?> rectangularPrism)
      Replies if the given rectangle is inside this shape.
      default boolean equalsToShape​(IT shape)
      Replies this shape is equal to the given shape.
      default P getClosestPointTo​(Path3ai<?,​?,​?,​?,​?,​?> path)
      Replies the closest point on this shape to the given rectangle.
      default P getClosestPointTo​(RectangularPrism3ai<?,​?,​?,​?,​?,​?> rectangle)
      Replies the closest point on this shape to the given rectangle.
      default P getClosestPointTo​(Segment3ai<?,​?,​?,​?,​?,​?> segment)
      Replies the closest point on this shape to the given rectangle.
      default P getClosestPointTo​(Sphere3ai<?,​?,​?,​?,​?,​?> circle)
      Replies the closest point on this shape to the given rectangle.
      default P getClosestPointTo​(Point3D<?,​?> pt)
      Replies the point on the shape that is closest to the given point.
      default double getDistanceL1​(Point3D<?,​?> pt)
      Computes the L-1 (Manhattan) distance between this shape and point p1.
      default double getDistanceLinf​(Point3D<?,​?> pt)
      Computes the L-infinite distance between this shape and point p1.
      default double getDistanceSquared​(Point3D<?,​?> pt)
      Replies the squared value of the minimal distance from this shape to the given point.
      default P getFarthestPointTo​(Point3D<?,​?> pt)
      Replies the point on the shape that is farthest the given point.
      default P getP1()
      Replies the first point.
      default P getP2()
      Replies the second point.
      default PathIterator3ai<IE> getPathIterator​(Transform3D transform)
      Replies the elements of the paths.
      default Iterator<P> getPointIterator()
      Replies an iterator on the points of the segment.
      int getX1()
      Replies the X of the first point.
      int getX2()
      Replies the X of the second point.
      int getY1()
      Replies the Y of the first point.
      int getY2()
      Replies the Y of the second point.
      int getZ1()
      Replies the Z of the first point.
      int getZ2()
      Replies the Z of the second point.
      default boolean intersects​(MultiShape3ai<?,​?,​?,​?,​?,​?,​?> multishape)
      Replies if this shape is intersecting the given multishape.
      default boolean intersects​(PathIterator3ai<?> iterator)
      Replies if this shape is intersecting the path described by the given iterator.
      default boolean intersects​(RectangularPrism3ai<?,​?,​?,​?,​?,​?> rectangularPrism)
      Replies if this shape is intersecting the given rectangular prism.
      default boolean intersects​(Segment3ai<?,​?,​?,​?,​?,​?> segment)
      Replies if this shape is intersecting the given segment.
      default boolean intersects​(Sphere3ai<?,​?,​?,​?,​?,​?> sphere)
      Replies if this shape is intersecting the given sphere.
      static boolean intersectsSegmentSegment​(int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3, int x4, int y4, int z4)
      Replies if two segments are intersecting.
      static boolean intersectsSegmentSegment​(int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3, int x4, int y4, int z4, boolean enableThirdPoint, boolean enableFourthPoint, Point3D<?,​?> intersectionPoint)
      Replies if two segments are intersecting pixel per pixel.
      default boolean isEmpty()
      Replies if this shape is empty.
      void set​(int x1, int y1, int z1, int x2, int y2, int z2)
      Change the line.
      default void set​(IT shape)
      Set this shape with the attributes of the given shape.
      default void set​(Point3D<?,​?> firstPoint, Point3D<?,​?> secondPoint)
      Change the line.
      default void setP1​(int x, int y, int z)
      Change the first point.
      default void setP1​(Point3D<?,​?> point)
      Change the first point.
      default void setP2​(int x, int y, int z)
      Change the second point.
      default void setP2​(Point3D<?,​?> point)
      Change the second point.
      void setX1​(int x)
      Change the X of the first point.
      void setX2​(int x)
      Change the X of the second point.
      void setY1​(int y)
      Change the Y of the first point.
      void setY2​(int y)
      Change the Y of the second point.
      void setZ1​(int z)
      Change the Z of the first point.
      void setZ2​(int z)
      Change the Z of the second point.
      default void toBoundingBox​(B box)
      Replies the bounds of the shape.
      default void transform​(Transform3D transform)
      Transform the current segment.
      default void translate​(int dx, int dy, int dz)
      Translate the shape.
    • Method Detail

      • computeClosestPointToPoint

        @Pure
        static void computeClosestPointToPoint​(int ax,
                                               int ay,
                                               int az,
                                               int bx,
                                               int by,
                                               int bz,
                                               int px,
                                               int py,
                                               int pz,
                                               Point3D<?,​?> 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
        az - is the z-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
        bz - is the z-coordinate of the second point of the segment
        px - is the x-coordinate of the point
        py - is the y-coordinate of the point
        pz - is the z-coordinate of the point
        result - the closest point in the segment to the point.
      • computeClosestPointToSegment

        @Pure
        static double computeClosestPointToSegment​(int s1x1,
                                                   int s1y1,
                                                   int s1z1,
                                                   int s1x2,
                                                   int s1y2,
                                                   int s1z2,
                                                   int s2x1,
                                                   int s2y1,
                                                   int s2z1,
                                                   int s2x2,
                                                   int s2y2,
                                                   int s2z2,
                                                   Point3D<?,​?> 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.
        s1z1 - is the z 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.
        s1z2 - is the z 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.
        s2z1 - is the z 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.
        s2z2 - is the z coordinate of the second point of the second segment.
        result - the is point on the shape.
        Returns:
        the square distance between the segments.
      • computeClosestPointToSegment

        @Pure
        static double computeClosestPointToSegment​(int s1x1,
                                                   int s1y1,
                                                   int s1z1,
                                                   int s1x2,
                                                   int s1y2,
                                                   int s1z2,
                                                   int s2x1,
                                                   int s2y1,
                                                   int s2z1,
                                                   int s2x2,
                                                   int s2y2,
                                                   int s2z2,
                                                   Point3D<?,​?> resultOnFirstSegment,
                                                   Point3D<?,​?> 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.
        s1z1 - is the z 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.
        s1z2 - is the z 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.
        s2z1 - is the z 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.
        s2z2 - is the z 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.
      • computeClosestPointToRectangle

        @Pure
        static double computeClosestPointToRectangle​(int sx1,
                                                     int sy1,
                                                     int sz1,
                                                     int sx2,
                                                     int sy2,
                                                     int sz2,
                                                     int rx,
                                                     int ry,
                                                     int rz,
                                                     int rwidth,
                                                     int rheight,
                                                     int rdepth,
                                                     Point3D<?,​?> 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.
        sz1 - is the z 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.
        sz2 - is the z coordinate of the second point of the segment.
        rx - is the x coordinate of the rectangle.
        ry - is the y coordinate of the rectangle.
        rz - is the z coordinate of the rectangle.
        rwidth - is the width of the rectangle.
        rheight - is the height of the rectangle.
        rdepth - is the depth of the rectangle.
        result - the is point on the segment.
        Returns:
        the square distance between the segments.
      • computeFarthestPointTo

        @Pure
        static void computeFarthestPointTo​(int ax,
                                           int ay,
                                           int az,
                                           int bx,
                                           int by,
                                           int bz,
                                           int px,
                                           int py,
                                           int pz,
                                           Point3D<?,​?> result)
        Replies the farthest 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
        az - is the z-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
        bz - is the z-coordinate of the second point of the segment
        px - is the x-coordinate of the point
        py - is the x-coordinate of the point
        pz - is the x-coordinate of the point
        result - the farthest point in the segment to the point.
      • computeSideLinePoint

        @Pure
        static int computeSideLinePoint​(int x1,
                                        int y1,
                                        int z1,
                                        int x2,
                                        int y2,
                                        int z2,
                                        int px,
                                        int py,
                                        int pz)
        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
        z1 - the Z 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
        z2 - the Z 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
        pz - the Z 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)
      • computeCrossingsFromSphere

        @Pure
        static int computeCrossingsFromSphere​(int crossings,
                                              int cx,
                                              int cy,
                                              int cz,
                                              int radius,
                                              int x0,
                                              int y0,
                                              int z0,
                                              int x1,
                                              int y1,
                                              int z1)
        Calculates the number of times the line from (x0,y0,z0) to (x1,y1,z1) crosses the sphere (ex0,ey0,ez0,rad) extending to the right.

        When the line (x0;y0;z1) to (x1;y1;z1) is crossing one of the up or bottom borders of the shadow of the sphere, the crossings count is increased or decreased, depending if the line is going down or up, respectively. In the following figure, the sphere 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.
        cz - 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.
        z0 - is the first point of the line.
        x1 - is the second point of the line.
        y1 - is the secondpoint of the line.
        z1 - is the secondpoint of the line.
        Returns:
        the crossing, or GeomConstants.SHAPE_INTERSECTS.
      • computeCrossingsFromSegment

        @Pure
        static int computeCrossingsFromSegment​(int crossings,
                                               int sx1,
                                               int sy1,
                                               int sz1,
                                               int sx2,
                                               int sy2,
                                               int sz2,
                                               int x0,
                                               int y0,
                                               int z0,
                                               int x1,
                                               int y1,
                                               int z1)
        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.
        sz1 - 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.
        sz2 - 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.
        z0 - is the first point of the line.
        x1 - is the second point of the line.
        y1 - is the secondpoint of the line.
        z1 - is the secondpoint of the line.
        Returns:
        the crossing, or GeomConstants.SHAPE_INTERSECTS.
      • computeCrossingsFromRect

        @Pure
        static int computeCrossingsFromRect​(int crossings,
                                            int rxmin,
                                            int rymin,
                                            int rzmin,
                                            int rxmax,
                                            int rymax,
                                            int rzmax,
                                            int x0,
                                            int y0,
                                            int z0,
                                            int x1,
                                            int y1,
                                            int z1)
        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.
        rzmin - is the first corner of the rectangle.
        rxmax - is the second corner of the rectangle.
        rymax - is the second corner of the rectangle.
        rzmax - is the second corner of the rectangle.
        x0 - is the first point of the line.
        y0 - is the first point of the line.
        z0 - is the first point of the line.
        x1 - is the second point of the line.
        y1 - is the secondpoint of the line.
        z1 - is the secondpoint of the line.
        Returns:
        the crossing, or GeomConstants.SHAPE_INTERSECTS.
      • computeCrossingsFromPoint

        @Pure
        static int computeCrossingsFromPoint​(int crossing,
                                             int px,
                                             int py,
                                             int pz,
                                             int x0,
                                             int y0,
                                             int z0,
                                             int x1,
                                             int y1,
                                             int z1)
        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.
        pz - is the reference point to test.
        x0 - is the first point of the line.
        y0 - is the first point of the line.
        z0 - is the first point of the line.
        x1 - is the second point of the line.
        y1 - is the secondpoint of the line.
        z1 - is the secondpoint of the line.
        Returns:
        the crossing, GeomConstants.SHAPE_INTERSECTS
      • computeCrossingsFromPoint

        @Pure
        static int computeCrossingsFromPoint​(int crossing,
                                             int px,
                                             int py,
                                             int pz,
                                             int x0,
                                             int y0,
                                             int z0,
                                             int x1,
                                             int y1,
                                             int z1,
                                             boolean enableTopBorder,
                                             boolean enableBottomBorder)
        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.
        pz - is the reference point to test.
        x0 - is the first point of the line.
        y0 - is the first point of the line.
        z0 - is the first point of the line.
        x1 - is the second point of the line.
        y1 - is the second point of the line.
        z1 - is the second point 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.
        Returns:
        the crossing; or GeomConstants.SHAPE_INTERSECTS if the segment is on the point.
      • intersectsSegmentSegment

        @Pure
        static boolean intersectsSegmentSegment​(int x1,
                                                int y1,
                                                int z1,
                                                int x2,
                                                int y2,
                                                int z2,
                                                int x3,
                                                int y3,
                                                int z3,
                                                int x4,
                                                int y4,
                                                int z4)
        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.
        z1 - 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.
        z2 - 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.
        z3 - 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.
        z4 - 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 z1,
                                                int x2,
                                                int y2,
                                                int z2,
                                                int x3,
                                                int y3,
                                                int z3,
                                                int x4,
                                                int y4,
                                                int z4,
                                                boolean enableThirdPoint,
                                                boolean enableFourthPoint,
                                                Point3D<?,​?> 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.
        z1 - 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.
        z2 - 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.
        z3 - 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.
        z4 - 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
      • computeIntersectionTypeSegmentSegment

        static int computeIntersectionTypeSegmentSegment​(int x1,
                                                         int y1,
                                                         int z1,
                                                         int x2,
                                                         int y2,
                                                         int z2,
                                                         int x3,
                                                         int y3,
                                                         int z3,
                                                         int x4,
                                                         int y4,
                                                         int z4,
                                                         boolean enableThirdPoint,
                                                         boolean enableFourthPoint,
                                                         Point3D<?,​?> 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.
        z1 - 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.
        z2 - 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.
        z3 - 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.
        z4 - 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.
      • isEmpty

        @Pure
        default boolean isEmpty()
        Description copied from interface: Shape3D
        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 Shape3D<ST extends Shape3ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment3ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement3ai,​P extends Point3D<? super P,​? super V>,​V extends Vector3D<? super V,​? super P>,​B extends RectangularPrism3ai<?,​?,​IE,​P,​V,​B>>
        Returns:
        true if the shape is empty; false otherwise.
      • set

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

        default void set​(Point3D<?,​?> firstPoint,
                         Point3D<?,​?> 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.
      • getZ1

        @Pure
        int getZ1()
        Replies the Z of the first point.
        Returns:
        the z 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.
      • getZ2

        @Pure
        int getZ2()
        Replies the Z of the second point.
        Returns:
        the z 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.
      • setZ1

        @Pure
        void setZ1​(int z)
        Change the Z of the first point.
        Parameters:
        z - the z 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.
      • setZ2

        @Pure
        void setZ2​(int z)
        Change the Z of the second point.
        Parameters:
        z - the z 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​(Point3D<?,​?> point)
        Change the first point.
        Parameters:
        point - the first point.
      • setP1

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

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

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

        @Pure
        default double getDistanceSquared​(Point3D<?,​?> pt)
        Description copied from interface: Shape3D
        Replies the squared value of the minimal distance from this shape to the given point.
        Specified by:
        getDistanceSquared in interface Shape3D<ST extends Shape3ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment3ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement3ai,​P extends Point3D<? super P,​? super V>,​V extends Vector3D<? super V,​? super P>,​B extends RectangularPrism3ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        pt - the point.
        Returns:
        squared value of the minimal distance between this shape and the point.
      • getDistanceLinf

        @Pure
        default double getDistanceLinf​(Point3D<?,​?> pt)
        Description copied from interface: Shape3D
        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), abs(z1-z2)].
        Specified by:
        getDistanceLinf in interface Shape3D<ST extends Shape3ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment3ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement3ai,​P extends Point3D<? super P,​? super V>,​V extends Vector3D<? super V,​? super P>,​B extends RectangularPrism3ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        pt - the point.
        Returns:
        the distance.
      • contains

        @Pure
        default boolean contains​(int x,
                                 int y,
                                 int z)
        Description copied from interface: Shape3ai
        Replies if the given point is inside this shape.
        Specified by:
        contains in interface Shape3ai<ST extends Shape3ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment3ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement3ai,​P extends Point3D<? super P,​? super V>,​V extends Vector3D<? super V,​? super P>,​B extends RectangularPrism3ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        x - x coordinate of the point to test.
        y - y coordinate of the point to test.
        z - z coordinate of the point to test.
        Returns:
        true if the given point is inside this shape, otherwise false.
      • getClosestPointTo

        default P getClosestPointTo​(Sphere3ai<?,​?,​?,​?,​?,​?> circle)
        Description copied from interface: Shape3ai
        Replies the closest point on this shape to the given rectangle.
        Specified by:
        getClosestPointTo in interface Shape3ai<ST extends Shape3ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment3ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement3ai,​P extends Point3D<? super P,​? super V>,​V extends Vector3D<? super V,​? super P>,​B extends RectangularPrism3ai<?,​?,​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​(Segment3ai<?,​?,​?,​?,​?,​?> segment)
        Description copied from interface: Shape3ai
        Replies the closest point on this shape to the given rectangle.
        Specified by:
        getClosestPointTo in interface Shape3ai<ST extends Shape3ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment3ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement3ai,​P extends Point3D<? super P,​? super V>,​V extends Vector3D<? super V,​? super P>,​B extends RectangularPrism3ai<?,​?,​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​(Path3ai<?,​?,​?,​?,​?,​?> path)
        Description copied from interface: Shape3ai
        Replies the closest point on this shape to the given rectangle.
        Specified by:
        getClosestPointTo in interface Shape3ai<ST extends Shape3ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment3ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement3ai,​P extends Point3D<? super P,​? super V>,​V extends Vector3D<? super V,​? super P>,​B extends RectangularPrism3ai<?,​?,​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 Shape3ai<ST extends Shape3ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment3ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement3ai,​P extends Point3D<? super P,​? super V>,​V extends Vector3D<? super V,​? super P>,​B extends RectangularPrism3ai<?,​?,​IE,​P,​V,​B>>
        Returns:
        an iterator on the points along the Bresenham line.
      • clipToRectangle

        default boolean clipToRectangle​(int rxmin,
                                        int rymin,
                                        int rzmin,
                                        int rxmax,
                                        int rymax,
                                        int rzmax)
        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.
        rzmin - 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.
        rzmax - 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​(RectangularPrism3ai<?,​?,​?,​?,​?,​?> rectangularPrism)
        Description copied from interface: Shape3ai
        Replies if this shape is intersecting the given rectangular prism.
        Specified by:
        intersects in interface Shape3ai<ST extends Shape3ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment3ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement3ai,​P extends Point3D<? super P,​? super V>,​V extends Vector3D<? super V,​? super P>,​B extends RectangularPrism3ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        rectangularPrism - the rectangular prism.
        Returns:
        true if this shape is intersecting the given shape; false if there is no intersection.
      • intersects

        @Pure
        default boolean intersects​(Sphere3ai<?,​?,​?,​?,​?,​?> sphere)
        Description copied from interface: Shape3ai
        Replies if this shape is intersecting the given sphere.
        Specified by:
        intersects in interface Shape3ai<ST extends Shape3ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment3ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement3ai,​P extends Point3D<? super P,​? super V>,​V extends Vector3D<? super V,​? super P>,​B extends RectangularPrism3ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        sphere - the sphere
        Returns:
        true if this shape is intersecting the given shape; false if there is no intersection.
      • intersects

        @Pure
        default boolean intersects​(Segment3ai<?,​?,​?,​?,​?,​?> segment)
        Description copied from interface: Shape3ai
        Replies if this shape is intersecting the given segment.
        Specified by:
        intersects in interface Shape3ai<ST extends Shape3ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment3ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement3ai,​P extends Point3D<? super P,​? super V>,​V extends Vector3D<? super V,​? super P>,​B extends RectangularPrism3ai<?,​?,​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​(PathIterator3ai<?> iterator)
        Description copied from interface: Shape3ai
        Replies if this shape is intersecting the path described by the given iterator.
        Specified by:
        intersects in interface Shape3ai<ST extends Shape3ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment3ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement3ai,​P extends Point3D<? super P,​? super V>,​V extends Vector3D<? super V,​? super P>,​B extends RectangularPrism3ai<?,​?,​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​(MultiShape3ai<?,​?,​?,​?,​?,​?,​?> multishape)
        Description copied from interface: Shape3ai
        Replies if this shape is intersecting the given multishape.
        Specified by:
        intersects in interface Shape3ai<ST extends Shape3ai<?,​?,​IE,​P,​V,​B>,​IT extends Segment3ai<?,​?,​IE,​P,​V,​B>,​IE extends PathElement3ai,​P extends Point3D<? super P,​? super V>,​V extends Vector3D<? super V,​? super P>,​B extends RectangularPrism3ai<?,​?,​IE,​P,​V,​B>>
        Parameters:
        multishape - the ùmultishape
        Returns:
        true if this shape is intersecting the given shape; false if there is no intersection.