Add monotone cubic Hermite plot style to TimeValueLayer#3
Open
DMGiulioRomano wants to merge 1 commit into
Open
Add monotone cubic Hermite plot style to TimeValueLayer#3DMGiulioRomano wants to merge 1 commit into
DMGiulioRomano wants to merge 1 commit into
Conversation
Adds a new PlotCubicHermite plot style (appended to the PlotStyle enum as
value 7) that draws a smooth curve through the layer's breakpoints using
monotone cubic Hermite interpolation with Fritsch-Carlson tangents
(Fritsch & Carlson, "Monotone Piecewise Cubic Interpolation",
SIAM J. Numer. Anal. 17(2), 1980).
Unlike PlotCurve, which uses Bezier control points and can overshoot the
data on steep transitions or narrow peaks, this style is guaranteed to
stay within the range of the surrounding breakpoints: tangents are driven
to zero at local extrema, so plateaus stay flat and monotone runs never
overshoot. With only two breakpoints the curve degenerates to a symmetric
smoothstep.
Implementation (layer/TimeValueLayer.{h,cpp} only):
- Two file-local helpers, computeFritschCarlsonTangents() and
cubicHermite(). Coincident frames are guarded against division by zero.
- A dedicated rendering branch in paint() that samples the curve at 1px
(O(paint width), same cost as PlotCurve) and draws it with drawPath and
antialiasing. A single point falls back to a small rectangular marker.
- Plot Type range extended (max 6 -> 7) and a "Cubic Hermite" label.
- The style is treated as scrollable, like the other curve styles.
Tangents are computed over all model events, not just the visible window,
so the curve does not change shape while scrolling; for the same reason
the branch runs before the visible-window emptiness check, so a curve
passing between two off-screen breakpoints is still drawn. Interpolation
is done in value space and each sample is mapped through the vertical
CoordinateScale, so the curve is correct on a logarithmic vertical scale.
Save/load needs no change: toXml already serialises m_plotStyle as an
integer and setProperties casts it back, so plotStyle="7" round-trips, and
appending the value keeps the existing styles 0-6 unchanged.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016ANtJmJppqkSVEk6AVtKrn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new PlotCubicHermite plot style (appended to the PlotStyle enum as value 7) that draws a smooth curve through the layer's breakpoints using monotone cubic Hermite interpolation with Fritsch-Carlson tangents (Fritsch & Carlson, "Monotone Piecewise Cubic Interpolation", SIAM J. Numer. Anal. 17(2), 1980).
Unlike PlotCurve, which uses Bezier control points and can overshoot the data on steep transitions or narrow peaks, this style is guaranteed to stay within the range of the surrounding breakpoints: tangents are driven to zero at local extrema, so plateaus stay flat and monotone runs never overshoot. With only two breakpoints the curve degenerates to a symmetric smoothstep.
Implementation (layer/TimeValueLayer.{h,cpp} only):
Tangents are computed over all model events, not just the visible window, so the curve does not change shape while scrolling; for the same reason the branch runs before the visible-window emptiness check, so a curve passing between two off-screen breakpoints is still drawn. Interpolation is done in value space and each sample is mapped through the vertical CoordinateScale, so the curve is correct on a logarithmic vertical scale.
Save/load needs no change: toXml already serialises m_plotStyle as an integer and setProperties casts it back, so plotStyle="7" round-trips, and appending the value keeps the existing styles 0-6 unchanged.
Claude-Session: https://claude.ai/code/session_016ANtJmJppqkSVEk6AVtKrn