MCPcopy
hub / github.com/microsoft/SandDance / intersect

Function intersect

docs/app/js/sanddance-app.js:102199–102217  ·  view source on GitHub ↗
(a, b, edge, bbox, out = [])

Source from the content-addressed store, hash-verified

102197 return result;
102198}
102199function intersect(a, b, edge, bbox, out = []) {
102200 let t;
102201 let snap;
102202 if (edge & 8) {
102203 t = (bbox[3] - a[1]) / (b[1] - a[1]);
102204 snap = 3;
102205 } else if (edge & 4) {
102206 t = (bbox[1] - a[1]) / (b[1] - a[1]);
102207 snap = 1;
102208 } else if (edge & 2) {
102209 t = (bbox[2] - a[0]) / (b[0] - a[0]);
102210 snap = 2;
102211 } else if (edge & 1) {
102212 t = (bbox[0] - a[0]) / (b[0] - a[0]);
102213 snap = 0;
102214 } else return null;
102215 for(let i = 0; i < a.length; i++)out[i] = (snap & 1) === i ? bbox[snap] : t * (b[i] - a[i]) + a[i];
102216 return out;
102217}
102218function bitCode(p, bbox) {
102219 let code = 0;
102220 if (p[0] < bbox[0]) code |= 1;

Callers 6

clipPolylineFunction · 0.70
clipPolygonFunction · 0.70
sanddance-app.jsFile · 0.70
hasOverlapFunction · 0.70
arcFunction · 0.70
clipLineFunction · 0.70

Calls 5

intersectMarkFunction · 0.70
intersectGroupFunction · 0.70
filterFunction · 0.70
maxMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected