You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm proposing the addition of a new type of curve for d3-shape — aptly called curveCubicX by @mbostock on the original thread — that treats the Y coordinate as a function of the X coordinate, such that for any X coordinate there's a single corresponding Y value.
In the image below, the proposed curveCubicX in comparison with curveNatural and curveBasis:
(the cubic curve is generated with a cubic spline interpolator through small line segments joining 1000 samples of <x, f(x)>)
The algorithm for the interpolator is described on Wikipedia (also of note is its talk page, which makes it apparent that the page suffered various incarnations of the algorithm, of various readability levels).
There are also some demos and implementations of the algorithm:
However, these are all oriented towards finding the interpolator function, and any SVG paths are drawn with sampling the function, and I am severely out of my comfort zone in regards to obtaining the Bézier control points needed to draw the SVG path, so I'm hoping for some pointers or ideas on the matter...
As for the utility: I started with trying to recreate the Curves interface in Adobe Photoshop, which seems to be using such a cubic spline to interpolate the values. For data visualization, on the one hand it maintains Y being a function of X which makes sense in most types of charts, and the spline does pass through all the points, but on the other hand it tends to overshoot much more than other types of curves.
The text was updated successfully, but these errors were encountered:
Back from the field: I could not find any literature on how to implement this as a Bézier spline (it's possibly hidden in terms/explanations I don't understand) — but I did manage to independently re-implement curveNatural and curveBasis based on this explanation :). Unfortunately I'm lacking the theoretical foundation to have any intuition on how to use the algorithms for parametric splines (descriptions of which abound) to a non-parametric (explicit) spline... hopefully someone on Math StackExchange has some ideas.
Issue was originally in d3-interpolate#49
I'm proposing the addition of a new type of curve for d3-shape — aptly called curveCubicX by @mbostock on the original thread — that treats the Y coordinate as a function of the X coordinate, such that for any X coordinate there's a single corresponding Y value.
In the image below, the proposed
curveCubicX
in comparison withcurveNatural
andcurveBasis
:(the cubic curve is generated with a cubic spline interpolator through small line segments joining 1000 samples of
<x, f(x)>
)The algorithm for the interpolator is described on Wikipedia (also of note is its talk page, which makes it apparent that the page suffered various incarnations of the algorithm, of various readability levels).
There are also some demos and implementations of the algorithm:
However, these are all oriented towards finding the interpolator function, and any SVG paths are drawn with sampling the function, and I am severely out of my comfort zone in regards to obtaining the Bézier control points needed to draw the SVG path, so I'm hoping for some pointers or ideas on the matter...
As for the utility: I started with trying to recreate the Curves interface in Adobe Photoshop, which seems to be using such a cubic spline to interpolate the values. For data visualization, on the one hand it maintains Y being a function of X which makes sense in most types of charts, and the spline does pass through all the points, but on the other hand it tends to overshoot much more than other types of curves.
The text was updated successfully, but these errors were encountered: