Code_TYMPAN  4.2.0
Industrial site acoustic simulation
Public Member Functions | Private Attributes | List of all members
UniformPlaneSampler Class Reference

A Sampler class for sampling rays uniformely from a cone. More...

#include <UniformPlaneSampler.h>

Inheritance diagram for UniformPlaneSampler:
Inheritance graph
[legend]
Collaboration diagram for UniformPlaneSampler:
Collaboration graph
[legend]

Public Member Functions

 UniformPlaneSampler (const vector< vec3 > directions, const unsigned int &nbRays=8)
 Constructors. More...
 
 UniformPlaneSampler (const UniformPlaneSampler &other)
 
 UniformPlaneSampler (UniformPlaneSampler *other)
 
virtual SamplerClone ()
 Clone a sample. More...
 
virtual ~UniformPlaneSampler ()
 Destructor. More...
 
virtual vec3 getSample ()
 Return the sample. More...
 
virtual bool isAcceptableSample (vec3 v)
 Return true for an acceptable sample. More...
 
virtual void init ()
 Initialize the sample. More...
 
unsigned int getRealNbRays () const
 
- Public Member Functions inherited from Sampler
 Sampler (const unsigned int &nbRays=0, const decimal &Theta=(decimal) M_PIDIV2, const decimal &Phi=(decimal) M_2PI)
 Default constructor. More...
 
 Sampler (const Sampler &other)
 Copy constructors. More...
 
 Sampler (Sampler *sampler)
 
virtual ~Sampler ()
 Destructor. More...
 
virtual unsigned int getNbRays () const
 Get/Set the number of rays to launch. More...
 
virtual void setNbRays (const unsigned int &nbRays)
 
decimal getTheta () const
 Get/Set the polar angle. More...
 
void setTheta (const decimal &Theta)
 
decimal getPhi () const
 Get/Set the equatorial polar angle. More...
 
void setPhi (const decimal &Phi)
 
virtual unsigned int computeDiffractionNbr (const decimal &theta)
 Return the number of rays to launch after a diffraction event. More...
 

Private Attributes

unsigned int _real_nb_rays
 Real number of rays launched. More...
 
unsigned int _nb_rays_per_direction
 Number of rays launched per direction. More...
 
unsigned int _nb_rays_per_plane
 Number of rays launched per plane. More...
 
unsigned int _nb_directions
 Number of directions. More...
 
unsigned int _i
 
unsigned int _j
 Current indices ( respectively ray index and direction index) More...
 
vector< vec3 > _directions
 Directions. More...
 
Repere _repere
 Repere used to rotate the beam in direction of the directivity. More...
 

Additional Inherited Members

- Protected Attributes inherited from Sampler
unsigned int _nb_rays
 Number of rays to launch. More...
 
decimal _theta
 Global polar angle. More...
 
decimal _phi
 Global equatorial angle. More...
 

Detailed Description

A Sampler class for sampling rays uniformely from a cone.

Principle : Sample points on the spherical cap resulting from the intersection between the unit sphere and the cone of axis z-axis and opening angle alpha. Then rotate the samples so that the axis of the cone points in the direction of the directivity

The cap is divided into horizontal slices on which points are sampled. The angle between consecutive slices is phi. The angle between consecutive samples on the same slice is theta. Theta is computed so that the arc length between neighboring samples on the same slice is equal to the arc length between neihboring slices (hence the uniformity of the samples) This means that the phi angle directly controls the number of slices and indirectly controls the number samples on each one of them. This gives us a nice uniform distribution of the samples but it prevents us from chosing exactly how many samples are generated.

The phi angle (and therefore the number of slices) is choosen so that the real number of samples is at least equal to the desired number of rays (nbRays)

Note : The first sample is always (0,0,1) Therefore, if we launch at least one ray, the first ray is always collinear with the directivity of the source

