PolygonOps Class
Various static methods to perform computations on an array of points interpreted as a polygon.
Methods
| Name | Description | |
|---|---|---|
| constructor(): PolygonOps | ||
| addSecondMomentAreaProducts(points: IndexedXYZCollection, origin: Point3d, moments: Matrix4d): void Static | Accumulate to the matrix of area products of a polygon with respect to an origin. | |
| addSecondMomentVolumeProducts(points: IndexedXYZCollection, origin: Point3d, moments: Matrix4d): void Static | Accumulate to the matrix of volume products of a polygon with respect to an origin. | |
| area(points: Point3d[]): number Static | Compute the area of the polygon. | |
| areaNormal(points: Point3d[], result?: Vector3d): Vector3d Static | Compute the area and normal of the polygon, packaged as a vector. | |
| areaNormalGo(points: IndexedXYZCollection, result?: Vector3d): undefined | Vector3d Static | Compute the area and normal of the polygon, packaged as a vector. | |
| areaXY(points: IndexedXYZCollection | Point3d[]): number Static | Compute the projected XY area of the polygon. | |
| centroidAndAreaXY(points: Point2d[], centroid: Point2d): undefined | number Static | * Return (in caller-allocated centroid) the centroid of the xy polygon. | |
| centroidAreaNormal(points: IndexedXYZCollection | Point3d[], result?: Ray3d): undefined | Ray3d Static | Return a Ray3d with: | |
| classifyPointInPolygon(x: number, y: number, points: Readonly<WritableXAndY>[]): undefined | number Static | Test if point (x,y) is IN, OUT or ON a polygon. | |
| classifyPointInPolygonXY(x: number, y: number, points: IndexedXYZCollection): undefined | number Static | Test if point (x,y) is IN, OUT or ON a polygon. | |
| closestApproach(polygonA: IndexedXYZCollection | Point3d[], polygonB: IndexedXYZCollection | Point3d[], dMax: number = Number.MAX_VALUE, _searchInterior: boolean = false): undefined | PolygonLocationDetailPair Static | Find smallest distance between polygons. | |
| closestPoint(polygon: IndexedXYZCollection | Point3d[], testPoint: Point3d, tolerance: number = Geometry.smallMetricDistance, result?: PolygonLocationDetail): PolygonLocationDetail Static | Compute the closest point on the polygon boundary or its interior to the given point. | |
| closestPointOnBoundary(polygon: IndexedXYZCollection | Point3d[], testPoint: Point3d, tolerance: number | [number, number] = Geometry.smallMetricDistance, result?: PolygonLocationDetail): PolygonLocationDetail Static | Compute the closest point on the polygon boundary to the given point. | |
| convexBarycentricCoordinates(polygon: IndexedXYZCollection | Point3d[], point: Point3d, tolerance: number = Geometry.smallMetricDistance): undefined | number[] Static | Compute the barycentric coordinates for a point inside a convex polygon. | |
| ensureClosed(polygon: IndexedXYZCollection | Point3d[], tolerance: number = Geometry.smallMetricDistance): IndexedXYZCollection | Point3d[] Static | Return a closed polygon, cloning only if necessary. | |
| forceClosure(polygon: Point3d[] | GrowableXYZArray, tolerance: number = Geometry.smallMetricDistance): void Static | Force the polygon to be closed. | |
| intersectRay3d(polygon: IndexedXYZCollection | Point3d[], ray: Ray3d, tolerance: number | [number, number] = Geometry.smallMetricDistance, result?: PolygonLocationDetail): PolygonLocationDetail Static | Compute the intersection of a line (parameterized as a ray) with the plane of this polygon. | |
| intersectSegment(polygon: IndexedXYZCollection | Point3d[], point0: Point3d, point1: Point3d, tolerance: number = Geometry.smallMetricDistance, result?: PolygonLocationDetail): PolygonLocationDetail Static | Compute the intersection of a line (parameterized as a line segment) with the plane of this polygon. | |
| isConvex(polygon: IndexedXYZCollection | Point3d[]): boolean Static | Determine whether the polygon is convex. | |
| orientLoopsCCWForOutwardNormalInPlace(loops: IndexedReadWriteXYZCollection | IndexedReadWriteXYZCollection[], outwardNormal: Vector3d): number Static | Reverse loops as necessary to make them all have CCW orientation for given outward normal. | |
| sortOuterAndHoleLoops(loops: IndexedReadWriteXYZCollection[], defaultNormal: Vector3d): IndexedReadWriteXYZCollection[][] Static | Exactly like sortOuterAndHoleLoopsXY but allows loops in any plane. |
|
| sortOuterAndHoleLoopsXY(loops: IndexedReadWriteXYZCollection[]): IndexedReadWriteXYZCollection[][] Static | Reverse and reorder loops in the xy-plane for consistent orientation and containment. | |
| sumAreaXY(polygons: Point3d[][]): number Static | Sum the result of areaXY for multiple polygons. | |
| sumTriangleAreas(points: Point3d[] | GrowableXYZArray): number Static | Sum areas of triangles from points[0] to each far edge. | |
| sumTriangleAreasPerpendicularToUpVector(points: Point3d[] | GrowableXYZArray, upVector: Vector3d): number Static | Sum areas of triangles from points[0] to each far edge, as viewed with upVector pointing up. | |
| sumTriangleAreasXY(points: Point3d[]): number Static | Sum areas of triangles from points[0] to each far edge. | |
| testXYPolygonTurningDirections(points: Point3d[] | Point2d[]): number Static | Test the direction of turn at the vertices of the polygon, ignoring z-coordinates. | |
| unitNormal(points: IndexedXYZCollection, result: Vector3d): boolean Static | Return a unit normal to the plane of the polygon. | |
| volumeBetweenPolygonAndPlane(facetPoints: GrowableXYZArray, plane: Plane3d, options?: VolumeBetweenPolygonAndPlaneOptions): VolumeBetweenPolygonAndPlaneOutput Static | Compute the signed volume of the truncated prism between a facet and a plane. |
Defined in
- geometry3d/PolygonOps.ts Line 378
Last Updated: 29 October, 2025
Found something wrong, missing, or unclear on this page? Raise an issue in our repo.