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

Flat topped pentagon in the plane. More...

#include <pentagon.h>

Public Member Functions

 Pentagon2 ()
 Empty.
 
 Pentagon2 (const Vector2 &, const double &)
 Create a pentagon. More...
 
 Pentagon2 (const double &)
 Create an pentagon. More...
 
void Translate (const Vector2 &)
 Translate a pentagon. More...
 
void Scale (const double &)
 Scale a pentagon. More...
 
bool Inside (const Vector2 &) const
 Test if a point is inside. More...
 
double R (const Vector2 &) const
 Compute the squared Euclidean distance to the pentagon. More...
 
double Signed (const Vector2 &) const
 Compute the signed Euclidean distance to the pentagon. More...
 
Vector2 Normal (const Vector2 &) const
 Computes the distance vector between a pentagon and a point. More...
 
bool Intersect (const Ray2 &, double &, double &) const
 Compute the intersection with a ray. More...
 
Vector2 Center () const
 Return the center of the pentagon.
 
double Radius () const
 Return the radius of the pentagon.
 
double InscribedRadius () const
 Inscribed radius.
 
Vector2 Radial (int) const
 Return the radial vector of the k-th vertex. More...
 
Vector2 Edge (int) const
 Return the edge vector connecting vertexes k and k+1. More...
 
Vector2 Vertex (int) const
 Return the coordinates of the k-th vertex. More...
 
Box2 GetBox () const
 Computes the bounding box of a pentagon.
 
double Area () const
 Area of the pentagon.
 
double Perimeter () const
 Perimeter of the pentagon.
 
double Edge () const
 Edge length.
 
void Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const
 Draws an pentagon. More...
 

Static Protected Member Functions

static int Sector (const Vector2 &)
 Compute the sector given an input direction. More...
 

Protected Attributes

Vector2 c = Vector::Null
 Center.
 
double r = 1.0
 Radius.
 

Static Protected Attributes

static const Vector2 vertex [5]
 Array of vertices.
 
static const Vector2 normal [5]
 Array of normal vectors to the edges.
 
static const Vector2 edge [5]
 Unit edge vectors.
 
static const double Alpha = 1.0 / (2.0 * sqrt(5.0 - 2.0 * sqrt(5.0)))
 Constant.
 

Friends

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

Detailed Description

Flat topped pentagon in the plane.

Constructor & Destructor Documentation

◆ Pentagon2() [1/2]

Pentagon2::Pentagon2 ( const Vector2 c,
const double &  r 
)
explicit

Create a pentagon.

Parameters
cCenter.
rRadius.

◆ Pentagon2() [2/2]

Pentagon2::Pentagon2 ( const double &  r)
explicit

Create an pentagon.

Parameters
rRadius.

Member Function Documentation

◆ Draw()

void Pentagon2::Draw ( QGraphicsScene &  scene,
const QPen &  pen = QPen(),
const QBrush &  brush = QBrush() 
) const

Draws an pentagon.

Parameters
sceneGraphics scene.
penThe pen.
brushThe brush.

◆ Edge()

Vector2 Pentagon2::Edge ( int  k) const
inline

Return the edge vector connecting vertexes k and k+1.

Parameters
kIndex, should be in [0,4].

◆ Inside()

bool Pentagon2::Inside ( const Vector2 p) const

Test if a point is inside.

Parameters
pPoint.

◆ Intersect()

bool Pentagon2::Intersect ( const Ray2 ray,
double &  ta,
double &  tb 
) const

Compute the intersection with a ray.

Parameters
rayThe ray.
ta,tbIntersection depths

◆ Normal()

Vector2 Pentagon2::Normal ( const Vector2 p) const

Computes the distance vector between a pentagon and a point.

Parameters
pPoint.

◆ R()

double Pentagon2::R ( const Vector2 p) const

Compute the squared Euclidean distance to the pentagon.

Parameters
pPoint.

◆ Radial()

Vector2 Pentagon2::Radial ( int  k) const
inline

Return the radial vector of the k-th vertex.

Parameters
kIndex, should be in [0,4].

◆ Scale()

void Pentagon2::Scale ( const double &  s)

Scale a pentagon.

Parameters
sScaling factor.

◆ Sector()

int Pentagon2::Sector ( const Vector2 d)
staticprotected

Compute the sector given an input direction.

Parameters
dDirection.

◆ Signed()

double Pentagon2::Signed ( const Vector2 p) const

Compute the signed Euclidean distance to the pentagon.

Parameters
pPoint.

◆ Translate()

void Pentagon2::Translate ( const Vector2 t)

Translate a pentagon.

Parameters
tTranslation vector.

◆ Vertex()

Vector2 Pentagon2::Vertex ( int  k) const
inline

Return the coordinates of the k-th vertex.

Parameters
kIndex, should be in [0,4].

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  s,
const Pentagon2 pentagon 
)
friend

Overloaded.

Parameters
sStream.
pentagonThe pentagon.