Showing posts with label Bezier. Show all posts
Showing posts with label Bezier. Show all posts

Tuesday, March 6, 2012

Program Java untuk Kurva Bezier dengan 3 Titik Kontrol

void GambarKurvaBezier3(Graphics Img, int x1, int y1, int x2, int y2, int x3, int y3)
{
    int Px,Py,Qx,Qy;
    Px=x1;
    Py=y1;

    for (float t=0;t<=1;t+=0.00001)
    {
        Qx = (int)((Math.pow((1-t),2)*x1) + (2*(1-t)*t*x2) + (Math.pow(t,2)*x3));
        Qy = (int)((Math.pow((1-t),2)*y1) + (2*(1-t)*t*y2) + (Math.pow(t,2)*y3));

        Garis(Img, Px,Py,Qx,Qy);
        Px=Qx;
        Py=Qy;
    }
    Garis(Img, Px,Py,x3,y3);
}
sumber : http://mohsodq1608.wordpress.com

Thursday, February 16, 2012

Program Java untuk Kurva Bezier dengan 4 Titik Kontrol

void GambarKurvaBezier4(Graphics Img, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
    {
        int Px,Py,Qx,Qy;
        Px=x1;
        Py=y1;


        for (float t=0;t<=1;t+=0.00001)
        {
            Qx = (int)((Math.pow((1-t),3)*x1) + (3*Math.pow((1-t),2)*t*x2) + (3*(1-t)*Math.pow(t,2)*x3) + (Math.pow(t,3)*x4));
            Qy = (int)((Math.pow((1-t),3)*y1) + (3*Math.pow((1-t),2)*t*y2) + (3*(1-t)*Math.pow(t,2)*y3) + (Math.pow(t,3)*y4));


            Garis(Img, Px,Py,Qx,Qy);
            Px=Qx;
            Py=Qy;
        }
        Garis(Img, Px,Py,x4,y4);
    }
sumber : http://mohsodq1608.wordpress.com

Program Java untuk Kurva Bezier dengan 5 Titik Kontrol

void GambarKurvaBezier5(Graphics Img, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, int x5, int y5)
        {
            int Px,Py,Qx,Qy;
            Px=x1;
            Py=y1;
            for (float t=0;t<=1;t+=0.00001)
        {
                Qx = (int)((Math.pow((1-t),4)*x1) + (4*Math.pow((1-t),3)*t*x2) + (6*Math.pow((1-t),2)*Math.pow(t,2)*x3) + (4*(1-t)*Math.pow(t,3)*x4) + (Math.pow(t,4)*x5));
                Qy = (int)((Math.pow((1-t),4)*y1) + (4*Math.pow((1-t),3)*t*y2) + (6*Math.pow((1-t),2)*Math.pow(t,2)*y3) + (4*(1-t)*Math.pow(t,3)*y4) + (Math.pow(t,4)*y5));
   
                Garis(Img, Px,Py,Qx,Qy);
                Px=Qx;
                Py=Qy;
            }
            Garis(Img, Px,Py,x5,y5);
        }

sumber : http://mohsodq1608.wordpress.com