Math.rst 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. Math - Math utility functions
  2. -----------------------------
  3. .. ...............................................................................
  4. .. rubric:: Methods
  5. .. ...............................................................................
  6. .. function:: Math.clamp( x, a, b )
  7. Clamps the x to be between a and b
  8. :param float x: value to be clamped
  9. :param float a: minimum value
  10. :param float b: maximum value
  11. :returns: Clamped value
  12. :rtype: float
  13. .. function:: Math.clampBottom( x, a )
  14. Clamps the x to be larger than a
  15. :param float x: value to be clamped
  16. :param float a: minimum value
  17. :returns: Clamped value
  18. :rtype: float
  19. .. function:: Math.mapLinear( x, a1, a2, b1, b2 )
  20. Linear mapping of x from range <a1, a2> to range <b1, b2>
  21. :param float x: value to be mapped
  22. :param float a1: minimum value for range A
  23. :param float a2: maximum value for range A
  24. :param float b1: minimum value for range B
  25. :param float b2: maximum value for range B
  26. :returns: mapped value
  27. :rtype: float
  28. .. function:: Math.random16()
  29. Random float from <0, 1> with 16 bits of randomness
  30. (standard Math.random() creates repetitive patterns when applied over larger space)
  31. :returns: Random float from <0, 1> with 16 bits of randomness
  32. :rtype: float
  33. .. function:: Math.randInt( low, high )
  34. :returns: Random integer from *low* to *high* interval
  35. :rtype: integer
  36. .. function:: Math.randFloat( low, high )
  37. :returns: Random float from *low* to *high* interval
  38. :rtype: float
  39. .. function:: Math.randFloatSpread( range )
  40. :returns: Random float from -range/2 to range/2 interval
  41. :rtype: float