שמע ישראל ה' אלהינו ה' אחד
فمن كان يرجوا لقاء ربه فليعمل عملا صالحا ولا يشرك بعبادة ربه أحدا


May 8, 2015

Bezier Curve

Posted By Snow at 5/08/2015

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◠)' ما شاء الله



0 comments on "Bezier Curve"


Welcome
Peace be upon you


Bat Zion

REMEMBER


קרן  .:💡:.  قرن
now in the cave
please forgive me if ever

Blog Archive




قربان

明 NIRVANA


يا غلام إني أعلمك كلمات
احفظ الله يحفظك
احفظ الله تجده تجاهك

إذا سألت فاسأل الله
وإذا استعنت فاستعن بالله

واعلم‏‏ أن الأمة لو اجتمعت
على أن ينفعوك بشيء
لم ينفعوك إلا بشيء
قد كتبه الله لك

وإن اجتمعوا
على أن يضروك بشيء
لم يضروك بشيء
إلا بشيء قد كتبه الله عليك

رفعت الأقلام وجفت الصحف



2009-2024 Lovely Memoirالحمد لله على نعمة الإسلام
Q Quran . SB Sahih Bukhari . SM Sahih Muslim . AD Abu Dawood . AN An Nasai . IM Ibn Majah . MM Muwatta Malik