MCPcopy Create free account
hub / github.com/idank/explainshell / d3_geo_pathCentroidLineStart

Function d3_geo_pathCentroidLineStart

explainshell/web/static/js/d3.v3.js:3402–3421  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3400 ++d3_geo_centroidZ;
3401 }
3402 function d3_geo_pathCentroidLineStart() {
3403 var x0, y0;
3404 if (d3_geo_centroidDimension !== 1) {
3405 if (d3_geo_centroidDimension < 1) {
3406 d3_geo_centroidDimension = 1;
3407 d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0;
3408 } else return;
3409 }
3410 d3_geo_pathCentroid.point = function(x, y) {
3411 d3_geo_pathCentroid.point = nextPoint;
3412 x0 = x, y0 = y;
3413 };
3414 function nextPoint(x, y) {
3415 var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy);
3416 d3_geo_centroidX += z * (x0 + x) / 2;
3417 d3_geo_centroidY += z * (y0 + y) / 2;
3418 d3_geo_centroidZ += z;
3419 x0 = x, y0 = y;
3420 }
3421 }
3422 function d3_geo_pathCentroidLineEnd() {
3423 d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint;
3424 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected