Code_TYMPAN
4.2.0
Industrial site acoustic simulation
|
A Sampler class for sampling rays uniformely from a cone. More...
#include <UniformPlaneSampler.h>
Public Member Functions | |
UniformPlaneSampler (const vector< vec3 > directions, const unsigned int &nbRays=8) | |
Constructors. More... | |
UniformPlaneSampler (const UniformPlaneSampler &other) | |
UniformPlaneSampler (UniformPlaneSampler *other) | |
virtual Sampler * | Clone () |
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... | |
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.
|
inline |
Constructors.
Definition at line 62 of file UniformPlaneSampler.h.
|
inline |
Definition at line 76 of file UniformPlaneSampler.h.
|
inline |
Definition at line 89 of file UniformPlaneSampler.h.
|
inlinevirtual |
Destructor.
Definition at line 107 of file UniformPlaneSampler.h.
|
inlinevirtual |
|
inline |
Definition at line 164 of file UniformPlaneSampler.h.
|
inlinevirtual |
Return the sample.
Reimplemented from Sampler.
Definition at line 111 of file UniformPlaneSampler.h.
|
inlinevirtual |
Initialize the sample.
Reimplemented from Sampler.
Definition at line 154 of file UniformPlaneSampler.h.
|
inlinevirtual |
Return true for an acceptable sample.
Reimplemented from Sampler.
Definition at line 152 of file UniformPlaneSampler.h.
|
private |
Directions.
Definition at line 173 of file UniformPlaneSampler.h.
|
private |
Definition at line 172 of file UniformPlaneSampler.h.
|
private |
Current indices ( respectively ray index and direction index)
Definition at line 172 of file UniformPlaneSampler.h.
|
private |
Number of directions.
Definition at line 171 of file UniformPlaneSampler.h.
|
private |
Number of rays launched per direction.
Definition at line 169 of file UniformPlaneSampler.h.
|
private |
Number of rays launched per plane.
Definition at line 170 of file UniformPlaneSampler.h.
|
private |
Real number of rays launched.
Definition at line 168 of file UniformPlaneSampler.h.
|
private |
Repere used to rotate the beam in direction of the directivity.
Definition at line 174 of file UniformPlaneSampler.h.