Thea

A triangle with three vertex positions stored locally, in the class itself. More...
#include <Triangle3.hpp>
Public Types  
typedef TriangleLocalVertexTriple3  VertexTriple 
Stores and provides access to the triangle's vertices. More...  
Public Member Functions  
Vector3  barycentricCoordinates (Vector3 const &p) const 
Get the barycentric coordinates of a point assumed to be in the plane of the triangle. More...  
Vector3  closestPoint (Vector3 const &p) const 
Get the point on this triangle closest to a given point. More...  
bool  contains (Vector3 const &p) const 
Check if the triangle contains a point. More...  
Real  distance (Vector3 const &p) const 
Get the distance of the triangle from a point. More...  
Real  distance (Triangle3Base< OtherVertexTripleT > const &other) const 
Get the distance of the triangle from another triangle. More...  
Real  distance (Ball3 const &ball) const 
Get the distance of this triangle from a ball. More...  
Real  distance (Line3 const &line) const 
Get the distance of this triangle from an infinite line. More...  
Real  distance (LineSegment3 const &seg) const 
Get the distance of this triangle from a line segment. More...  
Real  distance (Ray3 const &ray) const 
Get the distance of this triangle from a ray. More...  
Real  getArea () const 
Get the area of the triangle. More...  
AxisAlignedBox3  getBounds () const 
Get a bounding box for the triangle. More...  
Vector3 const &  getCentroid () const 
Get the centroid of the triangle. More...  
Vector3 const &  getEdge01 () const 
Get the edge vector corresponding to getVertex(1)  getVertex(0). More...  
Vector3 const &  getEdge02 () const 
Get the edge vector corresponding to getVertex(2)  getVertex(0). More...  
Vector3 const &  getNormal () const 
Get the normal of the triangle (righthand rule, going round vertices in order 0, 1, 2). More...  
Plane3 const &  getPlane () const 
Get the plane of the triangle. More...  
intx  getPrimaryAxis () const 
Get the primary axis of the triangle (closest to normal). More...  
Vector3  getVertex (int i) const 
Get a vertex of the triangle. More...  
VertexTriple const &  getVertices () const 
Get the vertices of the triangle. More...  
bool  intersects (Vector3 const &p) const 
Check if the triangle intersects (that is, contains) a point. More...  
bool  intersects (Triangle3Base< OtherVertexTripleT > const &other) const 
Check if the triangle intersects another triangle. More...  
bool  intersects (Triangle3Base< OtherVertexTripleT > const &other, bool &coplanar, LineSegment3 &seg) const 
Check if the triangle intersects another triangle. More...  
bool  intersects (Ball3 const &ball) const 
Check if the triangle intersects a ball. More...  
bool  intersects (AxisAlignedBox3 const &aab) const 
Check if the triangle intersects an axisaligned box. More...  
bool  intersects (Box3 const &box) const 
Check if the triangle intersects an oriented box. More...  
Triangle3  localClone () const 
Get a copy of this triangle (for consistency with the default template). More...  
Vector3  randomPoint () const 
Get a uniformly distributed random sample from the triangle. More...  
virtual RayIntersectionN< N, T >  rayIntersection (RayN< N, T > const &ray, T max_time=1) const 
Get the intersection of a ray with the object, including the hit time and the normal at the intersection point. More...  
virtual T  rayIntersectionTime (RayN< N, T > const &ray, T max_time=1) const =0 
Get the time taken for a ray to intersect the object, or a negative value if there was no intersection in the forward direction. More...  
virtual bool  rayIntersects (RayN< N, T > const &ray, T max_time=1) const 
Check if a ray intersects the object in the forward direction. More...  
void  set (VertexTriple const &vertices_) 
Initialize the triangle from its vertices. More...  
void  set (Vector3 const &v0, Vector3 const &v1, Vector3 const &v2) 
Initialize the triangle from its vertices. More...  
Real  squaredDistance (Vector3 const &p) const 
Get the squared distance of the triangle from a point. More...  
Real  squaredDistance (Triangle3Base< OtherVertexTripleT > const &other, Vector3 *this_pt=nullptr, Vector3 *other_pt=nullptr) const 
Get the squared distance between this triangle and another triangle, and optionally return the closest pair of points. More...  
Real  squaredDistance (Ball3 const &ball, Vector3 *this_pt=nullptr, Vector3 *ball_pt=nullptr) const 
Get the squared distance between this triangle and a ball, and optionally return the closest pair of points. More...  
Real  squaredDistance (Line3 const &line, Vector3 *this_pt=nullptr, Vector3 *line_pt=nullptr) const 
Get the squared distance between this triangle and an infinite line, and optionally return the closest pair of points. More...  
Real  squaredDistance (LineSegment3 const &seg, Vector3 *this_pt=nullptr, Vector3 *seg_pt=nullptr) const 
Get the squared distance between this triangle and a line segment, and optionally return the closest pair of points. More...  
Real  squaredDistance (Ray3 const &ray, Vector3 *this_pt=nullptr, Vector3 *ray_pt=nullptr) const 
Get the squared distance between this triangle and a ray, and optionally return the closest pair of points. More...  
Triangle3  transform (Matrix4 const &m) const 
Transform the triangle by a 4x4 matrix and return the result. More...  
Triangle3 ()  
Default constructor. More...  
Triangle3 (TriangleLocalVertexTriple3 const &vertices_)  
Construct from a set of vertices. More...  
Triangle3 (Vector3 const &v0, Vector3 const &v1, Vector3 const &v2)  
Construct from a set of vertices. More...  
Triangle3 (Triangle3 const &src)  
Copy constructor. More...  
void  update () const 
Update the properties of the triangle, assuming the positions of its three corners have changed. More...  
Protected Member Functions  
Real  squaredDistanceToPerimeter (LineLikeT const &line, Vector3 *this_pt=nullptr, Vector3 *line_pt=nullptr) const 
Get the squared distance between the perimiter of this triangle and a linelike object (Line3, Ray3 or LineSegment3), and optionally return the closest pair of points. More...  
Protected Attributes  
Real  area 
Triangle area. More...  
Vector3  centroid 
Centroid of the triangle (mean of three vertices). More...  
Vector3  edge01 
vertices[1]  vertices[0] More...  
Vector3  edge02 
vertices[2]  vertices[0] More...  
Plane3  plane 
Plane of the triangle. More...  
int  primary_axis 
Primary axis (closest to normal). More...  
VertexTriple  vertices 
The vertices of the triangle. More...  
A triangle with three vertex positions stored locally, in the class itself.
This class adds a more direct constructor and set() method for convenience to the default Triangle3 template.
Definition at line 624 of file Triangle3.hpp.

