diff --git a/README.md b/README.md index aaf04a2..c0711d3 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,9 @@ 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 flags corrections (⚠) beyond the turret's travel. +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 diff --git a/index.html b/index.html index dd5f672..a7b6984 100644 --- a/index.html +++ b/index.html @@ -734,6 +734,15 @@

Target Card

const overTravel = (clicks, total) => total > 0 && clicks > total; +/* Past the turret's travel the shooter dials the max and holds the remainder on + the reticle. Returned as a reticle reading (SFP-scaled), or null if dialable. */ +function overHold(offsetCm, dist, t, o) { + const clicks = clicksFor(offsetCm, dist, t.clickCm); + if (!overTravel(clicks, t.total) || !(dist > 0)) return null; + const restCm = offsetCm - t.total * t.clickCm * dist / 100; + return Math.max(0, restCm) / unitCm(trajUnit, dist) * o.scale; +} + /* ---- Reticle ---- An SFP reticle only subtends its nominal value at one magnification; at zoom M each division covers nominal × cal / M, so a hold of A reads as A × M / cal @@ -800,8 +809,11 @@

Target Card

detailEl.textContent = ''; return; } - outEl.innerHTML = r.clicks + ' clicks'; - const b = breakdownClicks(r.clicks, t.perMark, t.perTurn); + const o = opticSettings(); + const rest = overHold(r.offsetCm, dist, t, o); + const dial = rest == null ? r.clicks : t.total; + outEl.innerHTML = dial + ` clicks${rest == null ? '' : ' (max)'}`; + const b = breakdownClicks(dial, t.perMark, t.perTurn); const parts = []; if (b) { if (b.turns > 0) parts.push(`${b.turns} turn${b.turns !== 1 ? 's' : ''}`); @@ -809,10 +821,10 @@

Target Card

parts.push(`+ ${b.rem} click${b.rem !== 1 ? 's' : ''}`); } breakdownEl.textContent = parts.join(' · '); - if (overTravel(r.clicks, t.total)) { - breakdownEl.innerHTML += `
⚠ beyond the turret's ${t.total} clicks of travel — hold the rest
`; + if (rest != null) { + breakdownEl.innerHTML += `
⚠ needs ${r.clicks} clicks, turret has ${t.total} — ` + + `dial max and hold over ${rest.toFixed(2)} ${trajUnit}${holdTag(o) ? ' ' + holdTag(o) : ''}
`; } - const o = opticSettings(); const hold = r.offsetCm / unitCm(trajUnit, dist) * o.scale; detailEl.textContent = `${labelWord} = ${r.offsetCm.toFixed(2)} cm · 1 click = ${r.clickCmAtDist.toFixed(3)} cm @ ${dist} m · raw ${r.rawClicks.toFixed(2)}` + @@ -1137,16 +1149,19 @@

Target Card

return clickCmAtDist > 0 ? Math.round(offsetCm / clickCmAtDist) : 0; } -// "54 (13m+2)" or "150 (1t 1m+2)" — dialable directly on the turret; ⚠ past `total`. +// "54 (13m+2)" or "150 (1t 1m+2)" — dialable directly on the turret. +// Past `total` it shows the max that can be dialed, flagged "⚠ max". function fmtClicks(n, perMark, perTurn, total) { - const a = Math.abs(n); + const over = overTravel(Math.abs(n), total); + const a = over ? total : Math.abs(n); const b = breakdownClicks(a, perMark, perTurn); - const warn = overTravel(a, total) ? ' ⚠' : ''; + const warn = over ? ' ⚠ max' : ''; if (!b) return a + warn; return a + ' (' + (b.turns > 0 ? b.turns + 't ' : '') + b.mark + 'm+' + b.rem + ')' + warn; } -const TRAVEL_NOTE = t => `⚠ = beyond the turret's ${t.total} clicks of elevation travel — hold the rest on the reticle.`; +const TRAVEL_NOTE = (t, u) => `⚠ max = needs more than the turret's ${t.total} clicks of elevation — ` + + `dial the max and hold the "Over hold ${u}" value on the reticle.`; const angOf = (offsetCm, dist) => dist > 0 ? offsetCm / unitCm(trajUnit, dist) : 0; @@ -1273,30 +1288,33 @@

Target Card

const uLabel = trajUnit; const o = opticSettings(); const sfp = o.plane === 'SFP'; + const shots = raw.map(r => deriveShot(ctx, r, t)); + const over = shots.some(s => overTravel(s.eClk, t.total)); let html = '' + '' + `${sfp ? '' : ''}` + + (over ? `` : '') + `${sfp ? '' : ''}` + ''; let cards = ''; - let over = false; - for (const raw_r of raw) { - const s = deriveShot(ctx, raw_r, t); + for (const s of shots) { const dist = s.dist; + const rest = overHold(s.dropCm, dist, t, o); html += '' + `` + `` + (sfp ? `` : '') + `` + + (over ? `` : '') + `` + (sfp ? `` : '') + `` + ''; - if (overTravel(s.eClk, t.total)) over = true; cards += `
${dist} m
` + - `
Drop ${s.dropCm.toFixed(1)} cm · ${angOf(s.dropCm, dist).toFixed(2)} ${uLabel}${sfp ? ` (hold ${(angOf(s.dropCm, dist) * o.scale).toFixed(2)})` : ''} · dial UP ${fmtClicks(s.eClk, t.perMark, t.perTurn, t.total)}
` + + `
Drop ${s.dropCm.toFixed(1)} cm · ${angOf(s.dropCm, dist).toFixed(2)} ${uLabel}${sfp ? ` (hold ${(angOf(s.dropCm, dist) * o.scale).toFixed(2)})` : ''} · dial UP ${fmtClicks(s.eClk, t.perMark, t.perTurn, t.total)}` + + `${rest == null ? '' : ` + hold over ${rest.toFixed(2)} ${uLabel}`}
` + `
Wind ${Math.abs(s.windCm).toFixed(1)} cm ${s.side} · ${Math.abs(angOf(s.windCm, dist)).toFixed(2)} ${uLabel}${sfp ? ` (hold ${Math.abs(angOf(s.windCm, dist) * o.scale).toFixed(2)})` : ''} · dial ${s.side === 'R' ? 'LEFT' : 'RIGHT'} ${fmtClicks(s.wClk, t.perMark, t.perTurn)}
` + `
${s.v.toFixed(0)} m/s · ${s.energy.toFixed(0)} J · ${s.tof.toFixed(2)} s
`; } @@ -1304,7 +1322,7 @@

Target Card

wrap.innerHTML = html; cardsEl.innerHTML = cards; wrap.dataset.has = '1'; - noteEl.textContent = [noteEl.textContent, over ? TRAVEL_NOTE(t) : '', + noteEl.textContent = [noteEl.textContent, over ? TRAVEL_NOTE(t, uLabel) : '', sfp ? `Hold columns are reticle readings ${holdTag(o)}.` : ''].filter(Boolean).join(' '); } @@ -1374,11 +1392,12 @@

Target Card

const uLabel = trajUnit; const o = opticSettings(); const sfp = o.plane === 'SFP'; - let over = false; + const over = shots.some(s => s && overTravel(s.eClk, t.total)); let html = '
Dist mVel m/sEnergy JToF sDrop cmDrop ${uLabel}Elev holdElev clkOver hold ${uLabel}Wind cmWind ${uLabel}Wind holdWind clk
${dist}${s.v.toFixed(0)}${s.energy.toFixed(0)}${s.tof.toFixed(2)}${s.dropCm.toFixed(1)}${angOf(s.dropCm, dist).toFixed(2)}${(angOf(s.dropCm, dist) * o.scale).toFixed(2)}${fmtClicks(s.eClk, t.perMark, t.perTurn, t.total)}${rest == null ? '–' : rest.toFixed(2)}${Math.abs(s.windCm).toFixed(1)} ${s.side}${Math.abs(angOf(s.windCm, dist)).toFixed(2)}${Math.abs(angOf(s.windCm, dist) * o.scale).toFixed(2)}${fmtClicks(s.wClk, t.perMark, t.perTurn)} ${s.side}
' + '' + `${sfp ? '' : ''}` + + (over ? `` : '') + `${sfp ? '' : ''}` + '' + ''; @@ -1391,28 +1410,30 @@

Target Card

unreachable.push(name); const shown = dists[i] > 0 ? Math.round(dists[i]) : '–'; html += `` + - ''.repeat(sfp ? 10 : 8) + ''; + ''.repeat(8 + (sfp ? 2 : 0) + (over ? 1 : 0)) + ''; cards += `
${name} · ${shown} m
` + '
No solution — set a distance the bullet can reach.
'; return; } const dist = s.dist; const dialSide = s.side === 'R' ? 'LEFT' : 'RIGHT'; + const rest = overHold(s.dropCm, dist, t, o); html += '' + `` + `` + (sfp ? `` : '') + `` + + (over ? `` : '') + `` + `` + (sfp ? `` : '') + `` + `` + ''; - if (overTravel(s.eClk, t.total)) over = true; cards += `
${name} · ${dist} m
` + - `
Drop ${s.dropCm.toFixed(1)} cm · ${angOf(s.dropCm, dist).toFixed(2)} ${uLabel}${sfp ? ` (hold ${(angOf(s.dropCm, dist) * o.scale).toFixed(2)})` : ''} · dial UP ${fmtClicks(s.eClk, t.perMark, t.perTurn, t.total)}
` + + `
Drop ${s.dropCm.toFixed(1)} cm · ${angOf(s.dropCm, dist).toFixed(2)} ${uLabel}${sfp ? ` (hold ${(angOf(s.dropCm, dist) * o.scale).toFixed(2)})` : ''} · dial UP ${fmtClicks(s.eClk, t.perMark, t.perTurn, t.total)}` + + `${rest == null ? '' : ` + hold over ${rest.toFixed(2)} ${uLabel}`}
` + `
Wind ${Math.abs(s.windCm).toFixed(1)} cm ${s.side} · ${Math.abs(angOf(s.windCm, dist)).toFixed(2)} ${uLabel}${sfp ? ` (hold ${Math.abs(angOf(s.windCm, dist) * o.scale).toFixed(2)})` : ''} · dial ${dialSide} ${fmtClicks(s.wClk, t.perMark, t.perTurn)}
` + `
${s.v.toFixed(0)} m/s · ${s.energy.toFixed(0)} J · ${s.tof.toFixed(2)} s
`; }); @@ -1425,7 +1446,7 @@

Target Card

noteEl.textContent = `No solution for target${unreachable.length > 1 ? 's' : ''} ` + `${unreachable.join(', ')} — distance missing or beyond this load's reach.`; } - noteEl.textContent = [noteEl.textContent, over ? TRAVEL_NOTE(t) : '', + noteEl.textContent = [noteEl.textContent, over ? TRAVEL_NOTE(t, uLabel) : '', sfp ? `Hold columns are reticle readings ${holdTag(o)}.` : ''].filter(Boolean).join(' '); } diff --git a/test.js b/test.js index 96d16fb..967322c 100644 --- a/test.js +++ b/test.js @@ -68,9 +68,20 @@ test('travel limit is flagged only when set and exceeded', () => { assert.strictEqual(overTravel(120, 100), true); assert.strictEqual(overTravel(100, 100), false); assert.strictEqual(overTravel(120, 0), false); - assert.strictEqual(fmtClicks(113, 8, 100, 100), '113 (1t 1m+5) ⚠'); + assert.strictEqual(fmtClicks(113, 8, 100, 100), '100 (1t 0m+0) ⚠ max'); assert.strictEqual(fmtClicks(54, 4, 144, 200), '54 (13m+2)'); }); +test('past max travel: dial the max, hold the rest on the reticle', () => { + trajUnit = 'MOA'; + const t = { clickCm: clickCmFrom('MOA', '0.125', ''), total: 100 }; // 100 x 1/8 MOA = 12.5 MOA + const ffp = { scale: 1 }, sfp = { scale: reticleScale('SFP', 20, 40) }; + const at = 500, cm = 15 * unitCm('MOA', at); // 15 MOA of drop + approx(overHold(cm, at, t, ffp), 2.5, 1e-9, 'FFP holds 15 - 12.5 MOA'); + approx(overHold(cm, at, t, sfp), 1.25, 1e-9, 'SFP @ 20x of 40x halves it'); + assert.strictEqual(overHold(10 * unitCm('MOA', at), at, t, ffp), null, '10 MOA fits the turret'); + assert.strictEqual(overHold(cm, at, { ...t, total: 0 }, ffp), null, 'no limit set'); + trajUnit = 'MRAD'; +}); test('SFP reticle scale: true at cal mag, halves at half zoom; FFP always 1', () => { assert.strictEqual(reticleScale('SFP', 40, 40), 1); assert.strictEqual(reticleScale('SFP', 20, 40), 0.5);
TargetDist mDrop cmElev ${uLabel}Elev holdElev clk (UP)Over hold ${uLabel}Drift cmWind ${uLabel}Wind holdWind clk (dial)ToF sVel m/s
${name}${shown}–
–
${name}${dist}${s.dropCm.toFixed(1)}${angOf(s.dropCm, dist).toFixed(2)}${(angOf(s.dropCm, dist) * o.scale).toFixed(2)}${fmtClicks(s.eClk, t.perMark, t.perTurn, t.total)}${rest == null ? '–' : rest.toFixed(2)}${Math.abs(s.windCm).toFixed(1)} ${s.side}${Math.abs(angOf(s.windCm, dist)).toFixed(2)}${Math.abs(angOf(s.windCm, dist) * o.scale).toFixed(2)}${fmtClicks(s.wClk, t.perMark, t.perTurn)} ${dialSide.charAt(0)}${s.tof.toFixed(2)}${s.v.toFixed(0)}