Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
558 B

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=====================================================================================//
  6. #include <halton.h>
  7. HaltonSequenceGenerator_t::HaltonSequenceGenerator_t(int b)
  8. {
  9. base=b;
  10. fbase=(float) b;
  11. seed=1;
  12. }
  13. float HaltonSequenceGenerator_t::GetElement(int elem)
  14. {
  15. int tmpseed=seed;
  16. float ret=0.0;
  17. float base_inv=1.0/fbase;
  18. while(tmpseed)
  19. {
  20. int dig=tmpseed % base;
  21. ret+=((float) dig)*base_inv;
  22. base_inv/=fbase;
  23. tmpseed/=base;
  24. }
  25. return ret;
  26. }