Skip to content
zxpowerPublic

About

Simple web based ballistic calculator

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

38 Commits

Folders and files

Repository files navigation

Simple Web Ballistic Calculator

Ballistic calculator to match Schmidt & Bender PMII-2 scope turrets. Enter your distance, bullet drop (elevation) and wind drift (windage), each in MOA or MRAD, and it tells you how many turret clicks to dial — plus the breakdown into numbered marks and the dial direction (UP / LEFT / RIGHT).

How it works

The drop (angular) is converted to a linear offset at the target distance, then divided by the turret's click value at that distance:

  • 1 MOA subtends 2.908882 cm per 100 m
  • 1 MRAD subtends 10 cm per 100 m
  • Turret click default: 0.25 cm per 100 m (configurable in Setup → Optic)

In Setup → Optic you don't need to know the cm-per-100 m value. Pick the turret's units (MOA, MRAD or cm) and its click value (1/8, 1/4, 1/2 or 1 MOA; 0.05, 0.1 or 0.2 MRAD; 1/4, 1/2 or 1 cm), or choose Custom… and type any value in those units. The app works out what one click moves at 100 m. For example, 1/4 MOA = 0.727 cm and 0.1 MRAD = 1 cm.

Example: 4.6 MOA at 300 m

  • Drop = 4.6 × 2.908882 × 3 = 40.14 cm
  • 1 click = 0.25 × 3 = 0.75 cm at 300 m
  • Clicks = 40.14 / 0.75 ≈ 54 → 13 marks + 2 clicks

Both the click value and clicks-per-mark are adjustable for other scopes/turrets.

A full turn is set in clicks, so turrets whose turn ends mid-mark work too: a 100-click 1/8 MOA turret (8 clicks per mark = 12.5 marks per turn) dials 113 clicks as 1 turn · mark 1 · + 5 clicks. An optional total elevation clicks value caps the dial: past it the tables show the max clicks (⚠ max) plus an Over hold column with the remainder to hold over on the reticle (SFP-scaled when applicable).

Reticle: FFP / SFP

Set the focal plane and zoom range. For an SFP scope also set the magnification at which the reticle is true (defaults to max zoom, e.g. 40× on a 10-40×) and the magnification you're shooting at — editable right on the Turret, Trajectory and Targets tabs. Results then include the reticle value to hold over for that zoom (true angle × shooting zoom / true zoom) in extra hold columns.

Layout

The page is split into tabs: Setup (saved gear, rifle, optic, load), Weather, Turret (quick click calculator), Trajectory and Targets.

Full trajectory calculator

A second section computes the whole trajectory from first principles instead of a single known drop. It's a 3-DOF point-mass solver using the standard G1/G7 drag models:

  • Load: bullet weight (grains or grams; the toggle converts in place), muzzle velocity (m/s), ballistic coefficient (G1 or G7), bullet length (mm, optional: only needed for stability and spin drift)
  • Rifle/scope: caliber (picked from a list of common cartridges, or a custom bullet diameter in mm), zero distance, sight height over bore, barrel twist & twist direction (drives gyroscopic stability + spin drift)
  • Atmosphere: temperature, pressure, humidity (used for real air density)
  • Wind: speed + direction as a clock hour (12 = headwind, 3 = from the right)
  • Range: from / to / step

It auto-solves the launch angle for your zero, then prints a table with velocity, energy, time of flight, drop and wind drift (cm + your chosen MRAD or MOA) plus the required elevation and windage clicks (using the turret settings above).

From twist rate and bullet length it also computes the Miller gyroscopic stability factor (Sg) — with a warning if the bullet is marginal (< 1.4) or unstable (< 1.0) — and folds spin drift (Litz approximation, right/left twist aware) into the wind/drift column.

G1 / G7 ballistic coefficient

Enter the BC in whichever model your bullet is published in. Switching the G1 / G7 toggle converts the value in place — the same way the MOA/MRAD/cm toggles work in the turret card — so you keep describing one bullet and the whole app (trajectory table + target card) recalculates against the matching drag curve. The line under the field always shows the equivalent in the other model.

