Which Way Are You Facing?
How to count the turns of a closed loop by glancing at a handful of points
Walk all the way around a closed loop and you arrive back facing exactly the way you started — having turned some whole number of times along the way. That number is a genuine property of the loop: stretch it, dent it, wobble it, and the number refuses to budge. Finding it looks like it should require watching yourself continuously, all the way round. It doesn’t. Pick any direction at all, mark the few points where you happen to be travelling crosswise to it, note at each whether you are curving left or right, and do one subtraction. That is the whole method.
1. A walk around a loop
Draw a closed curve on paper — any closed curve, so long as it never stops and never has a sharp corner — and imagine walking along it. At every instant you are facing some direction. Set off, keep going, and eventually you arrive back where you started, facing the way you set out.
Your heading, meanwhile, has been busy. It swung left through the bulges, swung back right through the dents, and by the time you were home it had come back to where it began. But “back where it began” is not the same as “never moved”: a direction that goes all the way around and returns has made some whole number of complete turns. One, perhaps. Or none. Or two. That count is called the turning number of the curve, and it is the subject of this article.
The right-hand panel is the whole idea in one picture. Strip away where you were and keep only which way you were facing, and the walk becomes a spin. Counting turns of the curve means counting laps of that spin.
2. The heading remembers everything
It is worth watching the heading more carefully, because it does not simply rotate steadily. Figure 2 plots it against how far you have walked: not as a compass point, which would wrap around and lose count, but as a running total, the way a car’s odometer keeps climbing rather than resetting.
Three things are worth noticing. The graph wanders — that is the curve’s dents talking. It ends at exactly one full turn, not 0.98 of one, because the curve closes up and the heading has to come home. And nothing about the wandering in the middle affected the final answer. You could push the curve around, deepen the dents, add new ones, and as long as you never tear the curve or put a corner in it, the graph would still finish on the same horizontal line.
3. Not every loop turns once
A circle turns once. So does the wobbly loop above, dents and all. But the count is not always one.
The figure-eight is the instructive one. It is not that it never turns — it turns constantly. It is that the turning cancels: a full turn one way around the upper lobe, a full turn the other way around the lower one. Net zero. And no amount of stretching will ever make a figure-eight into an oval, because you cannot get from zero to one without, at some moment, putting a corner in the curve or pulling it apart.
4. You don’t have to watch the whole walk
So far, finding the number has meant tracking your heading continuously, all the way around. That is a lot of watching for a single integer. Here is the shortcut.
Pick a direction — any direction. North, say. Now walk the loop again, but instead of watching constantly, only stop at the moments when you are travelling exactly crosswise to north: due east or due west, neither gaining nor losing ground northward. On a generic loop there are only finitely many such moments, and they are easy to spot — they are the points where the curve is momentarily level, the tops of its humps and the bottoms of its troughs with respect to your chosen direction.
At each of those points, ask one question: am I curving left or curving right? Mark it + for left, − for right. Then:
\[ \text{turning number} \;=\; \frac{(\text{number of } +) - (\text{number of } -)}{2} . \]That is the entire recipe. Count, subtract, halve.
5. Why halve?
The division by two looks arbitrary until you notice how the marks are arranged. Follow the curve from one mark to the next and watch what your heading does between them.
Between the marks you are never crosswise to north, which means you are steadily gaining northward ground or steadily losing it — you are climbing, or you are descending, with no dithering in between. So the marks alternate: peak, trough, peak, trough, all the way around. And a stretch that runs from a peak to a trough swings your heading through half a turn, no more and no less, because you start facing one way across north and end facing the other.
So every mark sits between two stretches, and contributes half a turn’s worth of evidence to each of them. Add up what all the marks say and you have counted every stretch exactly twice. Hence the halving. The signs are there to record which way each half-turn went: a left-hand bend adds, a right-hand bend subtracts, and the dents of Figure 2 — those downward slides — are precisely the stretches bracketed by minus marks.
6. The direction was never the point
North was an arbitrary choice, and a suspicious one: the marks are entirely at its mercy. Tilt your chosen direction and the marks slide along the curve, appear in pairs, vanish in pairs. The count changes. The answer does not.
This is the part worth keeping. The chosen direction is scaffolding — it produces the marks, the marks produce the count, and then the direction drops out of the answer entirely. You are free to pick whichever direction makes the marks easiest to find, confident that the loop does not care which one you picked.
7. Count one yourself
Everything above is a few lines of Python. Sample the curve, find the points where it runs level with respect to your chosen direction, and add up the signs:
import numpy as np
# a wobbly closed loop: a circle with three dents
curve = lambda t: ((1 + 0.4*np.cos(3*t)) * np.cos(t),
(1 + 0.4*np.cos(3*t)) * np.sin(t))
marks, points, signs = critical_points(curve, direction=(0, 1))
print(signs) # [ 1. 1. -1. 1. -1. 1.]
print(signs.sum() / 2) # 1.0 -- the turning number
Change the direction and the list of signs changes; the last line does not. Change the curve to a figure-eight and it prints zero. Every figure in this article was drawn by that same code, which also checks its own arithmetic: for each curve it compares the tally against the turning number measured the slow way, by following the heading all the way around. They have always agreed, which is a reassuring thing for a shortcut to do.
Further reading
- H. Whitney, On regular closed curves in the plane, Compositio Mathematica 4 (1937) — where the turning number is shown to be the only obstruction.
- M. do Carmo, Differential Geometry of Curves and Surfaces, Prentice-Hall (1976) — the standard careful account of curvature and the turning tangents theorem.
- J. Milnor, Morse Theory, Princeton (1963) — the classic statement of the larger idea the last aside gestures at.
- L. Nicolaescu, An Invitation to Morse Theory, Springer (2011) — a modern and unusually readable route into the same territory.
I work as an independent consultant helping engineering and computational teams solve difficult problems in geometric modeling, surface processing, and algorithmic design. If your team is tackling a non-trivial spatial or mathematical challenge, reach out directly at cvalero@carlosvalero.com.