MCPcopy Index your code
hub / github.com/plotly/plotly.js / getLinearEdgeIntersections

Function getLinearEdgeIntersections

src/traces/scatter/line_points.js:155–176  ·  view source on GitHub ↗
(pt1, pt2)

Source from the content-addressed store, hash-verified

153 // spline uses this too, which isn't precisely correct but is actually pretty
154 // good, because Catmull-Rom weights far-away points less in creating the curvature
155 function getLinearEdgeIntersections(pt1, pt2) {
156 var out = [];
157 var ptCount = 0;
158 for(var i = 0; i < 4; i++) {
159 var edge = edges[i];
160 var ptInt = segmentsIntersect(
161 pt1[0], pt1[1], pt2[0], pt2[1],
162 edge[0], edge[1], edge[2], edge[3]
163 );
164 if(ptInt && (!ptCount ||
165 Math.abs(ptInt.x - out[0][0]) > 1 ||
166 Math.abs(ptInt.y - out[0][1]) > 1
167 )) {
168 ptInt = [ptInt.x, ptInt.y];
169 // if we have 2 intersections, make sure the closest one to pt1 comes first
170 if(ptCount && ptDist(ptInt, pt1) < ptDist(out[0], pt1)) out.unshift(ptInt);
171 else out.push(ptInt);
172 ptCount++;
173 }
174 }
175 return out;
176 }
177
178 function onlyConstrainedPoint(pt) {
179 if(pt[0] < xEdge0 || pt[0] > xEdge1 || pt[1] < yEdge0 || pt[1] > yEdge1) {

Callers

nothing calls this directly

Calls 2

ptDistFunction · 0.70
segmentsIntersectFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…