This example presents a simple approximate solution to path-line intersection by subdividing the path (via the built-in svg path function .getPointAtLength) into an arbitrary number of straight line segments and testing for line-line intersections at each one. A more accurate solution would be to similarly walk through segments of the path, but instead using the points specified in the path's d
definition, and computing the intersections with the lines, Bezier curves and arcs - that approach is forthcoming in another future example. See also Mike Bostock's related example on Line Segment Intersection.
The moveable intersecting line is based on this block.
For uses of this functionality, see the Path-Line Reflection and Bottled Gas Animation blocks.
https://d3js.org/d3.v3.min.js