Ref : This approach is refered as Rusin's discoball Some more details on evenly distributed points on a sphere : http://web.archive.org/web/20120107030109/http://cgafaq.info/wiki/Evenly_distributed_points_on_sphere Comparison with the "golden sector" and the "Saff & Kuijlaar" approaches : https://bendwavy.org/pack/pack.htm

Definition at line 58 of file UniformPlaneSampler.h.

Constructor & Destructor Documentation

◆ UniformPlaneSampler() [1/3]

UniformPlaneSampler::UniformPlaneSampler ( const vector< vec3 >  directions,
const unsigned int &  nbRays = 8 
)
inline

Constructors.

Definition at line 62 of file UniformPlaneSampler.h.

◆ UniformPlaneSampler() [2/3]

UniformPlaneSampler::UniformPlaneSampler ( const UniformPlaneSampler other)
inline

Definition at line 76 of file UniformPlaneSampler.h.

◆ UniformPlaneSampler() [3/3]

UniformPlaneSampler::UniformPlaneSampler ( UniformPlaneSampler other)
inline

Definition at line 89 of file UniformPlaneSampler.h.

◆ ~UniformPlaneSampler()

virtual UniformPlaneSampler::~UniformPlaneSampler ( )
inlinevirtual

Destructor.

Definition at line 107 of file UniformPlaneSampler.h.

Member Function Documentation

◆ Clone()

virtual Sampler* UniformPlaneSampler::Clone ( )
inlinevirtual

Clone a sample.

Reimplemented from Sampler.

Definition at line 101 of file UniformPlaneSampler.h.

◆ getRealNbRays()

unsigned int UniformPlaneSampler::getRealNbRays ( ) const
inline

Definition at line 164 of file UniformPlaneSampler.h.

◆ getSample()

virtual vec3 UniformPlaneSampler::getSample ( )
inlinevirtual

Return the sample.

Reimplemented from Sampler.

Definition at line 111 of file UniformPlaneSampler.h.

Here is the call graph for this function:

◆ init()

virtual void UniformPlaneSampler::init ( )
inlinevirtual

Initialize the sample.

Reimplemented from Sampler.

Definition at line 154 of file UniformPlaneSampler.h.

◆ isAcceptableSample()

virtual bool UniformPlaneSampler::isAcceptableSample ( vec3  v)
inlinevirtual

Return true for an acceptable sample.

Reimplemented from Sampler.

Definition at line 152 of file UniformPlaneSampler.h.

Member Data Documentation

◆ _directions

vector<vec3> UniformPlaneSampler::_directions
private

Directions.

Definition at line 173 of file UniformPlaneSampler.h.

◆ _i

unsigned int UniformPlaneSampler::_i
private

Definition at line 172 of file UniformPlaneSampler.h.

◆ _j

unsigned int UniformPlaneSampler::_j
private

Current indices ( respectively ray index and direction index)

Definition at line 172 of file UniformPlaneSampler.h.

◆ _nb_directions

unsigned int UniformPlaneSampler::_nb_directions
private

Number of directions.

Definition at line 171 of file UniformPlaneSampler.h.

◆ _nb_rays_per_direction

unsigned int UniformPlaneSampler::_nb_rays_per_direction
private

Number of rays launched per direction.

Definition at line 169 of file UniformPlaneSampler.h.

◆ _nb_rays_per_plane

unsigned int UniformPlaneSampler::_nb_rays_per_plane
private

Number of rays launched per plane.

Definition at line 170 of file UniformPlaneSampler.h.

◆ _real_nb_rays

unsigned int UniformPlaneSampler::_real_nb_rays
private

Real number of rays launched.

Definition at line 168 of file UniformPlaneSampler.h.

◆ _repere

Repere UniformPlaneSampler::_repere
private

Repere used to rotate the beam in direction of the directivity.

Definition at line 174 of file UniformPlaneSampler.h.


The documentation for this class was generated from the following file: