Find intersection of two paths or lines

3,153 views
Skip to first unread message

curiouslearn

unread,
Oct 27, 2012, 8:25:09 PM10/27/12
to d3...@googlegroups.com
Hello,

Is there a command in d3.js that gives coordinates of intersection of two paths?

Thank you.

Josh Faul

unread,
Oct 31, 2012, 6:40:39 PM10/31/12
to d3...@googlegroups.com
Not that I'm aware of.  Unfortunately, it's not a trivial thing to compute. Paths can intersect themselves and each other multiple times.  You may be able to get something useful out of Raphael.pathIntersection() http://raphaeljs.com/reference.html#Raphael.pathIntersection

If you're interested in the math behind it all, check out http://processingjs.nihongoresources.com/bezierinfo/

--Josh

Kai Chang

unread,
Nov 1, 2012, 8:10:11 PM11/1/12
to d3...@googlegroups.com
Check out intersection.js by Kevin Lindsey:

http://www.kevlindev.com/geometry/2D/intersections/index.htm
http://www.kevlindev.com/gui/math/intersection/Intersection.js

The library's 9 years old, but looks like exactly what you need. Nils
Schlomann showed this to me the other day. Definitely something I
wouldn't have thought to look for on my own.

Ian Johnson

unread,
Nov 1, 2012, 8:11:56 PM11/1/12
to d3...@googlegroups.com

curious2learn

unread,
Nov 4, 2012, 11:38:05 AM11/4/12
to d3...@googlegroups.com
Thanks a lot to all of you for the links. I will explore these.

Although it would be great if this functionality is added to d3.js. It is very useful when drawing geometrical figures and economics diagrams. 

Drawing packages in LaTeX such as TikZ also have this functionality. 

Thanks again.
Reply all
Reply to author
Forward
0 new messages