Euler Spiral / Clothoid - An Illustrated Explanation

Motivation

I’ve been playing around with some railway track geometry programming and I wanted to include an accurate transition portion between arcs and straight segments, like this:

I didn't find the existing explanations of the euler spiral very clear though, see for example its wiki page. So here’s hopefully a more approachable explanation.

A parametric curve

The Euler spiral (also called Clothoid) is a parametric curve with a special relationship between the length of the curve and its “curvature”.

First, a parametric (2D) curve is defined by two equations both using the same parameter. A more familiar example I’ll use throughout is the circle. This is the parametric definition of a circle:

$$ \begin{aligned} &t \equiv parameter \end{aligned} $$
$$ \begin{aligned} x = \cos(t)\\ y = \sin(t) \end{aligned} $$

Below is an illustration of the circle curve as $t$ varies. Next to the circle you can see each coordinate plotted as a separate function of $t$:

For the circle the curve “wraps around” at $t = \tau$ (1 turn radians).

The definition of the Euler spiral is a bit more complicated:

$$ \begin{aligned} &t \equiv parameter\\ &u \equiv arbitrary\ variable\ name\\ \end{aligned} $$
$$ \begin{aligned} x = \int_0^t \cos(u^2) \cdot du\\ y = \int_0^t \sin(u^2) \cdot du \end{aligned} $$

So, at $t$ the curve’s point’s $x$ coordinate will be the integral (area under the curve) of the function $\cos u^2$ from $u=0$ to $u=t$, and similarly for $y$.

And here’s an illustration of the spiral curve as $t$ varies:

On the right you can see the functions of $t$ which given their integral define each coordinate of the spiral. As $t$ approaches $\infin$ the spiral approaches the "center of the eye". The limit is $x=y=\sqrt{\tau/8}$.

Unlike the circle, the Euler spiral has a unique point defined for each value of $t$ from $-\infin$ towards $\infin$.

Length

For completeness I’ll add one more example, a horizontal line:

$$ \begin{aligned} \theta &\equiv angle\ (slope)\ of\ line\\ t &\equiv parameter\\ \end{aligned} $$
$$ \begin{aligned} x = \cos(\theta) \cdot t\\ y = \sin(\theta) \cdot t \end{aligned} $$

The length of the line, circle and Euler spiral curves from $t = 0$ to $t = L$ is $L$. The length grows linearly with the parameter. This is not the case for other curves, such as the parabola ($y = t^2$, $x = t$).

Here's an illustration of all three curve types as $t$ varies:

Curvature

The curvature of a curve at a given point is the reciprocal of the radius of the largest circle that would “fit” “under” the curve at that point, such that the curve would be tangent to the circle.

$$ \begin{aligned} k &\equiv curvature\\ R &\equiv radius\ of\ tangential\ circle \end{aligned} $$
$$ \begin{aligned} k = \frac{1}{R} \end{aligned} $$

The animation below shows both the curve and the "fitted" circle, the circle’s radius and the value of the curvature for given $t$. Tap it to replay.

$$ \begin{aligned} R &\approx \infin\\ k &\approx 0.00\\ \end{aligned} $$
$$ \begin{aligned} t &\approx 0.00 \cdot \tau \end{aligned} $$

The curvature grows linearly with $t$, and this is the defining characteristic of the Euler spiral. The exact relationship is:

$$ \begin{aligned} R &\equiv radius\ of\ tangential\ circle\\ t &\equiv parameter\\ k &\equiv curvature\\ \end{aligned} $$
$$ \begin{aligned} R &= \frac{1}{2 \cdot t} \\[1em] k &= 2 \cdot t\\ \end{aligned} $$

Slope

For the Euler spiral, just like for the circle, there is a relationship between the parameter $t$ and the angle of the curve, which can be measured either from the center(s) of the “fitted” circle(s), or as a slope of the curve (since the slope, the tangent, is always perpendicular to the point-center line). For the circle the relationship is:

