Core 1.0
|
A dodecahedron. More...
#include <dodecahedron.h>
Public Member Functions | |
Dodecahedron (const double &=1.0) | |
Create a dodecahedron. More... | |
Dodecahedron (const Vector &, const double &) | |
Create a dodecahedron. More... | |
double | Volume () const |
Compute the volume of the dodecahedron. | |
double | Area () const |
Compute the area of the dodecahedron. | |
double | Radius () const |
Compute the radius of the circmscribed sphere of the dodecahedron. | |
Vector | Vertex (int) const |
Return the i-th vertex. More... | |
Vector | Vertex (int, int) const |
Return the j-th vertex of the i-th face. More... | |
Vector | Normal (int) const |
Return the normal to the i-th face as a normalized vector. More... | |
Box | GetBox () const |
Return the bounding box of the shape. | |
Plane | GetPlane (int) const |
Return the plane of the k-th face. More... | |
bool | Inside (const Vector &) const |
Check if a point is inside. More... | |
Vector | RandomInside (Random &=Random::R239) const |
Generate a random vector inside the dodecahedron. More... | |
double | Signed (const Vector &) const |
Compute the approximate signed distance to the dodecahedron. More... | |
bool | Intersect (const Ray &, double &, double &, int &, int &) const |
Compute the intersection between a dodecahedron and a ray. More... | |
Static Public Member Functions | |
static constexpr int | VertexIndex (int, int) |
Return the index of the j-th vertex of the i-th face. More... | |
Protected Attributes | |
Vector | c = Vector::Null |
Center of dodecahedron. | |
double | r = 1.0 |
Radius. | |
Static Protected Attributes | |
static const double | R2 = sqrt(3.0) |
Radius of the circumscribed sphere of an dodecahedron with edge length 2.0/Phi. | |
static const double | Phi = (1 + sqrt(5.0)) / 2.0 |
Golden ratio. | |
static const Vector | vertex [20] |
Array of vertices. | |
static const Vector | normal [12] |
Array of normals. | |
static const int | face [12][5] |
Array of pentagons. | |
A dodecahedron.
The following Cartesian coordinates define the vertices of a dodecahedron with edge-length 2/ φ, centered at the origin.
( ± 1, ± 1, ± 1)
(0, ± 1/ φ, ± φ)
( ± 1/ φ, ± φ, 0)
( ± φ, 0, ± 1/ φ)
where φ=(1+sqrt(5))/2 is the golden ratio.
|
explicit |
Create a dodecahedron.
r | Radius. |
|
explicit |
Create a dodecahedron.
c | Center. |
r | Radius. |
Plane Dodecahedron::GetPlane | ( | int | k | ) | const |
Return the plane of the k-th face.
k | Index. |
bool Dodecahedron::Inside | ( | const Vector & | p | ) | const |
Check if a point is inside.
p | The point. |
bool Dodecahedron::Intersect | ( | const Ray & | ray, |
double & | ta, | ||
double & | tb, | ||
int & | fa, | ||
int & | fb | ||
) | const |
Compute the intersection between a dodecahedron and a ray.
Intersect the ray with the planes corresponding to the faces of the convex dodecahedron.
ray | The ray. |
ta,tb | Intersection depths. |
fa,fb | Index of the intersected faces. |
|
inline |
Return the normal to the i-th face as a normalized vector.
i | Index. |
Vector Dodecahedron::RandomInside | ( | Random & | random = Random::R239 | ) | const |
Generate a random vector inside the dodecahedron.
Uses a simple rejection method.
random | Random number generator. |
double Dodecahedron::Signed | ( | const Vector & | p | ) | const |
Compute the approximate signed distance to the dodecahedron.
p | Point. |
|
inline |
Return the i-th vertex.
i | Index. |
|
inline |
Return the j-th vertex of the i-th face.
i | Face (pentagon). |
j | Index representing the j-th vertex of the face. |
|
inlinestaticconstexpr |
Return the index of the j-th vertex of the i-th face.
i | Face (pentagon). |
j | Index representing the j-th vertex of the face. |