> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ploterr.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Polygon maths

> Measure, test and transform closed rings in the plan.

## Import

```typescript theme={null}
import {
  signedAreaXZ,
  ringAreaXZ,
  perimeterXZ,
  areaCentroidXZ,
  centroidXZ,
  pointInPolygonXZ,
  ringsOverlap,
  ringStrictlyInside,
  isConvexXZ,
  distancePointToSegmentXZ,
  ringDistanceXZ,
  offsetRingOutwardXZ,
  rotatePointsXZ,
  translatePointsXZ,
  validateAndNormalizeProfile,
  clonePolygonProfile,
} from '@opengeometry/floorkit';
```

## signedAreaXZ

Shoelace area on the XZ plane.

```typescript theme={null}
function signedAreaXZ(ring: PointXZ[]): number;
```

## ringAreaXZ

Absolute (unsigned) shoelace area of the ring.

```typescript theme={null}
function ringAreaXZ(ring: PointXZ[]): number;
```

## perimeterXZ

Sum of edge lengths around the (implicitly closed) ring.

```typescript theme={null}
function perimeterXZ(ring: PointXZ[]): number;
```

## areaCentroidXZ

Area-weighted centroid (shoelace formula).

```typescript theme={null}
function areaCentroidXZ(ring: PointXZ[]): PointXZ;
```

## centroidXZ

Average of all points.

```typescript theme={null}
function centroidXZ(ring: PointXZ[]): PointXZ;
```

## pointInPolygonXZ

Crossing-number point-in-polygon test on the XZ plane.

```typescript theme={null}
function pointInPolygonXZ(p: PointXZ, ring: PointXZ[]): boolean;
```

## ringsOverlap

True if any vertex of one ring lies inside the other, OR any pair of edges crosses.

```typescript theme={null}
function ringsOverlap(a: PointXZ[], b: PointXZ[]): boolean;
```

## ringStrictlyInside

True if every vertex of `inner` lies inside `outer` AND no edge of `inner` crosses any edge of `outer`.

```typescript theme={null}
function ringStrictlyInside(inner: PointXZ[], outer: PointXZ[]): boolean;
```

## isConvexXZ

True when every turn around the ring has the same sign (collinear runs allowed).

```typescript theme={null}
function isConvexXZ(ring: PointXZ[]): boolean;
```

## distancePointToSegmentXZ

Distance from `p` to the segment a→b (clamped to the segment).

```typescript theme={null}
function distancePointToSegmentXZ(p: PointXZ, a: PointXZ, b: PointXZ): number;
```

## ringDistanceXZ

Minimum distance between two rings' boundaries: 0 when they overlap or touch, else the closest vertex-to-edge approach in either direction.

```typescript theme={null}
function ringDistanceXZ(a: PointXZ[], b: PointXZ[]): number;
```

## offsetRingOutwardXZ

Offset every edge of the ring outward (away from the interior) by `distance`, rebuilding vertices as miter intersections of adjacent offset edges.

```typescript theme={null}
function offsetRingOutwardXZ(ring: PointXZ[], distance: number): PointXZ[];
```

## rotatePointsXZ

Rotate every point around `anchor` by `angleRad` (right-handed about +Y, i.e.

```typescript theme={null}
function rotatePointsXZ(ring: PointXZ[], angleRad: number, anchor: PointXZ): PointXZ[];
```

## translatePointsXZ

Translate every point.

```typescript theme={null}
function translatePointsXZ(ring: PointXZ[], dx: number, dz: number): PointXZ[];
```

## validateAndNormalizeProfile

Validate, dedupe/auto-close, and normalize winding of a polygon profile.

```typescript theme={null}
function validateAndNormalizeProfile(
  profile: PolygonProfile,
  label: string,
): NormalizedPolygonProfile;
```

## clonePolygonProfile

Deep-clone a profile so caller mutations don't bleed into element state.

```typescript theme={null}
function clonePolygonProfile(profile: PolygonProfile): PolygonProfile;
```

## Types

### PolygonProfile

Closed polygon profile in the world XZ plane.

```typescript theme={null}
interface PolygonProfile {
  outerRing: PointXZ[];
  holes?: PointXZ[][];
}
```

### NormalizedPolygonProfile

```typescript theme={null}
interface NormalizedPolygonProfile {
  outer: PointXZ[];
  holes: PointXZ[][];
}
```

### Winding

```typescript theme={null}
type Winding = 'CW' | 'CCW';
```

### PointXZ

```typescript theme={null}
type PointXZ = [number, number];
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.