martes, 15 de noviembre de 2016

Bezier Java

import java.awt.*;
import javax.swing.JFrame;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.lang.*;

class tresD extends  Frame {

 public tresD()
       {
        this.setTitle("Bezier");
     this.setSize(400,400);
        this.setBackground(Color.white);
     this.setVisible(true);
    }

 public static void main (String[] args) {
   new tresD();
 }

public  void paint(Graphics g){

double  x,y,z,xp,yp;
double s,t;

    for( s=0; s
        for( t=0; t


//            x=((Math.pow(1-s,2))*(-t*(1-t)))+
//              ((Math.pow(1-t,2))+((2*t*(1-t))+(Math.pow(t,2)))*(2*s*(1-s)))+
//              (((2*Math.pow(1-t,2))+(4*t*(1-t))+(2*Math.pow(t,2)))*Math.pow(s,2));
//            y=((2*t*(1-t))+(2.5*Math.pow(t,2))*(Math.pow(1-s,2)))+
//              ((2*t*(1-t))+(2.5*Math.pow(t,2))*(2*s*(1-s)))+
//              ((2*t*(1-t))+(2*Math.pow(t,2))*(Math.pow(s,2)));    
//            z=((Math.pow(1-s,2))*((Math.pow(1-t,2))+(4*t*(1-t))))+
//              ((2*s*(1-s))*((2*Math.pow(1-t,2))+(6*t*(1-t))+(2*Math.pow(t,2))))+
//              ((Math.pow(s,2))*(4*t*(1-t)));

    x= -t*(1-t)*(Math.pow((1-s),2)) + (2*s)*(1-s)*( Math.pow((1-t),2) + (2*t)*(1-t)  + (Math.pow(t,2) ) ) + Math.pow(s,2)*(  2*Math.pow((1-t),2) + (4*t)*(1-t) + 2*(Math.pow(t,2)));//200* Math.cos(Math.toRadians(j))*Math.cos(Math.toRadians(i));
    y= Math.pow((1-s),2)*(2*t*(1-t) + 2.5*Math.pow(t,2)) + 2*s*(1-s)*(2*t*(1-t) + 2.5*Math.pow(t,2)) + Math.pow(s,2)*( 2*t*(1-t) /*+ 2*Math.pow(t,2) */);           //200*Math.sin(Math.toRadians(j)); //sii
    z= Math.pow((1-s),2)*(Math.pow((1-t),2) + 4*t*(1-t)) + 2*s*(1-s)*(2*(Math.pow((1-t),2)) + 6*t*(1-t) + 2*Math.pow(t,2)) + Math.pow(s,2)*(4*t*(1-t));                              //-200*Math.cos(Math.toRadians(j))*Math.sin(Math.toRadians(i));


               xp=x+(z*0.45*Math.cos(Math.toRadians(45)));
            yp=y+(z*0.45*Math.sin(Math.toRadians(45)));

    

            //pinta vertices
            g.fillOval(200 + (int)xp*40, 200 -(int)yp*40,4,4);    
        }
     }
 }
}

No hay comentarios:

Publicar un comentario