Draw equidistant points on a spiral
Data Structures & Algorithms practice on Codemia
Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.
Introduction
If you place points on a spiral by stepping a fixed angle each time, the points will not be equally spaced along the curve. The angle step has to change as the spiral radius changes. For an Archimedean spiral, a practical solution is to step forward by arc length: at each point, estimate how much the angle must increase so the next point lands one chosen distance farther along the curve.
Use an Archimedean Spiral Model
A common spiral for drawing is the Archimedean spiral:
- '
r = a + b * theta'
Converted to Cartesian coordinates:
- '
x = r * cos(theta)' - '
y = r * sin(theta)'
Here, a controls the starting radius and b controls how quickly the spiral expands.
Why Equal Angle Steps Do Not Work
The curve gets longer per unit of angle as the radius grows. So a constant angular increment creates points that spread farther apart as you move outward.
To keep the spacing approximately constant, step by distance along the curve instead of by raw angle.
Arc-Length-Based Step Formula
For the Archimedean spiral r = a + b * theta, the local arc-length factor is:
- '
sqrt((a + b * theta)^2 + b^2)'
If you want the next point to be about spacing units away, use this approximation:
- '
delta_theta = spacing / sqrt((a + b * theta)^2 + b^2)'
Then update theta repeatedly.
Runnable Python Example
The following script generates approximately equidistant points on the spiral.
This produces points with much more even spacing than a constant-angle approach.
Plot the Result
To visualize the points, plot them with Matplotlib.
The points will still be approximate because the step formula is local, not an exact inverse of the spiral’s cumulative arc-length function. For drawing and visualization, though, it is usually good enough.
When You Need Higher Accuracy
If the spacing must be extremely precise, solve for the next theta numerically using the exact arc-length function instead of the local approximation. That is more computation, but it gives tighter control when the geometry matters more than drawing speed.
For most graphics tasks, the iterative approximation is the better tradeoff because it is simple and stable.
Common Pitfalls
- Using a fixed angle increment and expecting equal distances along the curve.
- Forgetting that “equidistant” means equal arc length, not equal radius or equal angle.
- Mixing up the spiral parameters and getting the wrong growth rate.
- Expecting the local approximation to be mathematically exact over large steps.
- Plotting without an equal aspect ratio and misjudging the spacing visually.
Summary
- Equal spacing on a spiral is an arc-length problem, not an angle problem.
- For an Archimedean spiral, a changing
delta_thetagives much better spacing than a constant angle. - A practical approximation is
spacing / sqrt(r^2 + b^2). - The iterative method is simple and works well for drawing.
- Use a numerical arc-length solve only when you need higher precision than the approximation provides.
Related reading
- dynamic programming and the use of matrices
- Dynamic Programming Coin Change Problems
- Dynamic Programming Sum-of-products
- Easiest algorithm of Voronoi diagram to implement?
- Easy interview question got harder given numbers 1..100, find the missing number(s) given exactly k are missing
- Efficient algorithm for finding a common divisor closest to some value?
- efficient algorithm to find nearest point in a graph that does not have a known equation
- Efficient algorithm to find the largest rectangle from a set of points

DSA Fundamentals
Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Data Structures & Algorithms practice on Codemia
Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.