Implementation of Fast piecewise 3 spline curve fitting and polyline resampling algorithm

Source: Internet
Author: User
Tags polyline

In this paper, 3 times spline function is used, and the fast calculation method of piecewise interpolation is applied to achieve the use of mouse to draw any smooth curve on the screen, and the fitting method of line resampling is used to remove redundant interpolation points. The algorithm described in this paper can be used to draw smooth curves such as contour lines, and because of the use of the line of resampling, the smallest amount of data to ensure the accuracy of the drawing.

This paper is based on the author's 2002 Years of calculation method (Tongji University Press), the algorithm for the basis of the modified, because the time immemorial, here no longer describe what is the specific tension spline formula. Simply introduce the tension spline.

1 The question of the proposed

In the application of curve digitizing, or drawing curves, the curve is generally required to be smooth and through control points. In higher mathematics, there is a special term describing the continuity of the derivative. Here's an image metaphor: Take a strong, resilient steel wire and get a smooth curve that meets our requirements by fixing a series of points on the plank. When we put a huge pull on the 2 end of the wire, we can see that the wire is becoming less smooth at the fixed point until it becomes a folded segment. This force is tension. We use a coefficient to show that the tension coefficient f. The tension coefficient is the reciprocal of the tension, when the f=0, the maximum tension, the curve degenerated into a folding line. When F=1, basically similar to parabolic line. The more appropriate values are:

f=0.1666667

2 spline functions

On the spline function, I really forget the principle. Readers are asked to learn the principles of their own part. In practice, it is usually the method of piecewise fitting:

A spline function formula between P1,P2 can be determined by requiring the spline wire to pass through these 4 points, given the 4 fixed points on the board (P0,P1,P2,P3). According to this formula and a certain step steps, we can interpolate a series of points between the P1,p2 q1,q2,..., qn. By connecting these points in sequence, we get the spline curve which is fitted out by the fold segment. The smaller the step, the more the folded points are fitted, the nearer the true value of the curve. But the more data there is.

3 Sectional Fitting method

To point a series of fixed point p0,p1,p2,...,pn-3,pn-2,pn-1, sequentially sampling the above paragraph fitting method:

1) Fitting p0,p1,p2,p3 to get p1,p2 between the points: q11,q12,q13,..., q1m.

2) Fitting Q1M,P2,P3,P4 to get p2,p3 between the points: q21,q22,q23,..., q2n.

3) Fitting Q2N,P3,P4,P5 to get p3,p4 between the points: q31,q32,q33,..., q3w.

4) ...

According to the above method, has been fitted: pn-3,pn-2 between the points.

The above fitting points and the original control points form the fitting line of the whole function curve in order. Sampling this fitting method, the computation quantity is small, extremely easy to compile the program.

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.