Math.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 degToRad]( [page:Float degrees] )</h3>
  53. <div>
  54. degrees -- [page:Float]
  55. </div>
  56. <div>
  57. Converts degrees to radians.
  58. </div>
  59. <h3>[method:Float radToDeg]( [page:Float radians] )</h3>
  60. <div>
  61. radians -- [page:Float]
  62. </div>
  63. <div>
  64. Converts radians to degrees
  65. </div>
  66. <h3>[method:Float lerp]( [page:Float x], [page:Float y], [page:Float t] )</h3>
  67. <div>
  68. x -- Start point. <br />
  69. y -- End point. <br />
  70. t -- Closed unit interval from [0,1].
  71. </div>
  72. <div>
  73. Returns a value interpolated from two known points based on the interval.<br/><br/>
  74. [link:https://en.wikipedia.org/wiki/Linear_interpolation Wikipedia]
  75. </div>
  76. <h3>[method:Float smoothstep]( [page:Float x], [page:Float min], [page:Float max] )</h3>
  77. <div>
  78. x -- The value to evaluate based on its position between min and max. <br />
  79. min -- Any x value below min will be 0 <br />
  80. max -- Any x value above max will be 1
  81. </div>
  82. <div>
  83. 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/>
  84. [link:http://en.wikipedia.org/wiki/Smoothstep Wikipedia]
  85. </div>
  86. <h3>[method:Float smootherstep]( [page:Float x], [page:Float min], [page:Float max] )</h3>
  87. <div>
  88. x -- The value to evaluate based on its position between min and max. <br />
  89. min -- Any x value below min will be 0 <br />
  90. max -- Any x value above max will be 1
  91. </div>
  92. <div>
  93. Returns a value between 0-1. It works the same as smoothstep, but more smooth.
  94. </div>
  95. <h2>Source</h2>
  96. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  97. </body>
  98. </html>