package uk.org.floop.epq3d; 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 Point3D(double[] xyz){ if(xyz.length != 3){ throw new RuntimeException("Point3D cannot be instantiated from != 3 points " + "(attempted: " + xyz.length + ")"); } x = xyz[0]; y = xyz[1]; z = xyz[2]; } public Point3D(){ x = 0; y = 0; z = 0; } 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 void translate(Vector3D trVec){ x += trVec.x; y += trVec.y; z += trVec.z; } public Point2D project(double fpdis, int scrX, int scrY){ return new Point2D( scrX - (int)(scrX*0.5*((fpdis*y)/(z) + 1)), (int)(scrX*0.5*((fpdis*x)/(z) + ((double)scrY/(double)scrX))) ); } public Point2D project(drawData drawData) { Point2D point = new Point2D(0,0); // draw Data.scrX - (int)(drawData.scrX*0.5*((drawData.FPDis*y)/(z) + 1)), // (int)(drawData.scrX*0.5*((drawData.FPDis*x)/(z) + ((double)drawData.scrY/(double)drawData.scrX))) point.x = drawData.scrX - (int)(drawData.scrX*0.5*((drawData.FPDis*y)/(z) + 1)); point.y = (int)(drawData.scrX*0.5*((drawData.FPDis*x)/(z) + ((double)drawData.scrY/(double)drawData.scrX))); point.z = z; if(Math.abs(point.x) > 5000 || Math.abs(point.y) > 5000){ int debug = 12; } return point; } public void projectOn(drawData drawData, Point2D point){ // this is a mess of random fixes because none of my coordinates are correct. :( // sorry point.x = drawData.scrX - (int)(drawData.scrX*0.5*((drawData.FPDis*y)/(z) + 1)); point.y = (int)(drawData.scrX*0.5*((drawData.FPDis*x)/(z) + ((double)drawData.scrY/(double)drawData.scrX))); point.z = z; } public double[] get(){ return new double[]{x, y, z}; } }