trailphysics

How long a ride, hike or run really takes.

Route geometry and pace physics for JavaScript and Swift, open source and held to the same numbers by 242 shared test vectors. Move the sliders: every figure below is computed live by the library.

npmnpm install trailphysics SwiftPM.package(url: "https://github.com/ehilzinger/trailphysics-swift", from: "0.1.3")
Hover the chart for exact values

Dashed: a loaded tourer, 75 + 25 kg at 180 W, for comparison.

On the flat–
Up 8%–
10 km at 7%–
Drag area (CdA)–
Speed against gradient, km/hYour riderLoaded tourer

Loading trailphysics…

Below −2% the model has the rider freewheel, which is the step in the curve. Descents are capped at 65 km/h.

The same call in your code

Loading…

Two ports, one set of numbers

The JavaScript package writes the test vectors; the Swift package reads byte-identical copies, and both suites check every one. A phone and a browser give the same person the same time for the same route. How the vectors work.

242shared vectors
0.01 stolerance on times
10⁻⁶on everything else