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

Function getPolygonSignedAreaPoints

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

Source from the content-addressed store, hash-verified

101678 return Math.sign(getPolygonSignedAreaPoints(points, options));
101679}
101680function getPolygonSignedAreaPoints(points, options = {}) {
101681 const { start =0 , end =points.length } = options;
101682 let area = 0;
101683 for(let i = start, j = end - 1; i < end; ++i){
101684 area += (points[i][0] - points[j][0]) * (points[i][1] + points[j][1]);
101685 j = i;
101686 }
101687 return area / 2;
101688}
101689function forEachSegmentInPolygonPoints(points, visitor, options = {}) {
101690 const { start =0 , end =points.length , isClosed } = options;
101691 for(let i = start; i < end - 1; ++i)visitor(points[i], points[i + 1], i, i + 1);

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected