Plane.cc

Go to the documentation of this file.
00001 
00005 #include "Plane.h"
00006 #include "HitRecord.h"
00007 #include "Math.h"
00008 #include "Ray.h"
00009 #include <iostream>
00010 #include <stdlib.h>
00011 using namespace std;
00012 
00013 Plane::Plane(Material* material, const Vector& normal, const Point& point)
00014   : Primitive(material), n(normal)
00015 {
00016   n.normalize();
00017   d = Dot(n, point);
00018 }
00019 
00020 Plane::~Plane()
00021 {
00022 }
00023 
00024 void Plane::intersect(HitRecord& hit, const RenderContext& context, const Ray& ray) const
00025 {
00026   double denom = Dot(n, ray.direction());
00027   if(Abs(denom) > 1.e-6){
00028     double t = (d-Dot(n, ray.origin()))/denom;
00029     hit.hit(t, this, matl);
00030   }
00031 }
00032 
00033 void Plane::normal(Vector& normal, const RenderContext&,
00034                    const Point&, const Ray&, const HitRecord&) const
00035 {
00036   normal = n;
00037 }
00038 
00039 void Plane::getBounds(BoundingBox& bbox) const
00040 {
00041   cerr <<  "Plane::getBounds() called!" << endl;
00042   exit( 1 );
00043 }
00044 

Generated on Tue Jan 29 21:34:53 2008 for specter by  doxygen 1.4.6