Core 1.0
|
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< 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. | |
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. | |
Regular Octogons (in the plane).
|
explicit |
Create an octogon.
c | Center. |
r | Radius. |
|
explicit |
Create an octogon.
r | Radius. |
void Octogon2::Draw | ( | QGraphicsScene & | scene, |
const QPen & | pen = QPen(), | ||
const QBrush & | brush = QBrush() ) const |
Draws an octogon.
scene | Graphics scene. |
pen | The pen. |
brush | The brush. |
|
inline |
Return the edge vector connecting vertexes k and k+1.
k | Index, should be in [0,7]. |
bool Octogon2::Inside | ( | const Vector2 & | p | ) | const |
Test if a point is inside.
p | Point. |
Computes the distance vector between an octogon and a point.
p | Point. |
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.
r | Radius of the discs. |
n | Number of candidate points. |
s | Set of points. |
a | Add 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). |
random | Random number generator. |
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.
r | Radius of the discs. |
n | Number of candidate points. |
random | Random number generator. |
double Octogon2::R | ( | const Vector2 & | p | ) | const |
Compute the squared Euclidean distance to the octogon.
p | Point. |
|
inline |
Return the radial vector of the k-th vertex.
k | Index, should be in [0,7]. |
Generate a random vector inside the box.
random | Random number generator. |
void Octogon2::Scale | ( | const double & | s | ) |
Scale an octogon.
s | Scaling factor. |
double Octogon2::Signed | ( | const Vector2 & | p | ) | const |
Compute the signed Euclidean distance to the octogon.
p | Point. |
void Octogon2::Translate | ( | const Vector2 & | t | ) |
Translate an octogon.
t | Translation vector. |
|
inline |
Return the coordinates of the k-th vertex.
k | Index, should be in [0,7]. |
|
friend |
Overloaded.
s | Stream. |
octogon | The octogon. |