mirror of
https://github.com/mapillary/mapillary-js.git
synced 2026-01-18 13:56:53 +00:00
11 lines
346 B
TypeScript
11 lines
346 B
TypeScript
export function isClockwise(polygon: number[][]): boolean {
|
|
if (polygon.length < 3) { return false; };
|
|
let edgeSum = 0;
|
|
for (let i = 0; i < polygon.length; ++i) {
|
|
const [x1, y1] = polygon[i];
|
|
const [x2, y2] = polygon[(i + 1) % polygon.length];
|
|
edgeSum += (x2 - x1) * (y2 + y1);
|
|
}
|
|
return edgeSum > 0;
|
|
}
|