Newer
Older
EPQ-3D-renderer / src / Point3D.java
@cory cory on 6 Nov 2022 678 bytes Implementation of:
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(
                (((fpdis*y)/z + .5)*scrX),
                (((fpdis*x)/z + .5)*scrY)
        );
    }
    public double[] get(){
        return new double[]{x, y, z};
    }
}