Main Page | Class Hierarchy | Class List | File List | Class Members

sphere.h

00001 /* ************************************************************************* 00002 sphere.h - description 00003 ------------------- 00004 begin : Wed Oct 16 2002 00005 copyright : (C) 2002 by Micha Riser 00006 email : mriser@gmx.net 00007 00008 $Id: sphere_8h-source.html,v 1.1 2005/02/04 21:02:27 micha Exp $ 00009 00010 ************************************************************************* */ 00011 00012 /* ************************************************************************* 00013 * * 00014 * This program is free software; you can redistribute it and/or modify * 00015 * it under the terms of the GNU General Public License as published by * 00016 * the Free Software Foundation; either version 2 of the License, or * 00017 * (at your option) any later version. * 00018 * * 00019 ************************************************************************* */ 00020 00021 #ifndef SPHERE_H 00022 #define SPHERE_H 00023 00024 //#define SPHERE_STORE_RSQ 00025 00026 #include "object3d.h" 00027 #include "intersection.h" 00028 00033 class Sphere: public Object3D { 00034 00035 public: // Constructors and destructor 00036 00040 Sphere(DBL r): radius(r) 00041 #ifdef SPHERE_STORE_RSQ 00042 , radiussq(r*r) 00043 #endif 00044 {} 00045 00046 00051 Sphere(DBL r, Vector3 l): Object3D(l), radius(r) 00052 #ifdef SPHERE_STORE_RSQ 00053 , radiussq(r*r) 00054 #endif 00055 {} 00056 00057 public: // Pulblic methods 00058 00059 // Inherited from Object3D 00060 Object3D* duplicate() const {return new Sphere(*this);} 00061 00062 void rotateRad(const Vector3& v); 00063 void rotateDeg(const Vector3& v); 00064 void scale(const Vector3& v); 00065 Intersection* intersectLocal(const Ray &r) const; 00066 Intersection* intersectLocalLimitedTime(const Ray &r, DBL maxtime) const; 00067 bool isInsideAt(const Vector3 &locallocation) const; 00068 00069 bool hasFinitBounding() const; 00070 Vector3 getBoundingMin() const; 00071 Vector3 getBoundingMax() const; 00072 PatchObject* toPatch(double precision) const; 00073 00074 private: // Static members 00075 static HitStatistics stat; 00076 00077 private: // Private attributes 00078 DBL radius; 00079 #ifdef SPHERE_STORE_RSQ 00080 DBL radiussq; 00081 #endif 00082 00083 private: // Private methods 00084 void calculateBoundingBox(); 00085 Vector3 point(double angle1, double angle2) const; 00086 00087 private: // Inner classes 00088 00091 class SphereIntersection: public Intersection { 00092 00093 private: // Private attributes 00094 DBL currenttime; 00095 DBL secondtime; 00096 00097 public: // Constructor and destructor 00098 SphereIntersection(const Object3D* o, const Ray &r, DBL t1, DBL t2): 00099 Intersection(o,r), currenttime(t1), secondtime(t2) {} 00100 00101 public: // Pulblic methods 00102 00103 //Inherited from Intersection 00104 DBL currentTime() {return currenttime;} 00105 void next(); 00106 Vector3 normal(); 00107 00108 }; 00109 00110 }; 00111 00112 #endif

Generated on Thu Jan 27 12:16:06 2005 for raytracer.kdevelop by doxygen 1.3.8