8.8.3. pyafv.calibrate tools

polygon_centroid(pts)[source]

Centroid (center of mass) of a simple polygon with uniform density.

Parameters:

pts (ndarray) – (N,2) array of vertices in order (first need not repeat at end).

Returns:

(2,) centroid array. (If degenerate area, returns vertex mean.)

Return type:

ndarray

polygon_area_perimeter(pts)[source]

Compute the area and perimeter for a Counter-ClockWise (CCW) polygon.

Parameters:

pts (ndarray) – (N,2) array of vertices in CCW order (first need not repeat at end).

Returns:

A tuple of (area, perimeter).

Return type:

tuple[float, float]

resample_polyline(pts, M=None)[source]

Resample an open polyline to M points with uniform arclength spacing. Keeps endpoints exactly. If M is None, uses original number of points.

Parameters:
  • pts (ndarray) – (N,2) array of polyline vertices.

  • M (int | None) – Number of output points; if None, uses N.

Returns:

(M,2) array of resampled polyline vertices.

Return type:

ndarray