MCPcopy Create free account
hub / github.com/microsoft/SandDance / extendBasis

Function extendBasis

docs/app/js/sanddance-app.js:137977–137999  ·  view source on GitHub ↗
(B, p)

Source from the content-addressed store, hash-verified

137975 return e;
137976};
137977function extendBasis(B, p) {
137978 var i, j;
137979 if (enclosesWeakAll(p, B)) return [
137980 p
137981 ];
137982 // If we get here then B must have at least one element.
137983 for(i = 0; i < B.length; ++i){
137984 if (enclosesNot(p, B[i]) && enclosesWeakAll(encloseBasis2(B[i], p), B)) return [
137985 B[i],
137986 p
137987 ];
137988 }
137989 // If we get here then B must have at least two elements.
137990 for(i = 0; i < B.length - 1; ++i)for(j = i + 1; j < B.length; ++j){
137991 if (enclosesNot(encloseBasis2(B[i], B[j]), p) && enclosesNot(encloseBasis2(B[i], p), B[j]) && enclosesNot(encloseBasis2(B[j], p), B[i]) && enclosesWeakAll(encloseBasis3(B[i], B[j], p), B)) return [
137992 B[i],
137993 B[j],
137994 p
137995 ];
137996 }
137997 // If we get here then something is very wrong.
137998 throw new Error;
137999}
138000function enclosesNot(a, b) {
138001 var dr = a.r - b.r, dx = b.x - a.x, dy = b.y - a.y;
138002 return dr < 0 || dr * dr < dx * dx + dy * dy;

Callers 1

sanddance-app.jsFile · 0.70

Calls 4

enclosesWeakAllFunction · 0.70
enclosesNotFunction · 0.70
encloseBasis2Function · 0.70
encloseBasis3Function · 0.70

Tested by

no test coverage detected