orient_counterclockwise#
- ktch.harmonic.orient_counterclockwise(X)[source]#
Return a 2D outline traced counterclockwise, keeping its first point.
The direction is read from the signed area of the point list (the shoelace sum over the closed polygon). A clockwise outline is reversed with its first point kept first;
np.flipwould move that point to the end and shift a homologous start point. A counterclockwise outline, or one with zero signed area, is returned unchanged. An outline whose last point repeats the first is reversed as a whole and stays closed.The signed area is the sum over the harmonics of
pi * n * (a_n d_n - b_n c_n); the direction EFA’s registration reads is the sign of the first term alone, the determinant of the first-harmonic block. The two agree when the first-harmonic ellipse carries the sign of the area, as it does for most outlines. They can disagree when that ellipse is very thin and higher harmonics carry the area, as for a strip coiled into a spiral, and for a self-intersecting outline, which has no single direction.- Parameters:
- Xarray-like of shape (n_coords, 2)
Coordinate values of one outline.
- Returns:
- ndarray of shape (n_coords, 2)
The outline, traced counterclockwise.