Plane - } //...

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

View Full Document Right Arrow Icon
package raytracer.geometricObjects; import raytracer.utility.*; public class Plane extends GeometricObject { private Point3D a; // point through which plane passes private Normal n; // normal to the plane private static final double kEpsilon = 0.001; // for shadows and secondary rays // ---------------------------------------------------------------------- default constructor public Plane() { super(); a = new Point3D(0.0); n = new Normal(0, 1, 0); } // ---------------------------------------------------------------------- constructor public Plane(Point3D point, Normal normal) { super(); a = new Point3D(point); n = new Normal(normal); n.normalize(); } // ---------------------------------------------------------------- copy constructor public Plane(Plane plane) { super(plane); a = new Point3D(plane.a); n = new Normal(plane.n); } // ---------------------------------------------------------------- clone public GeometricObject clone() { return (new Plane(this));
Background image of page 1

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

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

Unformatted text preview: } // ---------------------------------------------------------------- assignment operator public void set (Plane rhs) { if (this != rhs) { super.set(rhs); a.set(rhs.a); n.set(rhs.n); } } // ----------------------------------------------------------------- hit // textbook has it return a boolean // we altered it here so it returns tmin // hit returns a -1 if no hit // hit returns a number > 0 if hit public double hit(Ray ray, ShadeRec sr) { double t = ((a.subtract(ray.o)).dot(n)) / ((ray.d.dot(n))); if (t > kEpsilon) { sr.normal = n; sr.local_hit_point = ray.o.add(ray.d.multiply(t)); return t; } return -1; } public boolean equals(Object obj) { if (obj == null || this.getClass() != obj.getClass()) { return false; } else { Plane other = (Plane)obj; return (super.equals(obj) && a.equals(other.a) && n.equals(other.n)); } } public String toString() { return color + "plane through " + a + " with " + n; } }...
View Full Document

Page1 / 2

Plane - } //...

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