Skip to content

Ride bends on a smooth curve, and lean into them - #81

Merged
pepperstm merged 3 commits into
mainfrom
fix/smooth-corners
Nov 12, 2026
Merged

pepperstm merged 3 commits into
mainfrom
fix/smooth-corners

Conversation

@pepperstm

Copy link
Copy Markdown
Owner

What and why

Riders didn't flow through bends: they moved in a series of small snaps, and they stayed upright however tight the turn.

  • No kinks: the line between route samples (one every 5 m) was straight, so a tight bend was a kink at every sample. The heading was also averaged over 25 m, longer than a hairpin, so riders faced slightly the wrong way in tight bends. Riders now follow a Catmull-Rom curve through the samples and face along it.
  • Leaning into bends: riders lean by what balances the turn at their speed, atan(v² / g r), up to 40°, on top of any banking from berms or the velodrome. On a slow climbing hairpin that's a few degrees, as on a real bike; at speed it's clear, for example about 19° in a 30 m bend at 36 km/h.
  • Both renderers: the page's renderer and the native one get the same changes, for the rider, ghosts and other riders.

Checked

  • npm run check passes.
  • A new test rides two laps of a 30 m circle. It checks that the heading and the path change smoothly for every 10 cm, that the rider faces the way they move, and that the lean is the balancing angle, with none when stopped and no more than the limit. It fails on the old code.
  • Checked a live preview in demo mode on the Alpe d'Huez hairpins, in the native renderer.

The rider's heading was taken over a fixed window round the sample behind
them, so it held still between samples and jumped at each one: through a
corner the rider turned in steps. It's now blended between neighbouring
samples, centred where the rider is, in both the page's renderer and the
native one.
The line between route samples was straight, so a tight bend was a kink every
5 m, and the heading was averaged over 25 m, longer than a hairpin. Riders now
follow a Catmull-Rom curve through the samples and face along it.

Riders also lean into bends by what balances the turn at their speed,
atan(v² / g r), up to 40°, on top of any banking. Both renderers.
@pepperstm
pepperstm merged commit 0359184 into main Nov 12, 2026
6 checks passed
@pepperstm
pepperstm deleted the fix/smooth-corners branch November 12, 2026 14:25
@pepperstm pepperstm mentioned this pull request Nov 12, 2026
pepperstm added a commit that referenced this pull request Nov 12, 2026
Version 0.3.10: laps (#68, by Rallensooo), Herne Hill Velodrome (#75), signposted road routes (#77), your Strava routes (#78), the Dreeve connector and pluggable connectors (#74, #83, by Jörn), remembered sensors (#79), smooth bends with lean (#81) and the Linux Bluetooth fix (#84).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant