<p>Winding number as in <a href="https://en.wikipedia.org/wiki/Winding_number" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Winding_number</a>?</p>

<p>Unless I'm mistaken, one way is to fire, say, a horizontal 'ray' out from your point towards, say, <span class="math-container">$+\infty$</span>. Each time you cross an edge, <span class="math-container">$(V_n V_{n+1})$</span> that is going up (i.e.<span class="math-container">$V_n[y] &lt;V_{n+1}[y]$</span>) , increment a counter, and decrement if the edge is going down.</p>

<p>The special cases of horizontal edges and vertices that lie on the ray are left as a (not too difficult) exercise for the reader.</p>

<p>If you want to do it quickly/approximately with a graphics API, you can use stencil buffers.</p>

CC BY-SA 4.0
2020-03-10T08:55:29.667Z
2020-03-10T08:55:29.667Z
Simon F
<p>Pretty much the title, given a closed curve in 2D, defined by a set of points, and a point. What's the algorithm to calculate the winding number of that curve, point pair?</p>

<mathematics><computational-geometry><geometry><curve>
How do you compute the winding number of a closed poly curve?
Makogan
# How do you compute the winding number of a closed poly curve?

(Asked by: username_0 on 2020-03-06)

Pretty much the title, given a closed curve in 2D, defined by a set of points, and a point. What's the algorithm to calculate the winding number of that curve, point pair?

**Tags:** mathematics, computational-geometry, geometry, curve


---

## 1 answers

### Answer by username_1 on 2020-03-10. Score: 1

Winding number as in <https://en.wikipedia.org/wiki/Winding_number>?

Unless I'm mistaken, one way is to fire, say, a horizontal 'ray' out from your point towards, say, $+\infty$. Each time you cross an edge, $(V\_n V\_{n+1})$ that is going up (i.e.$V\_n[y] <V\_{n+1}[y]$) , increment a counter, and decrement if the edge is going down.

The special cases of horizontal edges and vertices that lie on the ray are left as a (not too difficult) exercise for the reader.

If you want to do it quickly/approximately with a graphics API, you can use stencil buffers.


---

