import java.awt.*;
import java.awt.event.*;
import java.awt.Graphics;
class
pro extends Frame {
public static void main(String [] args) {
Frame f=[[new]] pro();
f.setTitle("pro");
f.setSize(700,700);
f.setBackground(Color.yellow);
f.setVisible(true);
}
pro(){addWindowListener(new stopwin());}
class stopwin extends WindowAdapter{
public void windowClosing(WindowEvent we){System.exit(0);}
}
public void paint(Graphics g){
int x1,y1,z1;
int px,py;
int x[]=new int[3];
int y[]=new int[3];
x1=0;
y1=0;
z1=500;
px=pointx(x1,y1,z1);
py=pointy(x1,y1,z1);
g.drawLine(
100,600,100+px,600-py);
x1=500;
y1=0;
z1=0;
px=pointx(x1,y1,z1);
py=pointy(x1,y1,z1);
g.drawLine(100,600,100+px,600-py);
x1=0;
y1=500;
z1=0;
px=pointx(x1,y1,z1);
py=pointy(x1,y1,z1);
g.drawLine(100,600,100+px,600-py);
g.setColor(Color.red);
x[0]=600;
x[1]=500;
x[2]=300;
y[0]=100;
y[1]=200;
y[2]=300;
g.fillPolygon(x,y,3);
}
public static int pointy(double x,double y,double z){
int p2;
double theta,phi;
theta=-0.222222*Math.PI;
phi=0.333333*Math.PI;
p2=(int)(-Math.cos(theta)*Math.cos(phi)*x-Math.sin(theta)*Math.cos(phi)*y+Math.sin(phi)*z);
return p2;
}
public static int pointx(double x,double y,double z){
int p1;
double theta;
theta=-0.222222*Math.PI;
p1=(int)(-Math.sin(theta)*x+Math.cos(theta)*y);
return p1;
}
}
最終更新:2010年09月24日 23:03