Class IntersectCubicCurvePoint

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

public class IntersectCubicCurvePoint extends Object
  • Method Details

    • intersectCubicCurvePointEx

      public static IntersectionResultEx intersectCubicCurvePointEx(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3, double cx, double cy)
    • intersectCubicCurvePointEx

      public static IntersectionResultEx intersectCubicCurvePointEx(double a0x, double a0y, double a1x, double a1y, double a2x, double a2y, double a3x, double a3y, double cx, double cy, double epsilon)
    • intersectCubicCurvePoint

      public static IntersectionResult intersectCubicCurvePoint(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3, double cx, double cy, double epsilon)
      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 + 3·(1 - t)²·t·p1 + 3·(1 - t)·t²·p2 + t³·p3 , 0 ≤ t ≤ 1
        : cubic bezier equation, vector form
      2. -(p0 - 3*p1 + 3*p2 - p3)*t^3 + 3*(p0 - 2*p1 + p2)*t^2 - 3*(p0 - p1)*t + p0
        : expanded, and then collected for t
      3. c3·t³ + c2·t² + c1·t + c0
        : coefficients compacted
      4. c3x·t³ + c2x·t² + c1x·t + c0x , c3y·t³ + 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. c3x^2*t^6 + 2*c2x*c3x*t^5 + (c2x^2 + 2*c1x*c3x)*t^4 + 2*(c1x*c2x + c0x*c3x - c3x*cx)*t^3 + (c1x^2 + 2*c0x*c2x - 2*c2x*cx)*t^2 + c0x^2 - 2*c0x*cx + cx^2 + 2*(c0x*c1x - c1x*cx)*t
        + ..same for y-axis...
        : coefficients expanded
      8. (c3x^2 + c3y^2)*t^6
        + 2*(c2x*c3x + c2y*c3y)*t^5
        + (c2x^2 + c2y^2 + 2*c1x*c3x + 2*c1y*c3y)*t^4
        + 2*(c1x*c2x + c1y*c2y + c0x*c3x + c0y*c3y - c3x*cx - c3y*cy)*t^3
        + (c1x^2 + c1y^2 + 2*c0x*c2x + 2*c0y*c2y - 2*c2x*cx - 2*c2y*cy)*t^2
        + 2*(c0x*c1x + c0y*c1y - c1x*cx - c1y*cy)*t
        + c0x^2 + c0y^2 - 2*c0x*cx + cx^2 - 2*c0y*cy + cy^2
        : coefficients collected for t
      9. a·t⁶ + b·t⁵ + c·t⁴ + d·t³ + e·t² + f·t + g = 0, 0 ≤ t ≤ 1
        : final polynomial equation
      10. 6·a·t⁵ + 5·b·t⁴ + 4·c·t³ + 3·d·t² + 2·e·t + f = 0, 0 ≤ t ≤ 1
        : derivative
      Parameters:
      x0 - x-coordinate of control point P0 of the bezier curve
      y0 - y-coordinate of control point P0 of the bezier curve
      x1 - x-coordinate of control point P1 of the bezier curve
      y1 - y-coordinate of control point P1 of the bezier curve
      x2 - x-coordinate of control point P2 of the bezier curve
      y2 - y-coordinate of control point P2 of the bezier curve
      x3 - x-coordinate of control point P3 of the bezier curve
      y3 - y-coordinate of control point P3 of the bezier curve
      cx - x-coordinate of the point
      cy - y-coordinate of the point
      epsilon - the tolerance radius
      Returns:
      the intersection