Math.rst 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. Math - Math utility functions
  2. -----------------------------
  3. **function**::THREE.Math.clamp(*x*, *a*, *b*)
  4. Clamps the *x* to be between *a* and *b*
  5. +-----------+-------+----------------------+
  6. | Parameter | Type | Description |
  7. +===========+=======+======================+
  8. | *x* | float | value to be clamped |
  9. +-----------+-------+----------------------+
  10. | *a* | float | minimum value |
  11. +-----------+-------+----------------------+
  12. | *b* | float | maximum value |
  13. +-----------+-------+----------------------+
  14. | returns | float | value after clamping |
  15. +-----------+-------+----------------------+
  16. **function**::THREE.Math.clampBottom(*x*, *a*)
  17. Clamps the *x* to be larger than *a*
  18. +-----------+-------+----------------------+
  19. | Parameter | Type | Description |
  20. +===========+=======+======================+
  21. | *x* | float | value to be clamped |
  22. +-----------+-------+----------------------+
  23. | *a* | float | minimum value |
  24. +-----------+-------+----------------------+
  25. | returns | float | value after clamping |
  26. +-----------+-------+----------------------+
  27. **function**::THREE.Math.mapLinear(*x*, *a1*, *a2*, *b1*, *b2*)
  28. //todo
  29. **function**::THREE.Math.random16()
  30. +-----------+-------+-----------------------------------------------------+
  31. | Parameter | Type | Description |
  32. +===========+=======+=====================================================+
  33. | returns | float | Random float from <0, 1> with 16 bits of randomness |
  34. +-----------+-------+-----------------------------------------------------+
  35. (standard Math.random() creates repetitive patterns when applied over larger space)
  36. **function**::THREE.Math.randInt(*low*, *high*)
  37. +-----------+---------+----------------------------------------------+
  38. | Parameter | Type | Description |
  39. +===========+=========+==============================================+
  40. | returns | integer | Random integer from *low* to *high* interval |
  41. +-----------+---------+----------------------------------------------+
  42. **function**::THREE.Math.randFloat(*low*, *high*)
  43. +-----------+-------+--------------------------------------------+
  44. | Parameter | Type | Description |
  45. +===========+=======+============================================+
  46. | returns | float | Random float from *low* to *high* interval |
  47. +-----------+-------+--------------------------------------------+
  48. **function**::THREE.Math.randFloatSpread(*range*)
  49. +-----------+-------+---------------------------------------------------+
  50. | Parameter | Type | Description |
  51. +===========+=======+===================================================+
  52. | returns | float | Random float from -*range*/2 to *range*/2 interval|
  53. +-----------+-------+---------------------------------------------------+