public class Point3D { public double x; public double y; public double z; public Point3D(double _x, double _y, double _z){ x = _x; y = _y; z = _z; } public void set(double[] _new){ x = _new[0]; y = _new[1]; z = _new[2]; } public void translate(Point3D trVec){ x += trVec.x; y += trVec.y; z += trVec.z; } public Point2D project(double fpdis, int scrX, int scrY){ return new Point2D( (int)(((fpdis*y)/(z) + .5)*scrX), (int)(((fpdis*x)/(z) + .5)*scrY) // multiply by scrX both times such that the projected screen always projects points between -1<x<1. // this means that there isn't any weird scaling, and the FOV is in terms of horizontal.. ness. ); } public void projectOn(double fpdis, int scrX, int scrY, Point2D point){ // this is a mess of random fixes because none of my coordinates are correct. :( // sorry point.x = scrX - (int)(scrX*0.5*((fpdis*y)/(z) + 1)); point.y = (int)(scrX*0.5*((fpdis*x)/(z) + ((double)scrY/(double)scrX))); } public double[] get(){ return new double[]{x, y, z}; } }