When you wanna draw a curve, you want something like this right... And the computer draws it for you - using math. Like this curve, it is drawn using the Bezier function. Bezier is one of the many math functions that can be used, each with its own way to draw a curve.

So when the computer draws a curve, it basically plots points ★ on your screen's display grid. First, you set the controls ❤ to control how the curve looks like. Then the math figures out where to plot points which make up the curve. | what is display grid

And... steady ya'all... here's the math equation to figure that out. OK Pierre Bezier worked out that math equation - that's why we call it the Bezier. So others simply turn that into code, to program the computer to do the math stuffs. An walla, here's the math turned into code (HTML JavaScript):

**function facto (number)**

{ fac = 1;

for (f=1; f<=number; f++) fac*=f;

return fac;

}

**function blend (u, i)**

{ return facto(nctrls) / (facto(i) * facto(nctrls-i)) * Math.pow(u,i) * Math.pow((1-u),(nctrls-i));

}

**function drawbeziercurve ()**

{ for (np = 0; np < npoints; np++) // from first point (P1) to last point (Pn)

{ x = 0; y = 0;

u = np / (npoints - 1);

for (i=0; i < nctrls; i++) // get point's coordinate (x,y)

{ x += blend(u,i) * c[i].x;

y += blend(u,i) * c[i].y;

}

document.write ("<div style='left:" + x + "; top:" + y + ";'>★</div>"); // plot point at (x,y)

}

}

An example of Bezier surface modelling (using OpenGL)

And when we can draw a curve on a computer, we can draw so many things! Like these things below. This can help people design homes, planes; or terrains, cities; or model the human body for medical purposes. There's so many things you can do when you can visualize things on the computer.

So this goes to show, some people did go to university with a purpose. So cheer up Malaysia, some people exists. And cheer up Snow, destiny for you - is beautiful. (◠v◠)' ما شاء الله

Curve Control | Computer Graphic | Space | Visible Invisible | Beautiful |

## 0 comments on "Bezier Curve"

Post a Comment