MCPcopy Create free account
hub / github.com/tdewolff/canvas / intersectionRayLine

Function intersectionRayLine

path_intersection_util.go:782–796  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

780// see T.W. Sederberg and S.R. Parry, "Comparison of three curve intersection algorithms", 1986
781
782func 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
799func intersectionRayCircle(l0, l1, c Point, r float64) (Point, Point, bool) {

Callers 1

JoinMethod · 0.85

Calls 5

EqualFunction · 0.85
IntervalFunction · 0.85
SubMethod · 0.80
PerpDotMethod · 0.80
InterpolateMethod · 0.80

Tested by

no test coverage detected