mirror of
https://github.com/nillerusr/source-engine.git
synced 2024-12-22 06:06:50 +00:00
31 lines
558 B
C++
31 lines
558 B
C++
|
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||
|
//
|
||
|
// Purpose:
|
||
|
//
|
||
|
//=====================================================================================//
|
||
|
|
||
|
#include <halton.h>
|
||
|
|
||
|
HaltonSequenceGenerator_t::HaltonSequenceGenerator_t(int b)
|
||
|
{
|
||
|
base=b;
|
||
|
fbase=(float) b;
|
||
|
seed=1;
|
||
|
|
||
|
}
|
||
|
|
||
|
float HaltonSequenceGenerator_t::GetElement(int elem)
|
||
|
{
|
||
|
int tmpseed=seed;
|
||
|
float ret=0.0;
|
||
|
float base_inv=1.0/fbase;
|
||
|
while(tmpseed)
|
||
|
{
|
||
|
int dig=tmpseed % base;
|
||
|
ret+=((float) dig)*base_inv;
|
||
|
base_inv/=fbase;
|
||
|
tmpseed/=base;
|
||
|
}
|
||
|
return ret;
|
||
|
}
|