Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 1x 1x 1x 1x 1x 1x | import { glMatrix } from 'gl-matrix';
import type { Types } from '@cornerstonejs/core';
import * as math from '..';
/**
* A polyline is considered closed if the start and end points are at the same position
*
* @param polyline - Polyline points (2D)
* @returns True if the polyline is already closed or false otherwise
*/
export default function isClosed(polyline: Types.Point2[]): boolean {
Iif (polyline.length < 3) {
return false;
}
const numPolylinePoints = polyline.length;
const firstPoint = polyline[0];
const lastPoint = polyline[numPolylinePoints - 1];
const distFirstToLastPoints = math.point.distanceToPointSquared(
firstPoint,
lastPoint
);
return glMatrix.equals(0, distFirstToLastPoints);
}
|