In order to specify some things first: The user should be able to create a graph by specifying 3 to 5 points on a 2D field. The first and the last points are always at the bounds of that field (their position may only be changed in y direction - not x). The derivation of the graph at these positions should be 0. The position of the 3rd and following points may be specified freely. A graph should be interpolated, which goes through all the points. However, this graph should be as smooth and flat as possible. (please apologize for not being mathematically correct)
The important thing: I need to sample values of that graph afterwards and apply them to a discrete signal. Second thing: Within the range of the x-Axis the values of the function should not exceed the boundaries on the y-Axis.. In my pics that would be 0 and 1 on the y-Axis. I created some pics to illustrate what I am talking about using 3 points.
Some thoughts I had:
So far, I don't have in depth understanding of these techniques, so I might miss some great technique or algorithm I haven't known about yet.
There is one more thing, that would be great to be able to do: Being able to adjust the steepness of the curve via the change of one or a few parameters. I illustrated this by using a red and a black graph in some of my pictures. Any ideas or hints how to solve that efficiently?
For example, a smooth function of class C2 has both a first derivative and a second derivative. If all derivatives exist, the function is called infinitely smooth or infinitely differentiable. The derivatives are continuous. In other words, its derivative is a continuous function.
Smooth functions have a unique defined first derivative (slope or gradient) at every point. Graphically, a smooth function of a single variable can be plotted as a single continuous line with no abrupt bends or breaks.
Continuity. The terms parametric continuity (Ck) and geometric continuity (Gn) were introduced by Brian Barsky, to show that the smoothness of a curve could be measured by removing restrictions on the speed, with which the parameter traces out the curve.
A smooth function is a function that has continuous derivatives up to some desired order over some domain.
Do you understand how splines are arrived at?
You break the range into pieces based on the control points (splitting at the control points or putting the breaks between them), and plop some parameterized function into each sub-range, then constrain the functions by the control points, artificially introduced end-point constraints, and inter-segment constrains.
If you've counted your degrees of freedom and constraints right, you get a solvable system of equations which tells you the right parameters in terms of the control points and away you go.
The result is a set of parameters for a piecewise function. Generally a piecewise continuous and differentiable function, because what would be the point otherwise.
So consider making each interior point the center of a segment which will be occupied by a peak-like function (Gaussian on a linear background, maybe) and use the end points as constraints.
For n
total points you'd have D*(n-2)
parameters if each segment has D
parameters. You have four end-point constraints f(start)=y_0
, f(end)=y_n
, f'(start) = f'(end) = 0)
, and some set of match constraints between the segments:
f_n(between n and n+1) = f_n+1(between n and n+1)
f'_n(between n and n+1) = f'_n+1(between n and n+1)
...
plus each segment is constrained by it's relationship to the control point (usually either f(point n) = y_n
or f'(point n) = 0
or both (but you get to decide).
How many matching constraints you can have depends on the number of degrees of freedom (total number of constraints must equal total number of DoF, right?). You have have to introduce some extra endpoint constraints in the form f''(start) = 0
... to get it right.
At that point you're just looking at a lot of tedious algebra to earn how to translate this into a big system of linear equation which you can solve with a matrix inversion.
Most numeric methods books will cover this stuff.
There is no reason you cannot use splines. If you have a formulation/library for that that deals with increments, just step from the starting point to the end point of your graph with the desired number of points.
If you want more control over the behavior of the derivative at the control points, you can compose your own piece-wise polynomial that satisfy the conditions of continuity in the function and its derivative. These conditions end up as equations for a linear system of equations that you will then solve with matrix methods as you indicate. This is one way to clamp the derivative at zero for the endpoints.
The degree of freedom that allows you to broaden or narrow the peaks in the interpolated function are more ambiguous. One possibility is to order an otherwise under-determined set of equations by its properties in higher order derivatives, or by its deviation from the first order (linear) interpolator.
Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With