java.lang.Object
org.jhotdraw8.geom.intersect.IntersectCubicCurvePoint
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull IntersectionResultintersectCubicCurvePoint(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.static @NonNull IntersectionResultExintersectCubicCurvePointEx(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3, double cx, double cy) static @NonNull IntersectionResultExintersectCubicCurvePointEx(double a0x, double a0y, double a1x, double a1y, double a2x, double a2y, double a3x, double a3y, double cx, double cy, double epsilon)
-
Method Details
-
intersectCubicCurvePointEx
public static @NonNull 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 @NonNull 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 @NonNull 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 - t)³·p0 + 3·(1 - t)²·t·p1 + 3·(1 - t)·t²·p2 + t³·p3 , 0 ≤ t ≤ 1
: cubic bezier equation, vector form - -(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 - c3·t³ + c2·t² + c1·t + c0
: coefficients compacted - c3x·t³ + c2x·t² + c1x·t + c0x , c3y·t³ + 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 - 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 - (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 - a·t⁶ + b·t⁵ + c·t⁴ + d·t³ + e·t² + f·t + g = 0, 0 ≤ t ≤ 1
: final polynomial equation - 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 curvey0- y-coordinate of control point P0 of the bezier curvex1- x-coordinate of control point P1 of the bezier curvey1- y-coordinate of control point P1 of the bezier curvex2- x-coordinate of control point P2 of the bezier curvey2- y-coordinate of control point P2 of the bezier curvex3- x-coordinate of control point P3 of the bezier curvey3- y-coordinate of control point P3 of the bezier curvecx- x-coordinate of the pointcy- y-coordinate of the pointepsilon- the tolerance radius- Returns:
- the intersection
- (1 - t)³·p0 + 3·(1 - t)²·t·p1 + 3·(1 - t)·t²·p2 + t³·p3 , 0 ≤ t ≤ 1
-