Path Tracer
Sphere.h
Go to the documentation of this file.
1 #ifndef DEF_SPHERE
2 #define DEF_SPHERE
3 
4 #include "Object3D.h"
5 
103 class Sphere : public Object3D {
104 private:
105  DoubleVec3D center;
106  double radius;
107 
108 public:
109  Sphere();
110  Sphere(const DoubleVec3D& center, double radius, Material* material);
111  Sphere(const Sphere& sphere);
112 
113  double getRadius() const;
114  DoubleVec3D getCenter() const; // virtual method
115 
116  void setCenter(const DoubleVec3D& center);
117  void setRadius(double radius);
118 
119  void computeArea();
120  Object3D* deepCopy() const;
121 
122  double smallestPositiveIntersection(const Ray& ray) const;
123  DoubleUnitVec3D getNormal(const DoubleVec3D& point) const;
124  DoubleVec3D getRandomPoint() const;
125  DoubleVec3D getMinCoord() const;
126  DoubleVec3D getMaxCoord() const;
127 
128  std::ostream& getDescription(std::ostream& stream) const;
129  std::string getType() const;
130  json getLocationJson() const;
131  void setLocationJson(const json& j);
132 };
133 
134 #endif
nlohmann::json json
Definition: InterfaceGestion.h:14
Defines the Object3D class and some functions around it.
A three-dimensional unit vector using doubles.
Definition: DoubleUnitVec3D.h:61
A three-dimensional vector using double values.
Definition: DoubleVec3D.h:190
Abstrat class that models a material.
Definition: Material.h:77
Abstract class for a three-dimentional object.
Definition: Object3D.h:121
Combination of an origin and a direction.
Definition: Ray.h:44
A sphere described by its center and its radius.
Definition: Sphere.h:103
DoubleVec3D getMinCoord() const
Returns the minimum coordinate of a cuboid containing this object.
Definition: Sphere.cpp:70
std::ostream & getDescription(std::ostream &stream) const
Returns this object's description.
Definition: Sphere.cpp:78
DoubleVec3D getMaxCoord() const
Returns the maximum coordinate of a cuboid containing this object.
Definition: Sphere.cpp:74
json getLocationJson() const
Converts this objects's location to json.
Definition: Sphere.cpp:87
double smallestPositiveIntersection(const Ray &ray) const
Computes the smallest positive intersection between the ray and this object.
Definition: Sphere.cpp:37
void setLocationJson(const json &j)
Sets this object's location according to json.
Definition: Sphere.cpp:92
void setCenter(const DoubleVec3D &center)
Setter for the center.
Definition: Sphere.cpp:26
Sphere()
Default constructor.
Definition: Sphere.cpp:4
void computeArea()
Computes this sphere's area.
Definition: Sphere.cpp:31
double getRadius() const
Getter for the radius.
Definition: Sphere.cpp:22
DoubleVec3D getCenter() const
Getter for the center.
Definition: Sphere.cpp:21
DoubleVec3D getRandomPoint() const
Computes a random point on the object.
Definition: Sphere.cpp:65
Object3D * deepCopy() const
Makes a deep copy of this object.
Definition: Sphere.cpp:33
DoubleUnitVec3D getNormal(const DoubleVec3D &point) const
Computes the normal at a point on the object.
Definition: Sphere.cpp:60
void setRadius(double radius)
Setter for the radius.
Definition: Sphere.cpp:27
std::string getType() const
Returns this object type.
Definition: Sphere.cpp:85