Interface Segment2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>
-
- Type Parameters:
ST- is the type of the general implementation.IT- is the type of the implementation of this shape.IE- is the type of the path elements.P- is the type of the points.V- is the type of the vectors.B- is the type of the bounding boxes.
- All Superinterfaces:
Cloneable,JsonableObject,Serializable,Shape2afp<ST,IT,IE,P,V,B>,Shape2D<ST,IT,PathIterator2afp<IE>,P,V,B>
- All Known Implementing Classes:
Segment2d,Segment2dfx,SegmentPoint2d
public interface Segment2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>> extends Shape2afp<ST,IT,IE,P,V,B>
Fonctional interface that represented a 2D segment/line on a plane.- Version:
- 17.0 2020-01-04 14:41:43
- Author:
- Stéphane GALLAND, Hamza JAFFALI
- Maven Group Id:
- org.arakhne.afc.core
- Maven Artifact Id:
- mathgeom
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classSegment2afp.SegmentPathIterator<T extends PathElement2afp>Iterator on the path elements of the segment.static classSegment2afp.UncertainIntersectionResult of the intersection between segments in a context where a single test is not enough.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static intcalculatesCrossingsCircleShadowSegment(int crossings, double cx, double cy, double radius, double x0, double y0, double x1, double y1)Calculates the number of times the line from (x0, y0) to (x1, y1) crosses the circle (cx, cy) with radius extending to the right.static intcalculatesCrossingsEllipseShadowSegment(int crossings, double ex, double ey, double ew, double eh, double x0, double y0, double x1, double 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(double px, double py, double x0, double y0, double x1, double y1)Calculates the number of times the line from (x0, y0) to (x1, y1) crosses the ray extending to the right from (px, py).static intcalculatesCrossingsPointShadowSegmentWithoutEquality(double px, double py, double x0, double y0, double x1, double y1)Calculates the number of times the line from (x0, y0) to (x1, y1) crosses the ray extending to the right from (px, py).static intcalculatesCrossingsRectangleShadowSegment(int crossings, double rxmin, double rymin, double rxmax, double rymax, double x0, double y0, double x1, double y1)Accumulate the number of times the line crosses the shadow extending to the right of the rectangle.static intcalculatesCrossingsRoundRectangleShadowSegment(int crossings, double rxmin, double rymin, double rxmax, double rymax, double arcWidth, double arcHeight, double x0, double y0, double x1, double y1)Accumulate the number of times the line crosses the shadow extending to the right of the round rectangle.static intcalculatesCrossingsSegmentShadowSegment(int crossings, double sx1, double sy1, double sx2, double sy2, double x0, double y0, double x1, double 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.static intcalculatesCrossingsTriangleShadowSegment(int crossings, double tx1, double ty1, double tx2, double ty2, double tx3, double ty3, double x0, double y0, double x1, double y1)Accumulate the number of times the line crosses the shadow extending to the right of the triangle.static doublecalculatesDistanceLinePoint(double x1, double y1, double x2, double y2, double px, double py)Compute the distance between a point and a line.static doublecalculatesDistanceSegmentPoint(double x1, double y1, double x2, double y2, double px, double py)Compute the distance between a point and a segment.static doublecalculatesDistanceSquaredLinePoint(double x1, double y1, double x2, double y2, double px, double py)Compute the distance between a point and a line.static doublecalculatesDistanceSquaredSegmentPoint(double x1, double y1, double x2, double y2, double px, double py)Compute the square distance between a point and a segment.static doublecalculatesDistanceSquaredSegmentSegment(double s1x1, double s1y1, double s1x2, double s1y2, double s2x1, double s2y1, double s2x2, double s2y2)Replies the distance between the two segments.static doublecalculatesLineLineIntersectionFactor(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)Replies the position factory for the intersection point between two lines.static doublecalculatesRelativeDistanceLinePoint(double x1, double y1, double x2, double y2, double px, double py)Replies the relative distance from the given point to the given line.static doublecalculatesSegmentSegmentIntersectionFactor(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)Replies one position factor for the intersection point between two lines.static intccw(double x1, double y1, double x2, double y2, double px, double py, double epsilon)Replies the relative counterclockwise (CCW) of a segment against a point.default voidclear()Reset this shape to be equivalent to an just-created instance of this shape type.default booleanclipToRectangle(double rxmin, double rymin, double rxmax, double rymax)Clip the segment against the clipping rectangle according to the Cohen-Sutherland algorithm.default booleancontains(double x, double y)Replies if the given point is inside this shape.default booleancontains(Rectangle2afp<?,?,?,?,?,?> 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(double ax, double ay, double bx, double by, double px, double py, Point2D<?,?> result)Replies the point on the segment that is closest to the given point.static voidfindsClosestPointSegmentRectangle(double sx1, double sy1, double sx2, double sy2, double rx, double ry, double rwidth, double rheight, Point2D<?,?> result)Replies the point on the segment that is closest to the rectangle.static doublefindsClosestPointSegmentSegment(double s1x1, double s1y1, double s1x2, double s1y2, double s2x1, double s2y1, double s2x2, double s2y2, Point2D<?,?> result)Replies the point on the first segment that is closest to the second segment.static doublefindsClosestPointSegmentSegment(double s1x1, double s1y1, double s1x2, double s1y2, double s2x1, double s2y1, double s2x2, double s2y2, Point2D<?,?> resultOnFirstSegment, Point2D<?,?> resultOnSecondSegment)Replies the point on the first segment that is closest to the second segment.static voidfindsFarthestPointSegmentPoint(double ax, double ay, double bx, double by, double px, double py, Point2D<?,?> result)Replies the point on the segment that is farthest to the given point.static voidfindsFarthestPointSegmentRectangle(double sx1, double sy1, double sx2, double sy2, double rx, double ry, double rwidth, double rheight, Point2D<?,?> result)Replies the point on the segment that is farthest to the rectangle.static doublefindsFarthestPointSegmentSegment(double s1x1, double s1y1, double s1x2, double s1y2, double s2x1, double s2y1, double s2x2, double s2y2, Point2D<?,?> result)Replies the point on the first segment that is farthest to the second segment.static booleanfindsLineLineIntersection(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, Point2D<?,?> result)Compute the intersection of two lines specified by the specified points and vectors.static doublefindsProjectedPointPointLine(double px, double py, double s1x, double s1y, double s2x, double s2y)Replies the projection a point on a segment.static booleanfindsSegmentSegmentIntersection(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, Point2D<?,?> result)Replies the intersection point between two segments.static intfindsSideLinePoint(double x1, double y1, double x2, double y2, double px, double py, double epsilon)} Replies on which side of a line the given point is located.static Segment2afp.UncertainIntersectionfindsUncertainIntersectionSegmentSegmentWithEnds(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)Do an intersection test of two segments for ensuring that the answer of "no intersect" is safe.static Segment2afp.UncertainIntersectionfindsUncertainIntersectionSegmentSegmentWithoutEnds(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)Do an intersection test of two segments for ensuring that the answer of "no intersect" is safe.default PgetClosestPointTo(Circle2afp<?,?,?,?,?,?> circle)Replies the closest point on this shape to the given circle.default PgetClosestPointTo(Ellipse2afp<?,?,?,?,?,?> ellipse)Replies the closest point on this shape to the given ellipse.default PgetClosestPointTo(OrientedRectangle2afp<?,?,?,?,?,?> orientedRectngle)Replies the closest point on this shape to the given oriented rectangle.default PgetClosestPointTo(Parallelogram2afp<?,?,?,?,?,?> parallelogram)Replies the closest point on this shape to the given parallelogram.default PgetClosestPointTo(Path2afp<?,?,?,?,?,?> path)Replies the closest point on this shape to the given path.default PgetClosestPointTo(Rectangle2afp<?,?,?,?,?,?> rectangle)Replies the closest point on this shape to the given rectangle.default PgetClosestPointTo(RoundRectangle2afp<?,?,?,?,?,?> roundRectangle)Replies the closest point on this shape to the given round rectangle.default PgetClosestPointTo(Segment2afp<?,?,?,?,?,?> segment)Replies the closest point on this shape to the given segment.default PgetClosestPointTo(Triangle2afp<?,?,?,?,?,?> triangle)Replies the closest point on this shape to the given triangle.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(Segment2afp<?,?,?,?,?,?> 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 doublegetLength()Replies the length of the segment.default doublegetLengthSquared()Replies the squared length of the segment.default PgetP1()Replies the first point.default PgetP2()Replies the second point.default PathIterator2afp<IE>getPathIterator(Transform2D transform)Replies the elements of the paths.doublegetX1()Replies the X of the first point.doublegetX2()Replies the X of the second point.doublegetY1()Replies the Y of the first point.doublegetY2()Replies the Y of the second point.static voidinterpolates(double p1x, double p1y, double p2x, double p2y, double factor, Point2D<?,?> result)Compute the interpolate point between the two points.default booleanintersects(Circle2afp<?,?,?,?,?,?> circle)Replies if this shape is intersecting the given circle.default booleanintersects(Ellipse2afp<?,?,?,?,?,?> ellipse)Replies if this shape is intersecting the given ellipse.default booleanintersects(MultiShape2afp<?,?,?,?,?,?,?> multishape)Replies if this shape is intersecting the given multishape.default booleanintersects(OrientedRectangle2afp<?,?,?,?,?,?> orientedRectangle)Replies if this shape is intersecting the given rectangle.default booleanintersects(Parallelogram2afp<?,?,?,?,?,?> parallelogram)Replies if this shape is intersecting the given parallelogram.default booleanintersects(PathIterator2afp<?> iterator)Replies if this shape is intersecting the shape representing the given path iterator.default booleanintersects(Rectangle2afp<?,?,?,?,?,?> rectangle)Replies if this shape is intersecting the given rectangle.default booleanintersects(RoundRectangle2afp<?,?,?,?,?,?> roundRectangle)Replies if this shape is intersecting the given rectangle.default booleanintersects(Segment2afp<?,?,?,?,?,?> segment)Replies if this shape is intersecting the given line.default booleanintersects(Triangle2afp<?,?,?,?,?,?> triangle)Replies if this shape is intersecting the given triangle.static booleanintersectsLineLine(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)Replies if two lines are intersecting.static booleanintersectsSegmentLine(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)Replies if a segment and a line are intersecting.static booleanintersectsSegmentSegmentWithEnds(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)Replies if two segments are intersecting.static booleanintersectsSegmentSegmentWithoutEnds(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)Replies if two segments are intersecting.static booleanisCollinearLines(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)Replies if two lines are colinear.default booleanisEmpty()Replies if this shape is empty.static booleanisParallelLines(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)Replies if two lines are parallel.static booleanisPointClosedToLine(double x1, double y1, double x2, double y2, double x, double y, double hitDistance)Replies if a point is closed to a line.static booleanisPointClosedToSegment(double x1, double y1, double x2, double y2, double x, double y, double hitDistance)Replies if a point is closed to a segment.voidset(double x1, double y1, double x2, double 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(double x, double y)Change the first point.default voidsetP1(Point2D<?,?> pt)Change the first point.default voidsetP2(double x, double y)Change the second point.default voidsetP2(Point2D<?,?> pt)Change the second point.voidsetX1(double x)Sets a new value in the X of the first point.voidsetX2(double x)Sets a new value in the X of the second point.voidsetY1(double y)Sets a new value in the Y of the first point.voidsetY2(double y)Sets a new value in 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(double dx, double 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.afp.Shape2afp
contains, createTransformedShape, getClosestPointTo, getClosestPointTo, getDistanceSquared, getDistanceSquared, getDistanceSquared, getDistanceSquared, getDistanceSquared, getDistanceSquared, 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
-
ccw
@Pure static int ccw(double x1, double y1, double x2, double y2, double px, double py, double epsilon)Replies the relative counterclockwise (CCW) of a segment against a point. Returns an indicator of where the specified point(px, py)lies with respect to the line segment from(x1, y1)to(x2, y2). The return value can be either 1, -1, or 0 and indicates in which direction the specified line must pivot around its first end point,(x1, y1), in order to point at the specified point(px, py). In other words, given three point P1, P2, and P, is the segments (P1-P2-P) a counterclockwise turn?In opposite to
findsSideLinePoint(double, double, double, double, double, double, double), this function tries to classifies the point if it is colinear to the segment. The classification is explained below.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, this direction is clockwise.
A return value of 0 indicates that the point lies exactly on the line segment. Note that an indicator value of 0 is rare and not useful for determining colinearity because of floating point rounding issues.
If the point is colinear with the line segment, but not between the end points, then the value will be -1 if the point lies "beyond
(x1, y1)" or 1 if the point lies "beyond(x2, y2)".- 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 segmentepsilon- approximation of the tests for equality to zero.- 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:
calculatesRelativeDistanceLinePoint(double, double, double, double, double, double),findsSideLinePoint(double, double, double, double, double, double, double)
-
findsClosestPointSegmentPoint
static void findsClosestPointSegmentPoint(double ax, double ay, double bx, double by, double px, double py, Point2D<?,?> result)Replies the point on the segment that is closest to the given point.- Parameters:
ax- is the x coordinate of the first point of the segment.ay- is the y coordinate of the first point of the segment.bx- is the x coordinate of the second point of the segment.by- is the y coordinate of the second point of the segment.px- is the x coordinate of the point.py- is the y coordinate of the point.result- the is point on the shape.
-
findsClosestPointSegmentRectangle
static void findsClosestPointSegmentRectangle(double sx1, double sy1, double sx2, double sy2, double rx, double ry, double rwidth, double 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.
-
findsClosestPointSegmentSegment
static double findsClosestPointSegmentSegment(double s1x1, double s1y1, double s1x2, double s1y2, double s2x1, double s2y1, double s2x2, double 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.
-
findsClosestPointSegmentSegment
static double findsClosestPointSegmentSegment(double s1x1, double s1y1, double s1x2, double s1y2, double s2x1, double s2y1, double s2x2, double 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.
-
calculatesCrossingsCircleShadowSegment
@Pure static int calculatesCrossingsCircleShadowSegment(int crossings, double cx, double cy, double radius, double x0, double y0, double x1, double y1)Calculates the number of times the line from (x0, y0) to (x1, y1) crosses the circle (cx, cy) with radius extending to the right.- 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.
-
calculatesCrossingsEllipseShadowSegment
@Pure static int calculatesCrossingsEllipseShadowSegment(int crossings, double ex, double ey, double ew, double eh, double x0, double y0, double x1, double 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.- Parameters:
crossings- is the initial value for the number of crossings.ex- is the first corner of the ellipse to extend.ey- is the first corner of the ellipse to extend.ew- is the width of the ellipse to extend.eh- is the height of the ellipse 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.
-
calculatesCrossingsPointShadowSegment
@Pure static int calculatesCrossingsPointShadowSegment(double px, double py, double x0, double y0, double x1, double y1)Calculates the number of times the line from (x0, y0) to (x1, y1) crosses the ray extending to the right from (px, py). If the point lies on the line, then no crossings are recorded. +1 is returned for a crossing where the Y coordinate is increasing -1 is returned for a crossing where the Y coordinate is decreasingThis function differs from
calculatesCrossingsPointShadowSegmentWithoutEquality(double, double, double, double, double, double). The equality test is used in this function.- Parameters:
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.
-
calculatesCrossingsPointShadowSegmentWithoutEquality
@Pure static int calculatesCrossingsPointShadowSegmentWithoutEquality(double px, double py, double x0, double y0, double x1, double y1)Calculates the number of times the line from (x0, y0) to (x1, y1) crosses the ray extending to the right from (px, py). If the point lies on the line, then no crossings are recorded. +1 is returned for a crossing where the Y coordinate is increasing -1 is returned for a crossing where the Y coordinate is decreasingThis function differs from
calculatesCrossingsPointShadowSegment(double, double, double, double, double, double). The equality test is not used in this function.- Parameters:
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.
-
calculatesCrossingsRectangleShadowSegment
@Pure static int calculatesCrossingsRectangleShadowSegment(int crossings, double rxmin, double rymin, double rxmax, double rymax, double x0, double y0, double x1, double y1)Accumulate the number of times the line crosses the shadow extending to the right of the rectangle. See the comment for theGeomConstants.SHAPE_INTERSECTSconstant for more complete details.- 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.
-
calculatesCrossingsRoundRectangleShadowSegment
@Pure static int calculatesCrossingsRoundRectangleShadowSegment(int crossings, double rxmin, double rymin, double rxmax, double rymax, double arcWidth, double arcHeight, double x0, double y0, double x1, double y1)Accumulate the number of times the line crosses the shadow extending to the right of the round rectangle. See the comment for theGeomConstants.SHAPE_INTERSECTSconstant for more complete details.- 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.arcWidth- is the width of the rectangle arcs.arcHeight- is the height of the rectangle arcs.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, double sx1, double sy1, double sx2, double sy2, double x0, double y0, double x1, double 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.- 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
-
calculatesCrossingsTriangleShadowSegment
@Pure static int calculatesCrossingsTriangleShadowSegment(int crossings, double tx1, double ty1, double tx2, double ty2, double tx3, double ty3, double x0, double y0, double x1, double y1)Accumulate the number of times the line crosses the shadow extending to the right of the triangle. See the comment for theGeomConstants.SHAPE_INTERSECTSconstant for more complete details.- Parameters:
crossings- is the initial value for the number of crossings.tx1- is the first point of the triangle.ty1- is the first point of the triangle.tx2- is the second point of the triangle.ty2- is the second point of the triangle.tx3- is the third point of the triangle.ty3- is the third point of the triangle.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.
-
calculatesDistanceLinePoint
@Pure static double calculatesDistanceLinePoint(double x1, double y1, double x2, double y2, double px, double py)Compute the distance between a point and a line.- Parameters:
x1- horizontal position of the first point of the line.y1- vertical position of the first point of the line.x2- horizontal position of the second point of the line.y2- vertical position of the second point of the line.px- horizontal position of the point.py- vertical position of the point.- Returns:
- the distance beetween the point and the line.
- See Also:
calculatesDistanceSquaredLinePoint(double, double, double, double, double, double),calculatesRelativeDistanceLinePoint(double, double, double, double, double, double)
-
calculatesDistanceSegmentPoint
@Pure static double calculatesDistanceSegmentPoint(double x1, double y1, double x2, double y2, double px, double py)Compute the distance between a point and a segment.- Parameters:
x1- horizontal position of the first point of the segment.y1- vertical position of the first point of the segment.x2- horizontal position of the second point of the segment.y2- vertical position of the second point of the segment.px- horizontal position of the point.py- vertical position of the point.- Returns:
- the distance beetween the point and the segment.
-
calculatesDistanceSquaredLinePoint
@Pure static double calculatesDistanceSquaredLinePoint(double x1, double y1, double x2, double y2, double px, double py)Compute the distance between a point and a line.- Parameters:
x1- horizontal position of the first point of the line.y1- vertical position of the first point of the line.x2- horizontal position of the second point of the line.y2- vertical position of the second point of the line.px- horizontal position of the point.py- vertical position of the point.- Returns:
- the distance beetween the point and the line.
- See Also:
calculatesDistanceLinePoint(double, double, double, double, double, double)
-
calculatesDistanceSquaredSegmentPoint
@Pure static double calculatesDistanceSquaredSegmentPoint(double x1, double y1, double x2, double y2, double px, double py)Compute the square distance between a point and a segment.- Parameters:
x1- horizontal position of the first point of the segment.y1- vertical position of the first point of the segment.x2- horizontal position of the second point of the segment.y2- vertical position of the second point of the segment.px- horizontal position of the point.py- vertical position of the point.- Returns:
- the distance beetween the point and the segment.
-
calculatesDistanceSquaredSegmentSegment
@Pure static double calculatesDistanceSquaredSegmentSegment(double s1x1, double s1y1, double s1x2, double s1y2, double s2x1, double s2y1, double s2x2, double s2y2)Replies the distance between the two segments.- Parameters:
s1x1- x coordinate of the first point of the first triangle.s1y1- y coordinate of the first point of the first triangle.s1x2- x coordinate of the second point of the first triangle.s1y2- y coordinate of the second point of the first triangle.s2x1- x coordinate of the first point of the second triangle.s2y1- y coordinate of the first point of the second triangle.s2x2- x coordinate of the second point of the second triangle.s2y2- y coordinate of the second point of the second triangle.- Returns:
- the distance between the two segments.
-
findsFarthestPointSegmentPoint
static void findsFarthestPointSegmentPoint(double ax, double ay, double bx, double by, double px, double py, Point2D<?,?> result)Replies the point on the segment that is farthest to the given point.- Parameters:
ax- is the x coordinate of the first point of the segment.ay- is the y coordinate of the first point of the segment.bx- is the x coordinate of the second point of the segment.by- is the y coordinate of the second point of the segment.px- is the x coordinate of the point.py- is the y coordinate of the point.result- the farthest point on the shape.
-
findsFarthestPointSegmentRectangle
static void findsFarthestPointSegmentRectangle(double sx1, double sy1, double sx2, double sy2, double rx, double ry, double rwidth, double rheight, Point2D<?,?> result)Replies the point on the segment that is farthest 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.
-
findsFarthestPointSegmentSegment
static double findsFarthestPointSegmentSegment(double s1x1, double s1y1, double s1x2, double s1y2, double s2x1, double s2y1, double s2x2, double s2y2, Point2D<?,?> result)Replies the point on the first segment that is farthest 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 minimal square distance between the point on the first segment and any point on the second segment.
-
findsLineLineIntersection
static boolean findsLineLineIntersection(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, Point2D<?,?> result)Compute the intersection of two lines specified by the specified points and vectors.- Parameters:
x1- horizontal position of the first point of the line.y1- vertical position of the first point of the line.x2- horizontal position of the second point of the line.y2- vertical position of the second point of the line.x3- horizontal position of the first point of the line.y3- vertical position of the first point of the line.x4- horizontal position of the second point of the line.y4- vertical position of the second point of the line.result- the intersection point.- Returns:
trueif there is an intersection.
-
calculatesLineLineIntersectionFactor
@Pure static double calculatesLineLineIntersectionFactor(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)Replies the position factory for the intersection point between two lines.Let line equations for L1 and L2:
L1: P1 + factor1 * (P2-P1)
L2: P3 + factor2 * (P4-P3)
If lines are intersecting, then
P1 + factor1 * (P2-P1) = P3 + factor2 * (P4-P3)This function computes and replies
factor1.- Parameters:
x1- is the X coordinate of the first point of the first line.y1- is the Y coordinate of the first point of the first line.x2- is the X coordinate of the second point of the first line.y2- is the Y coordinate of the second point of the first line.x3- is the X coordinate of the first point of the second line.y3- is the Y coordinate of the first point of the second line.x4- is the X coordinate of the second point of the second line.y4- is the Y coordinate of the second point of the second line.- Returns:
factor1orDouble.NaNif no intersection.
-
findsProjectedPointPointLine
@Pure static double findsProjectedPointPointLine(double px, double py, double s1x, double s1y, double s2x, double s2y)Replies the projection a point on a segment.- Parameters:
px- is the coordinate of the point to projectpy- is the coordinate of the point to projects1x- is the x-coordinate of the first line point.s1y- is the y-coordinate of the first line point.s2x- is the x-coordinate of the second line point.s2y- is the y-coordinate of the second line point.- Returns:
- the projection of the specified point on the line. If
equal to
0, the projection is equal to the first segment point. If equal to1, the projection is equal to the second segment point. If inside]0;1[, the projection is between the two segment points. If inside]-inf;0[, the projection is outside on the side of the first segment point. If inside]1;+inf[, the projection is outside on the side of the second segment point.
-
calculatesRelativeDistanceLinePoint
@Pure static double calculatesRelativeDistanceLinePoint(double x1, double y1, double x2, double y2, double px, double py)Replies the relative distance from the given point to the given line. The replied distance may be negative, depending on which side of the line the point is.- 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:
- the positive or negative distance from the point to the line
- See Also:
ccw(double, double, double, double, double, double, double),findsSideLinePoint(double, double, double, double, double, double, double)
-
findsSegmentSegmentIntersection
static boolean findsSegmentSegmentIntersection(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, Point2D<?,?> result)Replies the intersection point between two segments.- Parameters:
x1- is the X coordinate of the first point of the first segment.y1- is the Y coordinate of the first point of the first segment.x2- is the X coordinate of the second point of the first segment.y2- is the Y coordinate of the second point of the first segment.x3- is the X coordinate of the first point of the second segment.y3- is the Y coordinate of the first point of the second segment.x4- is the X coordinate of the second point of the second segment.y4- is the Y coordinate of the second point of the second segment.result- the intersection point.- Returns:
trueif an intersection exists.
-
calculatesSegmentSegmentIntersectionFactor
@Pure static double calculatesSegmentSegmentIntersectionFactor(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)Replies one position factor for the intersection point between two lines.Let line equations for L1 and L2:
L1: P1 + factor1 * (P2-P1)
L2: P3 + factor2 * (P4-P3)
If lines are intersecting, then
P1 + factor1 * (P2-P1) = P3 + factor2 * (P4-P3)This function computes and replies
factor1.- Parameters:
x1- is the X coordinate of the first point of the first segment.y1- is the Y coordinate of the first point of the first segment.x2- is the X coordinate of the second point of the first segment.y2- is the Y coordinate of the second point of the first segment.x3- is the X coordinate of the first point of the second segment.y3- is the Y coordinate of the first point of the second segment.x4- is the X coordinate of the second point of the second segment.y4- is the Y coordinate of the second point of the second segment.- Returns:
factor1orDouble.NaNif no intersection.
-
findsSideLinePoint
@Pure static int findsSideLinePoint(double x1, double y1, double x2, double y2, double px, double py, double epsilon)} 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, this direction is clockwise.
A return value of 0 indicates that the point lies exactly on the line segment. Note that an indicator value of 0 is rare and not useful for determining colinearity because of floating point rounding issues.
This function uses the equal-to-zero test with the error
Math.ulp(double).In opposite of
ccw(double, double, double, double, double, double, double), this function does not try to classify the point if it is colinear to the segment. If the point is colinear, O is always returns.- 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 segmentepsilon- approximate epsilon.- 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:
calculatesRelativeDistanceLinePoint(double, double, double, double, double, double),MathUtil.isEpsilonZero(double),ccw(double, double, double, double, double, double, double)
-
findsUncertainIntersectionSegmentSegmentWithEnds
@Pure static Segment2afp.UncertainIntersection findsUncertainIntersectionSegmentSegmentWithEnds(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
Do an intersection test of two segments for ensuring that the answer of "no intersect" is safe.If the function replies
Segment2afp.UncertainIntersection.NO, we are sure that the two given segments are not intersecting. If the function repliesSegment2afp.UncertainIntersection.PERHAPS, the two segments may intersects (uncertain answer).This function considers that the ends of the segments are intersecting.
- 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:
- the type of intersection.
- See Also:
intersectsSegmentSegmentWithEnds(double, double, double, double, double, double, double, double)
-
findsUncertainIntersectionSegmentSegmentWithoutEnds
@Pure static Segment2afp.UncertainIntersection findsUncertainIntersectionSegmentSegmentWithoutEnds(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
Do an intersection test of two segments for ensuring that the answer of "no intersect" is safe. If the function repliestrue, it may This function does not consider that the ends of the segments are intersecting.- 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:
- the type of intersection.
- See Also:
intersectsSegmentSegmentWithoutEnds(double, double, double, double, double, double, double, double)
-
interpolates
static void interpolates(double p1x, double p1y, double p2x, double p2y, double factor, Point2D<?,?> result)Compute the interpolate point between the two points.- Parameters:
p1x- x coordinate of the first point.p1y- y coordinate of the first point.p2x- x coordinate of the second point.p2y- y coordinate of the second point.factor- is between 0 and 1; 0 for p1, and 1 for p2.result- the interpolate point.
-
intersectsLineLine
@Pure static boolean intersectsLineLine(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)Replies if two lines are intersecting.- Parameters:
x1- is the first point of the first line.y1- is the first point of the first line.x2- is the second point of the first line.y2- is the second point of the first line.x3- is the first point of the second line.y3- is the first point of the second line.x4- is the second point of the second line.y4- is the second point of the second line.- Returns:
trueif the two shapes are intersecting; otherwisefalse
-
intersectsSegmentLine
@Pure static boolean intersectsSegmentLine(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)Replies if a segment and a line are intersecting.- 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 line.y3- is the first point of the second line.x4- is the second point of the second line.y4- is the second point of the second line.- Returns:
trueif the two shapes are intersecting; otherwisefalse
-
intersectsSegmentSegmentWithEnds
@Pure static boolean intersectsSegmentSegmentWithEnds(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)Replies if two segments are intersecting. This function considers that the ends of the segments are intersecting. To ignore the ends of the segments, seeintersectsSegmentSegmentWithoutEnds(double, double, double, double, double, double, double, double).- 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- See Also:
intersectsSegmentSegmentWithoutEnds(double, double, double, double, double, double, double, double)
-
intersectsSegmentSegmentWithoutEnds
@Pure static boolean intersectsSegmentSegmentWithoutEnds(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)Replies if two segments are intersecting. This function considers that the ends of the segments are not intersecting. To include the ends of the segments in the intersection ranges, seeintersectsSegmentSegmentWithEnds(double, double, double, double, double, double, double, double).- 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- See Also:
intersectsSegmentSegmentWithEnds(double, double, double, double, double, double, double, double)
-
isCollinearLines
@Pure static boolean isCollinearLines(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)Replies if two lines are colinear.The given two lines are described respectivaly by two points, i.e.
(x1, y1)and(x2, y2)for the first line, and(x3, y3)and(x4, y4)for the second line.If you are interested to test if the two lines are parallel, see
isParallelLines(double, double, double, double, double, double, double, double).- Parameters:
x1- is the X coordinate of the first point of the first line.y1- is the Y coordinate of the first point of the first line.x2- is the X coordinate of the second point of the first line.y2- is the Y coordinate of the second point of the first line.x3- is the X coordinate of the first point of the second line.y3- is the Y coordinate of the first point of the second line.x4- is the X coordinate of the second point of the second line.y4- is the Y coordinate of the second point of the second line.- Returns:
trueif the two given lines are collinear.- See Also:
isParallelLines(double, double, double, double, double, double, double, double),Point2D.isCollinearPoints(double, double, double, double, double, double)
-
isParallelLines
@Pure static boolean isParallelLines(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)Replies if two lines are parallel.The given two lines are described respectivaly by two points, i.e.
(x1, y1)and(x2, y2)for the first line, and(x3, y3)and(x4, y4)for the second line.If you are interested to test if the two lines are colinear, see
isCollinearLines(double, double, double, double, double, double, double, double).- Parameters:
x1- is the X coordinate of the first point of the first line.y1- is the Y coordinate of the first point of the first line.x2- is the X coordinate of the second point of the first line.y2- is the Y coordinate of the second point of the first line.x3- is the X coordinate of the first point of the second line.y3- is the Y coordinate of the first point of the second line.x4- is the X coordinate of the second point of the second line.y4- is the Y coordinate of the second point of the second line.- Returns:
trueif the two given lines are parallel.- See Also:
isCollinearLines(double, double, double, double, double, double, double, double)
-
isPointClosedToLine
@Pure static boolean isPointClosedToLine(double x1, double y1, double x2, double y2, double x, double y, double hitDistance)Replies if a point is closed to a line.- Parameters:
x1- horizontal location of the first-line begining.y1- vertical location of the first-line ending.x2- horizontal location of the second-line begining.y2- vertical location of the second-line ending.x- horizontal location of the point.y- vertical location of the point.hitDistance- is the maximal hitting distance.- Returns:
trueif the point and the line have closed locations.
-
isPointClosedToSegment
@Pure static boolean isPointClosedToSegment(double x1, double y1, double x2, double y2, double x, double y, double hitDistance)Replies if a point is closed to a segment.- Parameters:
x1- horizontal location of the first-segment begining.y1- vertical location of the first-segment ending.x2- horizontal location of the second-segment begining.y2- vertical location of the second-segment ending.x- horizontal location of the point.y- vertical location of the point.hitDistance- is the maximal hitting distance.- Returns:
trueif the point and the line have closed locations.
-
clear
default void clear()
Description copied from interface:Shape2DReset this shape to be equivalent to an just-created instance of this shape type.
-
clipToRectangle
@Pure default boolean clipToRectangle(double rxmin, double rymin, double rxmax, double 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.
-
contains
default boolean contains(double x, double y)Replies if the given point is inside this shape.This function uses the equal-to-zero test with the error
Math.ulp(double).- Specified by:
containsin interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
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.- See Also:
MathUtil.isEpsilonZero(double)
-
contains
@Pure default boolean contains(Rectangle2afp<?,?,?,?,?,?> rectangle)
Description copied from interface:Shape2afpReplies if the given rectangle is inside this shape.- Specified by:
containsin interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
rectangle- the rectangle.- Returns:
trueif the given rectangle is inside this shape, otherwisefalse.
-
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 interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Specified by:
containsin interfaceShape2D<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
shape- the shape to compare to.- Returns:
trueif the given shape is inside this shape;falseotherwise.
-
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 Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
shape- the shape to compare to.- Returns:
trueif this shape is equal is equal to the given path.
-
getClosestPointTo
@Pure default P getClosestPointTo(Circle2afp<?,?,?,?,?,?> circle)
Description copied from interface:Shape2afpReplies the closest point on this shape to the given circle.If the two shapes are intersecting, the replied point is always at the intersection of the two shapes. This function does not enforce the meaning of the replied point in the case of shape intersection. In other words, this function is warranting that the reply point is the either the penetration point, nor a perimeter point, nor any point with a specific meaning.
- Specified by:
getClosestPointToin interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
circle- the circle.- Returns:
- the closest point on the shape; or the point itself if it is inside the shape.
-
getClosestPointTo
default P getClosestPointTo(Ellipse2afp<?,?,?,?,?,?> ellipse)
Description copied from interface:Shape2afpReplies the closest point on this shape to the given ellipse.If the two shapes are intersecting, the replied point is always at the intersection of the two shapes. This function does not enforce the meaning of the replied point in the case of shape intersection. In other words, this function is warranting that the reply point is the either the penetration point, nor a perimeter point, nor any point with a specific meaning.
- Specified by:
getClosestPointToin interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
ellipse- the ellipse.- Returns:
- the closest point on the shape; or the point itself if it is inside the shape.
-
getClosestPointTo
default P getClosestPointTo(OrientedRectangle2afp<?,?,?,?,?,?> orientedRectngle)
Description copied from interface:Shape2afpReplies the closest point on this shape to the given oriented rectangle.If the two shapes are intersecting, the replied point is always at the intersection of the two shapes. This function does not enforce the meaning of the replied point in the case of shape intersection. In other words, this function is warranting that the reply point is the either the penetration point, nor a perimeter point, nor any point with a specific meaning.
- Specified by:
getClosestPointToin interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
orientedRectngle- the oriented rectangle.- Returns:
- the closest point on the shape; or the point itself if it is inside the shape.
-
getClosestPointTo
default P getClosestPointTo(Parallelogram2afp<?,?,?,?,?,?> parallelogram)
Description copied from interface:Shape2afpReplies the closest point on this shape to the given parallelogram.If the two shapes are intersecting, the replied point is always at the intersection of the two shapes. This function does not enforce the meaning of the replied point in the case of shape intersection. In other words, this function is warranting that the reply point is the either the penetration point, nor a perimeter point, nor any point with a specific meaning.
- Specified by:
getClosestPointToin interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
parallelogram- the parallelogram.- Returns:
- the closest point on the shape; or the point itself if it is inside the shape.
-
getClosestPointTo
default P getClosestPointTo(Path2afp<?,?,?,?,?,?> path)
Description copied from interface:Shape2afpReplies the closest point on this shape to the given path.If the two shapes are intersecting, the replied point is always at the intersection of the two shapes. This function does not enforce the meaning of the replied point in the case of shape intersection. In other words, this function is warranting that the reply point is the either the penetration point, nor a perimeter point, nor any point with a specific meaning.
- Specified by:
getClosestPointToin interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
path- the path.- Returns:
- the closest point on the shape; or the point itself if it is inside the shape.
-
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 Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
pt- the point.- Returns:
- the closest point on the shape; or the point itself if it is inside the shape.
-
getClosestPointTo
@Pure default P getClosestPointTo(Rectangle2afp<?,?,?,?,?,?> rectangle)
Description copied from interface:Shape2afpReplies the closest point on this shape to the given rectangle.If the two shapes are intersecting, the replied point is always at the intersection of the two shapes. This function does not enforce the meaning of the replied point in the case of shape intersection. In other words, this function is warranting that the reply point is the either the penetration point, nor a perimeter point, nor any point with a specific meaning.
- Specified by:
getClosestPointToin interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
rectangle- the rectangle.- Returns:
- the closest point on the shape; or the point itself if it is inside the shape.
-
getClosestPointTo
default P getClosestPointTo(RoundRectangle2afp<?,?,?,?,?,?> roundRectangle)
Description copied from interface:Shape2afpReplies the closest point on this shape to the given round rectangle.If the two shapes are intersecting, the replied point is always at the intersection of the two shapes. This function does not enforce the meaning of the replied point in the case of shape intersection. In other words, this function is warranting that the reply point is the either the penetration point, nor a perimeter point, nor any point with a specific meaning.
- Specified by:
getClosestPointToin interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
roundRectangle- the round rectangle.- Returns:
- the closest point on the shape; or the point itself if it is inside the shape.
-
getClosestPointTo
@Pure default P getClosestPointTo(Segment2afp<?,?,?,?,?,?> segment)
Description copied from interface:Shape2afpReplies the closest point on this shape to the given segment.If the two shapes are intersecting, the replied point is always at the intersection of the two shapes. This function does not enforce the meaning of the replied point in the case of shape intersection. In other words, this function is warranting that the reply point is the either the penetration point, nor a perimeter point, nor any point with a specific meaning.
- Specified by:
getClosestPointToin interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
segment- the segment.- Returns:
- the closest point on the shape; or the point itself if it is inside the shape.
-
getClosestPointTo
@Pure default P getClosestPointTo(Triangle2afp<?,?,?,?,?,?> triangle)
Description copied from interface:Shape2afpReplies the closest point on this shape to the given triangle.If the two shapes are intersecting, the replied point is always at the intersection of the two shapes. This function does not enforce the meaning of the replied point in the case of shape intersection. In other words, this function is warranting that the reply point is the either the penetration point, nor a perimeter point, nor any point with a specific meaning.
- Specified by:
getClosestPointToin interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
triangle- the triangle.- Returns:
- the closest point on the shape; or the point itself if it is inside the shape.
-
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 Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
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 Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
pt- the point- Returns:
- the distance.
-
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 Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
pt- the point.- Returns:
- squared value of the minimal distance between this shape and the point.
-
getDistanceSquared
@Pure default double getDistanceSquared(Segment2afp<?,?,?,?,?,?> segment)
Description copied from interface:Shape2afpReplies the minimum distance between this shape and the given segment.- Specified by:
getDistanceSquaredin interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
segment- the segment.- Returns:
- the minimum distance between the two shapes.
-
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 Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
pt- the point.- Returns:
- the farthest point on the shape.
-
getLength
@Pure default double getLength()
Replies the length of the segment.- Returns:
- the length.
-
getLengthSquared
@Pure default double getLengthSquared()
Replies the squared length of the segment.- Returns:
- the squared length.
-
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.
-
getPathIterator
@Pure default PathIterator2afp<IE> getPathIterator(Transform2D transform)
Description copied from interface:Shape2DReplies the elements of the paths.- Specified by:
getPathIteratorin interfaceShape2D<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
transform- is the transformation to apply to the path.- Returns:
- the elements of the path.
-
getX1
@Pure double getX1()
Replies the X of the first point.- Returns:
- the x of the first point.
-
getX2
@Pure double getX2()
Replies the X of the second point.- Returns:
- the x of the second point.
-
getY1
@Pure double getY1()
Replies the Y of the first point.- Returns:
- the y of the first point.
-
getY2
@Pure double getY2()
Replies the Y of the second point.- Returns:
- the y of the second point.
-
intersects
@Pure default boolean intersects(Circle2afp<?,?,?,?,?,?> circle)
Description copied from interface:Shape2afpReplies if this shape is intersecting the given circle.- Specified by:
intersectsin interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
circle- the circle.- Returns:
trueif this shape is intersecting the given shape;falseif there is no intersection.
-
intersects
@Pure default boolean intersects(Ellipse2afp<?,?,?,?,?,?> ellipse)
Description copied from interface:Shape2afpReplies if this shape is intersecting the given ellipse.- Specified by:
intersectsin interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
ellipse- the ellipse.- Returns:
trueif this shape is intersecting the given shape;falseif there is no intersection.
-
intersects
@Pure default boolean intersects(MultiShape2afp<?,?,?,?,?,?,?> multishape)
Description copied from interface:Shape2afpReplies if this shape is intersecting the given multishape.- Specified by:
intersectsin interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
multishape- the multishape.- Returns:
trueif this shape is intersecting the given shape;falseif there is no intersection.
-
intersects
@Pure default boolean intersects(OrientedRectangle2afp<?,?,?,?,?,?> orientedRectangle)
Description copied from interface:Shape2afpReplies if this shape is intersecting the given rectangle.- Specified by:
intersectsin interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
orientedRectangle- the oriented rectangle.- Returns:
trueif this shape is intersecting the given shape;falseif there is no intersection.
-
intersects
@Pure default boolean intersects(Parallelogram2afp<?,?,?,?,?,?> parallelogram)
Description copied from interface:Shape2afpReplies if this shape is intersecting the given parallelogram.- Specified by:
intersectsin interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
parallelogram- the parallelogram.- Returns:
trueif this shape is intersecting the given shape;falseif there is no intersection.
-
intersects
@Pure default boolean intersects(PathIterator2afp<?> iterator)
Description copied from interface:Shape2afpReplies if this shape is intersecting the shape representing the given path iterator.- Specified by:
intersectsin interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
iterator- the path iterator.- Returns:
trueif this shape is intersecting the given shape;falseif there is no intersection.
-
intersects
@Pure default boolean intersects(Rectangle2afp<?,?,?,?,?,?> rectangle)
Description copied from interface:Shape2afpReplies if this shape is intersecting the given rectangle.- Specified by:
intersectsin interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
rectangle- the rectangle.- Returns:
trueif this shape is intersecting the given shape;falseif there is no intersection.
-
intersects
@Pure default boolean intersects(RoundRectangle2afp<?,?,?,?,?,?> roundRectangle)
Description copied from interface:Shape2afpReplies if this shape is intersecting the given rectangle.- Specified by:
intersectsin interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
roundRectangle- the round rectangle.- Returns:
trueif this shape is intersecting the given shape;falseif there is no intersection.
-
intersects
@Pure default boolean intersects(Segment2afp<?,?,?,?,?,?> segment)
Description copied from interface:Shape2afpReplies if this shape is intersecting the given line.- Specified by:
intersectsin interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
segment- the segment.- Returns:
trueif this shape is intersecting the given shape;falseif there is no intersection.
-
intersects
@Pure default boolean intersects(Triangle2afp<?,?,?,?,?,?> triangle)
Description copied from interface:Shape2afpReplies if this shape is intersecting the given triangle.- Specified by:
intersectsin interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
triangle- the triangle.- Returns:
trueif this shape is intersecting the given shape;falseif there is no intersection.
-
isEmpty
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 Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Returns:
trueif the shape is empty;falseotherwise.
-
set
void set(double x1, double y1, double x2, double 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(IT shape)
Description copied from interface:Shape2DSet this shape with the attributes of the given shape.- Specified by:
setin interfaceShape2D<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
shape- the shape to copy.
-
set
default void set(Point2D<?,?> firstPoint, Point2D<?,?> secondPoint)
Change the line.- Parameters:
firstPoint- the first point.secondPoint- the second point.
-
setP1
default void setP1(double x, double y)Change the first point.- Parameters:
x- x coordinate of the first point.y- y coordinate of the first point.
-
setP1
default void setP1(Point2D<?,?> pt)
Change the first point.- Parameters:
pt- the first point.
-
setP2
default void setP2(double x, double y)Change the second point.- Parameters:
x- x coordinate of the second point.y- y coordinate of the second point.
-
setP2
default void setP2(Point2D<?,?> pt)
Change the second point.- Parameters:
pt- the second point.
-
setX1
void setX1(double x)
Sets a new value in the X of the first point.- Parameters:
x- the new value double x
-
setX2
void setX2(double x)
Sets a new value in the X of the second point.- Parameters:
x- the new value double x
-
setY1
void setY1(double y)
Sets a new value in the Y of the first point.- Parameters:
y- the new value double y
-
setY2
void setY2(double y)
Sets a new value in the Y of the second point.- Parameters:
y- the new value double y
-
toBoundingBox
@Pure default void toBoundingBox(B box)
Description copied from interface:Shape2DReplies the bounds of the shape.- Specified by:
toBoundingBoxin interfaceShape2D<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
box- is set with the bounds of the shape.
-
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:
Shape2afp.createTransformedShape(org.arakhne.afc.math.geometry.d2.Transform2D)
-
translate
default void translate(double dx, double dy)Description copied from interface:Shape2afpTranslate the shape.- Specified by:
translatein interfaceShape2afp<ST extends Shape2afp<?,?,IE,P,V,B>,IT extends Segment2afp<?,?,IE,P,V,B>,IE extends PathElement2afp,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Rectangle2afp<?,?,IE,P,V,B>>- Parameters:
dx- x translation.dy- y translation.
-
-