import java.awt.*;
import java.awt.event.*;
class game0421 extends Frame implements Runnable{
double x,y,z;
double rx,ry;
double x1,x2,x3,y1,y2,y3;
double px[][][]=new double[2][2][2];
double py[][][]=new double[2][2][2];
int m1,m2,m3;
public static void main(String [] args) {
Frame f=new game0421();
f.setTitle("game0421");
f.setSize(700,700);
f.setBackground(Color.yellow);
f.setVisible(true);
}
game0421(){
for (m1=0;m1<2;m1++){
for (m2=0;m2<2;m2++){
for (m3=0;m3<2;m3++){
x=100+m1*100;
y=100+m2*100;
z=100+m3*100;
rot(x,y,z);
px[m1][m2][m3]=rx;
py[m1][m2][m3]=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 gx1,gy1,gx2,gy2;
gx1=seekgx(px[0][0][0]);
gy1=seekgy(py[0][0][0]);
gx2=seekgx(px[1][0][0]);
gy2=seekgy(py[1][0][0]);
g.drawLine(gx1,gy1,gx2,gy2);
gx1=seekgx(px[1][0][0]);
gy1=seekgy(py[1][0][0]);
gx2=seekgx(px[1][1][0]);
gy2=seekgy(py[1][1][0]);
g.drawLine(gx1,gy1,gx2,gy2);
gx1=seekgx(px[1][1][0]);
gy1=seekgy(py[1][1][0]);
gx2=seekgx(px[0][1][0]);
gy2=seekgy(py[0][1][0]);
g.drawLine(gx1,gy1,gx2,gy2);
gx1=seekgx(px[0][1][0]);
gy1=seekgy(py[0][1][0]);
gx2=seekgx(px[0][0][0]);
gy2=seekgy(py[0][0][0]);
g.drawLine(gx1,gy1,gx2,gy2);
}
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:45