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

0 comments:

Post a Comment