Class Intersection2D_F32

java.lang.Object
georegression.metric.Intersection2D_F32

@Generated("georegression.metric.Intersection2D_F64") public class Intersection2D_F32 extends Object
Functions relating to finding the points at which two shapes intersect with each other.
  • Constructor Details

    • Intersection2D_F32

      public Intersection2D_F32()
  • Method Details

    • containsConvex

      public static boolean containsConvex(Polygon2D_F32 polygon, Point2D_F32 pt)

      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

      public static boolean containsConvex2(Polygon2D_F32 polygon, float x, float y)
      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-coordinate
      y - y-coordinate
      Returns:
      True if the point is contained inside the polygon.
    • containsConcave

      public static boolean containsConcave(Polygon2D_F32 polygon, Point2D_F32 pt)
      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

      public static boolean contains(Quadrilateral_F32 quad, Point2D_F32 pt)
      True if the point is contained inside the quadrilateral.
      Parameters:
      quad - quadrilateral
      pt - point
      Returns:
      true if the point is inside and false if it is not.
    • containTriangle

      public static boolean containTriangle(Point2D_F32 a, Point2D_F32 b, Point2D_F32 c, Point2D_F32 pt)
      Returns true of the the point is inside the triangle. This function is simply an unrolled version of containsConcave(Polygon2D_F32, Point2D_F32).
      Parameters:
      a - vertex in triangle
      b - vertex in triangle
      c - vertex in triangle
      pt - 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_F32 intersection(LineParametric2D_F32 a, LineParametric2D_F32 b, @Nullable @Nullable Point2D_F32 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_F32 intersection(LineParametric2D_F32 a, LineParametric2D_F32 b, boolean ray, @Nullable @Nullable Point2D_F32 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 allowed
      ret - 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

      public static float intersection(LineParametric2D_F32 a, LineParametric2D_F32 b)
      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 Float. NaN is returned.
    • intersection

      @Nullable public static @Nullable Point2D_F32 intersection(LineSegment2D_F32 l_0, LineSegment2D_F32 l_1, @Nullable @Nullable Point2D_F32 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

      public static boolean intersects(LineSegment2D_F32 a, LineSegment2D_F32 b, float tol)
      Returns true if the two line segments intersect. Two end points touching will be considered an intersection.
      Parameters:
      a - (Input) Line segment
      b - (Input) Line segment
      tol - (Input) tolerance for lines being colinear
      Returns:
      true if they intersect
    • intersects

      public static boolean intersects(Point2D_F32 a, Point2D_F32 b, Point2D_F32 c, Point2D_F32 d, float tol)
    • intersects2

      public static boolean intersects2(LineSegment2D_F32 a, LineSegment2D_F32 b, float tol)
      Returns true if the two line segments intersect. Two end points touching will not be considered an intersection.
      Parameters:
      a - (Input) Line segment
      b - (Input) Line segment
      tol - (Input) tolerance for lines being colinear
      Returns:
      true if they intersect
    • intersects2

      public static boolean intersects2(Point2D_F32 a, Point2D_F32 b, Point2D_F32 c, Point2D_F32 d, float tol)
    • intersection

      public static Point3D_F32 intersection(LineGeneral2D_F32 a, LineGeneral2D_F32 b, @Nullable @Nullable Point3D_F32 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 - Line
      b - Line
      ret - Storage for point of intersection.
      Returns:
      Point of intersection represented in homogeneous coordinates.
    • intersection

      public static Point3D_F32 intersection(List<LineGeneral2D_F32> lines, @Nullable @Nullable Point3D_F32 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 lines
      ret - (Output) Optional storage for point of intersection
      Returns:
      Found best fit point of intersection.
      See Also:
    • intersection

      @Nullable public static @Nullable Point2D_F32 intersection(LineGeneral2D_F32 a, LineGeneral2D_F32 b, @Nullable @Nullable Point2D_F32 ret)

      Finds the intersection of two lines as a 2D point in coordinates. If the lines are parallel then null is returned.

      Parameters:
      a - Line
      b - Line
      ret - Storage for point of intersection.
      Returns:
      Point of intersection in 2D coordinates. null if intersection at infinity
    • intersection

      @Nullable public static @Nullable Point2D_F32 intersection(Point2D_F32 lineA0, Point2D_F32 lineA1, Point2D_F32 lineB0, Point2D_F32 lineB1, @Nullable @Nullable Point2D_F32 output)
      Finds the point of intersection between the two lines defined by the set sets of points passed in.
      Parameters:
      lineA0 - Point on line A
      lineA1 - Point on line A
      lineB0 - Point on line B
      lineB1 - Point on line B
      output - (Optional) storage for point of intersection
      Returns:
      Point of intersection or null if the lines are parallel
    • intersection

      public static float intersection(LineParametric2D_F32 target, LineSegment2D_F32 l)
      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 Float.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 Float.NaN is returned.
    • intersectionArea

      public static float intersectionArea(Polygon2D_F32 a, Polygon2D_F32 b)
      Finds the area of the intersection of two simple polygons. No self intersections allowed.
      Parameters:
      a - (Input) Polygon 2D
      b - (Input) Polygon 2D
      Returns:
      Area of intersection.
      See Also:
    • contains

      public static boolean contains(RectangleLength2D_F32 a, float x, float y)

      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 containment
      y - y-coordinate of point being tested for containment
      Returns:
      true if inside and false if output
    • contains2

      public static boolean contains2(RectangleLength2D_F32 a, float x, float y)

      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 containment
      y - y-coordinate of point being tested for containment
      Returns:
      true if inside and false if output
    • contains

      public static boolean contains(Rectangle2D_F32 a, float x, float y)

      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 containment
      y - y-coordinate of point being tested for containment
      Returns:
      true if inside and false if output
    • contains2

      public static boolean contains2(Rectangle2D_F32 a, float x, float y)

      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 containment
      y - y-coordinate of point being tested for containment
      Returns:
      true if inside and false if output
    • contains

      public static boolean contains(EllipseRotated_F32 ellipse, float x, float y)
      Tests to see if the provided point lies on or is contained inside the ellipse
      Parameters:
      ellipse - Ellipse
      x - x-coordinate of point being tested for containment
      y - y-coordinate of point being tested for containment
      Returns:
      true if inside and false if output
    • intersects

      public static boolean intersects(LineSegment2D_F32 line, Rectangle2D_F32 rect, float tol)
      Checks to see if the line segment and rectangle intersect each other.
      Parameters:
      line - Line segment
      rect - Rectangle
      tol - (Input) tolerance for lines being colinear
      Returns:
      true if they intersect
    • intersection

      @Nullable public static @Nullable RectangleLength2D_F32 intersection(RectangleLength2D_F32 a, RectangleLength2D_F32 b)
    • intersects

      public static boolean intersects(Rectangle2D_F32 a, Rectangle2D_F32 b)
      Checks to see if the two rectangles intersect each other
      Parameters:
      a - Rectangle
      b - Rectangle
      Returns:
      true if intersection
    • intersection

      public static boolean intersection(Rectangle2D_F32 a, Rectangle2D_F32 b, Rectangle2D_F32 result)
      Finds the intersection between two rectangles. If the rectangles don't intersect then false is returned.
      Parameters:
      a - Rectangle
      b - Rectangle
      result - Storage for the found intersection
      Returns:
      true if intersection
    • intersectionArea

      public static float intersectionArea(Rectangle2D_F32 a, Rectangle2D_F32 b)
      Returns the area of the intersection of two rectangles.
      Parameters:
      a - Rectangle
      b - Rectangle
      Returns:
      area of intersection
    • intersection

      public static int intersection(LineGeneral2D_F32 line, EllipseRotated_F32 ellipse, Point2D_F32 intersection0, Point2D_F32 intersection1, float 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 - Line
      ellipse - Ellipse
      intersection0 - 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.