Core 1.0
|
Poisson tiling. More...
#include <sampling.h>
Public Member Functions | |
DiscTile () | |
Empty. | |
DiscTile (const double &, const double &, const QVector< Vector2 > &) | |
Create a Poisson disc sampling over a square domain. | |
DiscTile (const double &, const double &, int, Random &=Random::R239) | |
Create a poisson sampling in a square domain. | |
DiscTile (const double &, const double &, int, const QVector< Vector2 > &, Random &=Random::R239) | |
Create a poisson sampling in a square domain. | |
~DiscTile () | |
Empty. | |
void | Relaxation (const double &=1.0/4.0) |
Perform a relaxation step over the Poisson-Disc distribution. | |
void | Relaxation (int, const double &=1.0/4.0) |
Perform a relaxation step over the Poisson-Disc distribution. | |
void | Scramble () |
Scramble the points inside the generated tile. | |
void | Draw (QGraphicsScene &) const |
Draw the distribution. | |
Box2 | GetBox () const |
Return the box. | |
double | Radius () const |
Return the radius. | |
Vector2 | Vertex (int) const |
Getter on the i-th sample. | |
Vector2 | Vertex (int, int, int) const |
Compute the i-th sample for a displaced tile. | |
Vector2 | Vertex (const QPoint &, int) const |
Compute the i-th sample for a displaced tile. | |
const QVector< Vector2 > | GetSet () const |
Return the vector containing the samples. | |
int | Size () const |
Return the number of samples. | |
void | Scale (const double &) |
Scale a disc tile. | |
QVector< Vector2 > | Sample (const Box2 &, double(*)(const Vector2 &)) const |
Sample a domain according to an input importance function. | |
QVector< Vector2 > | Sample (const ScalarField2 &) const |
Sample a domain according to an input importance function. | |
QVector< Vector2 > | Sample (const Box2 &) const |
Sample a domain according to an input importance function. | |
double | Packing () const |
Compute the packing density. | |
Static Public Member Functions | |
static bool | Check (const Vector2 &, const QVector< Vector2 > &, double) |
Performs a Poisson disc check on a set of point and a candidate position. | |
Static Public Attributes | |
static const DiscTile | UnitReference |
Reference unit disc tile with 231 discs. | |
Protected Member Functions | |
void | Generate (int, Random &=Random::R239) |
Generate the poisson sampling of the domain. | |
bool | Intersect (const Vector2 &, bool=true) const |
Check if a disc intersect existing discs inside the tile, with or without toric constraints. | |
Protected Attributes | |
double | s = 0.0 |
Size. | |
double | r = 0.0 |
Radius. | |
double | e = 0.0 |
Squared radius with small epsilon tolerance. | |
QVector< Vector2 > | p |
Set of samples. | |
Friends | |
std::ostream & | operator<< (std::ostream &s, const DiscTile &disctile) |
Overloaded. | |
Poisson tiling.
Can be used for importance sampling from Template Poisson disk tiles, Ares Lagae, Philip Dutré. See Ares Lagae, Philip Dutré. A procedural object distribution function. ACM Transactions on Graphics. 24(4), 1442–1461.
|
explicit |
Empty.
Initialize a poisson disc tiling.
|
explicit |
Create a Poisson disc sampling over a square domain.
s | Size of the side of the square. |
r | Radius of the samples. |
v | Set of points. |
|
explicit |
Create a poisson sampling in a square domain.
s | Size of the side of the square. |
r | Radius of the samples. |
n | Maximum number of samples in the dart throwing process. Note that the number of samples will be different. |
ra | Random number generator. |
|
explicit |
Create a poisson sampling in a square domain.
s | Size of the side of the square. |
r | Radius of the samples. |
n | Maximum number of samples in the dart throwing process. Note that the number of samples will be different. |
p | Set of samples that will be in the tile. |
ra | Random number generator. |
Performs a Poisson disc check on a set of point and a candidate position.
Returns true if the candidate intersects with the distribution, false otherwise.
p | Candidate position. |
s | Set of point. |
r | Poisson disc radius. |
void DiscTile::Draw | ( | QGraphicsScene & | scene | ) | const |
Draw the distribution.
scene | The graphics scene. |
|
protected |
Generate the poisson sampling of the domain.
n | Number of darts thrown on the domain. Note that the number of generated samples will be less than n. |
random | Random number generator. |
|
protected |
Check if a disc intersect existing discs inside the tile, with or without toric constraints.
This complexity is O(n), thus the function is expensive should it be called many times.
q | Point. |
t | Toric constraint, set to true as default. |
double DiscTile::Packing | ( | ) | const |
Compute the packing density.
void DiscTile::Relaxation | ( | const double & | c = 1.0 / 4.0 | ) |
Perform a relaxation step over the Poisson-Disc distribution.
c | Relaxation coefficient, it is the fraction of the Poisson radius. |
void DiscTile::Relaxation | ( | int | n, |
const double & | c = 1.0 / 4.0 ) |
Perform a relaxation step over the Poisson-Disc distribution.
c | Relaxation coefficient, it the fraction of the radius of the Poisson distribution. |
n | Number of steps. |
Sample a domain according to an input importance function.
box | The box. |
Sample a domain according to an input importance function.
b | The box. |
f | Importance function. |
QVector< Vector2 > DiscTile::Sample | ( | const ScalarField2 & | s | ) | const |
Sample a domain according to an input importance function.
s | Scalar field defining the importance function. |
void DiscTile::Scale | ( | const double & | s | ) |
Scale a disc tile.
s | Scaling factor. |
void DiscTile::Scramble | ( | ) |
Scramble the points inside the generated tile.
Use a modified version of the Fisher-Yates algorithm.
|
inline |
Compute the i-th sample for a displaced tile.
t | Integer coordinates of the tile. |
i | Sample index. |
|
inline |
Getter on the i-th sample.
i | Sample index. |
|
inline |
Compute the i-th sample for a displaced tile.
x,y | Integer coordinates of the tile. |
i | Sample index. |
|
friend |
Overloaded.
s | Stream. |
disctile | The disc tile. |