Home›Journal›This post

Clothoid Curves in SVG: Draw Smooth Motion

Turn linear curvature into a bounded Euler spiral, approximate it with editable SVG cubics, audit every join, and keep a reproducible path receipt.

JP
JP Casabianca
AI Engineer and Product Designer · full-stack delivery · Bogotá

Clothoid curves in SVG replace an abrupt turn with curvature that changes linearly along the path. This tutorial integrates a bounded Euler spiral, approximates it with cubic Bézier segments, and audits joins and residuals before art-directing the motion ribbon.

Clothoid curves in SVG begin with linear curvature

Clothoid curves in SVG are useful when a path should enter a turn gradually instead of jumping from zero curvature to a fixed-radius arc. Along an ideal clothoid, curvature changes linearly with arc length: κ(s)=κ₀+cs. Heading is the integral of curvature, and position is the integral of the heading direction.

Freeze the contract before drawing: start point, initial heading, initial curvature, curvature slope c, total arc length, scale, sample count, segment count, and tolerance. Those values describe geometry. Stroke width, color, glow, and animation timing are later artistic choices and must not change the path receipt.

The classical normalized case relates to the Fresnel integrals, but this studio numerically integrates the more directly parameterized heading equation. That makes initial heading and nonzero starting curvature explicit while retaining the characteristic Euler spiral behavior. It also creates an oracle surface that can be recomputed with a finer integration grid.

The first figure pairs the curvature ramp with the resulting Cornu spiral. Read them together: a straight line in curvature space becomes a continuously turning trace in position space. No decorative gradient carries that conclusion. Labels, axes, direction arrows, and a semantic list make the relation inspectable without color.

A linear curvature ramp becomes a Cornu traceA left chart shows curvature increasing linearly with arc length and a right panel shows the corresponding spiral-like path with direction arrows.CURVATURE LAWarc length sκ(s)κ₀ + csCORNU READINGheading integrates curvatureposition integrates heading
A linear curvature ramp becomes a Cornu trace. The curve turns progressively because curvature changes progressively, not because control handles were placed by eye.
  1. Curvature κ(s)=κ₀+cs is a straight ramp over arc length.
  2. Heading integrates the area under that ramp.
  3. Position integrates the heading direction.
  4. The right trace is a bounded numerical approximation, not an exact symbolic plot.

Reading rule: labels, values, shapes, order, and line styles carry the conclusion; color is supplementary.

Integrate heading and position under a work cap

Clothoid curves in SVG require the geometric law to be sampled before a path command exists. For each sample position s, compute θ(s)=θ₀+κ₀s+cs²/2. Position follows x(s)=x₀+∫cos(θ(u))du and y(s)=y₀+∫sin(θ(u))du. A composite midpoint or Simpson-style integrator can approximate those coordinates deterministically when the sample count and summation order are fixed.

The studio bounds length, curvature slope, scale, samples, and segment count before allocating arrays. It estimates work as integration steps times curve segments and rejects a configuration beyond the fixed cap. A higher sample count is not automatically better if the interface can become unresponsive or the receipt cannot be reproduced on a modest device.

Normalization deserves explicit treatment. An Euler spiral formula copied from a table may use a different π factor or normalized coordinate. The wrong-normalization mutant intentionally applies that mismatch and must disagree with frozen endpoint and heading probes. Units belong beside every field so a scale factor cannot masquerade as geometry.

This numerical path is deterministic within the declared JavaScript arithmetic and algorithm. It is not an exact evaluation of the Fresnel integrals, and it is not a claim about bit-identical rendering across SVG engines. The receipt stores sampled coordinates and integration policy; the picture is a view of those numbers.

Approximate the samples with cubic Bézier segments

SVG paths do not have a native clothoid command, so the sampled centerline must be approximated. Divide the arc-length interval into deterministic segments. At each boundary, use the analytic heading to form a unit tangent. Place cubic Bézier handles along the outgoing and incoming tangents, then choose handle lengths with a bounded deterministic residual fit.

