float(qrand())/max
(b-a)*static_cast<float>(qrand())/RAND_MAX + a
C++ (Qt)#include "MersenneTwister.h" struct Point3D{ Point3D(double x_ = 0.0, double y = 0.0, double z = 0.0) : x(x_), y(y_), z(z_) {} double x; double y; double z;}; int main() { vector<Point3D> vectorOfPoints(1000); MTRand mtRand; const double R = 1.0; for (size_t i = 0; i < vectorOfPoint.size(); ++i) { double theta = mtRand.rand(M_PI); double phi = mtRand.rand(M_PI+M_PI); double sin_theta = sin(theta); double z = R*cos(theta); double x = R*sin_theta * cos(phi); double y = R*sin_theta * sin(phi); vectorOfPoints[i] = Point3D(x, y, z); } return 0;}