Point Sequence Interpolation

前端 未结 9 667
广开言路
广开言路 2021-01-02 07:36

Given an arbitrary sequence of points in space, how would you produce a smooth continuous interpolation between them?

2D and 3D solutions are welcome. Solutions tha

9条回答
  •  情深已故
    2021-01-02 07:50

    One way is Lagrange polynominal, which is a method for producing a polynominal which will go through all given data points.

    During my first year at university, I wrote a little tool to do this in 2D, and you can find it on this page, it is called Lagrange solver. Wikipedia's page also has a sample implementation.

    How it works is thus: you have a n-order polynominal, p(x), where n is the number of points you have. It has the form a_n x^n + a_(n-1) x^(n-1) + ...+ a_0, where _ is subscript, ^ is power. You then turn this into a set of simultaneous equations:

    p(x_1) = y_1
    p(x_2) = y_2
    ...
    p(x_n) = y_n
    

    You convert the above into a augmented matrix, and solve for the coefficients a_0 ... a_n. Then you have a polynomial which goes through all the points, and you can now interpolate between the points.

    Note however, this may not suit your purpose as it offers no way to adjust the curvature etc - you are stuck with a single solution that can not be changed.

提交回复
热议问题