General idea of what I'm trying to do:

I'm trying to use python to generate a list of points that would approximate an archimedean spiral that I later plan to use in blender for a 3d rendering. I'm a little fuzzy on the math involved with this.

Specific goal:

I want to write a python function where I provide the total length of the spiral, the gap between rings, starting radius of the spiral and the number of points I want for each ring. (The last ring would have fewer points in most situations.)

Biggest things I don't understand

Calculate the number of rings this spiral would have and what the final angle should be for the last point.

My math knowledge

My math skills are not the best. I have a vague recollection of what integrals can do but not much in the way of how to actually use them. Calculus seems like it would be important somehow for creating a spiral of a specific length.

Steps I think need to happen, glossing over the important part of not knowing how to calculate the number of rings

  • Calculate the total number of rings a spiral the function arguments provide would have.
  • Divide $2\pi$ by the number of points I want to figure out the rotation per point.
  • Loop through all but the last ring
  • In each loop, loop again for the number of points desired:
  • For each point: $r= a + b(\frac{2\pi}{points}\times current\ point\ number)$
  • Final ring: Compare final angle to size of theta steps and stop when $current\ point\ number\times theta\ step > final\ angle$. Theta for the final point would be the final angle.

In python semi pseudocode

theta_step = 2 * pi / number_of_points
for ring in (number_of_rings - 1):
  for point in number_of_points:
    theta = point * theta_step
    r = starting_radius + gap * theta
    point_list.append(r, theta)

There might be a better way to accomplish this. I'm also going to assume I've got at least one small error in my algorithm.

Please let me know if there's any other information I can provide.

  • $\begingroup$ The length of an archimedean spiral is given by a formula : see here $\endgroup$
    – Jean Marie
    Apr 7, 2023 at 20:27

1 Answer 1


When you write about “the number of points [you] want for each ring” as an input, you seem to want constant angle between any two consecutive points, not constant path length. Which makes the problem a lot easier than it would be otherwise.

But your concept of “rings” is a bit flawed and getting in your way. It's better to think of the whole spiral as one continuous curve, and not artificially subdivide it.

  • Divide $2\pi$ by the number of points I want to figure out the rotation per point.

Yes, that's the angle difference between two consecutive points. Do this, but then go straight to

  • For each point: $r= a + b(\frac{2\pi}{points}\times current\ point\ number)$

Just keep counting, through all of your points. You will get angles in excess of $2\pi$ which means you'll automatically hit the same direction multiple times, and the difference between two consecutive encounters of the same direction will be $b\times 2\pi$. Which conversely means you can use the desired distance between windings to determine $b$.

My first piece of code would be

from math import sin, cos
b = 1
pts = [(b*phi*cos(phi), b*phi*sin(phi))
       for phi in range(0, 20, 0.3)]

This starts in the center, so it corresponds to $a=0$ in your formula. The distance between two windings is $b\cdot2\pi=2\pi$.

The number of points per winding is $\frac{2\pi}{0.3}$ which is not a whole number. So not all you windings will have the same number of points, and the points on two consecutive windings won't be in the same direction. If that is a problem then pick $\frac{2\pi}k$ for some $k\in\mathbb N$ instead of my 0.3.

The total number of windings will be $\approx\frac{20}{2\pi}$ which is again not a whole number. So you can see how this approach deals with a partial winding in an intuitive way. Actually the last value for phi will be 19.8 which is the biggest multiple of the step size 0.3 that is smaller than 20. So you can use that to compute the actual number of windings if you want. And if you want to get a whole number of windings with the same number of points for each winding, then you have to take into account that python omits the last value of the range operation, and that comparing floating point numbers will lead to rounding errors.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .