Code_TYMPAN
4.2.0
Industrial site acoustic simulation
|
A Sampler class for sampling rays uniformely from a cone. More...
#include <UniformBeamSampler.h>
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 Sampler * | Clone () |
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... | |
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.
|
inline |
Constructors.
Definition at line 62 of file UniformBeamSampler.h.
|
inline |
Definition at line 78 of file UniformBeamSampler.h.
|
inline |
Definition at line 92 of file UniformBeamSampler.h.
|
inlinevirtual |
Destructor.
Definition at line 112 of file UniformBeamSampler.h.
|
inlinevirtual |
|
inlinevirtual |
Return the number of rays to launch after a diffraction event.
Reimplemented from Sampler.
Definition at line 185 of file UniformBeamSampler.h.
|
inlineprivate |
Definition at line 193 of file UniformBeamSampler.h.
|
inline |
Definition at line 183 of file UniformBeamSampler.h.
|
inline |
Definition at line 176 of file UniformBeamSampler.h.
|
inline |
Definition at line 170 of file UniformBeamSampler.h.
|
inlinevirtual |
|
inlinevirtual |
Initialize the sample.
Reimplemented from Sampler.
Definition at line 150 of file UniformBeamSampler.h.
|
inlinevirtual |
Return true for an acceptable sample.
Reimplemented from Sampler.
Definition at line 148 of file UniformBeamSampler.h.
|
inline |
Definition at line 115 of file UniformBeamSampler.h.
|
inline |
Definition at line 180 of file UniformBeamSampler.h.
|
inline |
Definition at line 173 of file UniformBeamSampler.h.
|
private |
Opening angle of the cone.
Definition at line 226 of file UniformBeamSampler.h.
|
private |
Directivity of the beam.
Definition at line 227 of file UniformBeamSampler.h.
|
private |
Definition at line 228 of file UniformBeamSampler.h.
|
private |
Current indices ( respectively slice index and sample index of the current slice)
Definition at line 228 of file UniformBeamSampler.h.
|
private |
radius of the current slice
Definition at line 225 of file UniformBeamSampler.h.
|
private |
Real number of rays launched.
Definition at line 222 of file UniformBeamSampler.h.
|
private |
Repere used to rotate the beam in direction of the directivity.
Definition at line 229 of file UniformBeamSampler.h.
|
private |
Number of remaining rays to launch for the current slice.
Definition at line 224 of file UniformBeamSampler.h.
|
private |
Number of slices.
Definition at line 223 of file UniformBeamSampler.h.