MCPcopy Create free account
hub / github.com/d3/d3-shape / intersect

Function intersect

src/arc.js:25–32  ·  view source on GitHub ↗
(x0, y0, x1, y1, x2, y2, x3, y3)

Source from the content-addressed store, hash-verified

23}
24
25function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
26 var x10 = x1 - x0, y10 = y1 - y0,
27 x32 = x3 - x2, y32 = y3 - y2,
28 t = y32 * x10 - x32 * y10;
29 if (t * t < epsilon) return;
30 t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / t;
31 return [x0 + t * x10, y0 + t * y10];
32}
33
34// Compute perpendicular offset line of length rc.
35// http://mathworld.wolfram.com/Circle-LineIntersection.html

Callers 1

arcFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected