import java.awt.Graphics; import java.awt.Point; import java.lang.Math; public class Vertex { static double rad = Math.PI/180.0; double init_x,init_y,init_z; public double x,y,z; Point s=new Point(0,0); public Vertex() { init_x=init_y=init_z=0.0; x=y=z=0.0; } public Vertex(int ix,int iy,int iz) { init_x = x = (double)ix; init_y = y = (double)iy; init_z = z = (double)iz; } public void resetTransformations() { x = init_x; y = init_y; z = init_z; } public void move(double xd,double yd,double zd) { x+=xd; y+=yd; z+=zd; } public void rotate(double xa,double ya,double za) { double txa,tya,tza; double tSin,tCos; double tx,ty,tz; txa=xa*rad; tya=ya*rad; tza=za*rad; //rotate along Z axis tSin=Math.sin(tza); tCos=Math.cos(tza); tx = x*tCos - y*tSin; ty = x*tSin + y*tCos; x=tx; y=ty; //rotate along Y axis tSin=Math.sin(tya); tCos=Math.cos(tya); tx = x*tCos - z*tSin; tz = x*tSin + z*tCos; x=tx; z=tz; //rotate along X axis tSin=Math.sin(txa); tCos=Math.cos(txa); ty = y*tCos - z*tSin; tz = y*tSin + z*tCos; y=ty; z=tz; } public void scale(double xfactor,double yfactor,double zfactor) { x *= xfactor; y *= yfactor; z *= zfactor; } public void scale(double factor) { x *= factor; y *= factor; z *= factor; } public void project(int x_origin,int y_origin, double xZoom,double yZoom) { if(z<=0) return; s.x = (int)(( x*xZoom ) / z) + x_origin; s.y = (int)((-y*yZoom ) / z) + y_origin; } public int getx() { return(s.x); } public int gety() { return(s.y); } public Point getp() { return(s); } public void paint(Graphics g) { g.drawRect(s.x,s.y,1,1); } }