The resulting path uses M followed by C commands. Every segment stores its start, two control points, end, source interval, endpoint headings, and handle policy. Because adjacent segments share the same boundary point and analytic tangent direction, the construction targets positional and tangent continuity even though curvature remains an approximation.

The handle policy begins at one third of each segment chord, evaluates a bounded factor grid from 0.9 to 1.1 against the candidate integration samples, and records the deterministic winner. The fixed-handles mutant locks every factor at 1.0. Its dedicated high-slope fixture produces a larger independently measured residual, so the claim rests on executed numbers rather than one attractive default image. A release check should still try multiple slopes and at least three tolerances.

For a more general inspection tool, the Bézier curvature plotter explains how control points influence tangent and curvature. Here the intent is narrower: approximate a declared curvature-continuous source curve with enough cubic segments that the measured positional, tangent, and curvature residuals stay under the chosen bounds.

Audit every join, tangent, and curvature sample

Clothoid curves in SVG can look smooth while concealing a broken join. At each cubic boundary, compare the previous endpoint with the next start, normalize the incoming and outgoing derivative vectors, and measure their angular difference. Then estimate curvature on both sides from first and second derivatives. Store position gap, tangent gap, curvature jump, and pass state per join.

The reversed-tangent mutant flips one handle across its anchor. The join point still matches, so a position-only check passes while motion reverses locally. The broken-join mutant offsets an endpoint by a small amount that can disappear under a thick stroke. Both fail their dedicated measurements.

Sampling error also matters between joins. Evaluate the cubic at fixed parameter probes, map those probes back to source arc positions, and compare with the independently integrated oracle. Record maximum distance and the location of the worst residual. The hidden-undersampling mutant reduces probes while reporting the requested count; the receipt checks actual observations, not merely a configuration field.

The second figure presents a continuity table rather than another decorative curve. It exposes boundaries, position gaps, tangent gaps, curvature jumps, and tolerance results. That ledger is the bridge between an SVG path that feels graceful and an approximation that can be reviewed numerically.

Every cubic join carries a continuity ledger

A semantic table lists position gap, tangent gap, curvature jump, and tolerance state for deterministic cubic boundaries.

Every cubic join carries a continuity ledger reading guideRead each row from declared input through independently checked result.
JoinPosition gapTangent gapCurvature jumpResult
1 → 200.003°0.0018pass
2 → 300.004°0.0021pass
3 → 400.004°0.0024pass
Worst probe0.37 px——under 0.5 px
A thick stroke may hide a defect; the ledger records it before art direction begins.
  • Shared anchors prove positional continuity.
  • Normalized derivatives expose reversed or misaligned handles.
  • One-sided curvature estimates expose abrupt steering changes.
  • Interior residual probes compare the cubic with a finer integration oracle.

Reading rule: row labels, numeric values, and pass words carry the conclusion; color is supplementary.

Separate geometric tolerance from motion timing

A curvature-continuous path does not automatically create good animation. Travel speed, acceleration, easing, orientation, and camera framing are separate motion-system decisions. Clothoid curves in SVG control the spatial steering law; the timeline still needs its own intent and accessibility contract.

If an object follows the path, derive its orientation from the tangent and sample position by arc length rather than raw cubic parameter. A constant parameter increment can produce visible speed changes because cubic parameter is not distance. Build or approximate an arc-length lookup if constant travel speed matters, and test reduced-motion behavior independently.

The spring motion design guide helps choose temporal response when settling and interruption matter. The CSS linear easing spring workflow turns a sampled response into a timing function. Neither changes the centerline geometry; combining them requires naming which system owns the path and which owns progress over time.

This separation keeps the visual study honest. A graceful ribbon can suggest movement without proving vehicle comfort, physical feasibility, or universal perceptual smoothness. The lab measures geometric approximation. Product motion still needs task context, speed profiles, input interruption, and reduced-motion alternatives.

Make the curvature comb readable and useful

A curvature comb draws short normals whose lengths represent signed curvature at sampled positions. It turns an abstract κ(s) equation into a visible ramp: teeth begin short, grow predictably, and switch side only when curvature changes sign. The comb should use labeled scale and sparse enough sampling that individual marks remain legible.

