Import java.awt.*
Import javax.swing.*
public class gr3d4a extends gr3d1m {
/**
*<br> Method Description: Main method
*<br> input parameter:
*<br> return type:
*/
public static void Main (string[] args) {
gr3d4a G3 = New gr3d4a ();
}
/**
*<br> method Description: Builder
*<br> input parameters:
*<br> return type:
*/
Public gr3d4a () {
Sett Itle ("3D Cube Box");
Setdefaultcloseoperation (jframe.dispose_on_close);
Addmouselistener (this);
Addmousemotionlistener (this);
SetBackground (New Color (128,128,255));
SetSize (350,350);
Show ();
}
/**
*<br> Method Description: Draw a Cube box, overload the method in gr3d1m
*<br> input parameters:
*<br> return type:
*/
Public void Drawpg (Graphics g,double []x,double []y,
Double []z,int xp,int Yp,color Co) {
Double x1,y1,z0;< br> int len=x.length;
Double [] xw=new Double[len];
Double [] yw=new Double[len];
int [] xx=new int [Len];
Int []yy=new int [Len];
Final double rad=math.pi/180.0;
Double A=angx*rad;
Double B=angy*rad;
Double Sina=math.sin (a), Sinb=math.sin (b);
Double Cosa=math.cos (a), Cosb=math.cos (b);
for (int i=0; i<len; i++) {
x1= x[i]*cosb+z[i]*sinb;
Z0=-X[I]*SINB+Z[I]*COSB;
y1= Y[i]*cosa-z0*sina;
xx[i]=xp+ (int) math.rint (x1);
yy[i]=yp-(int) math.rint (y1);
Xw[i]=x1; yw[i]=y1;
}
if (Hvec (XW,YW) > 0) {
G.setcolor (CO);
G.fillpolygon (Xx,yy,len);//filled Polygon
}
}
/**
*<br> method Description: Shadow processing, if the plane is obscured will not be drawn
*<br> input parameters:
*<br> return Type:
*/
Double Hvec (double []x,double []y) {
Returns (x[0]* (y[1]-y[2)) +x[1]* (y[2]-y[0]) +x[2 ]* (y[0]-y[1]));
}
}