MCPcopy Create free account
hub / github.com/breck7/scroll / extendBasis

Function extendBasis

external/.d3.js:13310–13337  ·  view source on GitHub ↗
(B, p)

Source from the content-addressed store, hash-verified

13308}
13309
13310function extendBasis(B, p) {
13311 var i, j;
13312
13313 if (enclosesWeakAll(p, B)) return [p];
13314
13315 // If we get here then B must have at least one element.
13316 for (i = 0; i < B.length; ++i) {
13317 if (enclosesNot(p, B[i])
13318 && enclosesWeakAll(encloseBasis2(B[i], p), B)) {
13319 return [B[i], p];
13320 }
13321 }
13322
13323 // If we get here then B must have at least two elements.
13324 for (i = 0; i < B.length - 1; ++i) {
13325 for (j = i + 1; j < B.length; ++j) {
13326 if (enclosesNot(encloseBasis2(B[i], B[j]), p)
13327 && enclosesNot(encloseBasis2(B[i], p), B[j])
13328 && enclosesNot(encloseBasis2(B[j], p), B[i])
13329 && enclosesWeakAll(encloseBasis3(B[i], B[j], p), B)) {
13330 return [B[i], B[j], p];
13331 }
13332 }
13333 }
13334
13335 // If we get here then something is very wrong.
13336 throw new Error;
13337}
13338
13339function enclosesNot(a, b) {
13340 var dr = a.r - b.r, dx = b.x - a.x, dy = b.y - a.y;

Callers 1

packEncloseRandomFunction · 0.85

Calls 4

enclosesWeakAllFunction · 0.85
enclosesNotFunction · 0.85
encloseBasis2Function · 0.85
encloseBasis3Function · 0.85

Tested by

no test coverage detected