Core 1.0
DiscTiles Class Reference

Poisson disc sampling with two tiles and aperiodic tiling. More...

#include <sampling.h>

Public Member Functions

 DiscTiles (const double &, const double &, int, Random &=Random::R239)
 Create a Poisson sampling in a square domain.
 ~DiscTiles ()
 Empty.
Box2 GetBox () const
 Return the box.
Vector2 Vertex (int, int) const
 Getter on the i-th sample.
Vector2 Vertex (int, int, int) const
 Compute the i-th sample for a displaced tile.
int Size (int) const
 Return the number of samples.
QVector< Vector2 > Sample (const ScalarField2 &) const
 Sample a domain according to an input importance function.
QVector< Vector2 > Sample (const Box2 &) const
 Sample a box by tiling the domain with the tiles of the set.
void DrawDebug () const
 Draw the tiles for debugging purposes.
double Packing () const
 Compute the average packing density.

Protected Attributes

double s = 0.0
 Size.
double r = 0.0
 Radius.
double e = 0.0
 Squared radius with small epsilon tolerance.
DiscTile tiles [2]
 Tiles.

Detailed Description

Poisson disc sampling with two tiles and aperiodic tiling.

Constructor & Destructor Documentation

◆ DiscTiles()

DiscTiles::DiscTiles ( const double & s,
const double & r,
int n,
Random & ra = Random::R239 )
explicit

Create a Poisson sampling in a square domain.

Parameters
sSize of the side of the square.
rRadius of the samples.
nMaximum number of samples in the dart throwing process. Note that the number of samples will be different.
raRandom number generator.

Member Function Documentation

◆ DrawDebug()

void DiscTiles::DrawDebug ( ) const

Draw the tiles for debugging purposes.

This function has side effects on the file system: it writes three vector files in the parent of the current directory, ../tile1.pdf and ../tile2.pdf for the two tiles, and ../tile3.pdf for a sample of the tiling extended by two tile sizes. Existing files with the same names are overwritten.

◆ Packing()

double DiscTiles::Packing ( ) const

Compute the average packing density.

This is the mean of the packing densities of the two tiles.

Returns
The packing density.
See also
DiscTile::Packing()

◆ Sample() [1/2]

QVector< Vector2 > DiscTiles::Sample ( const Box2 & box) const

Sample a box by tiling the domain with the tiles of the set.

The tiles are selected by the aperiodic tiling, and only the samples that lie inside the box are returned.

Parameters
boxThe box.
Returns
The set of samples.

◆ Sample() [2/2]

QVector< Vector2 > DiscTiles::Sample ( const ScalarField2 & s) const

Sample a domain according to an input importance function.

Parameters
sScalar field defining the importance function.

◆ Size()

int DiscTiles::Size ( int t) const

Return the number of samples.

Parameters
tTile.

◆ Vertex() [1/2]

Vector2 DiscTiles::Vertex ( int t,
int i ) const

Getter on the i-th sample.

Parameters
tTile.
iSample index.

◆ Vertex() [2/2]

Vector2 DiscTiles::Vertex ( int x,
int y,
int i ) const

Compute the i-th sample for a displaced tile.

Parameters
iSample index, should be lower than the size of tile at (x,y).
x,yInteger coordinates of the tile.