TODO: bezier-bezier intersection TODO: bezier-ellipse intersection For Bézier-Bézier intersections: see T.W. Sederberg, "Computer Aided Geometric Design", 2012 see T.W. Sederberg and T. Nishita, "Curve intersection using Bézier clipping", 1990 see T.W. Sederberg and S.R. Parry, "Comparison of three
(a0, a1, b0, b1 Point)
| 780 | // see T.W. Sederberg and S.R. Parry, "Comparison of three curve intersection algorithms", 1986 |
| 781 | |
| 782 | func intersectionRayLine(a0, a1, b0, b1 Point) (Point, bool) { |
| 783 | da := a1.Sub(a0) |
| 784 | db := b1.Sub(b0) |
| 785 | div := da.PerpDot(db) |
| 786 | if Equal(div, 0.0) { |
| 787 | // parallel |
| 788 | return Point{}, false |
| 789 | } |
| 790 | |
| 791 | tb := da.PerpDot(a0.Sub(b0)) / div |
| 792 | if Interval(tb, 0.0, 1.0) { |
| 793 | return b0.Interpolate(b1, tb), true |
| 794 | } |
| 795 | return Point{}, false |
| 796 | } |
| 797 | |
| 798 | // https://mathworld.wolfram.com/Circle-LineIntersection.html |
| 799 | func intersectionRayCircle(l0, l1, c Point, r float64) (Point, Point, bool) { |