Hello,

I write because I observed some weird behavior with the random sampler in 
cylinders.
I attached a very simple test which samples particles with a given radius 
(1), in a disk of a given radius as well (20).

When running it and print the distance to [0,0], I obtain values that are 
well above 20.
Looking at the source code of the sampler, I do not really understand why. 
Do you have a clue of what I might be doing wrong?

Best regards,
Yves 


-- 
You received this message because you are subscribed to the Google Groups 
"ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/projectchrono/fb695b77-75d5-441b-a0f9-805304b22de4n%40googlegroups.com.
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <chrono>
#include "chrono/utils/ChUtilsSamplers.h"

using namespace chrono;

int main(int argc, char* argv[])
{
    srand(time(NULL));
    float r_particle = 1.;
    float r_cylinder = 20.;
    float z_cylinder = 10.;

    chrono::utils::PDSampler<float> sampler(2 * r_particle);
    std::vector<ChVector<float>> positions;
    auto points = sampler.SampleCylinderZ((0.,0.,z_cylinder), r_cylinder, 0.0);
    positions.insert(positions.end(), points.begin(), points.end());

    for (int k = 0; k < positions.size(); k++)
    {
        std::cout << "R: " << sqrt(pow(positions[k][0], 2) + 
pow(positions[k][1], 2)) << "\t\tZ:" << positions[k][2] << std::endl;
    }
}

Reply via email to