Is there an easy way to calculate a “smooth” function with the following characteristics in C / C ++?

To first point out some things: the user must be able to create a graph by specifying 3 to 5 points in a 2D field. The first and last points are always at the boundaries of this field (their position can only be changed in the y direction, not x). The output of the graph in these positions should be 0. The position of the 3rd and following paragraphs can be indicated freely. The graph must 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 then need to try the values ​​of this graph and apply them to the discrete signal. Second: within the x-axis, the values ​​of the function must not exceed the boundaries of the y-axis. In my photos, which would be 0 and 1 on the y axis. I created a few photos to illustrate what I'm talking about using 3 points.

Some thoughts I had:

  • Use (cubic?) Splines: their characteristics can be used to form such curves without any problems. However, as far as I know, they do not belong to the global x-axis. They are indicated relative to the next point through a parameter commonly called (s). Therefore, it will be difficult to display the graph values ​​associated with the x axis. Please correct me when I am wrong.
  • create a matrix containing points and derivations at these points, and solve this matrix using LU decomposition or something equivalent.

, - , .

, : . , . , ?

alt textalt textalt textalt text

+5
3

, ?

( ), plop , , .

, , .

. , - , .

, , , ( , ) .

n D*(n-2), D. f(start)=y_0, f(end)=y_n, f'(start) = f'(end) = 0) :

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)
...

( f(point n) = y_n f'(point n) = 0, ( ).

( DoF, ?). f''(start) = 0..., .

, , , .

.

+5

, . / , , .

, - , . , , . .

, , . , () .

!

+2

Why don't you use well-known solutions to your problem? Read about linear regression and polynomial regression . These are the algorithms you are looking for. UPDATE: polynomials will be your interests

-2
source

All Articles