123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <base href="../../" />
- <script src="list.js"></script>
- <script src="page.js"></script>
- <link type="text/css" rel="stylesheet" href="page.css" />
- </head>
- <body>
- <h1>[name]</h1>
- <div class="desc">Math utility functions</div>
- <h2>Properties</h2>
- <h2>Methods</h2>
- <h3>[method:Float clamp]( [page:Float value], [page:Float min], [page:Float max] )</h3>
- <div>
- value — Value to be clamped.<br />
- min — Minimum value<br />
- max — Maximum value.
- </div>
- <div>
- Clamps the *value* to be between *min* and *max*.
- </div>
- <h3>[method:Float degToRad]( [page:Float degrees] )</h3>
- <div>
- degrees -- [page:Float]
- </div>
- <div>
- Converts degrees to radians.
- </div>
- <h3>[method:Integer euclideanModulo]( [page:Integer n], [page:Integer m] )</h3>
- <div>
- n, m --Integers
- </div>
- <div>
- Compute the Euclidian modulo of m % n, that is:
- <code>( ( n % m ) + m ) % m</code>
- </div>
- <h3>[method:UUID generateUUID]( )</h3>
- <div>
- Generate a [link:https://en.wikipedia.org/wiki/Universally_unique_identifier UUID] (universally unique identifier).
- </div>
- <h3>[method:Boolean isPowerOfTwo]( n )</h3>
- <div>
- Return *true* if n is a power of 2.
- </div>
- <h3>[method:Float lerp]( [page:Float x], [page:Float y], [page:Float t] )</h3>
- <div>
- x -- Start point. <br />
- y -- End point. <br />
- t -- Closed unit interval from [0,1].
- </div>
- <div>
- Returns a value [link:https://en.wikipedia.org/wiki/Linear_interpolation linearly interpolated] from two known points based on the given interval.
- </div>
- <h3>[method:Float mapLinear]( [page:Float x], [page:Float a1], [page:Float a2], [page:Float b1], [page:Float b2] )</h3>
- <div>
- x — Value to be mapped.<br />
- a1 — Minimum value for range A.<br />
- a2 — Maximum value for range A.<br />
- b1 — Minimum value for range B.<br />
- b2 — Maximum value for range B.
- </div>
- <div>
- Linear mapping of *x* from range [*a1*, *a2*] to range [*b1*, *b2*].
- </div>
- <h3>[method:Integer nearestPowerOfTwo]( n )</h3>
- <div>
- Return the nearest power of 2 to a given number n.
- </div>
- <h3>[method:Integer nextPowerOfTwo]( n )</h3>
- <div>
- Return the nearest power of 2 that is bigger than n.
- </div>
- <h3>[method:Float radToDeg]( [page:Float radians] )</h3>
- <div>
- radians -- [page:Float]
- </div>
- <div>
- Converts radians to degrees
- </div>
- <h3>[method:Float randFloat]( [page:Float low], [page:Float high] )</h3>
- <div>
- Random float from *low* to *high* interval.
- </div>
- <h3>[method:Float randFloatSpread]( [page:Float range] )</h3>
- <div>
- Random float from *- range / 2* to *range / 2* interval.
- </div>
- <h3>[method:Integer randInt]( [page:Integer low], [page:Integer high] )</h3>
- <div>
- Random integer from *low* to *high* interval.
- </div>
- <h3>[method:Float random16]()</h3>
- <div>
- Random float from 0 to 1 with 16 bits of randomness.<br />
- Standard Math.random() creates repetitive patterns when applied over larger space.
- </div>
- <h3>[method:Float smoothstep]( [page:Float x], [page:Float min], [page:Float max] )</h3>
- <div>
- x -- The value to evaluate based on its position between min and max. <br />
- min -- Any x value below min will be 0 <br />
- max -- Any x value above max will be 1
- </div>
- <div>
- 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/>
- [link:http://en.wikipedia.org/wiki/Smoothstep Wikipedia]
- </div>
- <h3>[method:Float smootherstep]( [page:Float x], [page:Float min], [page:Float max] )</h3>
- <div>
- x -- The value to evaluate based on its position between min and max. <br />
- min -- Any x value below min will be 0 <br />
- max -- Any x value above max will be 1
- </div>
- <div>
- Returns a value between 0-1. It works the same as smoothstep, but more smooth.
- </div>
- <h2>Source</h2>
- [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
- </body>
- </html>
|