Math.html 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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>Properties</h2>
  13. <h2>Methods</h2>
  14. <h3>[method:Float clamp]( [page:Float x], [page:Float a], [page:Float b] )</h3>
  15. <div>
  16. x — Value to be clamped.<br />
  17. a — Minimum value<br />
  18. b — Maximum value.
  19. </div>
  20. <div>
  21. Clamps the *x* to be between *a* and *b*.
  22. </div>
  23. <h3>[method:Float clampBottom]( [page:Float x], [page:Float a] )</h3>
  24. <div>
  25. x — Value to be clamped.<br />
  26. a — Minimum value
  27. </div>
  28. <div>
  29. Clamps the *x* to be larger than *a*.
  30. </div>
  31. <h3>[method:Float mapLinear]( [page:Float x], [page:Float a1], [page:Float a2], [page:Float b1], [page:Float b2] )</h3>
  32. <div>
  33. x — Value to be mapped.<br />
  34. a1 — Minimum value for range A.<br />
  35. a2 — Maximum value for range A.<br />
  36. b1 — Minimum value for range B.<br />
  37. b2 — Maximum value for range B.
  38. </div>
  39. <div>
  40. Linear mapping of *x* from range [*a1*, *a2*] to range [*b1*, *b2*].
  41. </div>
  42. <h3>[method:Float random16]()</h3>
  43. <div>
  44. Random float from 0 to 1 with 16 bits of randomness.<br />
  45. Standard Math.random() creates repetitive patterns when applied over larger space.
  46. </div>
  47. <h3>[method:Integer randInt]( [page:Integer low], [page:Integer high] )</h3>
  48. <div>
  49. Random integer from *low* to *high* interval.
  50. </div>
  51. <h3>[method:Float randFloat]( [page:Float low], [page:Float high] )</h3>
  52. <div>
  53. Random float from *low* to *high* interval.
  54. </div>
  55. <h3>[method:Float randFloatSpread]( [page:Float range] )</h3>
  56. <div>
  57. Random float from *- range / 2* to *range / 2* interval.
  58. </div>
  59. <h3>[method:Float sign]( [page:Float x] )</h3>
  60. <div>
  61. Returns -1 if *x* is less than 0, 1 if *x* is greater than 0, and 0 if *x* is zero.
  62. </div>
  63. <h3>[method:Float degToRad]([page:Float degrees])</h3>
  64. <div>
  65. degrees -- [page:Float]
  66. </div>
  67. <div>
  68. Converts degrees to radians.
  69. </div>
  70. <h3>[method:Float radToDeg]([page:Float radians])</h3>
  71. <div>
  72. radians -- [page:Float]
  73. </div>
  74. <div>
  75. Converts radians to degrees
  76. </div>
  77. <h3>[method:Float smoothstep]([page:Float x], [page:Float min], [page:Float max])</h3>
  78. <div>
  79. x -- The value to evaluate based on its position between min and max. <br />
  80. min -- Any x value below min will be 0 <br />
  81. max -- Any x value above max will be 1
  82. </div>
  83. <div>
  84. Returns a value between 0-1 that represents the percentage that x has moved between min and max, but smoothed or slowed down the closer X is to the min and max.<br/><br/>
  85. [link:http://en.wikipedia.org/wiki/Smoothstep Wikipedia]
  86. </div>
  87. <h3>[method:Float smootherstep]([page:Float x], [page:Float min], [page:Float max])</h3>
  88. <div>
  89. x -- The value to evaluate based on its position between min and max. <br />
  90. min -- Any x value below min will be 0 <br />
  91. max -- Any x value above max will be 1
  92. </div>
  93. <div>
  94. Returns a value between 0-1. It works the same as smoothstep, but more smooth.
  95. </div>
  96. <h2>Source</h2>
  97. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  98. </body>
  99. </html>