|
Code_TYMPAN
4.4.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 64 of file UniformBeamSampler.h.
|
inline |
Constructors.
Definition at line 68 of file UniformBeamSampler.h.
|
inline |
Definition at line 77 of file UniformBeamSampler.h.
|
inline |
Definition at line 91 of file UniformBeamSampler.h.
|
inlinevirtual |
Destructor.
Definition at line 111 of file UniformBeamSampler.h.
|
inlinevirtual |
|
inlinevirtual |
Return the number of rays to launch after a diffraction event.
Reimplemented from Sampler.
Definition at line 207 of file UniformBeamSampler.h.
|
inlineprivate |
Definition at line 215 of file UniformBeamSampler.h.
|
inline |
Definition at line 202 of file UniformBeamSampler.h.
|
inline |
Definition at line 189 of file UniformBeamSampler.h.
|
inline |
Definition at line 176 of file UniformBeamSampler.h.
|
inlinevirtual |
|
inlinevirtual |
Initialize the sample.
Reimplemented from Sampler.
Definition at line 157 of file UniformBeamSampler.h.
|
inlinevirtual |
Return true for an acceptable sample.
Reimplemented from Sampler.
Definition at line 152 of file UniformBeamSampler.h.
|
inline |
Definition at line 114 of file UniformBeamSampler.h.
|
inline |
Definition at line 195 of file UniformBeamSampler.h.
|
inline |
Definition at line 182 of file UniformBeamSampler.h.
|
private |
Opening angle of the cone.
Definition at line 251 of file UniformBeamSampler.h.
|
private |
Directivity of the beam.
Definition at line 252 of file UniformBeamSampler.h.
|
private |
Definition at line 253 of file UniformBeamSampler.h.
|
private |
Current indices ( respectively slice index and sample index of the current slice)
Definition at line 254 of file UniformBeamSampler.h.
|
private |
radius of the current slice
Definition at line 250 of file UniformBeamSampler.h.
|
private |
Real number of rays launched.
Definition at line 247 of file UniformBeamSampler.h.
|
private |
Repere used to rotate the beam in direction of the directivity.
Definition at line 255 of file UniformBeamSampler.h.
|
private |
Number of remaining rays to launch for the current slice.
Definition at line 249 of file UniformBeamSampler.h.
|
private |
Number of slices.
Definition at line 248 of file UniformBeamSampler.h.