Class IntersectLinePoint

java.lang.Object
org.jhotdraw8.geom.intersect.IntersectLinePoint

public class IntersectLinePoint extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    argumentOnLine(double x1, double y1, double x2, double y2, double px, double py)
    Given a point p on a line, computes the value of the argument 't'.
    intersectLinePoint(double x0, double y0, double x1, double y1, double cx, double cy, double r)
    Computes the intersection between a line and a point with tolerance radius r.
    intersectLinePointEx(double x0, double y0, double x1, double y1, double cx, double cy, double r)
     
    static boolean
    lineContainsPoint(double x1, double y1, double x2, double y2, double px, double py)
     
    static boolean
    lineContainsPoint(double x1, double y1, double x2, double y2, double px, double py, double tolerance)
    Tests if a point is inside a line segment.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • intersectLinePoint

      public static IntersectionResult intersectLinePoint(double x0, double y0, double x1, double y1, double cx, double cy, double r)
      Computes the intersection between a line and a point with tolerance radius r.

      The returned intersection contain the parameters 't1' of the line in range [0,1].

      The intersection will have one of the following status:

      This method solves the last equation shown in the list below.

      1. p0 + (p1 - p0) · t1 , 0 ≤ t1 ≤ 1
        : line equation in vector form
      2. x0 + (x1 - x0) · t1, y0 + (y1 - y0) · t1
        : line equation in matrix form
      3. x0 + Δx · t1, y0 + Δy · t1
        : partially compacted coefficients
      4. fx, fy
        : compacted coefficients in matrix form
      5. (fx - cx)² + (fy - cy)² = 0
        : distance to point equation with fx, fy coefficients inserted
      6. Δx²·Δy²·t1²
        + 2·(Δx·(x0 - cx)+Δy·(y0 - cy))·t1
        - 2·(x0·cx + y0·cy) + cx² + cy² + x0² + y0² = 0
        : fx, fy coefficients expanded and equation reordered
      7. a·t1² + b·t1 + c = 0, 0 ≤ t1 ≤ 1
        : final quadratic polynomial
      8. 2·a·t1 + b = 0, 0 ≤ t1 ≤ 1
        : derivative

      Parameters:
      x0 - point 0 of the line
      y0 - point 0 of the line
      x1 - point 1 of the line
      y1 - point 1 of the line
      cx - the center of the point p.x
      cy - the center of the point p.y
      r - the tolerance radius
      Returns:
      computed intersection
    • intersectLinePointEx

      public static IntersectionResultEx intersectLinePointEx(double x0, double y0, double x1, double y1, double cx, double cy, double r)
    • lineContainsPoint

      public static boolean lineContainsPoint(double x1, double y1, double x2, double y2, double px, double py)
    • lineContainsPoint

      public static boolean lineContainsPoint(double x1, double y1, double x2, double y2, double px, double py, double tolerance)
      Tests if a point is inside a line segment.
      Parameters:
      x1 - the x coordinate of point 1 on the line
      y1 - the y coordinate of point 1 on the line
      x2 - the x coordinate of point 2 on the line
      y2 - the y coordinate of point 2 on the line
      px - the x coordinate of the point
      py - the y coordinate of the point
      tolerance - the maximal distance that the point may stray from the line
      Returns:
      true if the line contains the point within the given tolerance
    • argumentOnLine

      public static double argumentOnLine(double x1, double y1, double x2, double y2, double px, double py)
      Given a point p on a line, computes the value of the argument 't'.

      If the point p is not on the line it is projected perpendicularly on the line. In this case 't' may be outside of the range [0,1].

      Parameters:
      x1 - start of line
      y1 - start of line
      x2 - end of line
      y2 - end of line
      px - point
      py - point
      Returns:
      argument 't' at point px,py on the line.