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

Octogons in the plane. More...

#include <octogon.h>

Public Member Functions

 Octogon2 ()
 Empty.
 
 Octogon2 (const Vector2 &, const double &)
 Create an octogon. More...
 
 Octogon2 (const double &)
 Create an octogon. More...
 
void Translate (const Vector2 &)
 Translate an octogon. More...
 
void Scale (const double &)
 Scale an octogon. 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 octogon. More...
 
double Signed (const Vector2 &) const
 Compute the signed Euclidean distance to the octogon. More...
 
Vector2 Normal (const Vector2 &) const
 Computes the distance vector between an octogon and a point. More...
 
Vector2 Center () const
 Return the center of the octogon.
 
double Radius () const
 Return the radius of the octogon.
 
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 an octogon.
 
double Area () const
 Area of the octogon.
 
double Perimeter () const
 Perimeter of the octogon.
 
double Edge () const
 Edge length.
 
void Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const
 Draws an octogon. More...
 

Protected Attributes

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

Static Protected Attributes

static const Vector2 vertex [8]
 Array of vertices.
 
static const Vector2 normal [8]
 Array of normal vectors to the edges.
 
static const Vector2 edge [8]
 Unit edge vectors.
 

Friends

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

Detailed Description

Octogons in the plane.

Constructor & Destructor Documentation

◆ Octogon2() [1/2]

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

Create an octogon.

Parameters
cCenter.
rRadius.

◆ Octogon2() [2/2]

Octogon2::Octogon2 ( const double &  r)
explicit

Create an octogon.

Parameters
rRadius.

Member Function Documentation

◆ Draw()

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

Draws an octogon.

Parameters
sceneGraphics scene.
penThe pen.
brushThe brush.

◆ Edge()

Vector2 Octogon2::Edge ( int  k) const
inline

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

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

◆ Inside()

bool Octogon2::Inside ( const Vector2 p) const

Test if a point is inside.

Parameters
pPoint.

◆ Normal()

Vector2 Octogon2::Normal ( const Vector2 p) const

Computes the distance vector between an octogon and a point.

Parameters
pPoint.

◆ R()

double Octogon2::R ( const Vector2 p) const

Compute the squared Euclidean distance to the octogon.

Parameters
pPoint.

◆ Radial()

Vector2 Octogon2::Radial ( int  k) const
inline

Return the radial vector of the k-th vertex.

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

◆ Scale()

void Octogon2::Scale ( const double &  s)

Scale an octogon.

Parameters
sScaling factor.

◆ Signed()

double Octogon2::Signed ( const Vector2 p) const

Compute the signed Euclidean distance to the octogon.

Parameters
pPoint.

◆ Translate()

void Octogon2::Translate ( const Vector2 t)

Translate an octogon.

Parameters
tTranslation vector.

◆ Vertex()

Vector2 Octogon2::Vertex ( int  k) const
inline

Return the coordinates of the k-th vertex.

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

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  s,
const Octogon2 octogon 
)
friend

Overloaded.

Parameters
sStream.
octogonThe octogon.