Split a Bézier curve into two at the intersection with a closed path. Parameters ---------- bezier : (N, 2) array-like Control points of the Bézier segment. See `.BezierSegment`. inside_closedpath : callable A function returning True if a given point (x, y) is i
(
bezier, inside_closedpath, tolerance=0.01)
| 403 | |
| 404 | |
| 405 | def split_bezier_intersecting_with_closedpath( |
| 406 | bezier, inside_closedpath, tolerance=0.01): |
| 407 | """ |
| 408 | Split a Bézier curve into two at the intersection with a closed path. |
| 409 | |
| 410 | Parameters |
| 411 | ---------- |
| 412 | bezier : (N, 2) array-like |
| 413 | Control points of the Bézier segment. See `.BezierSegment`. |
| 414 | inside_closedpath : callable |
| 415 | A function returning True if a given point (x, y) is inside the |
| 416 | closed path. See also `.find_bezier_t_intersecting_with_closedpath`. |
| 417 | tolerance : float |
| 418 | The tolerance for the intersection. See also |
| 419 | `.find_bezier_t_intersecting_with_closedpath`. |
| 420 | |
| 421 | Returns |
| 422 | ------- |
| 423 | left, right |
| 424 | Lists of control points for the two Bézier segments. |
| 425 | """ |
| 426 | |
| 427 | bz = BezierSegment(bezier) |
| 428 | |
| 429 | t0, t1 = find_bezier_t_intersecting_with_closedpath( |
| 430 | lambda t: tuple(bz(t)), inside_closedpath, tolerance=tolerance) |
| 431 | |
| 432 | _left, _right = split_de_casteljau(bezier, (t0 + t1) / 2.) |
| 433 | return _left, _right |
| 434 | |
| 435 | |
| 436 | # matplotlib specific |
searching dependent graphs…