Download the source and code of the linear interpolation program with Visual Basic.NET (BezierSplines Cubic Splines vb.net)
Today, in this post, for you, dear users, we have prepared a source and code for a linear interpolation program with Visual Basic.NET ready for download.
This software is designed to support the algorithm calculation of x-y value curve positions, so that you can easily get any desired point in that drawn curve by drawing a BezierSpline with GDI+ (calling Graphics.DrawCurve(Points)).
A Bezier-Splines curve (brown), made by 7 support points, which divide the BezierSplines into 6 Bezier-Segments. 19 structure points that model the curve (orange). A "pointer curve" (red). It can be moved along the BezierSplines and its location is displayed, calculated by interpolating the BezierSplines.
How BezierSplines are made
Each segment between two support points is created as a BezierCurve with 4 construction points:
The two support points themselves and two additional points, which make sure that the Bezier degree that reaches the support point is the same as the Bezier degree. , which leaves the support point.
Now interpolate it
To get the Y value of an X position, I interpolate the BezierSplines in two steps:
First, I search for the Bezier-Segment that contains the X position. This is quickly done by a binary search:
Interpolating Bezier-Spline-Segments as a function Y = f(X) - is mathematically incorrect.
Although I keep the support points in "left to right" order, a segment can form where it represents more than one Y value at certain X positions.
My "append" ignores such cases and simply returns the first Y-Value.
The failure allows itself to be seen by some parts of the curve, which cannot be reached by interpolation.
It is mathematically correct to interpolate CubicSplines.
They are mathematically undefined only if two support points lie on the same X position (as a vertical line).
Polygon, cubic spline
While the interpolation of polygons is trivial, the same is - ahem - trivial in CubicSplines. There is no GDI+ - function that will draw it for you, so you have to deal with linear algebra to solve systems of linear equations - brrr! - I have done this without real understanding.