00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#ifndef SPHERE_H
00022
#define SPHERE_H
00023
00024
00025
00026
#include "object3d.h"
00027
#include "intersection.h"
00028
00033 class Sphere:
public Object3D {
00034
00035
public:
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:
00058
00059
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:
00075 static HitStatistics stat;
00076
00077 private:
00078 DBL radius;
00079 #ifdef SPHERE_STORE_RSQ
00080 DBL radiussq;
00081 #endif
00082
00083 private:
00084
void calculateBoundingBox();
00085
Vector3 point(
double angle1,
double angle2) const;
00086
00087 private:
00088
00091 class SphereIntersection: public
Intersection {
00092
00093
private:
00094 DBL currenttime;
00095 DBL secondtime;
00096
00097
public:
00098 SphereIntersection(
const Object3D* o,
const Ray &r, DBL t1, DBL t2):
00099 Intersection(o,r), currenttime(t1), secondtime(t2) {}
00100
00101
public:
00102
00103
00104 DBL currentTime() {
return currenttime;}
00105
void next();
00106
Vector3 normal();
00107
00108 };
00109
00110 };
00111
00112
#endif