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
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classSegment2ai.AbstractSegmentPathIterator<IE extends PathElement2ai>Abstract iterator on the path elements of the segment.static classSegment2ai.BresenhamLineIterator<P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>>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.static classSegment2ai.SegmentPathIterator<IE extends PathElement2ai>Iterator on the path elements of the segment.static classSegment2ai.TransformedSegmentPathIterator<IE extends PathElement2ai>Iterator on the path elements of the segment.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static intcalculatesCrossingsAndXPointShadowSegment(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).static intcalculatesCrossingsCircleShadowSegment(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.static intcalculatesCrossingsPointShadowSegment(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).static intcalculatesCrossingsRectangleShadowSegment(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.static intcalculatesCrossingsSegmentShadowSegment(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.default voidclear()Reset this shape to be equivalent to an just-created instance of this shape type.default booleanclipToRectangle(int rxmin, int rymin, int rxmax, int rymax)Clip the segment against the clipping rectangle according to the Cohen-Sutherland algorithm.default booleancontains(int x, int y)Replies if the given point is inside this shape.default booleancontains(Rectangle2ai<?,?,?,?,?,?> rectangle)Replies if the given rectangle is inside this shape.default booleancontains(Shape2D<?,?,?,?,?,?> shape)Replies if this shape is inside the given shape.default booleanequalsToShape(IT shape)Replies this shape is equal to the given shape.static voidfindsClosestPointSegmentPoint(int ax, int ay, int bx, int by, int px, int py, Point2D<?,?> result)Replies the closest point in a circle to a point.static doublefindsClosestPointSegmentRectangle(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.static doublefindsClosestPointSegmentSegment(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.static doublefindsClosestPointsSegmentSegment(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.static voidfindsFarthestPointSegmentPoint(int ax, int ay, int bx, int by, int px, int py, Point2D<?,?> result)Replies the farthest point on a segment to a point.static intfindsIntersectionTypeSegmentSegment(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.static intfindsSideLinePoint(int x1, int y1, int x2, int y2, int px, int py)Replies on which side of a line the given point is located.default PgetClosestPointTo(Circle2ai<?,?,?,?,?,?> circle)Replies the closest point on this shape to the given rectangle.default PgetClosestPointTo(Path2ai<?,?,?,?,?,?> path)Replies the closest point on this shape to the given rectangle.default PgetClosestPointTo(Rectangle2ai<?,?,?,?,?,?> rectangle)Replies the closest point on this shape to the given rectangle.default PgetClosestPointTo(Segment2ai<?,?,?,?,?,?> segment)Replies the closest point on this shape to the given rectangle.default PgetClosestPointTo(Point2D<?,?> pt)Replies the point on the shape that is closest to the given point.default doublegetDistanceL1(Point2D<?,?> pt)Computes the L-1 (Manhattan) distance between this shape and point p1.default doublegetDistanceLinf(Point2D<?,?> pt)Computes the L-infinite distance between this shape and point p1.default doublegetDistanceSquared(Rectangle2ai<?,?,?,?,?,?> rectangle)Replies the minimum distance between this shape and the given rectangle.default doublegetDistanceSquared(Segment2ai<?,?,?,?,?,?> segment)Replies the minimum distance between this shape and the given segment.default doublegetDistanceSquared(Point2D<?,?> pt)Replies the squared value of the minimal distance from this shape to the given point.default PgetFarthestPointTo(Point2D<?,?> pt)Replies the point on the shape that is farthest the given point.default PgetP1()Replies the first point.default PgetP2()Replies the second point.default PathIterator2ai<IE>getPathIterator(Transform2D transform)Replies the elements of the paths.default Iterator<P>getPointIterator()Replies an iterator on the points of the segment.intgetX1()Replies the X of the first point.intgetX2()Replies the X of the second point.intgetY1()Replies the Y of the first point.intgetY2()Replies the Y of the second point.default booleanintersects(Circle2ai<?,?,?,?,?,?> circle)Replies if this shape is intersecting the given circle.default booleanintersects(MultiShape2ai<?,?,?,?,?,?,?> multishape)Replies if this shape is intersecting the given multishape.default booleanintersects(PathIterator2ai<?> iterator)Replies if this shape is intersecting the path described by the given iterator.default booleanintersects(Rectangle2ai<?,?,?,?,?,?> rectangle)Replies if this shape is intersecting the given rectangle.default booleanintersects(Segment2ai<?,?,?,?,?,?> segment)Replies if this shape is intersecting the given segment.static booleanintersectsSegmentSegment(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)Replies if two segments are intersecting.static booleanintersectsSegmentSegment(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.default booleanisEmpty()Replies if this shape is empty.voidset(int x1, int y1, int x2, int y2)Change the line.default voidset(IT shape)Set this shape with the attributes of the given shape.default voidset(Point2D<?,?> firstPoint, Point2D<?,?> secondPoint)Change the line.default voidsetP1(int x, int y)Change the first point.default voidsetP1(Point2D<?,?> point)Change the first point.default voidsetP2(int x, int y)Change the second point.default voidsetP2(Point2D<?,?> point)Change the second point.voidsetX1(int x)Change the X of the first point.voidsetX2(int x)Change the X of the second point.voidsetY1(int y)Change the Y of the first point.voidsetY2(int y)Change the Y of the second point.default voidtoBoundingBox(B box)Replies the bounds of the shape.default voidtransform(Transform2D transform)Transform the current segment.default voidtranslate(int dx, int dy)Translate the shape.-
Methods inherited from interface org.arakhne.afc.vmutil.json.JsonableObject
toJson
-
Methods inherited from interface org.arakhne.afc.math.geometry.d2.ai.Shape2ai
contains, createTransformedShape, getClosestPointTo, getClosestPointTo, getDistanceSquared, getDistanceSquared, getDistanceSquared, getDistanceSquared, getGeomFactory, intersects, intersects, toBoundingBox, translate
-
Methods inherited from interface org.arakhne.afc.math.geometry.d2.Shape2D
clone, equalsToPathIterator, getDistance, getDistance, getPathIterator, operator_add, operator_and, operator_and, operator_minus, operator_multiply, operator_plus, operator_remove, operator_upTo
-
-
-
-
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 segmentay- is the y-coordinate of the first point of the segmentbx- is the x-coordinate of the second point of the segmentby- is the y-coordinate of the second point of the segmentpx- is the x-coordinate of the pointpy- is the x-coordinate of the pointresult- 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 segmentay- is the y-coordinate of the first point of the segmentbx- is the x-coordinate of the second point of the segmentby- is the y-coordinate of the second point of the segmentpx- is the x-coordinate of the pointpy- is the x-coordinate of the pointresult- 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 segmenty1- the Y coordinate of the start point of the specified line segmentx2- the X coordinate of the end point of the specified line segmenty2- the Y coordinate of the end point of the specified line segmentpx- the X coordinate of the specified point to be compared with the specified line segmentpy- 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_INTERSECTSis 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_INTERSECTSif 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:
trueif the two shapes are intersecting; otherwisefalse
-
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:
trueif the two segments are intersecting; otherwisefalse
-
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
0the two segments are not intersecting;1if the two segments are intersecting and the segment 2 has pixels on both sides of the segment 1;2if 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:Shape2DReplies this shape is equal to the given shape.- Specified by:
equalsToShapein interfaceShape2D<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:
trueif this shape is equal is equal to the given path.
-
clear
default void clear()
Description copied from interface:Shape2DReset this shape to be equivalent to an just-created instance of this shape type.
-
isEmpty
@Pure default boolean isEmpty()
Description copied from interface:Shape2DReplies if this shape is empty. The semantic associated to the state "empty" depends on the implemented shape. See the subclasses for details.- Specified by:
isEmptyin interfaceShape2D<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:
trueif the shape is empty;falseotherwise.
-
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.
-
set
default void set(IT shape)
Description copied from interface:Shape2DSet this shape with the attributes of the given shape.- Specified by:
setin interfaceShape2D<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 copy.
-
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.
-
toBoundingBox
@Pure default void toBoundingBox(B box)
Description copied from interface:Shape2DReplies the bounds of the shape.- Specified by:
toBoundingBoxin interfaceShape2D<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:
box- is set with the bounds of the shape.
-
getDistanceSquared
@Pure default double getDistanceSquared(Segment2ai<?,?,?,?,?,?> segment)
Description copied from interface:Shape2aiReplies the minimum distance between this shape and the given segment.- Specified by:
getDistanceSquaredin interfaceShape2ai<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:Shape2aiReplies the minimum distance between this shape and the given rectangle.- Specified by:
getDistanceSquaredin interfaceShape2ai<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:Shape2DReplies the squared value of the minimal distance from this shape to the given point.- Specified by:
getDistanceSquaredin interfaceShape2D<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:Shape2DComputes 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:
getDistanceL1in interfaceShape2D<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:Shape2DComputes 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:
getDistanceLinfin interfaceShape2D<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:Shape2aiReplies if the given point is inside this shape.- Specified by:
containsin interfaceShape2ai<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:
trueif the given point is inside this shape, otherwisefalse.
-
contains
@Pure default boolean contains(Rectangle2ai<?,?,?,?,?,?> rectangle)
Description copied from interface:Shape2aiReplies if the given rectangle is inside this shape.- Specified by:
containsin interfaceShape2ai<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:
trueif the given box is inside the shape.
-
contains
@Pure default boolean contains(Shape2D<?,?,?,?,?,?> shape)
Description copied from interface:Shape2DReplies 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:
containsin interfaceShape2ai<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:
containsin interfaceShape2D<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:
trueif the given shape is inside this shape;falseotherwise.
-
getClosestPointTo
@Pure default P getClosestPointTo(Point2D<?,?> pt)
Description copied from interface:Shape2DReplies the point on the shape that is closest to the given point.- Specified by:
getClosestPointToin interfaceShape2D<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:Shape2aiReplies the closest point on this shape to the given rectangle.- Specified by:
getClosestPointToin interfaceShape2ai<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:Shape2aiReplies the closest point on this shape to the given rectangle.- Specified by:
getClosestPointToin interfaceShape2ai<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:Shape2aiReplies the closest point on this shape to the given rectangle.- Specified by:
getClosestPointToin interfaceShape2ai<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:Shape2aiReplies the closest point on this shape to the given rectangle.- Specified by:
getClosestPointToin interfaceShape2ai<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.
-
getFarthestPointTo
@Pure default P getFarthestPointTo(Point2D<?,?> pt)
Description copied from interface:Shape2DReplies the point on the shape that is farthest the given point.- Specified by:
getFarthestPointToin interfaceShape2D<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 farthest point on the shape.
-
translate
default void translate(int dx, int dy)Description copied from interface:Shape2aiTranslate the shape.- Specified by:
translatein interfaceShape2ai<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:
dx- x translation.dy- y translation.
-
getPathIterator
@Pure default PathIterator2ai<IE> getPathIterator(Transform2D transform)
Description copied from interface:Shape2DReplies the elements of the paths.- Specified by:
getPathIteratorin interfaceShape2D<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:
transform- is the transformation to apply to the path.- Returns:
- the elements of the path.
-
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:
getPointIteratorin interfaceShape2ai<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.
-
transform
default void transform(Transform2D transform)
Transform the current segment. This function changes the current segment.- Parameters:
transform- is the affine transformation to apply.- See Also:
Shape2ai.createTransformedShape(Transform2D)
-
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:
trueif the segment has an intersection with the rectangle and the segment was clipped;falseif the segment does not intersect the rectangle.
-
intersects
@Pure default boolean intersects(Rectangle2ai<?,?,?,?,?,?> rectangle)
Description copied from interface:Shape2aiReplies if this shape is intersecting the given rectangle.- Specified by:
intersectsin interfaceShape2ai<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:
trueif this shape is intersecting the given shape;falseif there is no intersection.
-
intersects
@Pure default boolean intersects(Circle2ai<?,?,?,?,?,?> circle)
Description copied from interface:Shape2aiReplies if this shape is intersecting the given circle.- Specified by:
intersectsin interfaceShape2ai<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:
trueif this shape is intersecting the given shape;falseif there is no intersection.
-
intersects
@Pure default boolean intersects(Segment2ai<?,?,?,?,?,?> segment)
Description copied from interface:Shape2aiReplies if this shape is intersecting the given segment.- Specified by:
intersectsin interfaceShape2ai<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:
trueif this shape is intersecting the given shape;falseif there is no intersection.
-
intersects
@Pure default boolean intersects(PathIterator2ai<?> iterator)
Description copied from interface:Shape2aiReplies if this shape is intersecting the path described by the given iterator.- Specified by:
intersectsin interfaceShape2ai<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:
trueif this shape is intersecting the given shape;falseif there is no intersection.
-
intersects
@Pure default boolean intersects(MultiShape2ai<?,?,?,?,?,?,?> multishape)
Description copied from interface:Shape2aiReplies if this shape is intersecting the given multishape.- Specified by:
intersectsin interfaceShape2ai<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:
trueif this shape is intersecting the given shape;falseif there is no intersection.
-
-



