The analytic definition of the winding number of a closed curve and a point is:
$$\frac{1}{2\pi}\oint_C (\frac{x}{r^2}dy\frac{y}{r^2}dx)$$
Where $r^2 = x^2 + y^2$.
In my naivety, by thinking about what the winding number is (how many times does a curve turn around a point). I thought the following would be true:
Given a finite set of ordered points $C = \{p_0, p_1 \dots, p_{n-1}\}$ that describe a polygonal closed curve and a point P. The winding number of that curve is:
$$\frac{1}{2\pi}\sum^n_{i=0} A((p_{i} - P), (p_{((i+1) \mod n)} - P))$$
Where $$A(d_1, d_2) = \cos^{-1}\bigg(\frac{d1}{|d1|}\cdot\frac{d2}{|d2|}\bigg)$$
Or in plain English, the sum of the angle of every 2 subsequent vectors from the point to a point in the curve.
In other words, angle between (p0 - P) and (p1 - P) plus angle between (p1 - P) and (p2 - P)...
It very much seems that my formula is not equivalent to the analytic form for the discrete case, and I am trying to understand why.