Simbody
3.7

A geometric primitive representing a triangle by its vertices as points in some unspecified frame, and a collection of trianglerelated utility methods. More...
Public Member Functions  
Triangle_ ()  
Construct an uninitialized Triangle object; the vertices will be garbage. More...  
Triangle_ (const Vec3P &v0, const Vec3P &v1, const Vec3P &v2)  
Construct a triangle from its vertices. More...  
Triangle_ (const Vec3P *vertices)  
Construct a triangle from vertices stored in array which is presumed to contain at least three points. More...  
Triangle_ (const Vec3P **vertexPointers)  
Construct a triangle from an indirect list of vertices stored in array which is presumed to contain at least three pointers to points. More...  
Triangle_ &  setVertex (int i, const Vec3P &p) 
Change one vertex of this triangle. More...  
Triangle_ &  setVertices (const Vec3P &v0, const Vec3P &v1, const Vec3P &v2) 
Change the vertices of this triangle. More...  
Triangle_ &  setVertices (const Vec3P *vertices) 
Change the vertices of this triangle, taking the new ones from an array which is presumed to contain at least three points. More...  
const Vec3P &  getVertex (int i) const 
Access a vertex by index. Order is the same as construction. More...  
Vec3P &  updVertex (int i) 
Get writable access to a vertex by index. Order is the same as construction. More...  
const Vec3P &  operator[] (int i) const 
Access a vertex by indexing the triangle. More...  
Vec3P &  operator[] (int i) 
Get writable access to a vertex by indexing the triangle. More...  
LineSeg_< P >  getEdge (int i) const 
Return a LineSeg_ containing an edge of this triangle, with edges numbered in a counterclockwise direction so that edge0 is v0v1, edge1 is v1v2, and edge2 is v2v0. More...  
Vec3P  findPoint (const Vec2P &uv) const 
Return a point on the triangle's face given by its (u,v) coordinates. More...  
Vec3P  findCentroid () const 
Return the centroid point on the triangle's face; this is the same as findPoint(1/3,1/3) but faster. More...  
UnitVec3P  calcUnitNormal () const 
Calculate the unit normal to the triangle face taking the vertices in counterclockwise order. More...  
Sphere_< P >  calcBoundingSphere () const 
Calculate the smallest bounding sphere enclosing the three vertices of this triangle. More...  
RealP  calcArea () const 
Return the area of this triangle. More...  
RealP  calcAreaSqr () const 
Return the square of the area of this triangle. More...  
Vec3P  findNearestPoint (const Vec3P &position, Vec2P &uv) const 
Given a location in space, find the point of this triangular face that is closest to that location. More...  
bool  intersectsRay (const Vec3P &origin, const UnitVec3P &direction, RealP &distance, Vec2P &uv) const 
Determine whether a given ray intersects this triangle. More...  
bool  overlapsTriangle (const Triangle_< P > &other) const 
Determine yes/no whether this triangle overlaps another one. More...  
bool  intersectsTriangle (const Triangle_< P > &other, LineSeg_< P > &seg, bool &isCoplanar) const 
Determine whether this triangle intersects another one, and if so then if they are not coplanar return the line segment representing their intersection. More...  
A geometric primitive representing a triangle by its vertices as points in some unspecified frame, and a collection of trianglerelated utility methods.
We support a uv barycentric parameterization for the triangle.

inline 
Construct an uninitialized Triangle object; the vertices will be garbage.

inline 
Construct a triangle from its vertices.

inlineexplicit 
Construct a triangle from vertices stored in array which is presumed to contain at least three points.

inlineexplicit 
Construct a triangle from an indirect list of vertices stored in array which is presumed to contain at least three pointers to points.

inline 
Change one vertex of this triangle.

inline 
Change the vertices of this triangle.

inline 
Change the vertices of this triangle, taking the new ones from an array which is presumed to contain at least three points.

inline 
Access a vertex by index. Order is the same as construction.
You can use operator[] instead for a more compact notation.

inline 
Get writable access to a vertex by index. Order is the same as construction.
You can use operator[] instead for a more compact notation.

inline 
Access a vertex by indexing the triangle.

inline 
Get writable access to a vertex by indexing the triangle.

inline 
Return a LineSeg_ containing an edge of this triangle, with edges numbered in a counterclockwise direction so that edge0 is v0v1, edge1 is v1v2, and edge2 is v2v0.

inline 
Return a point on the triangle's face given by its (u,v) coordinates.
Cost is 17 flops.

inline 
Return the centroid point on the triangle's face; this is the same as findPoint(1/3,1/3) but faster.
Cost is 9 flops.

inline 
Calculate the unit normal to the triangle face taking the vertices in counterclockwise order.
Cost is about 50 flops.

inline 
Calculate the smallest bounding sphere enclosing the three vertices of this triangle.
We guarantee that no vertex is outside the sphere, but for numerical reasons it is possible for the sphere to be a little too big.

inline 
Return the area of this triangle.
Cost is about 40 flops.

inline 
Return the square of the area of this triangle.
Cost is 23 flops.

inline 
Given a location in space, find the point of this triangular face that is closest to that location.
If the answer is not unique then one of the equidistant points is returned.

inline 
Determine whether a given ray intersects this triangle.
TODO: is a perfect hit on the boundary an intersection?
bool SimTK::Geo::Triangle_< P >::overlapsTriangle  (  const Triangle_< P > &  other  )  const 
Determine yes/no whether this triangle overlaps another one.
Note that exactly touching is not overlapping.
bool SimTK::Geo::Triangle_< P >::intersectsTriangle  (  const Triangle_< P > &  other, 
LineSeg_< P > &  seg,  
bool &  isCoplanar  
)  const 
Determine whether this triangle intersects another one, and if so then if they are not coplanar return the line segment representing their intersection.
If the triangles are coplanar and intersect we'll return true and set isCoplanar true, but not return a line segment. Note that the triangles may meet at a point so the line segment may be degenerate in any case.