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

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

#include <UniformBeamSampler.h>

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

Public Member Functions

 UniformBeamSampler (const unsigned int &nbRays=0, const decimal &alpha=(decimal) M_PI, const vec3 &directivity=vec3(0, 0, 1))
 Constructors. More...
 
 UniformBeamSampler (const UniformBeamSampler &other)
 
 UniformBeamSampler (UniformBeamSampler *sampler)
 
virtual SamplerClone ()
 Clone a sample. More...
 
virtual ~UniformBeamSampler ()
 Destructor. More...
 
void next_slice ()
 
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
 
void setOpeningAngle (const decimal &Alpha)
 
decimal getOpeningAngle ()
 
void setDirectivity (const vec3 &Directivity)
 
vec3 getDirectivity ()
 
virtual unsigned int computeDiffractionNbr (const decimal &thetaCalcul)
 Return the number of rays to launch after a diffraction event. More...
 
- 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)
 

Private Member Functions

void find_number_of_slices ()
 

Private Attributes

unsigned int _real_nb_rays
 Real number of rays launched. More...
 
unsigned int _slices
 Number of slices. More...
 
unsigned int _slice_rays
 Number of remaining rays to launch for the current slice. More...
 
decimal _radius
 radius of the current slice More...
 
decimal _alpha
 Opening angle of the cone. More...
 
vec3 _directivity
 Directivity of the beam. More...
 
unsigned int _i
 
unsigned int _j
 Current indices ( respectively slice index and sample index of the current slice) 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 UniformBeamSampler.h.

Constructor & Destructor Documentation

◆ UniformBeamSampler() [1/3]

UniformBeamSampler::UniformBeamSampler ( const unsigned int &  nbRays = 0,
const decimal &  alpha = (decimal) M_PI,
const vec3 &  directivity = vec3(0,0,1) 
)
inline

Constructors.

Definition at line 62 of file UniformBeamSampler.h.

◆ UniformBeamSampler() [2/3]

UniformBeamSampler::UniformBeamSampler ( const UniformBeamSampler other)
inline

Definition at line 78 of file UniformBeamSampler.h.

◆ UniformBeamSampler() [3/3]

UniformBeamSampler::UniformBeamSampler ( UniformBeamSampler sampler)
inline

Definition at line 92 of file UniformBeamSampler.h.

◆ ~UniformBeamSampler()

virtual UniformBeamSampler::~UniformBeamSampler ( )
inlinevirtual

Destructor.

Definition at line 112 of file UniformBeamSampler.h.

Member Function Documentation

◆ Clone()

virtual Sampler* UniformBeamSampler::Clone ( )
inlinevirtual

Clone a sample.

Reimplemented from Sampler.

Definition at line 106 of file UniformBeamSampler.h.

◆ computeDiffractionNbr()

virtual unsigned int UniformBeamSampler::computeDiffractionNbr ( const decimal &  theta)
inlinevirtual

Return the number of rays to launch after a diffraction event.

Reimplemented from Sampler.

Definition at line 185 of file UniformBeamSampler.h.

◆ find_number_of_slices()

void UniformBeamSampler::find_number_of_slices ( )
inlineprivate

Definition at line 193 of file UniformBeamSampler.h.

◆ getDirectivity()

vec3 UniformBeamSampler::getDirectivity ( )
inline

Definition at line 183 of file UniformBeamSampler.h.

◆ getOpeningAngle()

decimal UniformBeamSampler::getOpeningAngle ( )
inline

Definition at line 176 of file UniformBeamSampler.h.

◆ getRealNbRays()

unsigned int UniformBeamSampler::getRealNbRays ( ) const
inline

Definition at line 170 of file UniformBeamSampler.h.

◆ getSample()

virtual vec3 UniformBeamSampler::getSample ( )
inlinevirtual

Return the sample.

Reimplemented from Sampler.

Definition at line 124 of file UniformBeamSampler.h.

◆ init()

virtual void UniformBeamSampler::init ( )
inlinevirtual

Initialize the sample.

Reimplemented from Sampler.

Definition at line 150 of file UniformBeamSampler.h.

◆ isAcceptableSample()

virtual bool UniformBeamSampler::isAcceptableSample ( vec3  v)
inlinevirtual

Return true for an acceptable sample.

Reimplemented from Sampler.

Definition at line 148 of file UniformBeamSampler.h.

◆ next_slice()

void UniformBeamSampler::next_slice ( )
inline

Definition at line 115 of file UniformBeamSampler.h.

◆ setDirectivity()

void UniformBeamSampler::setDirectivity ( const vec3 &  Directivity)
inline

Definition at line 180 of file UniformBeamSampler.h.

◆ setOpeningAngle()

void UniformBeamSampler::setOpeningAngle ( const decimal &  Alpha)
inline

Definition at line 173 of file UniformBeamSampler.h.

Member Data Documentation

◆ _alpha

decimal UniformBeamSampler::_alpha
private

Opening angle of the cone.

Definition at line 226 of file UniformBeamSampler.h.

◆ _directivity

vec3 UniformBeamSampler::_directivity
private

Directivity of the beam.

Definition at line 227 of file UniformBeamSampler.h.

◆ _i

unsigned int UniformBeamSampler::_i
private

Definition at line 228 of file UniformBeamSampler.h.

◆ _j

unsigned int UniformBeamSampler::_j
private

Current indices ( respectively slice index and sample index of the current slice)

Definition at line 228 of file UniformBeamSampler.h.

◆ _radius

decimal UniformBeamSampler::_radius
private

radius of the current slice

Definition at line 225 of file UniformBeamSampler.h.

◆ _real_nb_rays

unsigned int UniformBeamSampler::_real_nb_rays
private

Real number of rays launched.

Definition at line 222 of file UniformBeamSampler.h.

◆ _repere

Repere UniformBeamSampler::_repere
private

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

Definition at line 229 of file UniformBeamSampler.h.

◆ _slice_rays

unsigned int UniformBeamSampler::_slice_rays
private

Number of remaining rays to launch for the current slice.

Definition at line 224 of file UniformBeamSampler.h.

◆ _slices

unsigned int UniformBeamSampler::_slices
private

Number of slices.

Definition at line 223 of file UniformBeamSampler.h.


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