Class IntersectPointQuadCurve

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

public class IntersectPointQuadCurve extends Object
  • Method Details

    • intersectQuadCurvePoint

      public static IntersectionResult intersectQuadCurvePoint(double x0, double y0, double x1, double y1, double x2, double y2, double cx, double cy, double r)
      Computes the intersection between a quadratic bezier curve and a point with a tolerance radius.

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

      1. (1 - t)²·p0 + 2·(1 - t)·t·p1 + t²·p2 , 0 ≤ t ≤ 1
        : quadratic bezier equation, vector form
      2. (p0 - 2·p1 + p2)·t² - 2·(p0 - p1)·t + p0
        : expanded, and then collected for t
      3. c2·t² + c1·t + c0
        : coefficients compacted
      4. c2x·t² + c1x·t + c0x , c2y·t² + c1y·t + c0y
        : bezier equation in matrix form
      5. fx , fy
        : compacted matrix form
      6. (fx - cx)² + (fy - cy)² = 0
        : distance to point equation, with fx, fy inserted from matrix form
      7. c2x²·t⁴ + 2·c1x·c2x·t³ + (c1x² - 2·cx·c2x + 2·c0x·c2x)·t² + cx² - 2·cx·c0x + c0x² - 2·(cx·c1x - c0x·c1x)·t
        + ..same for y-axis...
        : coefficients expanded
      8. (c2x^2 + c2y^2)*t^4
        + 2*(c1x*c2x + c1y*c2y)*t^3
        + (c1x ^ 2 + c1y ^ 2 + 2 * c0x * c2x + 2 * c0y * c2y - 2 * c2x * cx - 2 * c2y * cy)*t^2
        + c0x^2 + c0y^2 - 2*c0x*cx + cx^2 - 2*c0y*cy + cy^2 + 2*(c0x*c1x + c0y*c1y - c1x*cx - c1y*cy)*t
        : coefficients collected for t
      9. a·t⁴ + b·t³ + c·t² + d·t + e = 0, 0 ≤ t ≤ 1
        : final polynomial equation
      10. 4·a·t³ + 3·b·t² + 2·c·t + d = 0, 0 ≤ t ≤ 1
        : derivative
      Parameters:
      x0 - x-coordinate of control point 0 of the bezier curve
      y0 - y-coordinate of control point 0 of the bezier curve
      x1 - x-coordinate of control point P0 of the bezier curve
      y1 - y-coordinate of control point P0 of the bezier curve
      x2 - x-coordinate of control point P1 of the bezier curve
      y2 - y-coordinate of control point P1 of the bezier curve
      cx - x-coordinate of the point
      cy - y-coordinate of the point
      r - the tolerance radius
      Returns:
      the intersection
    • intersectQuadCurvePointEx

      public static IntersectionResultEx intersectQuadCurvePointEx(double a0x, double a0y, double a1x, double a1y, double a2x, double a2y, double cx, double cy, double epsilon)