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

An axis aligned pyramid. More...

#include <pyramid.h>

Public Member Functions

 Pyramid (const Vector &, const double &)
 Create a pyramid. More...
 
 Pyramid (const Vector &, const double &, const double &)
 Create a pyramid. More...
 
 Pyramid (const double &, const double &)
 Create a pyramid. More...
 
double Volume () const
 Compute the volume of the pyramid.
 
double Area () const
 Compute the area of the pyramid. 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
 Normalized normal to the i-th face. More...
 
Vector Normal (const Vector &) const
 Compute the normal vector between a point and the pyramid. More...
 
double R (const Vector &) const
 Compute the squared distance between a point and the pyramid. More...
 
double Signed (const Vector &) const
 Compute the signed distance between a point and the pyramid. More...
 
Box GetBox () const
 Return the bounding box of the pyramid.
 
bool Inside (const Vector &) const
 Check if a point is inside the pyramid. More...
 

Static Public Member Functions

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

Protected Attributes

Vector center = Vector::Null
 Center.
 
double height = 1.0
 Height.
 
double a = 1.0
 Half base-side size.
 
Vector nt
 Normal to triangular face.
 
Vector neaa
 Unit diagonal vector of the triangular faces.
 

Static Protected Attributes

static const int face [6][3]
 Array of triangles.
 
static const Vector vertex [5]
 Array of vertices.
 

Friends

std::ostream & operator<< (std::ostream &, const Pyramid &)
 Overloaded. More...
 

Detailed Description

An axis aligned pyramid.

Constructor & Destructor Documentation

◆ Pyramid() [1/3]

Pyramid::Pyramid ( const Vector c,
const double &  s 
)
explicit

Create a pyramid.

Parameters
cCenter.
sHalf base-side size, which will be height as well.

◆ Pyramid() [2/3]

Pyramid::Pyramid ( const Vector c,
const double &  s,
const double &  z 
)
explicit

Create a pyramid.

Parameters
cCenter.
sHalf base-side size.
zHeight.

◆ Pyramid() [3/3]

Pyramid::Pyramid ( const double &  s,
const double &  z 
)
explicit

Create a pyramid.

Parameters
sHalf base-side size.
zHeight.

Member Function Documentation

◆ Area()

double Pyramid::Area ( ) const

Compute the area of the pyramid.

It is eight times the area of the small triangle, plus surface of the base square

◆ Inside()

bool Pyramid::Inside ( const Vector p) const

Check if a point is inside the pyramid.

Parameters
pPoint.

◆ Normal() [1/2]

Vector Pyramid::Normal ( const Vector p) const

Compute the normal vector between a point and the pyramid.

Parameters
pPoint.

◆ Normal() [2/2]

Vector Pyramid::Normal ( int  i) const

Normalized normal to the i-th face.

Parameters
iIndex.

◆ R()

double Pyramid::R ( const Vector p) const

Compute the squared distance between a point and the pyramid.

Parameters
pThe point.

◆ Signed()

double Pyramid::Signed ( const Vector p) const

Compute the signed distance between a point and the pyramid.

Parameters
pPoint.

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  s,
const Pyramid pyramid 
)
friend

Overloaded.

Parameters
sStream.
pyramidThe pyramid.