The two BCs are related by equal retardation, Cd_G1(M)/BC_G1 = Cd_G7(M)/BC_G7, so the conversion factor is just Cd_G1(M) / Cd_G7(M) read off the drag tables at your bullet's own Mach number. That factor is clamped to Mach 1.5–3.0, where it lands between 1.91 and 1.99 — matching the ~1.95 measured for modern boat-tails (175 gr SMK: 0.475 G1 / 0.243 G7). Outside that band, and especially through the transonic region, the ratio swings from 1.3 to 2.3 and is not meaningful.

A converted BC is an approximation of a measured one. If your bullet has a published BC in the model you want to shoot, type that instead.

Note: this is a helper/estimator. Verify against real dope before relying on it.

Target card

A third section builds a dial-up card for a set of known targets instead of an even range ladder. Add a row per target (minimum one), type its distance, and get the correction for each — rows are lettered A, B, C, … so they match how you range and call them.

It reuses the load, atmosphere, wind and turret settings from the other tabs, so the numbers agree with the trajectory table. For every target it shows drop (cm + MRAD/MOA), elevation clicks to dial UP, drift with the side it pushes to, windage clicks with the direction to dial, time of flight and remaining velocity. Targets are kept in the order you entered them, and any distance the bullet can't reach is reported as no solution rather than silently estimated.

Saved gear

The Saved gear card at the top stores named profiles for three kinds of equipment, so you can switch setups without retyping:

Kind What it stores
Rifle caliber, barrel twist, twist direction, sight height over bore, zero distance
Optic focal plane, zoom range, SFP true magnification, turret units + click value, clicks per mark / per turn / total, MRAD/MOA units
Load bullet weight (grains or grams), muzzle velocity, BC + G1/G7 model, bullet length (optional)

Pick a profile from the dropdown to load it. The calculators and any tables already on screen recalculate straight away. Save as… stores the current values under a new name, Save overwrites the selected profile, and Delete removes it. If you edit a field after loading a profile, the card shows Modified until you save. Profiles are mixed and matched freely (any rifle + any optic + any load). A load is an ammo load, so its name is free text: the cartridge, bullet, lot number or anything else that identifies it. Its weight and BC are restored together with their unit and drag model, so they are never re-converted. Bullet length is optional: a load saved without it loads with the field empty, and stability and spin drift are skipped until you enter one.

The caliber list covers common cartridges from .17 HMR to .50 BMG. Each one stores its real bullet diameter, which is what the stability calculation needs (".308 Win" and "7.62×51" are both a 0.308 in / 7.823 mm bullet). Pick Custom diameter… to type any other diameter in mm.

Profiles live in the browser's localStorage (bc-gear-v1). They stay on this device and browser and are separate from the autosaved form state.

Export to file downloads every saved profile as a JSON file (bc-gear-YYYY-MM-DD.json), and Import from file adds the profiles from such a file. Use these to back up your gear or move it to another browser or phone. Importing merges into what you already have: a profile whose name matches an existing one of the same kind (ignoring case) replaces it, and the rest are added. Files that aren't a saved-gear export are rejected, and malformed entries are skipped.

Tests

test.js extracts the app's <script> from index.html and runs 62 assertions against the pure functions (unit conversion, turret math and click presets, atmosphere, drag interpolation, Miller stability, spin drift, trajectory-solver behaviour, G1↔G7 BC conversion, grain/gram weight, caliber presets, the target-card row labels/solver, and saved-gear storage and export/import):

node test.js

CI runs these in a test job that gates the image build.

Run (Docker)

With Docker Compose:

docker compose up --build

Or with plain Docker:

docker build -t ballistic-calculator .
docker run -p 8080:80 ballistic-calculator

Then open http://localhost:8080

License

MIT © Reinholds Zviedris

Source: https://github.com/zxpower/bc

Disclaimer: provided as-is for informational/educational use, with no warranty. Ballistic outputs are estimates — always confirm against verified dope.

About

Simple web based ballistic calculator

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages