cplx_winding_number — MATH complex op

Datenarten: cpointsmeasurement

Aufruf: import mathops; mathops.cplx_winding_number(z, w=0.0) (oder opsmath.get("cplx_winding_number"))

Verwendung

Windungszahl einer geschlossenen Kontur um einen Punkt (Umlaufzahl).

> Die ausführliche Beschreibung unten ist der Originaltext — Zusammenfassung und Überschriften sind übersetzt.

How many times the polygon `z` (closing segment implicit) travels

counter-clockwise around *w*: `+1` for a simple positively-oriented loop

containing it, `-1 clockwise, 0 outside, ±k for a k`-fold

loop. Computed as the sum of the principal-value argument increments of

`z_k - w divided by 2*pi` and rounded — for a *polygon* that sum is an

exact multiple of `2*pi`, so the result is an exact integer, not an

estimate (the rounding merely removes ~1e-14 of accumulated float error).

Honest limitation — **the count can alias low, and no local check can stop

it**: this is the winding number of the polygon *through the samples*,

which equals that of the underlying curve only if the sampling resolves it.

A segment that turns the ray to *w* by `>= pi` is ambiguous (which side

did it pass?) and raises. Below that there is no contradiction to detect:

`z**5 sampled on a 4-point circle turns exactly pi/2` per step and

counts 1 instead of 5 (measured). From `pi/2` up, a

`RuntimeWarning says so (WIND_ALIAS_WARN`); the only real remedy is

the classical one — refine until the count stops changing.

Raises `ValueError`: *w* coincides with a vertex or lies on a segment

(the winding number is undefined on the contour), a segment subtends

`>= pi` as seen from *w* (undersampled — refine the contour), fewer than

3 points, degenerate contour, non-finite/masked input.

HALCON: no operator (`test_region_point` answers the related but weaker

inside/outside question for regions).

Familienweiter Eingabevertrag (fail-closed)

Jeder mathops-Operator prüft seine Eingabe vor der Berechnung (nichts rutscht stillschweigend durch):

• **Komplexe Eingaben lösen ValueError aus** — die Umwandlung nach float64 verwirft den Imaginärteil stillschweigend (numpy meldet nur eine ComplexWarning und liefert eine plausibel aussehende, falsche reelle Zahl). Schreiben Sie .real/.imag/abs() explizit oder nutzen Sie complexops.

• **Masked Arrays mit maskierten Elementen lösen ValueError aus** — die implizite Umwandlung, die die Maske abstreift und die Rohwerte darunter verwendet, wird abgelehnt. Geben Sie explizit an, ob gefüllt oder verworfen wird.

• **NaN/Inf löst bei jeder Eingabe ValueError aus** (mit Anzahl abgelehnt — es pflanzt sich durch das gesamte Ergebnis fort).

Formen sind strikt: 1-D und 2-D werden nie implizit hochgestuft oder gebroadcastet (eine Matrix im Vektor-Slot oder ein Vektor im Matrix-Slot löst ValueError aus; reshapen Sie explizit).

Größenobergrenze: Operatoren, die eine Matrix nehmen, sowie die stat_histogram-Bins lösen jenseits von mathops.MAX_ELEMENTS (2^26 ≈ 67 Mio. Elemente) ValueError aus.

Ausführlicher Anwendungsleitfaden

Leitfaden zur Familie math_metrology

Referenzen (Beispieldaten, Literatur)

• Katalog der Beispieldaten (Download-URLs / Lizenzen) — 2-D nutzt skimage.data (BSD/Public Domain) plus synthetische Bilder, 3-D nennt Download-URLs echter Datenquellen (Stanford, PDS, …).

• Herkunft und Literatur der Operatoren — die Quellen der Forschung/Verfahren, auf denen diese Operatorfamilie beruht.

• Der kanonische Algorithmus (Autor, Jahr) und seine Anwendungen stehen im Familienleitfaden oben.

Ausführbare Beispiele (verifizierte Samples, die diesen Operator wirklich aufrufen)

math_complexpy -3.11 examples/math_complex.py

Typkompatible Folge-Operatoren (nehmen measurement als Eingabe)

Gleiche Kategorie (complex)

cplx_contour_circle · cplx_poly_eval · cplx_contour_integral · cplx_cauchy_value · cplx_argument_principle · cplx_laurent_coeffs · cplx_joukowski · cplx_mobius


*Provenance: mathops.py — MATH Operator-Registry. Diese Notiz wird von tools/opdocs.py md erzeugt (nicht von Hand bearbeiten).*

© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.