$$ \begin{aligned} \theta &\equiv angle\ (slope)\ at\ t\\ t &\equiv parameter\\ \end{aligned} $$
$$ \begin{aligned} \theta = t \end{aligned} $$

For the Euler spiral the relationship is:

$$ \begin{aligned} \theta &\equiv angle\ (slope)\ at\ t\\ t &\equiv parameter\\ \end{aligned} $$
$$ \begin{aligned} \theta = t^2 \end{aligned} $$
$$ \begin{aligned} t^2 &\approx 0.00 \cdot \tau\\ \end{aligned} $$
$$ \begin{aligned} t &\approx 0.00 \cdot \tau\\ \end{aligned} $$

Scale

The radius of the circle shown before is $1$. When we want to change the radius we scale the curve uniformly:

$$ \begin{aligned} R \equiv radius\ of\ circle\\ \end{aligned} $$
$$ \begin{aligned} x = R \cdot \sin\biggl(\frac{t}{R}\biggr)\\[1em] y = R \cdot \cos\biggl(\frac{t}{R}\biggr)\\ \end{aligned} $$

I added the division by $R$ to maintain the following relationships:

$$ \begin{aligned} L &\equiv length\ of\ arc\ at\ t\\ t &\equiv parameter\\ \theta &\equiv angle\ (slope)\ at\ t\\ R &\equiv radius\ of\ circle\\ \end{aligned} $$
$$ \begin{aligned} L &= t\\ \theta &= \frac{t}{R} \end{aligned} $$

Similarly we can scale the Euler spiral to achieve a desired curvature at any point (for any $t$). In other words, we can scale the spiral to get a segment of desired length with a given tangent radius:

$$ \begin{aligned} t_L &\equiv chosen\ parameter\ value\\ R_L &\equiv desired\ radius\ at\ t_L\\ \end{aligned} $$
$$ \begin{aligned} &x = \sqrt{2 \cdot R_L \cdot t_L} \cdot \int_0^{\frac{t}{\sqrt{2 \cdot R_L \cdot t_L}} } \cos(u^2) \cdot du\\ &y = \sqrt{2 \cdot R_L \cdot t_L} \cdot \int_0^{\frac{t}{\sqrt{2 \cdot R_L \cdot t_L}} } \sin(u^2) \cdot du\\ \end{aligned} $$

This falls out of the definition of the curve, but I haven’t found a good explanation for it (if you know of one please get in touch).

If we call the square of the scaling multiplier "$A$", we get the following formulas:

$$ \begin{aligned} A &\equiv 2 \cdot R_L \cdot t_L\\ L &\equiv length\ of\ curve\ at\ t\\ R &\equiv radius\ of\ tangetial\ circle\\ \theta &\equiv angle\ (slope)\ at\ t\\ \end{aligned} $$
$$ \begin{aligned} L &= t\\ R &= \frac{A}{2 \cdot t}\\[1em] \theta &= \frac{t^2}{A}\\ \end{aligned} $$

Rendering the curve

So far I’ve been showing the proper definition of the Euler spiral using its parametric equations. But the integral does not have a simple analytical solution, and so to render the curve we need to employ some other method. The most common one is using the power series (Taylor series) expansion of the integrals:

$$ \begin{aligned} t &\equiv parameter\\ i &\equiv abitrary\ variable\ name\\ \end{aligned} $$
$$ \begin{aligned} x &= \sum_{i=0}^{\infin} \frac{ (-1)^i \cdot t^{4 \cdot i + 1} }{ (2 \cdot i)! \cdot (4 \cdot i + 1) }\\ y &= \sum_{i=0}^{\infin} \frac{ (-1)^i \cdot t^{4 \cdot i + 3} }{ (2 \cdot i + 1)! \cdot (4 \cdot i + 3) }\\ \end{aligned} $$

The larger the value of $t$, the more elements of the power series we need to employ (larger maximum $i$), as demonstrated below:

$$ \begin{aligned} \max(i) &= 1 \end{aligned} $$

Conclusion

I hope that you found this article helpful. Let me know if you found a mistake or have a suggestion for improvement.