Curve beauty (1) Bezier curve

xiaoxiao2021-03-06  41

When graphic image programming, we often need to determine a smooth curve according to a series of known point coordinates. Some curves need to be strictly through all known points, while some curves do not necessarily need. In the latter, a relatively representative curve is a Bézier SPlines.

Netizens may notice that the Bezier curve is widely used in many graphics image software, such as Flash, Illstrator, Coraldraw and Photoshop, and more. What is the Bezier curve? Let's take a look at this:

Hey ~ a very ordinary curve, it seems that I can't bring us a special feeling ~ The curve and draw it, put it, put it together, then look at it:

Hoho, the original, the Bezier curve is such a curve, which is a smooth curve that is made according to any of the four positions. We may wish to define these four-to-known coordinates (X0, Y0), (x1, y1), (x2, y2) and (x3, y3). The Bezier curve must pass the first end, called endpoints; although the middle two points may not pass, but it acts as a role of the shape path of the curve.

In history, the person who studies the Bessel curve is initially identified in accordance with known curve parameters equations to determine the idea of ​​four points to design such vector curve drawing. In order to introduce you to the formula of the Bessel curve, it is also intentionally to put the knowledge of the problem and reverse the position: If a curve is known, the coefficient is known, and the two equations contain one The parameter t, its value is between 0, 1, and the expression is as follows:

X (t) = AX * T ^ 3 bx * t ^ 2 CX * T X0

Y (t) = ay * t ^ 3 by * t ^ 2 cy * t Y0

Since the starting point (X0, Y0) of this curve is known, we can use the following formulas to see the coordinates of the remaining three points:

X1 = X0 CX / 3

X2 = x1 (CX BX) / 3

X3 = X0 CX BX AX

Y1 = Y0 CY / 3

Y2 = Y1 (CY by) / 3

Y3 = Y0 CY by ay

You will be carefully observed, no matter what the understanding of the equation, there are always six unknown numbers, and we can always find six equations (remember (X0, Y0) always known) That is to say, the above method is completely reversible, so we can reflect the coefficient of the curve parameter formula according to four known point coordinates. A slight change has got the following formula:

CX = 3 * (x1 - x0)

BX = 3 * (x2 - x1) - CX

AX = x3 - x0 - cx - bx

CY = 3 * (Y1 - Y0)

BY = 3 * (Y2 - Y1) - CY

AY = Y3 - Y0 - CY - by

So, for the four known points of coordinates, you can always create a Bessel curve. In the 2D graphics library of GDI , the drawing method of the Bessel curve has been encapsulated - the Drawbezier () method of the Graphics class. Drawbezier () method has many overload versions, very simple, and

There is a detailed introduction in MSDN, and 淌 淌 不 水 水 水 水. 水 水 水 水 水 水 水 水 水 水 水 水 水 (). It is necessary to sigh, strong GDI allows people who don't know the mathematical background of Bezier curve to draw a beautiful Bessel curve, which is of course a good thing for raising development efficiency! The interest of the Bessel curve is more in its "gluten effect" ~ that is, as the point is regularly moved, the curve will generate the same transformation, bring a visual impact. Come, look this picture.

:

Windows default screensaver has a "Bezier Curve" program, you can now open it. A group of unchanging curves to watch people sighing their changing, in fact, the truth is quite simple, only a group of points in the program, moving according to the law, the machine moves according to the point, according to the above The formula calculates the current Bessel curve in real time, and draws it on the computer screen, so that it is endless ...

In the 1970s,

French mathematician Pierre Bézier's first method of studying this vector drawing curve, and gives a detailed calculation formula, so use his last name to name it in the curve drawn in this formula ~ is for the Bezier curve .

The opening of the article I mentioned that there is a class of curves that must be strictly through all known points, typically distinctly to the Bessel curve. This type of curve will take up the space of other network logs to you, please wait patiently.

!

转载请注明原文地址:https://www.9cbs.com/read-54653.html

New Post(0)