Axiom Game Engine | Bezier Curves | Bifurcation Diagram | Lorenz Attractor |
Sep 22: New beta version 4.0.2091 of Google Earth available which includes layer data for Japan.
Aug 28: Canon have released the latest EOS 400D digital SLR. I wish I had waited a bit before buying the EOS 300D!!
Mathematicians call the basis functions "Bernstein Polynomials." Bernstein was a mathematician, and Bezier worked for Renault, the French car company, and 'popularized' Bernstein's work for practical use. Hence his name is usually associated with the splines. They have many interesting mathematical and geometric properties; the following provides an introduction to just some of these.
Some of the categorisations are as follows :- Vertices and Nodes Graphics, Drawing (Diagrams, Flowcharts) Plotting 2D and 3D functions, Geometric Design
The Bernstein polynomials exist in all orders: linear, quadratic, cubic, quartic, and fifth order as demonstrated here. The ideas hold good for any order. To get the Bernstein basis functions, use a funny trick: Write the number 1 as 1 = t + (1-t), and raise 1 to the fifth power (for fifth order splines - for cubic you would raise it to the third power):
1 = 1^5 = (t + (1-t))^5 = t^5 + 5*t^4*(1-t) + 10*t^3*(1-t)^2 + 10*t^2*(1-t)^3 + 5*t*(1-t)^4 + (1-t)^5
Note - for the expansion I used
>yacas("Expand((t+y)^5)")
and then I substituted y=(1-t) to obtain the expansion in t.
The basis functions are the 6 terms:
B0(t) = t^5
B1(t) = 5*t^4*(1-t)
B2(t) = 10*t^3*(1-t)^2
B3(t) = 10*t^2*(1-t)^3
B4(t) = 5*t*(1-t)^4
B5(t) = (1-t)^5
Because of the way you got it, B0(t)+B1(t)+B2(t)+B3(t)+B4(t)+b5(t) = 1, for all t.
The next step is to plot these functions (between 0 and 1) to see what they look like. In Euler define t to take values between 0 and 1 in steps of 0.01
and n to take integer values from 0 to 5
>t=0:0.01:1;
>n=(0:5)';
The easiest way to define the basis functions is to use the Euler binomial function (bin) which calculates the binomial coefficients :
S=bin(5,n)*t^n*(1-t)^(5-n)
This is a polynomial function true for all values of t and n values between 0 and 5
Now all we have to do is use xplot to plot the functions to give us the polynomials for n=0 to n=5
xplot(t,S);
To use the Bernstein basis functions to make a spline, you need 4 "control points" (5 for quartic, 3 for quadratic, and so on). Let them be (x0,y0), (x1,y1), (x2,y2), (x3,y3). (They can also be in three dimensions, if you like.) The (cubic) Bezier spline with the four control points above is given by this equation:
(x0*B0(t)+x1*B1(t)+x2*B2(t)+x3*B3(t),y0*B0(t)+y1*B1(t)+y2*B2(t)+y3*B3(t))
where t varies between 0 and 1. This spline goes through (x0,y0) and (x3,y3), it's tangent at those points is the line connecting (x0,y0) to (x1,y1) and to the line connecting (x3,y3) to (x2,y2). Theshape of the curve is determined by the positions of (x1,y1) and (x2,y2). (Sometimes books use a different notation, and the numbers of the B0, B1, B2, and B3 are reversed. In other words, B0(t) = (1-t)^3, B1(t) = 3*t*(1-t)^2, and so on.)