Math.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <script src="../../list.js"></script>
  6. <script src="../../page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="../../page.css" />
  8. </head>
  9. <body>
  10. <h1>[name]</h1>
  11. <div class="desc">Math utility functions</div>
  12. <h2>Methods</h2>
  13. <h3>.clamp( [page:Float x], [page:Float a], [page:Float b] ) [page:Float]</h3>
  14. <div>
  15. x — Value to be clamped.<br />
  16. a — Minimum value<br />
  17. b — Maximum value.
  18. </div>
  19. <div>
  20. Clamps the *x* to be between *a* and *b*.
  21. </div>
  22. <h3>.clampBottom( [page:Float x], [page:Float a] ) [page:Float]</h3>
  23. <div>
  24. x — Value to be clamped.<br />
  25. a — Minimum value
  26. </div>
  27. <div>
  28. Clamps the *x* to be larger than *a*.
  29. </div>
  30. <h3>.mapLinear( [page:Float x], [page:Float a] ) [page:Float]</h3>
  31. <div>
  32. x — Value to be mapped.<br />
  33. a1 — Minimum value for range A.<br />
  34. a2 — Maximum value for range A.<br />
  35. b1 — Minimum value for range B.<br />
  36. b2 — Maximum value for range B.
  37. </div>
  38. <div>
  39. Linear mapping of *x* from range [*a1*, *a2*] to range [*b1*, *b2*].
  40. </div>
  41. <h3>.random16() [page:Float]</h3>
  42. <div>
  43. Random float from 0 to 1 with 16 bits of randomness.<br />
  44. Standard Math.random() creates repetitive patterns when applied over larger space.
  45. </div>
  46. <h3>.randInt( [page:Integer low], [page:Integer high] ) [page:Integer]</h3>
  47. <div>
  48. Random integer from *low* to *high* interval.
  49. </div>
  50. <h3>.randFloat( [page:Float low], [page:Float high] ) [page:Float]</h3>
  51. <div>
  52. Random float from *low* to *high* interval.
  53. </div>
  54. <h3>.randFloatSpread( [page:Float range] ) [page:Float]</h3>
  55. <div>
  56. Random float from *- range / 2* to *range / 2* interval.
  57. </div>
  58. <h2>Source</h2>
  59. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  60. </body>
  61. </html>