|
| | Octahedron (const Vector &, const Vector &) |
| | Creates an octahedron given the vertices of its bounding box.
|
| | Octahedron (const Vector &, const double &) |
| | Creates a regular octahedron given its center and radius.
|
| | Octahedron (const double &) |
| | Creates a regular octahedron centered at the origin.
|
| double | Volume () const |
| | Compute the volume of the octahedron.
|
| double | Area () const |
| | Compute the area of the octahedron.
|
|
Vector | Vertex (int) const |
| | Return the i-th vertex as a vector.
|
|
Vector | Vertex (int, int) const |
| | Return the j-th vertex of the i-th face.
|
|
Vector | Normal (int) const |
| | Compute the normal to the i-th face as a normalized vector.
|
| Vector | Normal (const Vector &) const |
| | Compute the normal vector between a point and the octahedron.
|
| double | R (const Vector &) const |
| | Compute the squared Euclidean distance between a point and the octahedron.
|
| double | Signed (const Vector &) const |
| | Compute the signed Euclidean distance between a point and the octahedron.
|
| Plane | GetPlane (int) const |
| | Return the plane of the k-th face.
|
|
Box | GetBox () const |
| | Return the bounding box of the octahedron.
|
| bool | Inside (const Vector &) const |
| | Check if a point is inside the octahedron.
|
An axis aligned octahedron.
The octahedron is the convex hull of the six vertexes \( c \pm h_x e_x \), \( c \pm h_y e_y \) and \( c \pm h_z e_z \), where c is the center and \( (h_x,h_y,h_z) \) are the half diagonals, which are also the half sizes of its bounding box. It has eight triangular faces. Its volume and its area are:
\[V=\frac{4}{3}h_xh_yh_z, \quad A=4\|(h_yh_z,h_xh_z,h_xh_y)\|.
\]
The octahedron is regular if the three half diagonals are equal.
| double Octahedron::Area |
( |
| ) |
const |
|
inline |
Compute the area of the octahedron.
It is 8 times the area of one of its triangular faces. The face with vertexes \( (h_x,0,0) \), \( (0,h_y,0) \) and \( (0,0,h_z) \) has an area equal to half the norm of the cross product of two of its edges, which is \( \frac{1}{2}\|(h_yh_z,h_xh_z,h_xh_y)\| \), so that the area of the octahedron is:
\[A=4\|(h_yh_z,h_xh_z,h_xh_y)\|.
\]
The code has been optimized, instead of computing the normal of the triangle using Triangle::Normal(), the cross product has been inlined.
| double Octahedron::Volume |
( |
| ) |
const |
|
inline |
Compute the volume of the octahedron.
The octahedron is made of 8 tetrahedra, each one being defined by the center and by one of the 8 faces. Since the three edges of such a tetrahedron issued from the center are orthogonal, with lengths equal to the half diagonals \( h_x,h_y,h_z \), its volume is \( h_xh_yh_z/6 \), and the volume of the octahedron is:
\[V=\frac{4}{3}h_xh_yh_z,
\]
that is, 1/6 the volume of the box \( 8h_xh_yh_z \) which bounds the octahedron.