Smooth Move: Taming Trajectories with Polynomials

lioeters1 pts0 comments

Smooth Move: Taming Trajectories with Polynomials · ... and another thing ...

... and another thing ...

Smooth Move: Taming Trajectories with Polynomials

2026-08-03

robots

3dprint

python

maths

This article is all about movement.<br>Of a vehicle, or a robot, or something like a 3D printer.

A 3D printer is really just a specialized robot with a hot glue gun<br>which it can move in multiple directions while squirting out molten<br>plastic.

Position, Velocity, Acceleration …

Our robot, or print head, has a position in space and also a velocity<br>which is how fast it is moving and an acceleration which is how rapidly<br>that velocity is changing.

Velocity is just the derivative<br>of position: how fast is our position changing.<br>Acceleration is the derivative<br>of velocity: how rapidly our velocity is increasing or decreasing.

These are all vectors in that they have<br>both magnitude and direction<br>but for (many) 3D printers and machines each axis is a separate mechanism, so this<br>article is for now going to talk about them as if they were scalars, eg:<br>just a positive or negative number.

… Jerk?

Jerk is the derivative of<br>acceleration, which might seem like a pretty abstract thing to be worried about.

But imagine a mass in a box under constant acceleration.<br>Springs inside the box are pushing the mass to cause it to accelerate too.<br>But if we change the size or direction of the acceleration, the mass is going<br>to slide around until it reaches a new equilibrium.

Now imagine the box is your skull and the mass is your brain. Jerk is real!

Higher Orders

There’s also higher derivatives which are sometimes called<br>Snap, Crackle and Pop.

Snap (sometimes called Jounce) is the rate of change of Jerk; Crackle is the rate<br>of change of Snap, etc.<br>I don’t have as neat an illustration of what these physically mean but there seems to be a consensus that<br>they, and presumably even higher derivatives, have an effect on vibration and so on of<br>mechanisms, and so they should be minimized too.

Discontinuities

Our 3D printer or similar machine follows a path made up of many segments.<br>Some segments have fixed position and velocity: while the printer is extruding<br>or the CNC mill is cutting, it goes in a set direction at a set speed.

Other parts of the movement are more free: the printer just has to<br>get to the right place for the start of its next fixed segment, as rapidly<br>as is practical1.

The problem is smoothly transitioning between segments.<br>A discontinuity in velocity requires a large acceleration.<br>A discontinuity in acceleration requires a large jerk.<br>And so on.<br>When we combine segments into a path, it is important to match the ends to prevent<br>these discontinuities.<br>So our apparently “free” transport segments are actually critical to support<br>smooth transitions in and out of our “working” segments.

Transitions & Trajectories

So let’s look at a way to make our transitions smooth.

What we’re looking for is some kind of<br>Sigmoid Function<br>which has the right general shape.

The most obvious sigmoid functions is the<br>Logistic Function<br>which does indeed transition smoothly between 0 and 1 and has well<br>defined derivatives, but unfortunately it only converges towards 0<br>and 1 whereas we want to get our transition over and done with in<br>finite time.

There are other suitable functions though, including polynomials.

SmoothStep …

SmoothStep is a family of<br>polynomial functions which smoothly transition across the range [0,1]<br>in the domain [0,1] in a<br>Sigmoid shape.

$ S_1(t) = \begin{cases}0, & if\ t \leq 0 \\ 3t^2 - 2t^3, & if\ 0 \leq t \leq 1 \\ 1, & if\ 1 \leq t\end{cases} $

Smoothstep is a polynomial function and so the first derivative $ S^\prime_1 $, is polynomial too:

$ S'_1(t) = \begin{cases}0, & if\ t \leq 0 \\ -6t^2 + 6t, & if\ 0 \leq t \leq 1 \\ 0, & if\ 1 \leq t\end{cases} $

and has the handy property that it is neatly zero at both ends. However, $ S''_1 $ does not have<br>this property. Our velocity at each end of our movement is zero, but our acceleration is not.

… and SmootherStep …

If we want acceleration to be zero at the beginning and end of our trajectory, we can use<br>Smootherstep, which is a fifth-order<br>polynomial with this property:

$ S_2(t) = \begin{cases}0, & if\ t \leq 0 \\ 6t^5 - 15t^4 +10t^3, & 0 \leq t \leq 1 \\ 1, & 1 \leq t\end{cases} $

$ S'_2(t) = \begin{cases}0, & if\ t \leq 0 \\ 30t^4 - 60t^3 + 30t^2, & 0 \leq t \leq 1 \\ 0, & 1 \leq t\end{cases} $

$ S''_2(t) = \begin{cases}0, & if\ t \leq 0 \\ 120t^3 - 180t^2 + 60t, & 0 \leq t \leq 1 \\ 0, & 1 \leq t\end{cases} $

… and SmoothnStep

The SmoothStep function can be worked out to an arbitrary depth, for example $ S_6 $ is a 13th-order polynomial:

$ S_6(t) = \begin{cases}0, & t \leq 0 \\ 924t^{13} - 6006t^{12} + 16380t^{11} - 24024t^{10} + 20020t^9 - 9009t^8 + 1716t^7, & 0 \leq t \leq 1 \\ 1, & 1 \leq t\end{cases} $

For the $ n $-th Smoothstep function, all derivatives up to the $ n $-th derivative start and end at zero:

$ S^{(m)}_n(0) = S^{(m)}_n(1) = 0...

cases acceleration velocity segments begin smooth

Related Articles