20 #if !defined(__MITSUBA_CORE_TRIANGLE_H_)
21 #define __MITSUBA_CORE_TRIANGLE_H_
23 #include <mitsuba/mitsuba.h>
41 AABB result(positions[idx[0]]);
59 AABB getClippedAABB(
const Point *positions,
const AABB &aabb)
const;
63 Vector a = (positions[idx[1]] - positions[idx[0]]);
64 Vector b = (positions[idx[2]] - positions[idx[0]]);
67 Float da = std::sqrt(a2);
68 Float db = std::sqrt(b2);
71 Float daxb = std::sqrt(axb2);
72 return BSphere(positions[idx[0]] +
cross(a2 * b - b2 * a, axb) / (2 * axb2),
73 da * db * (a - b).length() / (2 * daxb));
82 Float surfaceArea(
const Point *positions)
const;
112 Vector edge1 = p1 - p0, edge2 = p2 - p0;
126 u =
dot(tvec, pvec) * inv_det;
127 if (u < 0.0 || u > 1.0)
134 v =
dot(ray.d, qvec) * inv_det;
137 if (v >= 0.0 && u + v <= 1.0) {
139 t =
dot(edge2, qvec) * inv_det;
173 positions[idx[0]], positions[idx[1]],
174 positions[idx[2]], ray, u, v, t);
Three-dimensional normal data structure.
Definition: normal.h:39
static FINLINE bool rayIntersect(const Point &p0, const Point &p1, const Point &p2, const Ray &ray, Float &u, Float &v, Float &t)
Ray-triangle intersection test.
Definition: triangle.h:109
Simple triangle class including a collection of routines for analysis and transformation.
Definition: triangle.h:35
void expandBy(const PointType &p)
Expand the bounding box to contain another point.
Definition: aabb.h:189
FINLINE bool rayIntersect(const Point *positions, const Ray &ray, Float &u, Float &v, Float &t) const
Ray-triangle intersection test.
Definition: triangle.h:170
Bounding sphere data structure in three dimensions.
Definition: bsphere.h:32
#define MTS_EXPORT_CORE
Definition: getopt.h:29
T det(const TVector2< T > &v1, const TVector2< T > &v2)
Definition: vector.h:411
Axis-aligned bounding box data structure in three dimensions.
Definition: aabb.h:437
BSphere getBSphere(const Point *positions) const
Definition: triangle.h:62
AABB getAABB(const Point *positions) const
Construct an axis-aligned box, which contains the triangle.
Definition: triangle.h:40
TVector3< T > cross(const TVector3< T > &v1, const TVector3< T > &v2)
Definition: vector.h:617
T dot(const TQuaternion< T > &q1, const TQuaternion< T > &q2)
Definition: quat.h:348