Math.html 3.2 KB

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