The spica renderer
sphere.h
1 #ifdef _MSC_VER
2 #pragma once
3 #endif
4 
5 #ifndef SPICA_SPHERE_H_
6 #define SPICA_SPHERE_H_
7 
8 #include "core/vector3d.h"
9 #include "core/ray.h"
10 
11 #include "core/shape.h"
12 
13 namespace spica {
14 
18 class SPICA_EXPORTS Sphere : public Shape {
19 public:
20  Sphere();
21  Sphere(const Point3d& center, double radius,
22  const Transform& objectToWorld = Transform());
23  Sphere(const Sphere& sphere);
24  ~Sphere();
25 
26  Sphere& operator=(const Sphere& sphere);
27 
28  bool intersect(const Ray& ray, double* tHit,
29  SurfaceInteraction* isect) const override;
30  bool intersect(const Ray& ray) const override;
31 
32  Interaction sample(const Point2d& rands) const override;
33  Interaction sample(const Interaction& isect,
34  const Point2d& rands) const override;
35 
36  double pdf(const Interaction& pObj, const Vector3d& wi) const override;
37 
38  Bounds3d objectBound() const override;
39 
40  double area() const override;
41 
42  std::vector<Triangle> triangulate() const override;
43 
44  inline Point3d center() const { return center_; }
45  inline double radius() const { return radius_; }
46 
47 private:
48  Point3d center_ = { 0.0, 0.0, 0.0 };
49  double radius_ = 0.0;
50 
51 }; // class Sphere
52 
53 } // namespace spica
54 
55 #endif // SPICA_SPHERE_H_
Sphere class.
Definition: sphere.h:18
Definition: interaction.h:68
Ray class.
Definition: ray.h:24
The transformation operator class.
Definition: transform.h:17
Definition: interaction.h:23
Abstract shape class.
Definition: shape.h:39