|
Path Tracer
|
A triangle defined by its three vertices. More...
#include <Triangle.h>
Public Member Functions | |
| Triangle () | |
| Default constructor. More... | |
| Triangle (const DoubleVec3D &vertex0, const DoubleVec3D &vertex1, const DoubleVec3D &vertex2, Material *material) | |
| Main constructor. More... | |
| Triangle (const Triangle &triangle) | |
| Copy constructor. More... | |
| DoubleVec3D | getVertex0 () const |
| Getter for the first vertex. More... | |
| DoubleVec3D | getVertex1 () const |
| Getter for the second vertex. More... | |
| DoubleVec3D | getVertex2 () const |
| Getter for the third vertex. More... | |
| DoubleVec3D | getCenter () const |
| Getter for the center. More... | |
| void | setVertex0 (const DoubleVec3D &vertex) |
| Setter for the first vertex. More... | |
| void | setVertex1 (const DoubleVec3D &vertex) |
| Setter for the second vertex. More... | |
| void | setVertex2 (const DoubleVec3D &vertex) |
| Setter for the third vertex. More... | |
| void | computeArea () |
| Computes this triangle's area. More... | |
| Object3D * | deepCopy () const |
| Makes a deep copy of this object. More... | |
| double | smallestPositiveIntersection (const Ray &ray) const |
| Computes the smallest positive intersection between the ray and this object. More... | |
| DoubleUnitVec3D | getNormal (const DoubleVec3D &point) const |
| Computes the normal at a point on the object. More... | |
| DoubleVec3D | getRandomPoint () const |
| Computes a random point on the object. More... | |
| DoubleVec3D | getMinCoord () const |
| Returns the minimum coordinate of a cuboid containing this object. More... | |
| DoubleVec3D | getMaxCoord () const |
| Returns the maximum coordinate of a cuboid containing this object. More... | |
| std::ostream & | getDescription (std::ostream &stream) const |
| Returns this object's description. More... | |
| std::string | getType () const |
| Returns this object type. More... | |
| json | getLocationJson () const |
| Converts this objects's location to json. More... | |
| void | setLocationJson (const json &j) |
| Sets this object's location according to json. More... | |
Public Member Functions inherited from Object3D | |
| Object3D () | |
| Default constructor. More... | |
| Object3D (Material *material) | |
| Main constructor. More... | |
| Object3D (const Object3D &obj) | |
| Copy constructor. More... | |
| ~Object3D () | |
| Destructor. More... | |
| Material * | getMaterial () const |
| Getter for the Material. More... | |
| double | getArea () const |
| Getter for this object's area. More... | |
| void | setMaterial (Material *material) |
| Setter for the Material. More... | |
| Object3D & | operator= (const Object3D &otherObject) |
| Assignment operator. More... | |
Additional Inherited Members | |
Protected Attributes inherited from Object3D | |
| double | area |
| Stores the area of this object. More... | |
A triangle defined by its three vertices.
The order of its vertices is important. See the main constructor for more information.
| Triangle::Triangle | ( | ) |
Default constructor.
Calls Object3D::Object3D(), then defines vertex0 = (1, 0, 0), vertex1 = (0, 1, 0) and vertex2 = (0, 0, 1).
| Triangle::Triangle | ( | const DoubleVec3D & | vertex0, |
| const DoubleVec3D & | vertex1, | ||
| const DoubleVec3D & | vertex2, | ||
| Material * | material | ||
| ) |
Main constructor.
The order of the vertices is important, because the normal is only on one side of the triangle (meaning that the triangle can only be seen from one side). Give the vertices counterclockwise from where you want the triangle to be visible.
| vertex0 | The first vertex of this triangle. |
| vertex1 | The second vertex of this triangle. |
| vertex2 | The third vertex of this triangle. |
| material | A pointer to the material of this triangle. |
| Triangle::Triangle | ( | const Triangle & | triangle | ) |
Copy constructor.
| triangle | The triangle that will be copied. |
|
virtual |
Computes this triangle's area.
Modifies Object3D::area. It uses the formula A = 0.5 * ||edge1 x edge2||, with edge1 = vertex1 - vertex0 and edge2 = vertex2 - vertex0.
Implements Object3D.
|
virtual |
Makes a deep copy of this object.
Implements Object3D.
|
virtual |
|
virtual |
Returns this object's description.
| stream | The current stream. |
Implements Object3D.
|
virtual |
Converts this objects's location to json.
Implements Object3D.
|
virtual |
Returns the maximum coordinate of a cuboid containing this object.
For each axis, picks the greatest coordinate among the three vertices.
Implements Object3D.
|
virtual |
Returns the minimum coordinate of a cuboid containing this object.
For each axis, picks the smallest coordinate among the three vertices.
Implements Object3D.
|
virtual |
Computes the normal at a point on the object.
| point | The point on the object at which we want to compute the normal. |
Implements Object3D.
|
virtual |
Computes a random point on the object.
Every point has the same probability to show up.
Implements Object3D.
|
virtual |
| DoubleVec3D Triangle::getVertex0 | ( | ) | const |
Getter for the first vertex.
| DoubleVec3D Triangle::getVertex1 | ( | ) | const |
Getter for the second vertex.
| DoubleVec3D Triangle::getVertex2 | ( | ) | const |
Getter for the third vertex.
|
virtual |
| void Triangle::setVertex0 | ( | const DoubleVec3D & | vertex | ) |
Setter for the first vertex.
Calls Triangle::computeArea().
| vertex | The new first vertex of this triangle. |
| void Triangle::setVertex1 | ( | const DoubleVec3D & | vertex | ) |
Setter for the second vertex.
Calls Triangle::computeArea().
| vertex | The new second vertex of this triangle. |
| void Triangle::setVertex2 | ( | const DoubleVec3D & | vertex | ) |
Setter for the third vertex.
Calls Triangle::computeArea().
| vertex | The new third vertex of this triangle. |
|
virtual |
Computes the smallest positive intersection between the ray and this object.
| ray | The ray with wich we want to compute the intersection. |
Implements Object3D.