Fix reciprocal minor tick spacing; bump to 0.84
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.
This commit is contained in:
@@ -65,8 +65,9 @@ Calculated numbers are rendered in fixed-point notation at 4 significant figures
|
|||||||
| Linear | Evenly spaced | Uniform | None |
|
| Linear | Evenly spaced | Uniform | None |
|
||||||
| √ | Quadratic (0, 1, 4, 9 … × max) — compresses low values | Crowded toward the low end of each interval | Min ≥ 0 |
|
| √ | 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 |
|
| 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
|
### Unit markup
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: m1730-generator
|
- name: m1730-generator
|
||||||
image: git.baumann.gr/adebaumann/m1730-generator:0.83
|
image: git.baumann.gr/adebaumann/m1730-generator:0.84
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 5000
|
- containerPort: 5000
|
||||||
|
|||||||
+5
-4
@@ -8,7 +8,7 @@ from fontTools.pens.svgPathPen import SVGPathPen
|
|||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
VERSION = "0.83"
|
VERSION = "0.84"
|
||||||
|
|
||||||
_LOGO_PATH = pathlib.Path(__file__).parent / 'static' / 'logo.png'
|
_LOGO_PATH = pathlib.Path(__file__).parent / 'static' / 'logo.png'
|
||||||
_LOGO_B64 = base64.b64encode(_LOGO_PATH.read_bytes()).decode()
|
_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):
|
for j in range(1, small_ticks + 1):
|
||||||
if scale_type == 'sqrt':
|
if scale_type == 'sqrt':
|
||||||
x = big_xs[i] + (j / sub) ** 2 * (big_xs[i + 1] - big_xs[i])
|
x = big_xs[i] + (j / sub) ** 2 * (big_xs[i + 1] - big_xs[i])
|
||||||
elif math.isinf(big_vals[i]):
|
elif scale_type == 'reciprocal' or math.isinf(big_vals[i]):
|
||||||
# First interval with ∞ at the left: interpolate in position space
|
# Reciprocal: interpolate in position space (= linear in 1/v).
|
||||||
# (linear value interpolation is undefined from ∞).
|
# 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])
|
x = big_xs[i] + (j / sub) * (big_xs[i + 1] - big_xs[i])
|
||||||
else:
|
else:
|
||||||
v = big_vals[i] + j * (big_vals[i + 1] - big_vals[i]) / sub
|
v = big_vals[i] + j * (big_vals[i + 1] - big_vals[i]) / sub
|
||||||
|
|||||||
Reference in New Issue
Block a user