Class Intersection2D_F64
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
contains
(EllipseRotated_F64 ellipse, double x, double y) Tests to see if the provided point lies on or is contained inside the ellipsestatic boolean
contains
(Quadrilateral_F64 quad, Point2D_F64 pt) True if the point is contained inside the quadrilateral.static boolean
contains
(Rectangle2D_F64 a, double x, double y) Checks to see if the specified point is inside the rectangle.static boolean
contains
(RectangleLength2D_F64 a, double x, double y) Checks to see if the specified point is inside the rectangle.static boolean
contains2
(Rectangle2D_F64 a, double x, double y) Checks to see if the specified point is inside the rectangle.static boolean
contains2
(RectangleLength2D_F64 a, double x, double y) Checks to see if the specified point is inside the rectangle.static boolean
containsConcave
(Polygon2D_F64 polygon, Point2D_F64 pt) Checks to see if the point is contained inside the concave polygon.static boolean
containsConvex
(Polygon2D_F64 polygon, Point2D_F64 pt) Checks to see if the point is contained inside the convex polygon.static boolean
containsConvex2
(Polygon2D_F64 polygon, double x, double y) True if the convex polygon contains the point.static boolean
containTriangle
(Point2D_F64 a, Point2D_F64 b, Point2D_F64 c, Point2D_F64 pt) Returns true of the the point is inside the triangle.static int
intersection
(LineGeneral2D_F64 line, EllipseRotated_F64 ellipse, Point2D_F64 intersection0, Point2D_F64 intersection1, double EPS) Determines the location(s) that a line and ellipse intersect.static @Nullable Point2D_F64
intersection
(LineGeneral2D_F64 a, LineGeneral2D_F64 b, @Nullable Point2D_F64 ret) Finds the intersection of two lines as a 2D point in coordinates.static Point3D_F64
intersection
(LineGeneral2D_F64 a, LineGeneral2D_F64 b, @Nullable Point3D_F64 ret) Finds the intersection of two lines as a 2D point in homogeneous coordinates.static double
Finds the point of intersection between two lines.static @Nullable Point2D_F64
intersection
(LineParametric2D_F64 a, LineParametric2D_F64 b, boolean ray, @Nullable Point2D_F64 ret) Finds the point of intersection between two lines or two rays and returns the point.static @Nullable Point2D_F64
intersection
(LineParametric2D_F64 a, LineParametric2D_F64 b, @Nullable Point2D_F64 ret) Finds the point of intersection between two lines and returns the point.static double
intersection
(LineParametric2D_F64 target, LineSegment2D_F64 l) Finds the point of intersection between a line and a line segment.static @Nullable Point2D_F64
intersection
(LineSegment2D_F64 l_0, LineSegment2D_F64 l_1, @Nullable Point2D_F64 ret) Finds the point of intersection between two lines segments.static @Nullable Point2D_F64
intersection
(Point2D_F64 lineA0, Point2D_F64 lineA1, Point2D_F64 lineB0, Point2D_F64 lineB1, @Nullable Point2D_F64 output) Finds the point of intersection between the two lines defined by the set sets of points passed in.static boolean
intersection
(Rectangle2D_F64 a, Rectangle2D_F64 b, Rectangle2D_F64 result) Finds the intersection between two rectangles.static @Nullable RectangleLength2D_F64
static Point3D_F64
intersection
(List<LineGeneral2D_F64> lines, @Nullable Point3D_F64 ret) Finds the intersection between two or more lines and a 2D point in homogenous coordinates.static double
Finds the area of the intersection of two simple polygons.static double
Returns the area of the intersection of two rectangles.static boolean
intersects
(LineSegment2D_F64 a, LineSegment2D_F64 b, double tol) Returns true if the two line segments intersect.static boolean
intersects
(LineSegment2D_F64 line, Rectangle2D_F64 rect, double tol) Checks to see if the line segment and rectangle intersect each other.static boolean
intersects
(Point2D_F64 a, Point2D_F64 b, Point2D_F64 c, Point2D_F64 d, double tol) static boolean
Checks to see if the two rectangles intersect each otherstatic boolean
intersects2
(LineSegment2D_F64 a, LineSegment2D_F64 b, double tol) Returns true if the two line segments intersect.static boolean
intersects2
(Point2D_F64 a, Point2D_F64 b, Point2D_F64 c, Point2D_F64 d, double tol)
-
Constructor Details
-
Intersection2D_F64
public Intersection2D_F64()
-
-
Method Details
-
containsConvex
Checks to see if the point is contained inside the convex polygon. If the point is an the polygon's perimeter it is considered to NOT be inside.
Clockwise or counter-clockwise order of the polygon does not matter.
- Parameters:
polygon
- Convex polygon. Not modified.pt
- Point. Not modified.- Returns:
- True if the point is contained inside the polygon.
-
containsConvex2
True if the convex polygon contains the point. The point is considered inside if it lies along the line.Clockwise or counter-clockwise order of the polygon does not matter.
- Parameters:
polygon
- Convex polygon. Not modified.x
- x-coordinatey
- y-coordinate- Returns:
- True if the point is contained inside the polygon.
-
containsConcave
Checks to see if the point is contained inside the concave polygon. NOTE: Points which lie along the perimeter may or may not be considered as inside- Parameters:
polygon
- Convex polygon. Not modified.pt
- Point. Not modified.- Returns:
- True if the point is contained inside the polygon.
-
contains
True if the point is contained inside the quadrilateral.- Parameters:
quad
- quadrilateralpt
- point- Returns:
- true if the point is inside and false if it is not.
-
containTriangle
Returns true of the the point is inside the triangle. This function is simply an unrolled version ofcontainsConcave(Polygon2D_F64, Point2D_F64)
.- Parameters:
a
- vertex in triangleb
- vertex in trianglec
- vertex in trianglept
- Point which is being tested for containment inside of triangle- Returns:
- true if the point is inside of triangle
-
intersection
@Nullable public static @Nullable Point2D_F64 intersection(LineParametric2D_F64 a, LineParametric2D_F64 b, @Nullable @Nullable Point2D_F64 ret) Finds the point of intersection between two lines and returns the point.- Parameters:
a
- Line.b
- Line.ret
- storage for the point of intersection. If null a new point will be declared.- Returns:
- If the two lines intersect it returns the point of intersection. null if they don't intersect or have infinite intersections.
-
intersection
@Nullable public static @Nullable Point2D_F64 intersection(LineParametric2D_F64 a, LineParametric2D_F64 b, boolean ray, @Nullable @Nullable Point2D_F64 ret) Finds the point of intersection between two lines or two rays and returns the point.- Parameters:
a
- Line.b
- Line.ray
- if true the lines are treated as a ray and only intersections on the positive side of both lines are allowedret
- storage for the point of intersection. If null a new point will be declared.- Returns:
- If the two lines/rays intersect it returns the point of intersection. null if they don't intersect or have infinite intersections.
-
intersection
Finds the point of intersection between two lines. The point of intersection is specified as a point along the parametric line 'a'. (x,y) = (x_0,y_0) + t*(slope_x,slope_y), where 't' is the location returned.- Parameters:
a
- Line.b
- Line.- Returns:
- The location along 'target'. If the lines do not intersect or have infinite intersections Double. NaN is returned.
-
intersection
@Nullable public static @Nullable Point2D_F64 intersection(LineSegment2D_F64 l_0, LineSegment2D_F64 l_1, @Nullable @Nullable Point2D_F64 ret) Finds the point of intersection between two lines segments.- Parameters:
l_0
- Line segment.l_1
- line segment.ret
- storage for the point of intersection. If null a new point will be declared.- Returns:
- If the two lines intersect it returns the point of intersection. null if they don't intersect or have infinite intersections.
-
intersects
Returns true if the two line segments intersect. Two end points touching will be considered an intersection.- Parameters:
a
- (Input) Line segmentb
- (Input) Line segmenttol
- (Input) tolerance for lines being colinear- Returns:
- true if they intersect
-
intersects
public static boolean intersects(Point2D_F64 a, Point2D_F64 b, Point2D_F64 c, Point2D_F64 d, double tol) -
intersects2
Returns true if the two line segments intersect. Two end points touching will not be considered an intersection.- Parameters:
a
- (Input) Line segmentb
- (Input) Line segmenttol
- (Input) tolerance for lines being colinear- Returns:
- true if they intersect
-
intersects2
public static boolean intersects2(Point2D_F64 a, Point2D_F64 b, Point2D_F64 c, Point2D_F64 d, double tol) -
intersection
public static Point3D_F64 intersection(LineGeneral2D_F64 a, LineGeneral2D_F64 b, @Nullable @Nullable Point3D_F64 ret) Finds the intersection of two lines as a 2D point in homogeneous coordinates. Because the solution is found in homogeneous coordinates it can even handle parallel lines which "intersect at infinity".
A 2D point in homogeneous coordinates is expressed as the triple (x,y,z), which can be converted into the standard notation as x' = x/z and y'= y/z. If the lines are parallel and intersect at infinity then z=0 and the above conversion will fail.
- Parameters:
a
- Lineb
- Lineret
- Storage for point of intersection.- Returns:
- Point of intersection represented in homogeneous coordinates.
-
intersection
public static Point3D_F64 intersection(List<LineGeneral2D_F64> lines, @Nullable @Nullable Point3D_F64 ret) Finds the intersection between two or more lines and a 2D point in homogenous coordinates. An algebraic method is used to find the point. Follow up by a non-linear refinement method that minimizes geometric distance is suggested when high precision is required.- Parameters:
lines
- (Input) list of 2 or more linesret
- (Output) Optional storage for point of intersection- Returns:
- Found best fit point of intersection.
- See Also:
-
intersection
@Nullable public static @Nullable Point2D_F64 intersection(LineGeneral2D_F64 a, LineGeneral2D_F64 b, @Nullable @Nullable Point2D_F64 ret) Finds the intersection of two lines as a 2D point in coordinates. If the lines are parallel then null is returned.
- Parameters:
a
- Lineb
- Lineret
- Storage for point of intersection.- Returns:
- Point of intersection in 2D coordinates. null if intersection at infinity
-
intersection
@Nullable public static @Nullable Point2D_F64 intersection(Point2D_F64 lineA0, Point2D_F64 lineA1, Point2D_F64 lineB0, Point2D_F64 lineB1, @Nullable @Nullable Point2D_F64 output) Finds the point of intersection between the two lines defined by the set sets of points passed in.- Parameters:
lineA0
- Point on line AlineA1
- Point on line AlineB0
- Point on line BlineB1
- Point on line Boutput
- (Optional) storage for point of intersection- Returns:
- Point of intersection or null if the lines are parallel
-
intersection
Finds the point of intersection between a line and a line segment. The point of intersection is specified as the distance along the parametric line. If no intersection is found then Double.NaN is returned.- Parameters:
target
- A line whose location along which the point of intersection is being found. Not modified.l
- Line segment which is being tested for intersection. Not modified.- Returns:
- The location along 'target'. If the lines do not intersect or have infinite intersections Double.NaN is returned.
-
intersectionArea
Finds the area of the intersection of two simple polygons. No self intersections allowed.- Parameters:
a
- (Input) Polygon 2Db
- (Input) Polygon 2D- Returns:
- Area of intersection.
- See Also:
-
contains
Checks to see if the specified point is inside the rectangle. A point is inside if it is ≥ the lower extend and < the upper extent.
inside = x ≥ x0 AND x < x0+width AND y ≥ y0 AND y < y0+height
- Parameters:
a
- Rectangle.x
- x-coordinate of point being tested for containmenty
- y-coordinate of point being tested for containment- Returns:
- true if inside and false if output
-
contains2
Checks to see if the specified point is inside the rectangle. A point is inside if it is ≥ the lower extend and ≤ the upper extent.
inside = x ≥ x0 AND x ≤ x0+width and y ≥ y0 AND y ≤ y0+height
- Parameters:
a
- Rectangle.x
- x-coordinate of point being tested for containmenty
- y-coordinate of point being tested for containment- Returns:
- true if inside and false if output
-
contains
Checks to see if the specified point is inside the rectangle. A point is inside if it is ≥ the lower extend and < the upper extent.
inside = x ≥ x0 AND x ≤ x1 AND y ≥ y0 AND y ≤ y1
- Parameters:
a
- Rectangle.x
- x-coordinate of point being tested for containmenty
- y-coordinate of point being tested for containment- Returns:
- true if inside and false if output
-
contains2
Checks to see if the specified point is inside the rectangle. A point is inside if it is ≥ the lower extend and ≤ the upper extent.
inside = x ≥ x0 AND x ≤ x1 AND y ≥ y0 AND y ≤ y1
- Parameters:
a
- Rectangle.x
- x-coordinate of point being tested for containmenty
- y-coordinate of point being tested for containment- Returns:
- true if inside and false if output
-
contains
Tests to see if the provided point lies on or is contained inside the ellipse- Parameters:
ellipse
- Ellipsex
- x-coordinate of point being tested for containmenty
- y-coordinate of point being tested for containment- Returns:
- true if inside and false if output
-
intersects
Checks to see if the line segment and rectangle intersect each other.- Parameters:
line
- Line segmentrect
- Rectangletol
- (Input) tolerance for lines being colinear- Returns:
- true if they intersect
-
intersection
@Nullable public static @Nullable RectangleLength2D_F64 intersection(RectangleLength2D_F64 a, RectangleLength2D_F64 b) -
intersects
Checks to see if the two rectangles intersect each other- Parameters:
a
- Rectangleb
- Rectangle- Returns:
- true if intersection
-
intersection
Finds the intersection between two rectangles. If the rectangles don't intersect then false is returned.- Parameters:
a
- Rectangleb
- Rectangleresult
- Storage for the found intersection- Returns:
- true if intersection
-
intersectionArea
Returns the area of the intersection of two rectangles.- Parameters:
a
- Rectangleb
- Rectangle- Returns:
- area of intersection
-
intersection
public static int intersection(LineGeneral2D_F64 line, EllipseRotated_F64 ellipse, Point2D_F64 intersection0, Point2D_F64 intersection1, double EPS) Determines the location(s) that a line and ellipse intersect. Returns the number of intersections found. NOTE: Due to floating point errors, it's possible for a single solution to returned as two points.- Parameters:
line
- Lineellipse
- Ellipseintersection0
- Storage for first point of intersection.intersection1
- Storage for second point of intersection.EPS
- Numerical precision. Set to a negative value to use default- Returns:
- Number of intersections. Possible values are 0, 1, or 2.
-