inherited 
Stores and provides access to the triangle's vertices.
Definition at line 138 of file Triangle3.hpp.
Triangle3  (  ) 

explicit 
Construct from a set of vertices.
Definition at line 636 of file Triangle3.hpp.
Triangle3  (  Vector3 const &  v0, 
Vector3 const &  v1,  
Vector3 const &  v2  
) 
Construct from a set of vertices.
Definition at line 639 of file Triangle3.hpp.
Triangle3  (  Triangle3< TriangleLocalVertexTriple3 > const &  src  ) 
Copy constructor.
Definition at line 642 of file Triangle3.hpp.

inherited 
Get the barycentric coordinates of a point assumed to be in the plane of the triangle.
Definition at line 222 of file Triangle3.hpp.

inherited 
Get the point on this triangle closest to a given point.
Definition at line 316 of file Triangle3.hpp.

inherited 
Check if the triangle contains a point.
Definition at line 301 of file Triangle3.hpp.

inherited 
Get the distance of the triangle from a point.
Definition at line 307 of file Triangle3.hpp.

inherited 
Get the distance of the triangle from another triangle.
Definition at line 329 of file Triangle3.hpp.

inherited 
Get the distance of this triangle from a ball.
Definition at line 421 of file Triangle3.hpp.

inherited 
Get the distance of this triangle from an infinite line.
Definition at line 464 of file Triangle3.hpp.

inherited 
Get the distance of this triangle from a line segment.
Definition at line 507 of file Triangle3.hpp.

inherited 
Get the distance of this triangle from a ray.
Definition at line 533 of file Triangle3.hpp.

inherited 
Get the area of the triangle.
Definition at line 200 of file Triangle3.hpp.

inherited 
Get a bounding box for the triangle.
Definition at line 239 of file Triangle3.hpp.

inherited 
Get the centroid of the triangle.
Definition at line 191 of file Triangle3.hpp.

inherited 
Get the edge vector corresponding to getVertex(1)  getVertex(0).
Definition at line 194 of file Triangle3.hpp.

inherited 
Get the edge vector corresponding to getVertex(2)  getVertex(0).
Definition at line 197 of file Triangle3.hpp.

inherited 
Get the normal of the triangle (righthand rule, going round vertices in order 0, 1, 2).
Definition at line 188 of file Triangle3.hpp.

inherited 
Get the plane of the triangle.
Definition at line 182 of file Triangle3.hpp.

inherited 
Get the primary axis of the triangle (closest to normal).
Definition at line 185 of file Triangle3.hpp.

inherited 
Get a vertex of the triangle.
Definition at line 176 of file Triangle3.hpp.

inherited 
Get the vertices of the triangle.
Definition at line 179 of file Triangle3.hpp.

inherited 
Check if the triangle intersects (that is, contains) a point.
Definition at line 246 of file Triangle3.hpp.

inherited 
Check if the triangle intersects another triangle.
Definition at line 249 of file Triangle3.hpp.

inherited 
Check if the triangle intersects another triangle.
If they do intersect, check if they are coplanar. If they are not coplanar, compute the line of intersection. The intersection test is somewhat slower than intersects().
Definition at line 270 of file Triangle3.hpp.

