-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sphere.h
69 lines (44 loc) · 1.38 KB
/
Sphere.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef __SPHERE__
#define __SPHERE__
// This file contains the declaration of the class Sphere
#include "GeometricObject.h"
//-------------------------------------------------------------------------------- class Sphere
class Sphere: public GeometricObject {
public:
Sphere(void); // Default constructor
Sphere(Point3D center, double r); // Constructor
Sphere(const Sphere& sphere); // Copy constructor
virtual Sphere* // Virtual copy constructor
clone(void) const;
virtual // Destructor
~Sphere(void);
Sphere& // assignment operator
operator= (const Sphere& sphere);
void
set_center(const Point3D& c);
void
set_center(const double x, const double y, const double z);
void
set_radius(const double r);
virtual bool
hit(const Ray& ray, double& t, ShadeRec& s) const;
private:
Point3D center; // center coordinates as a point
double radius; // the radius
static const double kEpsilon; // for shadows and secondary rays
};
inline void
Sphere::set_center(const Point3D& c) {
center = c;
}
inline void
Sphere::set_center(const double x, const double y, const double z) {
center.x = x;
center.y = y;
center.z = z;
}
inline void
Sphere::set_radius(const double r) {
radius = r;
}
#endif