From eff75e6d15eaebccec814b37504a6eeff53fb9e8 Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 18 Feb 2026 18:44:21 +0100 Subject: feat(mq_editor): switch curve interpolation to Lagrange through all control points Replace cubic Bezier with Lagrange interpolation so P1/P2 are actual points on the curve. Eval uses stored t1/t2 as arbitrary knot positions. fitBezier keeps least-squares but with Lagrange basis at u=1/3,2/3. Remove endpoint companion drag (no longer tangent handles). TODO: support arbitrary number of inner control points. handoff(Claude): Lagrange interpolation replaces Bezier in mq_editor curve eval/fit. Co-Authored-By: Claude Sonnet 4.6 --- tools/mq_editor/editor.js | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'tools/mq_editor/editor.js') diff --git a/tools/mq_editor/editor.js b/tools/mq_editor/editor.js index 0854ec0..a7d0879 100644 --- a/tools/mq_editor/editor.js +++ b/tools/mq_editor/editor.js @@ -25,8 +25,7 @@ class PartialEditor { // Private state this._selectedIndex = -1; - this._dragPointIndex = -1; - this._dragCompanionOff = null; // {dt, dv} offset of companion handle relative to anchor + this._dragPointIndex = -1; this._amp = { tMin: 0, tMax: 1, ampTop: 1 }; this._setupButtons(); @@ -496,12 +495,7 @@ class PartialEditor { for (let i = 0; i < 4; ++i) { if (Math.hypot(this._tToX(curve['t' + i]) - x, this._ampToY(curve['a' + i]) - y) <= 8) { if (this.onBeforeChange) this.onBeforeChange(); - this._dragPointIndex = i; - this._dragCompanionOff = null; - if (i === 0) - this._dragCompanionOff = { da: curve.a1 - curve.a0 }; - else if (i === 3) - this._dragCompanionOff = { da: curve.a2 - curve.a3 }; + this._dragPointIndex = i; canvas.style.cursor = 'grabbing'; e.preventDefault(); return; @@ -516,11 +510,6 @@ class PartialEditor { const curve = this.partials[this._selectedIndex].freqCurve; const i = this._dragPointIndex; curve['a' + i] = Math.max(0, this._yToAmp(y)); - if (this._dragCompanionOff) { - const off = this._dragCompanionOff; - if (i === 0) { curve.a1 = curve.a0 + off.da; } - else { curve.a2 = curve.a3 + off.da; } - } this._renderAmpEditor(); if (this.viewer) this.viewer.render(); e.preventDefault(); -- cgit v1.2.3