Path Tracer
Triangle.h
Go to the documentation of this file.
1 #ifndef DEF_TRIANGLE
2 #define DEF_TRIANGLE
3 
4 #include "Object3D.h"
5 
119 class Triangle : public Object3D {
120 private:
121  DoubleVec3D vertex0, vertex1, vertex2;
122 
123 public:
124  Triangle();
125  Triangle(const DoubleVec3D& vertex0, const DoubleVec3D& vertex1, const DoubleVec3D& vertex2, Material* material);
126  Triangle(const Triangle& triangle);
127 
128  DoubleVec3D getVertex0() const;
129  DoubleVec3D getVertex1() const;
130  DoubleVec3D getVertex2() const;
131  DoubleVec3D getCenter() const; // virtual method
132 
133  void setVertex0(const DoubleVec3D& vertex);
134  void setVertex1(const DoubleVec3D& vertex);
135  void setVertex2(const DoubleVec3D& vertex);
136 
137  void computeArea();
138  Object3D* deepCopy() const;
139 
140  double smallestPositiveIntersection(const Ray& ray) const;
141  DoubleUnitVec3D getNormal(const DoubleVec3D& point) const;
142  DoubleVec3D getRandomPoint() const;
143  DoubleVec3D getMinCoord() const;
144  DoubleVec3D getMaxCoord() const;
145 
146  std::ostream& getDescription(std::ostream& stream) const;
147  std::string getType() const;
148  json getLocationJson() const;
149  void setLocationJson(const json& j);
150 };
151 
152 #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 triangle defined by its three vertices.
Definition: Triangle.h:119
void computeArea()
Computes this triangle's area.
Definition: Triangle.cpp:36
Object3D * deepCopy() const
Makes a deep copy of this object.
Definition: Triangle.cpp:42
void setVertex0(const DoubleVec3D &vertex)
Setter for the first vertex.
Definition: Triangle.cpp:30
DoubleVec3D getRandomPoint() const
Computes a random point on the object.
Definition: Triangle.cpp:74
std::ostream & getDescription(std::ostream &stream) const
Returns this object's description.
Definition: Triangle.cpp:98
DoubleVec3D getVertex0() const
Getter for the first vertex.
Definition: Triangle.cpp:20
void setLocationJson(const json &j)
Sets this object's location according to json.
Definition: Triangle.cpp:113
DoubleVec3D getMaxCoord() const
Returns the maximum coordinate of a cuboid containing this object.
Definition: Triangle.cpp:90
DoubleVec3D getMinCoord() const
Returns the minimum coordinate of a cuboid containing this object.
Definition: Triangle.cpp:82
DoubleVec3D getCenter() const
Getter for the center.
Definition: Triangle.cpp:24
DoubleVec3D getVertex2() const
Getter for the third vertex.
Definition: Triangle.cpp:22
Triangle()
Default constructor.
Definition: Triangle.cpp:4
std::string getType() const
Returns this object type.
Definition: Triangle.cpp:105
DoubleVec3D getVertex1() const
Getter for the second vertex.
Definition: Triangle.cpp:21
json getLocationJson() const
Converts this objects's location to json.
Definition: Triangle.cpp:107
double smallestPositiveIntersection(const Ray &ray) const
Computes the smallest positive intersection between the ray and this object.
Definition: Triangle.cpp:46
DoubleUnitVec3D getNormal(const DoubleVec3D &point) const
Computes the normal at a point on the object.
Definition: Triangle.cpp:67
void setVertex2(const DoubleVec3D &vertex)
Setter for the third vertex.
Definition: Triangle.cpp:32
void setVertex1(const DoubleVec3D &vertex)
Setter for the second vertex.
Definition: Triangle.cpp:31