Core 1.0
|
A simple tetrahedron. More...
#include <tetrahedra.h>
Public Member Functions | |
Tetrahedra () | |
Empty. | |
Tetrahedra (const Vector &, const Vector &, const Vector &, const Vector &) | |
Creates a tetrahedron. More... | |
Tetrahedra (const Box &, int) | |
Returns the k-th tetrahedron of the box. More... | |
~Tetrahedra () | |
Empty. | |
Vector | Vertex (int) const |
Returns the i-thvertex of the tetrahedron. More... | |
Triangle | GetTriangle (int) const |
Returns the i-th triangle of the tetrahedron. More... | |
Plane | GetPlane (int) const |
Returns the i-th plane of the tetrahedron. More... | |
Vector | Normal (int) const |
Returns the normal of the i-th triangle of the tetrahedron. More... | |
constexpr int | VertexIndex (int, int) const |
Return the index of the j-th vertex of the i-th triangle. More... | |
Vector | Normal (const Vector &) const |
Computes the vector distance between the tetrahedron and a point. More... | |
Vector | Normal2 (const Vector &) const |
Computes the vector distance between the tetrahedron and a point. More... | |
double | R (const Vector &) const |
Computes the squared distance between the tetrahedron and a point. More... | |
double | Signed (const Vector &) const |
Computes the signed distance between the tetrahedron and a point. More... | |
double | Volume () const |
Compute the volume of a tetrahedron. More... | |
double | Area () const |
Compute the surface area of a tetrahedron. More... | |
Box | GetBox () const |
Compute the bounding box of a tetrahedron. | |
Sphere | GetSphere () const |
Compute the sphere bounding the argument tetrahedron. More... | |
Tetrahedra | Scaled (const Vector &) const |
Scale the tetrahedron. More... | |
Tetrahedra | Scaled (const double &) const |
Uniform scaling. More... | |
Tetrahedra | Translated (const Vector &) const |
Translate the tetrahedron. More... | |
Tetrahedra | Rotated (const Matrix &) const |
Rotate the tetrahedron. More... | |
bool | Intersect (const Ray &, double &, double &) const |
Compute the intersection between tetrahedra and a ray. More... | |
bool | Intersect (const Ray &, double &, double &, Vector &, Vector &) const |
Compute the intersection between tetrahedra and a ray. More... | |
bool | Inside (const Vector &) const |
Check if a point lies inside the tetrahedron. More... | |
bool | Intersect (const Tetrahedra &) const |
Check if two tetrahedra overlap. More... | |
bool | Inside (const Plane &) const |
Compute if the tetrahedra is inside a half plane. More... | |
Vector | RandomInside (Random &=Random::R239) const |
Generate a random point inside the tetrahedron. More... | |
Static Public Attributes | |
static double | epsilon = 1e-7 |
Internal epsilon constant. | |
Protected Attributes | |
Vector | p [4] |
Array of vertices. | |
Vector | n [4] |
Normals to the faces. | |
Static Protected Attributes | |
static const int | vertex [4][3] |
Array of indexes defining the faces of the tetrahedron. | |
static const int | split [6][4] |
Indexes of the vertexes of the sub-tetrahedron of a cube. | |
Friends | |
std::ostream & | operator<< (std::ostream &, const Tetrahedra &) |
Overloaded. More... | |
A simple tetrahedron.
The class stores the vertices, the normals of the triangles, and the unit vectors of the edges.
This class also implements some useful functions, such as the intersection with a ray. The member function GetSphere() used to compute the bounding sphere of a tetrahedron simply calls the right Sphere constructor.
|
explicit |
Creates a tetrahedron.
Note that vertices should be ordered so that triangle normals should point outward.
a,b,c,d | Vertices. |
|
explicit |
Returns the k-th tetrahedron of the box.
The box is divided into six tetrahedra.
box | The box. |
k | Index of the tetrahedron. |
double Tetrahedra::Area | ( | ) | const |
Compute the surface area of a tetrahedron.
The surface is defined as the sum of the surface areas of its four triangle faces. Other techniques define the surface area as:
A=(u+v+w).(v-w+u).(w-u+v).(u-v+w)
Here u, v and w denote the three edges length.
Plane Tetrahedra::GetPlane | ( | int | i | ) | const |
Returns the i-th plane of the tetrahedron.
i | Index. |
Sphere Tetrahedra::GetSphere | ( | ) | const |
Compute the sphere bounding the argument tetrahedron.
This is convenience function, simply calling the constructor of Sphere with four vertices.
|
inline |
Returns the i-th triangle of the tetrahedron.
i | Index. |
bool Tetrahedra::Inside | ( | const Plane & | plane | ) | const |
Compute if the tetrahedra is inside a half plane.
plane | The plane. |
bool Tetrahedra::Inside | ( | const Vector & | p | ) | const |
Check if a point lies inside the tetrahedron.
p | Point. |
bool Tetrahedra::Intersect | ( | const Ray & | ray, |
double & | ta, | ||
double & | tb | ||
) | const |
Compute the intersection between tetrahedra and a ray.
Sorted intersection depths are returned if intersection occurs.
ray | The ray. |
ta,tb | Intersection depths. |
bool Tetrahedra::Intersect | ( | const Ray & | ray, |
double & | ta, | ||
double & | tb, | ||
Vector & | na, | ||
Vector & | nb | ||
) | const |
Compute the intersection between tetrahedra and a ray.
Sorted intersection depths are returned if intersection occurs.
ray | The ray. |
ta,tb | Returned intersection depths. |
na,nb | Returned normals at intersection points. |
bool Tetrahedra::Intersect | ( | const Tetrahedra & | T | ) | const |
Check if two tetrahedra overlap.
After F. Ganovelli, F. Ponchio, and C. Rocchini. Fast tetrahedron-tetrahedron overlap algorithm. Journal of Graphics Tools, 7(2):17-26, 2002.
T | Argument tetrahedron. |
Computes the vector distance between the tetrahedron and a point.
x | Point. |
|
inline |
Returns the normal of the i-th triangle of the tetrahedron.
i | Index. |
Computes the vector distance between the tetrahedron and a point.
x | Point. |
double Tetrahedra::R | ( | const Vector & | x | ) | const |
Computes the squared distance between the tetrahedron and a point.
x | Point. |
Vector Tetrahedra::RandomInside | ( | Random & | r = Random::R239 | ) | const |
Generate a random point inside the tetrahedron.
The method proposed here is a generalization of one of the techniques used by Turk to generate a random point inside a triangle. Generate a random point in a parallelogram and reflectit around the center of the parallelogram.
After C. Rocchini and P. Cignoni, Generating random points in a tetrahedron, Journal of graphics tools, 5(4):9-12, 2000.
r | Random number generator. |
Tetrahedra Tetrahedra::Rotated | ( | const Matrix & | r | ) | const |
Rotate the tetrahedron.
r | Rotation matrix. |
Tetrahedra Tetrahedra::Scaled | ( | const double & | s | ) | const |
Uniform scaling.
s | Scaling factor. |
Tetrahedra Tetrahedra::Scaled | ( | const Vector & | s | ) | const |
Scale the tetrahedron.
s | Scaling vector. |
double Tetrahedra::Signed | ( | const Vector & | x | ) | const |
Computes the signed distance between the tetrahedron and a point.
This function does not generate an Euclidean distance.
x | Point. |
Tetrahedra Tetrahedra::Translated | ( | const Vector & | t | ) | const |
Translate the tetrahedron.
t | Translation vector. |
|
inline |
Returns the i-thvertex of the tetrahedron.
i | Index. |
|
inlineconstexpr |
Return the index of the j-th vertex of the i-th triangle.
i | Triangle index. |
j | Vertex index. |
double Tetrahedra::Volume | ( | ) | const |
Compute the volume of a tetrahedron.
The volume may be defined as one-sixth the volume of a parallelepiped whose three main edges emanate from a single vertex.
|
friend |
Overloaded.
s | Stream. |
t | The tetrahedron. |