I have an Archimedean spiral determined by the parametric equations $x = r t *cos (t)$ and $y = r t *sin (t)$.

I need to place $n$ points equidistantly along the spiral. The exact definition of equidistant doesn't matter too much - it only has to be approximate.

Using just $r$, $t$ and $n$ as parameters, how can I calculate the coordinates of each equidistant point?

Any algorithm will suffice, as I will eventually be translating this to JavaScript. Thank you very much for your time.

I've already looked at some of answers to similar questions - there's this one, where the formula proposed in the question is already far beyond my understanding; and this one for which the answer seems to use a unit spiral rather than an absolute spiral. A more easy-to-understand solution would be very appreciated.



2 Answers 2


I concur with Aretino's answer; I just wanted to dig in to the details a bit, in the hopes it illustrates some of the options and approaches we can utilise here.

Length of the curve $$\begin{cases} x(t) = r t \cos(t)\\y(t) = r t \sin(t)\end{cases}\tag{1}\label{1}$$from $t_0$ to $t_1$ is $$s( t_0 ,\, t_1 ) = \int_{t_0}^{t_1} ds(t) \, dt$$ where $$ds(t) = \sqrt{\left( \frac{d \, x(t)}{d \, t} \right)^2 + \left ( \frac{ d \, y(t) }{d \, t} \right)^2} $$ i.e. $$\begin{array}{rl} s( t_0 ,\, t_1 ) = & \frac{r \, t_1}{2} \sqrt{ t_1^2 + 1 } - \frac{r \, t_0}{2} \sqrt{ t_0^2 + 1 } \; - \\ \; & \frac{r}{2} \log_e\left(t_0 + \sqrt{t_0^2 + 1}\right) - \frac{r}{2} \log_e\left(\sqrt{t_1^2 + 1} - t_1\right) \end{array}\tag{2}\label{2}$$

In practice, we'd like to know $t_1 = f( d, t_0 )$, i.e. the position $t_1$ on the curve that is distance $d$ from $t_0$ along the curve, fulfilling $s( t_0 , t_1 ) = d$. Unfortunately, there are no algebraic solutions for function $f(d, t_0)$.

Numerically, we can roughly approximate $s'(t_0 ,\, t_1) \approx (t_1^2 -t_0^2) \, r/2$. It is a bit off when $t_0$ is very small (near the center of the spiral), but gets better as $t_0$ and/or $t_1$ increase. (Since the spiral is tightest near the center, $t_0 = 0$, I suspect that humans tend to not perceive that error, which means this approximation should be okay for visual purposes.)

If we need a result to within a specific precision, we can use a binary search to find $t_1$ from $s(t_0 ,\, t_1) = d$, numerically. (This has $O(\log N)$ time complexity, and generally requires $N$ iterations (evaluations of $s(t_0 , t_1)$) to get $N$ bits (binary digits) of precision, so it is quite efficient, too.)

For approximately equally spaced (as measured along the curve) points, we can use $$\tau_n = \sqrt{\frac{2 \, d \, n}{r}}, \qquad 0 \le n \in \mathbb{Z}$$Then, $$s'( \tau_n ,\, \tau_{n+1} ) = d \tag{3}\label{3}$$ which means that $$\begin{cases} x_n = x( \tau_n ) = r \sqrt{\frac{2 \, d \, n}{r}} \cos\left(\sqrt{\frac{2 d \, n}{r}} \right) \\ y_n = y( \tau_n ) = r \sqrt{\frac{2 \, d \, n}{r}} \sin\left(\sqrt{\frac{2 d \, n}{r}} \right) \end{cases}$$ gives us points $(x_n , y_n)$ that are spaced roughly $d$ apart, measuring along the curve.

If we substitute $k = 2 d / r$, Aretino's answer directly follows.

  • $\begingroup$ is $i$ the iterator or the imaginary number? $\endgroup$ Jun 25, 2017 at 16:39
  • $\begingroup$ @snazzybouche: Iterator. I'll change it to $n$ for clarity. $\endgroup$ Jun 25, 2017 at 17:08
  • $\begingroup$ Ah, that makes more sense. Cheers! $\endgroup$ Jun 25, 2017 at 17:26

I can only repeat the suggestion I gave as a comment for a previous question: if you don't need absolute accuracy, points whose parameters are spaced proportionally to $\sqrt{n}$ will be fairly equidistant: $$ x_n=r\sqrt{kn}\cos(\sqrt{kn}), \quad y_n=r\sqrt{kn}\sin(\sqrt{kn}), $$ where $n=1, 2, \ldots$ and $k$ is a parameter you can set to adjust spacing.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.