Core 1.0
Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Octahedron Class Reference

An axis aligned octahedron. More...

#include <octahedron.h>

Public Member Functions

 Octahedron (const Vector &, const Vector &)
 Creates an octahedron given the vertices of its bounding box. More...
 
 Octahedron (const Vector &, const double &)
 Creates an octahedron given its center and radius. More...
 
 Octahedron (const double &)
 Creates an octahedron. More...
 
double Volume () const
 Compute the volume of the octahedron. More...
 
double Area () const
 Compute the area of the octahedron. More...
 
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. More...
 
double R (const Vector &) const
 Compute the squared Euclidean distance between a point and the octahedron. More...
 
double Signed (const Vector &) const
 Compute the signed Euclidean distance between a point and the octahedron. More...
 
Plane GetPlane (int) const
 Return the plane of the k-th face. More...
 
Box GetBox () const
 Return the bounding box of the octahedron.
 
bool Inside (const Vector &) const
 Check if a point is inside the octahedron. More...
 

Static Public Member Functions

static int VertexIndex (int, int)
 Return the index of the j-th vertex of the i-th face.
 

Protected Attributes

Vector center
 Center.
 
Vector half
 Half diagonal of the box.
 
Vector planenormal
 Normal to the plane in the first octant.
 
Vector ezxn
 Edge normals.
 

Static Protected Attributes

static const int face [8][3]
 Array of triangles.
 
static const Vector vertex [6]
 Array of internal vertexes for computing vertices.
 

Detailed Description

An axis aligned octahedron.

Constructor & Destructor Documentation

◆ Octahedron() [1/3]

Octahedron::Octahedron ( const Vector a,
const Vector b 
)
explicit

Creates an octahedron given the vertices of its bounding box.

Parameters
a,bVectors.

◆ Octahedron() [2/3]

Octahedron::Octahedron ( const Vector c,
const double &  r 
)
explicit

Creates an octahedron given its center and radius.

Parameters
cCenter.
rRadius.

◆ Octahedron() [3/3]

Octahedron::Octahedron ( const double &  r)
explicit

Creates an octahedron.

Parameters
rRadius.

Member Function Documentation

◆ Area()

double Octahedron::Area ( ) const
inline

Compute the area of the octahedron.

It is 8 times the area of one of its triangular faces.

The code has been optimized, instead of computing the normal of the triangle using Triangle::Normal(), the cross product has been inlined.

◆ GetPlane()

Plane Octahedron::GetPlane ( int  k) const

Return the plane of the k-th face.

Parameters
kIndex.

◆ Inside()

bool Octahedron::Inside ( const Vector p) const

Check if a point is inside the octahedron.

Parameters
pPoint.

◆ Normal()

Vector Octahedron::Normal ( const Vector p) const

Compute the normal vector between a point and the octahedron.

Parameters
pPoint.

◆ R()

double Octahedron::R ( const Vector p) const

Compute the squared Euclidean distance between a point and the octahedron.

Parameters
pThe point.

◆ Signed()

double Octahedron::Signed ( const Vector p) const

Compute the signed Euclidean distance between a point and the octahedron.

Parameters
pPoint.

◆ Volume()

double Octahedron::Volume ( ) const
inline

Compute the volume of the octahedron.

It is 8 times the volume of a tetrahedron. Since three vectors are orthogonal, the volume is 1/6 the volume of a half box (thus 1/48 the volume of the box).