|
|
| Triangle () |
| | Empty.
|
| | Triangle (const Vector &, const Vector &, const Vector &) |
| | Create a triangle.
|
|
| ~Triangle () |
| | Empty.
|
| Vector | operator[] (int) const |
| | Return the i-th vertex.
|
| Vector & | operator[] (int) |
| | Return a reference to the i-th vertex.
|
| Vector | Vertex (const double &, const double &) const |
| | Compute a point in the triangle, given uv-coordinates.
|
| bool | Intersect (const Ray &, double &) const |
| | Compute the intersection between a ray and a triangle.
|
| bool | Intersect (const Ray &, double &, double &, double &) const |
| | Compute the intersection between a ray and a triangle.
|
| bool | Intersect (const Sphere &) const |
| | Check if a sphere intersects or contains a triangle.
|
| bool | Intersect (const Triangle &) const |
| | Check if two triangles intersect.
|
| void | Translate (const Vector &) |
| | Translates a triangle by a given vector.
|
| void | Rotate (const Matrix &) |
| | Rotates a triangle.
|
| void | Scale (const Vector &) |
| | Scale a triangle.
|
| void | Transform (const Frame &) |
| | Transforms a triangle given a frame transformation.
|
| Triangle | Transformed (const FrameScaled &) const |
| | Transforms a triangle given a frame transformation.
|
| void | Shrink (const double &) |
| | Shrinks a triangle.
|
| Vector | Normal () const |
| | Compute the normal vector of the triangle.
|
| Vector | AreaNormal () const |
| | Compute the normal vector of the triangle, and scale the normal using its area.
|
|
Vector | Center () const |
| | Compute the barycenter of the triangle.
|
| double | R (const Vector &) const |
| | Computes the squared distance between a point and a triangle.
|
| Vector | Normal (const Vector &) const |
| | Computes the normal vector to a triangle.
|
| Sphere | Inscribed () const |
| | Compute the sphere inscribed in the triangle.
|
| Sphere | Circumscribed () const |
| | Compute the sphere circumscribing the triangle.
|
|
Plane | GetPlane () const |
| | Compute the plane of the triangle.
|
|
double | Area () const |
| | Compute the area of the triangle.
|
|
double | Length () const |
| | Compute the perimeter of the triangle.
|
| double | Aspect () const |
| | Computes the aspect ratio of the triangle.
|
|
Box | GetBox () const |
| | Computes the axis aligned box enclosing the triangle.
|
| int | Intersect (const Plane &, Segment &) const |
| | Compute the intersection between a triangle and a plane.
|
| int | Intersect (const double &, Segment &) const |
| | Compute the intersection between a triangle and a horizontal plane.
|
| Vector | BarycentricCoordinates (const Vector &) const |
| | Compute the barycentric coordinates of the projection of the point onto the plane of the triangle.
|
| void | Subdivide (int, QVector< Vector > &, QVector< int > &) const |
| | Create an n-adic subdivision of a triangle.
|
| double | InscribedRadius () const |
| | Compute the radius of the circle inscribed in the triangle.
|
|
double | CircumscribedRadius () const |
| | Compute the radius of the circumscribed circle of the triangle.
|
| Vector | RandomInside (Random &=Random::R239) const |
| | Generate a random vector inside the triangle.
|
Base minimum storage triangle class.
The data-structure of the triangle does not include the normalized normal vector.
| Sphere Triangle::Inscribed |
( |
| ) |
const |
Compute the sphere inscribed in the triangle.
The center of the sphere is the center of (A,a), (B,b) and (C,c) where A, B and C are the vertices of the triangle and coefficients a, b and c represent the length of their facing edge.
| bool Triangle::Intersect |
( |
const Ray & | ray, |
|
|
double & | t ) const |
Compute the intersection between a ray and a triangle.
Uses the Möller-Trumbore algorithm, after Tomas Möller and Ben Trumbore, Fast, minimum storage ray-triangle intersection, Journal of graphics tools, 2(1):21-28, 1997.
- Parameters
-
| ray | The ray (direction should be of unit length). |
| t | Intersection depth, intersections behind the origin of the ray (negative depth) are rejected. |
| bool Triangle::Intersect |
( |
const Ray & | ray, |
|
|
double & | t, |
|
|
double & | u, |
|
|
double & | v ) const |
Compute the intersection between a ray and a triangle.
Return the barycentric coordinates of the intersection if within the triangle.
Uses the Möller-Trumbore algorithm, after Tomas Möller and Ben Trumbore, Fast, minimum storage ray-triangle intersection, Journal of graphics tools, 2(1):21-28, 1997.
- Parameters
-
| ray | The ray (direction should be of unit length). |
| t | Intersection depth, intersections behind the origin of the ray (negative depth) are rejected. |
| u,v | Parametric coordinates of the intersection depth in the triangle. |
| bool Triangle::Intersect |
( |
const Sphere & | sphere | ) |
const |
Check if a sphere intersects or contains a triangle.
It does not attempt to compute the set of intersection.
A triangle vertex lying exactly on the sphere is considered inside, whereas a triangle whose vertices are all outside the sphere intersects it only if its distance to the center is strictly smaller than the radius. The algorithm proceeds as follows.
1. All three triangle vertices are contained in the sphere. The sphere completely contains the triangle.
2. At least one vertex is inside the sphere and at least one vertex is outside the sphere. The sphere and triangle intersect.
3. All three vertices are outside the sphere. The sphere and triangle intersect when the distance from sphere center to triangle is less than the sphere radius.
- Parameters
-
| bool Triangle::Intersect |
( |
const Triangle & | other | ) |
const |
Check if two triangles intersect.
The triangles are considered as closed sets: they intersect if they have at least one point in common, including a vertex or an edge. The function handles all the cases: triangles crossing in three dimensional space, triangles touching each other, coplanar triangles whose edges intersect, and coplanar triangles such that one is inside the other one. Vertices closer to the plane of the other triangle than a small fraction of the size of the triangles are considered as lying in the plane, and triangles which are closer to each other than this tolerance are considered as touching, so that the result is robust for contacts.
Triangles of null area are not supported: the function returns false if one of the triangles is degenerate.
After Tomas Moller, A Fast Triangle-Triangle Intersection Test, Journal of Graphics Tools, 2(2):25-30, 1997.
- Parameters
-
- Returns
- True if the triangles intersect.
Generate a random vector inside the triangle.
After R. Osada, T. Funkhouser, B. Chazelle, D. Dobkin. Shape Distributions, ACM Transactions on Graphics, 21(4), 807-832, 2002.
- Parameters
-
| random | Random number generator. |