Algorithm for connecting points in a graph with curved lines

3

I need to develop an algorithm that connects points in a nonlinear way, that is, with smooth curves, as in the image below:

TheproblemisthatIcannotfindthebestsolution,eitherusing Bezier curves , Polimonial Interpolation , Curve Adjustment , among others.

In short, I need a formula that interpolates the points according to the figure above, generating N intermediate points between one coordinate and another.

Ex: In the image above, the first coordinate (c1) is (x = 1, y = 220) and the second (c2) is (x = 2, y = 40).

So if I want to create for example 4 intermediate coordinates between c1 and c2 I will have to get an array (x, y) of 4 elements something like this:

[1.2, 180], [1.4, 140], [1.6, 120], [1.8, 80] 

Would anyone have any ideas?

    
asked by anonymous 05.08.2018 / 04:03

1 answer

0

What you want is a tween interpolation.

This consists of finding a function f (x) that gives n points p1, p2, ..., pn, f (x) passes through all points.

How is this done?

Let's think of the simplest case, 2 points (n = 2), in this case we want to find a line (remember, there is always a line that passes through 2 non-coincident points), a line is a function of the form

f (x) = ax + b

Note that f (x) is a polynomial of degree 1, in the case of polynomial interpolation, we want f (x) to be a polynomial of the lowest possible degree.

There are several interpolation algorithms, you can find the description of them here, but most languages already have a lib with this implemented

link

link

    
04.09.2018 / 19:57