From 8d45a6d10f364072ceeca55a8fc22ed6ed365b20 Mon Sep 17 00:00:00 2001 From: "Adrian A. Baumann" Date: Tue, 14 Jul 2026 23:33:55 +0200 Subject: [PATCH] Fix reciprocal minor tick spacing; bump to 0.84 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Minor ticks on 1/x scales were using linear value interpolation between harmonically-spaced major ticks. Because 1/v is highly convex, equal value steps near a large major-value (left side of the first interval) map to tiny physical steps, piling all ticks against the left wall. At a 1:1000 ratio the first four minor ticks land at 0%/0%/1%/2% of the interval. Fix: interpolate in position space (uniform physical spacing) for all reciprocal intervals, matching how major ticks are laid out (also equal physical steps) and matching the already-correct ∞-first-interval handling. Also documents 1/x scale and ∞ max in README. --- README.md | 3 ++- k8s/deployment.yaml | 2 +- web/app.py | 9 +++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f626fc4..ce020b5 100644 --- a/README.md +++ b/README.md @@ -65,8 +65,9 @@ Calculated numbers are rendered in fixed-point notation at 4 significant figures | Linear | Evenly spaced | Uniform | None | | √ | Quadratic (0, 1, 4, 9 … × max) — compresses low values | Crowded toward the low end of each interval | Min ≥ 0 | | Log | Geometric (min × r⁰, r¹, r² …) — each interval spans the same ratio | Crowded toward the high end of each interval | Min and Max > 0 | +| 1/x | Harmonic (values decrease left → right, e.g. ∞, 10, 5, 2, 1) — compresses high values | Uniform (in position space, i.e. proportional to 1/v) | Min and Max > 0; Max may be ∞ | -The √ mapping is typical for AC RMS current and power meters, where needle deflection is proportional to the square of the measured quantity. +The √ mapping is typical for AC RMS current and power meters, where needle deflection is proportional to the square of the measured quantity. The 1/x mapping is used for ohms/resistance scales, where values decrease from left (high resistance / ∞) to right (low resistance). ### Unit markup diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml index 841cef7..3850f52 100644 --- a/k8s/deployment.yaml +++ b/k8s/deployment.yaml @@ -15,7 +15,7 @@ spec: spec: containers: - name: m1730-generator - image: git.baumann.gr/adebaumann/m1730-generator:0.83 + image: git.baumann.gr/adebaumann/m1730-generator:0.84 imagePullPolicy: Always ports: - containerPort: 5000 diff --git a/web/app.py b/web/app.py index 22cc8e6..4763850 100644 --- a/web/app.py +++ b/web/app.py @@ -8,7 +8,7 @@ from fontTools.pens.svgPathPen import SVGPathPen app = Flask(__name__) -VERSION = "0.83" +VERSION = "0.84" _LOGO_PATH = pathlib.Path(__file__).parent / 'static' / 'logo.png' _LOGO_B64 = base64.b64encode(_LOGO_PATH.read_bytes()).decode() @@ -487,9 +487,10 @@ def generate_svg(unit, min_val, max_val, range_label, big_ticks, small_ticks, la for j in range(1, small_ticks + 1): if scale_type == 'sqrt': x = big_xs[i] + (j / sub) ** 2 * (big_xs[i + 1] - big_xs[i]) - elif math.isinf(big_vals[i]): - # First interval with ∞ at the left: interpolate in position space - # (linear value interpolation is undefined from ∞). + elif scale_type == 'reciprocal' or math.isinf(big_vals[i]): + # Reciprocal: interpolate in position space (= linear in 1/v). + # Linear value interpolation would map huge early value ranges + # through 1/v and pile all ticks against the left wall. x = big_xs[i] + (j / sub) * (big_xs[i + 1] - big_xs[i]) else: v = big_vals[i] + j * (big_vals[i + 1] - big_vals[i]) / sub