-
Notifications
You must be signed in to change notification settings - Fork 1
/
Sphere.h
69 lines (43 loc) · 1.19 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__
#include "GeometricObject.h"
class Sphere: public GeometricObject{
public:
Sphere(void);
Sphere(Point3D center, double r);
Sphere(const Sphere& sphere);
virtual Sphere* clone(void) const;
virtual ~Sphere(void);
Sphere& 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;
virtual bool shadow_hit(const Ray& ray, float& tmin) const;
virtual void set_color(float r, float g, float b);
virtual RGBColor get_color() const;
private:
Point3D center;
double radius;
static const double kEpsilon;
};
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;
}
inline void Sphere::set_color(float r, float g, float b) {
temp_color.r = r;
temp_color.g = g;
temp_color.b = b;
}
inline RGBColor Sphere::get_color() const {
return (temp_color);
}
#endif