Core 1.0
Octogon2 Class Reference

Regular Octogons (in the plane). More...

#include <octogon.h>

Public Member Functions

 Octogon2 ()
 Empty.
 
 Octogon2 (const Vector2 &, const double &)
 Create an octogon.
 
 Octogon2 (const double &)
 Create an octogon.
 
void Translate (const Vector2 &)
 Translate an octogon.
 
void Scale (const double &)
 Scale an octogon.
 
bool Inside (const Vector2 &) const
 Test if a point is inside.
 
double R (const Vector2 &) const
 Compute the squared Euclidean distance to the octogon.
 
double Signed (const Vector2 &) const
 Compute the signed Euclidean distance to the octogon.
 
Vector2 Normal (const Vector2 &) const
 Computes the distance vector between an octogon and a point.
 
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.
 
Vector2 Edge (int) const
 Return the edge vector connecting vertexes k and k+1.
 
Vector2 Vertex (int) const
 Return the coordinates of the k-th vertex.
 
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.
 
Vector2 RandomInside (Random &) const
 Generate a random vector inside the box.
 
QVector< Vector2Poisson (const double &, int, const QVector< Vector2 > &, bool=true, Random &=Random::R239) const
 Compute a Poisson disc distribution inside the irregular octogon.
 
QVector< Vector2Poisson (const double &, int, Random &=Random::R239) const
 Compute a Poisson disc distribution inside the irregular octogon.
 
void Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const
 Draws an octogon.
 

Protected Attributes

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

Static Protected Attributes

static const Vector2 vertex [8]
 Array of vertexes.
 
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 &s, const Octogon2 &octogon)
 Overloaded.
 

Detailed Description

Regular 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.

◆ Poisson() [1/2]

QVector< Vector2 > Octogon2::Poisson ( const double & r,
int n,
const QVector< Vector2 > & s,
bool a = true,
Random & random = Random::R239 ) const

Compute a Poisson disc distribution inside the irregular octogon.

This function uses a simple dart throwing algorithm.

Parameters
rRadius of the discs.
nNumber of candidate points.
sSet of points.
aAdd set of points flag: set to true it the set points should be added to the sampling, set to false to define constraints (typically for borders).
randomRandom number generator.

◆ Poisson() [2/2]

QVector< Vector2 > Octogon2::Poisson ( const double & r,
int n,
Random & random = Random::R239 ) const

Compute a Poisson disc distribution inside the irregular octogon.

This function uses a simple dart throwing algorithm.

Parameters
rRadius of the discs.
nNumber of candidate points.
randomRandom number generator.

◆ 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].

◆ RandomInside()

Vector2 Octogon2::RandomInside ( Random & random) const

Generate a random vector inside the box.

Parameters
randomRandom number generator.

◆ 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 Symbol Documentation

◆ operator<<

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

Overloaded.

Parameters
sStream.
octogonThe octogon.