{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Triangle - package raytracer.geometricObjects import...

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

View Full Document Right Arrow Icon
package raytracer.geometricObjects; import raytracer.utility.*; //this is the triangle discussed in Section 19.3 public class Triangle extends GeometricObject { private Point3D v0, v1, v2; private Normal normal; // ---------------------------------------------------------------- default constructor public Triangle(){ super(); v0 = new Point3D(0,0,0); v1 = new Point3D(0,0,1); v2 = new Point3D(1,0,0); normal = new Normal(0,1,0); } // ---------------------------------------------------------------- constructor public Triangle (Point3D a, Point3D b, Point3D c){ super(); v0 = new Point3D(a); v1 = new Point3D(b); v2 = new Point3D(c); compute_normal(); } // ---------------------------------------------------------------- copy constructor public Triangle (Triangle triangle){ super(triangle); v0 = new Point3D(triangle.v0); v1 = new Point3D(triangle.v1); v2 = new Point3D(triangle.v2); normal = new Normal(triangle.normal); } // ---------------------------------------------------------------- clone public Triangle clone() { return (new Triangle(this)); } // ---------------------------------------------------------------- assignment operator public void set(Triangle rhs) { if (this != rhs) { super.set(rhs); v0.set(rhs.v0); v1.set(rhs.v1); v2.set(rhs.v2); normal.set(rhs.normal);
Background image of page 1

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

View Full Document Right Arrow Icon
} } // ---------------------------------------------------------------- compute_normal protected void compute_normal() { normal = new Normal((v1.subtract(v0)).cross(v2.subtract(v0))); normal.normalize(); } /* public BBox get_bounding_box() { double delta = 0.000001; return (new BBox(Math.min(Math.min(v0.x, v1.x), v2.x) - delta,
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}