Core 1.0
IrregularOctogon2 Class Reference

Irregular octogon (in the plane). More...

#include <octogon.h>

Public Member Functions

 IrregularOctogon2 ()
 Empty.
 IrregularOctogon2 (const double &, const double &)
 Create an octogon.
 IrregularOctogon2 (const Vector2 &, const double &, const double &)
 Create an octogon.
void Translate (const Vector2 &)
 Translate an octogon.
IrregularOctogon2 Translated (const Vector2 &) const
 Translate an octogon.
void Scale (const double &)
 Scale an octogon.
bool Inside (const Vector2 &) const
 Test if a point is inside.
double Signed (const Vector2 &) const
 Compute the signed distance.
double R (const Vector2 &) const
 Compute the squared distance.
Vector2 Center () const
 Return the center of the octogon.
double Radius () const
 Return the radius of the octogon, i.e., the radius of the circumscribed circle.
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.
void Draw (QGraphicsScene &, const QPen &=QPen(), const QBrush &=QBrush()) const
 Draws an octogon.
Vector2 RandomInside (Random &) const
 Generate a random vector inside the box.
QVector< Vector2 > Poisson (const double &, int, const QVector< Vector2 > &, bool=true, Random &=Random::R239) const
 Compute a Poisson disc distribution inside the irregular octogon.
QVector< Vector2 > Poisson (const double &, int, Random &=Random::R239) const
 Compute a Poisson disc distribution inside the irregular octogon.

Protected Attributes

Vector2 c = Vector::Null
 Center.
double s = 1.0
 Half length of axis aligned edges.
double t = 1.0
 Leg of the cut corners, diagonal edges have length \( t\sqrt{2} \).

Friends

std::ostream & operator<< (std::ostream &stream, const IrregularOctogon2 &octogon)
 Overloaded.

Detailed Description

Irregular octogon (in the plane).

Constructor & Destructor Documentation

◆ IrregularOctogon2() [1/2]

IrregularOctogon2::IrregularOctogon2 ( const double & s,
const double & t )
explicit

Create an octogon.

Parameters
s,tHalf length of axis aligned edges, and leg of the cut corners (diagonal edges have length \( t\sqrt{2} \)).

◆ IrregularOctogon2() [2/2]

IrregularOctogon2::IrregularOctogon2 ( const Vector2 & c,
const double & s,
const double & t )
explicit

Create an octogon.

Parameters
cCenter.
s,tHalf length of axis aligned edges, and leg of the cut corners (diagonal edges have length \( t\sqrt{2} \)).

Member Function Documentation

◆ Draw()

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

Draws an octogon.

Parameters
sceneGraphics scene.
penThe pen.
brushThe brush.

◆ Inside()

bool IrregularOctogon2::Inside ( const Vector2 & p) const

Test if a point is inside.

Parameters
pPoint.

◆ Poisson() [1/2]

QVector< Vector2 > IrregularOctogon2::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 > IrregularOctogon2::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 IrregularOctogon2::R ( const Vector2 & p) const

Compute the squared distance.

Parameters
pPoint.

◆ Radius()

double IrregularOctogon2::Radius ( ) const
inline

Return the radius of the octogon, i.e., the radius of the circumscribed circle.

All vertices are at the same distance from the center, for instance the vertex (s+t, s):

\[ r = \sqrt{(s+t)^2 + s^2} \]

◆ RandomInside()

Vector2 IrregularOctogon2::RandomInside ( Random & random) const

Generate a random vector inside the box.

Parameters
randomRandom number generator.

◆ Scale()

void IrregularOctogon2::Scale ( const double & s)

Scale an octogon.

Parameters
sScaling factor.

◆ Signed()

double IrregularOctogon2::Signed ( const Vector2 & p) const

Compute the signed distance.

Parameters
pPoint.

◆ Translate()

void IrregularOctogon2::Translate ( const Vector2 & u)

Translate an octogon.

Parameters
uTranslation vector.

◆ Translated()

IrregularOctogon2 IrregularOctogon2::Translated ( const Vector2 & u) const

Translate an octogon.

Parameters
uTranslation vector.

◆ Vertex()

Vector2 IrregularOctogon2::Vertex ( int k) const
inline

Return the coordinates of the k-th vertex.

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

◆ operator<<

std::ostream & operator<< ( std::ostream & stream,
const IrregularOctogon2 & octogon )
friend

Overloaded.

Parameters
streamStream.
octogonThe octogon.