Interpolation and Splines

Source: Internet
Author: User

Let's talk about some other things first. I went back to my hometown a few days ago and turned out some textbooks from college ten years ago. I thought that I had to study hard before the exam, and I had to fight for myself-now I have become empty. It's really embarrassing. One of the textbooks is "Numerical Analysis". This course is also very difficult, at least for me to understand. In numerical analysis, interpolation is the foundation of this course.

The continuous function is inserted on the basis of discrete data so that this continuous curve passes through all given discrete data points. Interpolation is an important method of discrete function approximation. It can be used to estimate the approximate value of a function at other points by the value of a function at a finite point. Interpolation can be used to fill gaps between pixels during image transformation. Interpolation, fitting, and approximation are three basic tools for numerical analysis. In the general sense, they differ in that interpolation is a known point column and completely goes through the point column; fitting is a known point column, approaching them is a known curve or a point column. by approaching them, the constructed functions are infinitely close to them. Scientific and engineering problems can be used to obtain discrete data through methods such as sampling and experiments. Based on these data, we often want to obtain a continuous function (that is, a curve) or more intensive discrete equations are consistent with known data.

The interpolation problem is assumed that the real-value function f (x) on the interval [a, B] is n + 1x0, X1 ...... The value at XN is F (x0 ),...... F (Xn) requires the estimation of the value of f (x) at a point X * in [a, B. The basic idea is to find a function p (x) in x0, X1 ...... The value of the f (x) function on the XN node is the same (sometimes, or even the first-order derivative value), and the value of P (x *) is used as the function f (x *). In short, it refers to the number of values on known data, and the value is filled with unknown values.

Splines are a class of functions with smooth segments and certain smoothness at the intersection of each segment. The word spline is derived from the tool used by the engineering drawing personnel to connect some specified points into a smooth curve, that is, elastic wood strips or thin steel bars. A curve formed by such a spline has a continuous slope and curvature at the connection point. Piecewise low-level polynomials, functional interpolation with a certain degree of smoothness at the segments is developed by simulating the above principles. It overcomes the oscillation phenomenon that may occur during higher-level polynomial interpolation, it has good numerical stability and convergence. The function generated by this Interpolation Process is a polynomial spline function.

Before the computer is used, the numerical calculation is completed manually. Although piecewise functions such as SIGNUM functions or step functions are also used, generally prefer polynomials because they are easier to calculate. With the development of computers, splines become increasingly important. They were originally used as substitutes for polynomials in interpolation, and later used as tools to construct smooth and variable shapes in computer graphics. The Study of splines began in the middle of the 20th century. By 1960s, it was successfully applied to shape design by combining with computer-aided design. Splines have become a powerful tool for function approximation. Its application scope is also expanding. It is not only widely used in data processing, numerical differentiation, numerical integration, differential equations, Numerical Solutions of integral equations, and other mathematical fields, it is closely related to optimal control, variational issues, statistics, computational ry, functional analysis, and other disciplines.

I have talked so much about it. In fact, the purpose of my blog is to show you the splines I have implemented. Please refer to the following software:

This is a program demo that implements more than 10 kinds of splines. For: http://files.cnblogs.com/WhyEngine/TestSpline.zip

The software usage is as follows:

    1. The scroll wheel is used to control the scaling of the entire scenario.
    2. Right-click a scene to drag it.
    3. When you press Ctrl and click the left mouse button, a sampling point is added.
    4. You can select a sampling point by clicking the left mouse button. After selecting a sample point, drag the mouse to modify its coordinates. If you select a sample point, press Ctrl and then drag the mouse to insert a new sample point.
    5. Click Delete on the keyboard to delete the sampling point.
    6. CTRL + Delete can delete all sampling points.
    7. You can use the list box on the left of the interface to select a spline calculation method.

The Code uses C ++ and the development environment is vs2008. All splines are subclasses of a base class:

/****************************************************************  File name   :  YicSpline.h  Author      :  叶峰  Version     :  2.0  Create Date :  2014/08/18    Description :  样条*****************************************************************/#ifndef __YicSpline_H__#define __YicSpline_H__// INCLUDES -----------------------------------------------------------------------------#include "..\WhyDefines.h"#include "..\WhyAssert.h"// --------------------------------------------------------------------------------------class YicSpline{public:    // 计算样条数值    virtual bool    BuildSpline(const void* ctrlValuesPtr, Yuint ctrlStride, Yuint ctrlCount,         void* splineValuesPtr, Yuint splineStride) const = NULL;    // 计算切线数值    virtual bool    BuildTangent(const void* ctrlValuesPtr, Yuint ctrlStride, Yuint ctrlCount,         void* tangentValuesPtr, Yuint tangentStride) const    {        return false;    }};// --------------------------------------------------------------------------------------inline float YfGetFloatValue(const void* valuesPtr, int stride, int index){    return *(float*)((char*)valuesPtr + stride*index);}// --------------------------------------------------------------------------------------#endif

In the following blog, I will introduce the interpolation algorithms of these splines one by one:

(1) Spline-based besell)

(2) B of Splines

(3) catmullrom of Splines

(4) hermit of splines (Hermite)

(5) interpolation functions of the family of splines using the interfaces of the Laplace (Inter-region)

(6) parabolic (one dollar three points) interpolation function of Splines

(7) piecewise interpolation functions of Splines

(8) Spline-hermit (Hermite) interpolation function

(9) Spline-based Aitken step-by-step interpolation function

(10) ehmt interpolation function of Splines

(11) Akima smooth interpolation function of Splines

(12) Calculate polynomial using the least squares algorithm of Splines

(13) polynomial calculation using the cut-by-sprue algorithm of Splines

 

Finally, go to the previous poem at http://blog.sciencenet.cn/blog-39437-530669.html:

Interpolation

 

There is a magic called simple beauty

There is a wonderful thing: data processing.

This is a very old story.

The main character of the story is not only ermiit

 

There is a fitting called the least squares

There is a type of interpolation called Langran.

It's all about you.

The combined score is never bad.

One seedling is called a spline.

There is a kind of oscillation, which has no end but no interest

You don't have to look ahead

Yang Mi Gao must start from the base

 

Some twists and turns may be somewhat frustrated

Occasionally derailed and occasionally aborted

All of this is not important.

What matters is the process and experience.

 

Interpolation and Splines

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.