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

Function getPolygonSignedArea

docs/app/js/sanddance-app.js:101637–101646  ·  view source on GitHub ↗
(points, options = {})

Source from the content-addressed store, hash-verified

101635 return Math.sign(getPolygonSignedArea(points, options));
101636}
101637function getPolygonSignedArea(points, options = {}) {
101638 const { start =0 , end =points.length } = options;
101639 const dim = options.size || 2;
101640 let area = 0;
101641 for(let i = start, j = end - dim; i < end; i += dim){
101642 area += (points[i] - points[j]) * (points[i + 1] + points[j + 1]);
101643 j = i;
101644 }
101645 return area / 2;
101646}
101647function forEachSegmentInPolygon(points, visitor, options = {}) {
101648 const { start =0 , end =points.length , size =2 , isClosed } = options;
101649 const numPoints = (end - start) / size;

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected