MCPcopy
hub / github.com/mewo2/terrain / getFlux

Function getFlux

terrain.js:334–352  ·  view source on GitHub ↗
(h)

Source from the content-addressed store, hash-verified

332}
333
334function getFlux(h) {
335 var dh = downhill(h);
336 var idxs = [];
337 var flux = zero(h.mesh);
338 for (var i = 0; i < h.length; i++) {
339 idxs[i] = i;
340 flux[i] = 1/h.length;
341 }
342 idxs.sort(function (a, b) {
343 return h[b] - h[a];
344 });
345 for (var i = 0; i < h.length; i++) {
346 var j = idxs[i];
347 if (dh[j] >= 0) {
348 flux[dh[j]] += flux[j];
349 }
350 }
351 return flux;
352}
353
354function getSlope(h) {
355 var dh = downhill(h);

Callers 4

erosionRateFunction · 0.85
cityScoreFunction · 0.85
getRiversFunction · 0.85
getTerritoriesFunction · 0.85

Calls 2

downhillFunction · 0.85
zeroFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…