Math.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. <h1>[name]</h1>
  12. <div class="desc">Math utility functions</div>
  13. <h2>Properties</h2>
  14. <h2>Methods</h2>
  15. <h3>[method:Float clamp]( [page:Float value], [page:Float min], [page:Float max] )</h3>
  16. <div>
  17. value — Value to be clamped.<br />
  18. min — Minimum value<br />
  19. max — Maximum value.
  20. </div>
  21. <div>
  22. Clamps the *value* to be between *min* and *max*.
  23. </div>
  24. <h3>[method:Float mapLinear]( [page:Float x], [page:Float a1], [page:Float a2], [page:Float b1], [page:Float b2] )</h3>
  25. <div>
  26. x — Value to be mapped.<br />
  27. a1 — Minimum value for range A.<br />
  28. a2 — Maximum value for range A.<br />
  29. b1 — Minimum value for range B.<br />
  30. b2 — Maximum value for range B.
  31. </div>
  32. <div>
  33. Linear mapping of *x* from range [*a1*, *a2*] to range [*b1*, *b2*].
  34. </div>
  35. <h3>[method:Float random16]()</h3>
  36. <div>
  37. Random float from 0 to 1 with 16 bits of randomness.<br />
  38. Standard Math.random() creates repetitive patterns when applied over larger space.
  39. </div>
  40. <h3>[method:Integer randInt]( [page:Integer low], [page:Integer high] )</h3>
  41. <div>
  42. Random integer from *low* to *high* interval.
  43. </div>
  44. <h3>[method:Float randFloat]( [page:Float low], [page:Float high] )</h3>
  45. <div>
  46. Random float from *low* to *high* interval.
  47. </div>
  48. <h3>[method:Float randFloatSpread]( [page:Float range] )</h3>
  49. <div>
  50. Random float from *- range / 2* to *range / 2* interval.
  51. </div>
  52. <h3>[method:Float sign]( [page:Float x] )</h3>
  53. <div>
  54. Returns -1 if *x* is less than 0, 1 if *x* is greater than 0, and 0 if *x* is zero.
  55. </div>
  56. <h3>[method:Float degToRad]([page:Float degrees])</h3>
  57. <div>
  58. degrees -- [page:Float]
  59. </div>
  60. <div>
  61. Converts degrees to radians.
  62. </div>
  63. <h3>[method:Float radToDeg]([page:Float radians])</h3>
  64. <div>
  65. radians -- [page:Float]
  66. </div>
  67. <div>
  68. Converts radians to degrees
  69. </div>
  70. <h3>[method:Float smoothstep]([page:Float x], [page:Float min], [page:Float max])</h3>
  71. <div>
  72. x -- The value to evaluate based on its position between min and max. <br />
  73. min -- Any x value below min will be 0 <br />
  74. max -- Any x value above max will be 1
  75. </div>
  76. <div>
  77. 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/>
  78. [link:http://en.wikipedia.org/wiki/Smoothstep Wikipedia]
  79. </div>
  80. <h3>[method:Float smootherstep]([page:Float x], [page:Float min], [page:Float max])</h3>
  81. <div>
  82. x -- The value to evaluate based on its position between min and max. <br />
  83. min -- Any x value below min will be 0 <br />
  84. max -- Any x value above max will be 1
  85. </div>
  86. <div>
  87. Returns a value between 0-1. It works the same as smoothstep, but more smooth.
  88. </div>
  89. <h2>Source</h2>
  90. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  91. </body>
  92. </html>