方法1.
vtkMath,从平均0.0和标准偏差2.0的高斯分布中产生了3个随机数
#include <vtkMath.h>
#include <time.h>
#include <QDebug>
int main(int, char *[])
{
unsigned int numRand = 3;
vtkMath::RandomSeed(time(nullptr));
for (unsigned int i = 0; i < numRand; ++i)
{
double num = vtkMath::Gaussian(0.0, 2.0);
qDebug() << "num : " << num;
}
return EXIT_SUCCESS;
}
方法2.
vtkMinimalStandardRandomSequence,它实际上是一个随机序列生成器
#include <vtkSmartPointer.h>
#include <vtkMinimalStandardRandomSequence.h>
#include <QDebug>
int main(int, char *[])
{
vtkSmartPointer<vtkMinimalStandardRandomSequence> sequence = vtkSmartPointer<vtkMinimalStandardRandomSequence>::New();
sequence->SetSeed(1);
double x = sequence->G