java.lang.Object
org.jhotdraw8.geom.intersect.IntersectPointQuadCurve
-
Method Summary
Modifier and TypeMethodDescriptionstatic IntersectionResultintersectQuadCurvePoint(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.static IntersectionResultExintersectQuadCurvePointEx(double a0x, double a0y, double a1x, double a1y, double a2x, double a2y, double cx, double cy, double epsilon)
-
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 - t)²·p0 + 2·(1 - t)·t·p1 + t²·p2 , 0 ≤ t ≤ 1
: quadratic bezier equation, vector form - (p0 - 2·p1 + p2)·t² - 2·(p0 - p1)·t + p0
: expanded, and then collected for t - c2·t² + c1·t + c0
: coefficients compacted - c2x·t² + c1x·t + c0x , c2y·t² + c1y·t + c0y
: bezier equation in matrix form - fx , fy
: compacted matrix form - (fx - cx)² + (fy - cy)² = 0
: distance to point equation, with fx, fy inserted from matrix form - 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 - (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 - a·t⁴ + b·t³ + c·t² + d·t + e = 0, 0 ≤ t ≤ 1
: final polynomial equation - 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 curvey0- y-coordinate of control point 0 of the bezier curvex1- x-coordinate of control point P0 of the bezier curvey1- y-coordinate of control point P0 of the bezier curvex2- x-coordinate of control point P1 of the bezier curvey2- y-coordinate of control point P1 of the bezier curvecx- x-coordinate of the pointcy- y-coordinate of the pointr- the tolerance radius- Returns:
- the intersection
- (1 - t)²·p0 + 2·(1 - t)·t·p1 + t²·p2 , 0 ≤ t ≤ 1
-
intersectQuadCurvePointEx
public static IntersectionResultEx intersectQuadCurvePointEx(double a0x, double a0y, double a1x, double a1y, double a2x, double a2y, double cx, double cy, double epsilon)
-