(points, options = {})
| 101635 | return Math.sign(getPolygonSignedArea(points, options)); |
| 101636 | } |
| 101637 | function 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 | } |
| 101647 | function forEachSegmentInPolygon(points, visitor, options = {}) { |
| 101648 | const { start =0 , end =points.length , size =2 , isClosed } = options; |
| 101649 | const numPoints = (end - start) / size; |
no outgoing calls
no test coverage detected