inherited 
Check if the triangle intersects a ball.
Definition at line 292 of file Triangle3.hpp.

inherited 
Check if the triangle intersects an axisaligned box.
Definition at line 295 of file Triangle3.hpp.

inherited 
Check if the triangle intersects an oriented box.
Definition at line 298 of file Triangle3.hpp.
Triangle3 localClone  (  )  const 
Get a copy of this triangle (for consistency with the default template).
Definition at line 660 of file Triangle3.hpp.

inherited 
Get a uniformly distributed random sample from the triangle.
Definition at line 203 of file Triangle3.hpp.

virtualinherited 
Get the intersection of a ray with the object, including the hit time and the normal at the intersection point.
A negative time is returned if there was no intersection in the forward direction. If the normal cannot be computed, the zero vector is returned.
ray  The ray to test for intersection. 
max_time  Maximum allowable hit time, ignored if negative. 
Reimplemented in AxisAlignedBoxNBase< N, T >, AxisAlignedBoxNBase< 3, T >, BallN< N, T >, HyperplaneNBase< N, T >, HyperplaneNBase< N, Real >, HyperplaneNBase< 3, T >, BoxN< N, T >, and BoxN< 3, Real >.
Definition at line 102 of file RayIntersectableN.hpp.

pure virtualinherited 
Get the time taken for a ray to intersect the object, or a negative value if there was no intersection in the forward direction.
All subclasses must reimplement this method. If the return value is negative, it should be at least
ray  The ray to test for intersection. 
max_time  Maximum allowable hit time, ignored if negative. 
Implemented in AxisAlignedBoxNBase< N, T >, AxisAlignedBoxNBase< 3, T >, HyperplaneNBase< N, T >, HyperplaneNBase< N, Real >, HyperplaneNBase< 3, T >, BallN< N, T >, BoxN< N, T >, and BoxN< 3, Real >.

virtualinherited 
Check if a ray intersects the object in the forward direction.
ray  The ray to test for intersection. 
max_time  Maximum allowable hit time, ignored if negative. 
Reimplemented in AxisAlignedBoxNBase< N, T >, AxisAlignedBoxNBase< 3, T >, HyperplaneNBase< N, T >, HyperplaneNBase< N, Real >, HyperplaneNBase< 3, T >, BallN< N, T >, BoxN< N, T >, and BoxN< 3, Real >.
Definition at line 80 of file RayIntersectableN.hpp.

inherited 
Initialize the triangle from its vertices.
Definition at line 155 of file Triangle3.hpp.
void set  (  Vector3 const &  v0, 
Vector3 const &  v1,  
Vector3 const &  v2  
) 
Initialize the triangle from its vertices.
Definition at line 653 of file Triangle3.hpp.

inherited 
Get the squared distance of the triangle from a point.
Definition at line 310 of file Triangle3.hpp.

inherited 
Get the squared distance between this triangle and another triangle, and optionally return the closest pair of points.
Definition at line 335 of file Triangle3.hpp.

inherited 
Get the squared distance between this triangle and a ball, and optionally return the closest pair of points.
Definition at line 427 of file Triangle3.hpp.

inherited 
Get the squared distance between this triangle and an infinite line, and optionally return the closest pair of points.
Definition at line 472 of file Triangle3.hpp.

inherited 
Get the squared distance between this triangle and a line segment, and optionally return the closest pair of points.
Definition at line 515 of file Triangle3.hpp.

inherited 
Get the squared distance between this triangle and a ray, and optionally return the closest pair of points.
Definition at line 541 of file Triangle3.hpp.

protectedinherited 
Get the squared distance between the perimiter of this triangle and a linelike object (Line3, Ray3 or LineSegment3), and optionally return the closest pair of points.
Definition at line 581 of file Triangle3.hpp.
Triangle3 transform  (  Matrix4 const &  m  )  const 
Transform the triangle by a 4x4 matrix and return the result.
Definition at line 645 of file Triangle3.hpp.

inherited 
Update the properties of the triangle, assuming the positions of its three corners have changed.
Useful for external callers if the mutable positions are not locally stored within the triangle.
Definition at line 161 of file Triangle3.hpp.

mutableprotectedinherited 
Triangle area.
Definition at line 610 of file Triangle3.hpp.

mutableprotectedinherited 
Centroid of the triangle (mean of three vertices).
Definition at line 607 of file Triangle3.hpp.

mutableprotectedinherited 
vertices[1]  vertices[0]
Definition at line 608 of file Triangle3.hpp.

mutableprotectedinherited 
vertices[2]  vertices[0]
Definition at line 609 of file Triangle3.hpp.

mutableprotectedinherited 
Plane of the triangle.
Definition at line 605 of file Triangle3.hpp.

mutableprotectedinherited 
Primary axis (closest to normal).
Definition at line 606 of file Triangle3.hpp.

protectedinherited 
The vertices of the triangle.
Definition at line 602 of file Triangle3.hpp.