Point3D - package raytracer.utility; public class Point3D {...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: package raytracer.utility; public class Point3D { public double x, y, z; // --------------------------------------------- default constructor public Point3D(){ x = y = z = 0; } // --------------------------------------------- constructor public Point3D(double a){ x = y = z = a; } // --------------------------------------------- constructor public Point3D(double a, double b, double c){ x = a; y = b; z = c; } // --------------------------------------------- copy constructor public Point3D(Point3D p){ this.x = p.x; this.y = p.y; this.z = p.z; } // ---------------------------------------------------------- assignment operator /** assignment operation * @param p point */ public void set (Point3D p) { if (this != p) { x = p.x; y = p.y; z = p.z; } } // --------------------------------------------- distance // distance between two points public double distance(Point3D p) { return (Math.sqrt( (x - p.x) * (x - p.x) + (y - p.y) * (y - p.y) + (z - p.z) * (z - p.z) )); } // -------------------------------------------------------------- operator- // unary minus public Point3D minus() { return new Point3D(-x, -y, -z); } // -------------------------------------------------------------- operator-...
View Full Document

Page1 / 4

Point3D - package raytracer.utility; public class Point3D {...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online