PolygonOps Class

Various (static method) computations for arrays 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 return the area of the polygon.  
areaNormal(points: Point3d[], result?: Vector3d): Vector3d Static return a vector which is perpendicular to the polygon and has magnitude equal to the polygon area.  
areaNormalGo(points: IndexedXYZCollection, result?: Vector3d): undefined | Vector3d Static return a vector which is perpendicular to the polygon and has magnitude equal to the polygon area.  
areaXY(points: Point3d[] | IndexedXYZCollection): number Static return 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: Point3d[] | IndexedXYZCollection): undefined | Ray3d Static Return a Ray3d with (assuming the polygon is planar and not self-intersecting)  
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.  
closestPointOnBoundary(polygon: Point3d[] | IndexedXYZCollection, testPoint: Point3d, tolerance: number = Geometry.smallMetricDistance, result?: PolygonLocationDetail): PolygonLocationDetail Static Compute the closest point on the polygon boundary to the given point.  
convexBarycentricCoordinates(polygon: Point3d[] | IndexedXYZCollection, point: Point3d, tolerance: number = Geometry.smallMetricDistance): undefined | number[] Static Compute the barycentric coordinates for a point inside a convex polygon.  
intersectRay3d(polygon: Point3d[] | IndexedXYZCollection, ray: Ray3d, tolerance: 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: Point3d[] | IndexedXYZCollection, 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: Point3d[] | IndexedXYZCollection): 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: undefined | Vector3d): IndexedReadWriteXYZCollection[][] Static Exactly like sortOuterAndHoleLoopsXY but allows loops in any plane.  
sortOuterAndHoleLoopsXY(loops: IndexedReadWriteXYZCollection[]): IndexedReadWriteXYZCollection[][] Static Reverse loops as necessary to make them all have CCW orientation for given outward normal.  
sumAreaXY(polygons: Point3d[][]): number Static Sum the areaXY () values 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.  

Defined in

Last Updated: 20 June, 2023