import java.awt.*;
import java.awt.event.*;
class game0420 extends Frame implements Runnable{
double x,y,z;
double rx,ry;
double x1,x2,x3,y1,y2,y3;
public static void main(String [] args) {
Frame f=new game0420();
f.setTitle("game0420");
f.setSize(700,700);
f.setBackground(Color.blue);
f.setVisible(true);
}
game0420(){
x=500;
y=0;
z=0;
rot(x,y,z);
x1=rx;
y1=ry;
x=0;
y=500;
z=0;
rot(x,y,z);
x2=rx;
y2=ry;
x=0;
y=0;
z=500;
rot(x,y,z);
x3=rx;
y3=ry;
Thread th=new Thread(this);
th.start();
addWindowListener(new stopwin());
}
class stopwin extends WindowAdapter{
public void windowClosing(WindowEvent we){System.exit(0);}
}
public void run(){
int t;
t=1;
while(t<100){
repaint();
try{
Thread.sleep(1000);
}catch(InterruptedException e){}
t=t+1;
}
repaint();
}
public void paint(Graphics g){
int gx,gy;
gx=seekgx(x1);
gy=seekgy(y1);
g.drawLine(100,400,gx,gy);
gx=seekgx(x2);
gy=seekgy(y2);
g.drawLine(100,400,gx,gy);
gx=seekgx(x3);
gy=seekgy(y3);
g.drawLine(100,400,gx,gy);
}
public int seekgx(double x){
return (int)(100+x);
}
public int seekgy(double y){
return (int)(400-y);
}
public void rot(double x,double y,double z){
double theta,phi;
double a1,a2,a3,a4;
theta = -40*Math.PI/180;
phi=60*Math.PI/180;
a1=Math.cos(theta);
a2=Math.sin(theta);
a3=Math.cos(phi);
a4=Math.sin(phi);
rx=-a2*x+a1*y;
ry=-a1*a4*x-a2*a3*y+a4*z;
}
}
最終更新:2011年02月22日 09:21