Overlay cubic handles only on demand. Handles explain construction, while the comb explains the source law; showing both at full density can obscure the curve. The studio provides separate toggles and includes their state in an export view description without letting them affect the geometry hash.

Art direction comes after proof. The third figure turns one verified trace into a ribbon with a quiet centerline, measured comb, and tolerance badge. A second stroke provides depth, but the semantic equivalent still states slope, length, segment count, maximum residual, and whether every join passed. Color supports hierarchy rather than carrying status alone.

The view-transitions motion hierarchy offers a broader composition language for spatial continuity between UI states. Clothoid curves in SVG can contribute one path vocabulary inside that system, but they should not become ornamental motion everywhere. Use the geometry where gradual steering clarifies relationship or direction.

One verified path becomes a motion ribbonAn art-directed ribbon is overlaid with sparse curvature-comb teeth, cubic handles, a direction arrow, and a numeric tolerance badge.RESIDUAL 0.37 pxPASS · tolerance 0.50GEOMETRY FIRST · TREATMENT SECOND
One verified path becomes a motion ribbon. A verified centerline can support expressive treatment without making appearance the proof.
  • The wide ribbon is an artistic layer around one verified centerline.
  • Sparse normal teeth show the increasing curvature comb.
  • Dashed handle lines expose one cubic segment's construction.
  • The badge states measured residual and tolerance in text.

Reading rule: labels, values, shapes, order, and line styles carry the conclusion; color is supplementary.

Export SVG beside a canonical receipt

Clothoid curves in SVG need a portable visual and a portable explanation. The SVG export contains a viewBox, one path, optional construction overlays, a title, and a description. The structured receipt contains inputs, integration policy, samples, cubic segments, join metrics, residual probes, tolerances, invariant results, and hashes. Keep the pair together: the path is convenient for design tools, while the receipt explains how it was made.

Canonical hashing includes start conditions, scale, length, curvature parameters, requested and actual sampling, segment count, algorithm version, path data, and measured errors. The scale-omitted-hash mutant proves that visually and numerically different exports cannot share an identity merely because their normalized trace looks similar.

JSON and CSV validators reparse their payloads, reconstruct the calculation, and reject a modified length, slope, scale, path command, or pass flag. The SVG validator checks that the declared path data matches the receipt and that the accessible title and description remain present. Export validation should fail closed instead of repairing an unknown field silently.

Run three tolerance levels before choosing an edition. A coarse tolerance reveals construction economy, a medium tolerance is a practical candidate, and a strict tolerance exposes where segment count grows. The useful artifact is not the prettiest single path; it is a small frontier connecting tolerance, segments, residual, and visual judgment.

Know what the clothoid evidence does not prove

Clothoid curves in SVG provide a disciplined way to move from linear curvature to an editable vector approximation. They let a designer inspect the curvature ramp, tangents, joins, residuals, and rendering treatment in one bounded studio. They also make iteration explicit: change slope or length, regenerate, and compare receipts instead of dragging handles until a path merely looks acceptable.

Before shipping, test the path at its actual display size, device pixel ratios, stroke widths, animation speeds, and reduced-motion state. Confirm that transformed coordinate systems preserve the intended tangent orientation. If the path guides a physical system, hand it to the domain model rather than treating this browser geometry as a dynamics solver.

The mathematical references on Fresnel-integral applications and the SVG path specification define adjacent foundations. This lab joins them through a declared numerical approximation; it does not claim an exact symbolic conversion.

The truth boundary is therefore precise. The artifact proves a bounded numerical integration, deterministic cubic construction, measured continuity, validated exports, and identity-bound replay. It does not prove vehicle dynamics, universal smoothness, exact Fresnel evaluation, or identical rasterization across engines. Keep that boundary in the caption, the lab, and the release receipt.

Runnable local artifact — A numerical clothoid SVG does not prove vehicle dynamics, universal perceptual smoothness, exact Fresnel evaluation, or cross-engine raster identity.

Plain text1 line
Choose bounded heading, curvature, slope, scale, length, samples, segments, and tolerance; inspect the path, comb, handles, joins, residuals, mutants, and SVG/JSON/CSV exports.