Building a Zero-Upload Golf Ballistics Engine & Launch Monitor CSV Analyzer in Vanilla JS
Most online golf distance charts fail developers and golfers for the exact same reason: they treat ballistics as a single linear multiplier (swing_speed * 2.3) and force you to upload personal launch monitor exports to a
Most online golf distance charts fail developers and golfers for the exact same reason: they treat ballistics as a single linear multiplier (swing_speed * 2.3) and force you to upload personal launch monitor exports to a third-party backend just to compute gapping and smash factor.
While building the open browser tools at Club Carry, I wanted every calculationβfrom 11-club carry tables to Garmin R10 / Rapsodo MLM2PRO CSV parsingβto run deterministically in client-side ES modules with zero dependencies and zero server uploads.
Here are the three core engineering problems we solved and the exact math behind them.
1. Nonlinear Carry Curves Anchored to Two Tour Regimes
A common mistake in amateur swing speed calculators is assuming carry yards scale linearly with clubhead speed across all speeds. In reality, carry per mph of ball speed rises as ball speed increases because higher launch momentum sustains aerodynamic lift longer downrange.
Instead of inventing an arbitrary curve, we anchor two reference regimes from TrackMan's 2023 PGA and LPGA Tour averages:
-
LPGA Tour Driver Anchor:
96 mphclub speed β143 mphball speed β223 ydcarry (~1.4896smash factor,~1.5594 yd/mphball-to-carry) -
PGA Tour Driver Anchor:
115 mphclub speed β171 mphball speed β282 ydcarry (~1.4870smash factor,~1.6491 yd/mphball-to-carry)
From those two points, carry as a function of ball speed $b$ becomes a clean slope-intercept model over ball speed efficiency:
const CARRY_PER_BALL_LPGA = 223 / 143;
const CARRY_PER_BALL_SLOPE = (282 / 171 - CARRY_PER_BALL_LPGA) / (171 - 143);
export function driverCarryFromBallSpeed(ballSpeedMph) {
return ballSpeedMph * (
CARRY_PER_BALL_LPGA + (ballSpeedMph - 143) * CARRY_PER_BALL_SLOPE
);
}
We then scale tour ball speed by three empirical amateur strike tiers (smash factor ratios):
-
Average Amateur (
~1.415smash,133 / 94): typical weekend strike -
Low Handicap (
~1.455smash,147 / 101): solid center-adjacent contact -
Tour Level (
~1.488smash): centered sweet-spot compression
Here is the verified output across four swing speed bands (see the full interactive matrix on the Driver Swing Speed Chart):
| Driver Swing Speed | Avg Strike Ball / Carry | Low-HCP Ball / Carry | Tour Strike Ball / Carry | Low-HCP 7-Iron Carry |
|---|---|---|---|---|
85 mph |
120.4 mph / 179 yd
|
123.8 mph / 185 yd
|
126.6 mph / 191 yd
|
119 yd |
95 mph |
134.5 mph / 206 yd
|
138.4 mph / 214 yd
|
141.5 mph / 220 yd
|
137 yd |
105 mph |
148.6 mph / 234 yd
|
152.8 mph / 243 yd
|
156.3 mph / 250 yd
|
154 yd |
115 mph |
162.6 mph / 264 yd
|
167.2 mph / 274 yd
|
171.0 mph / 282 yd
|
171 yd |
2. Inverting 7-Iron Carry & Ball Speed with 44-Step Bisection
Golfers rarely know their driver clubhead speed on the range without a radar unit, but almost everyone knows their stock 7-iron air carry (or sees ball speed on a Toptracer bay screen).
Because the forward carry model is piecewise-interpolated across 11 clubs (Driver, 3W, 5W, Hybrid, 4iβPW) and nonlinear in ball speed, inverting it analytically is messy. Instead, since estimate(mph, strike) is strictly monotonic across [50, 130] mph, 44 iterations of binary search (2^-44 β 5.68e-14 interval width) invert any 7-iron carry or ball speed back to driver clubhead speed in microseconds:
const LOFT_OFFSETS_YD = { traditional: 0, players: 6, strong: 12 };
export function invertSevenIronCarryToDriverMph(targetCarryYd, strike = 'good', loft = 'traditional') {
const equivalentTourCarry = Math.max(55, targetCarryYd - (LOFT_OFFSETS_YD[loft] ?? 0));
let lo = 50;
let hi = 130;
for (let i = 0; i < 44; i += 1) {
const mid = (lo + hi) / 2;
const sevenIron = estimate(mid, strike).clubs.find((c) => c.id === '7i');
if (sevenIron.carry < equivalentTourCarry) lo = mid;
else hi = mid;
}
return (lo + hi) / 2;
}
Notice the LOFT_OFFSETS_YD calibration: Tour 7-irons sit at 32Β°β34Β°, whereas modern game-improvement 7-irons are often stamped at 27Β°β29.5Β° (effectively a traditional 5-iron). Without subtracting that ~12 yd loft jack, a 150-yard 7-iron falsely reads as a 102.6 mph driver swing (83.0 mph 7i) instead of a realistic 95.5 mph driver swing (77.6 mph 7i).
You can test both inversions live in the 7-Iron Distance to Swing Speed Calculator and the Ball Speed to Swing Speed Inverter.
3. Normalizing Messy Launch Monitor CSV Exports in Browser Memory
When building the Launch Monitor CSV Analyzer for Garmin Approach R10, Rapsodo MLM2PRO, SkyTrak, Mevo+, and TrackMan files, three real-world CSV quirks broke naive parsers:
-
Unit subtitle rows (Garmin R10): Row 2 is not a shotβit looks like
,,,yds,yds,mph,mph,,deg,rpm,yds. If you don't detect and strip unit metadata rows while preserving their unit hints (mvsyds,m/svsmph), every column shifts or fails numeric coercion. -
Directional lateral strings (Rapsodo MLM2PRO): Offline dispersion arrives as strings like
"8.2R"or"3.1L"instead of signed floats (+8.2/-3.1). -
Mishit distortion on gapping: A single topped
96.4 yddriver shot (1.11smash factor) drags the club mean down by~18 yardsand makes a 3-wood look longer than a driver unless you expose mishit filtering and warn when adjacent iron gaps collapse below10 yards.
Bonus: Checking Garage Simulator Geometry Before Buying Hardware
If you are pairing CSV session tracking with an indoor winter build, hardware optics change your minimum room depth drastically. Behind-the-ball Doppler radar units (Garmin R10, Mevo+) typically need 7β8 ft behind the tee plus 8β10 ft of ball flight (16β20 ft total depth), whereas photometric front/side camera units (like Square Golf) sit beside or in front of the ball and skip the behind-tee radar buffer.
We mapped both ceiling-clearance swing arcs and sensor placement envelopes in the Golf Simulator Room Size Calculator and Square Golf vs. Radar Room Size Guide.
All calculators run strictly in browser memory with zero cookies or third-party data uploadsβtry dropping a sample Garmin R10 or MLM2PRO CSV into the analyzer and inspecting the gapping ladder directly.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.