[name]
Math utility functions
Properties
Methods
.clamp( [page:Float x], [page:Float a], [page:Float b] ) [page:Float]
x — Value to be clamped.
a — Minimum value
b — Maximum value.
Clamps the *x* to be between *a* and *b*.
.clampBottom( [page:Float x], [page:Float a] ) [page:Float]
x — Value to be clamped.
a — Minimum value
Clamps the *x* to be larger than *a*.
.mapLinear( [page:Float x], [page:Float a1], [page:Float a2], [page:Float b1], [page:Float b2] ) [page:Float]
x — Value to be mapped.
a1 — Minimum value for range A.
a2 — Maximum value for range A.
b1 — Minimum value for range B.
b2 — Maximum value for range B.
Linear mapping of *x* from range [*a1*, *a2*] to range [*b1*, *b2*].
.random16() [page:Float]
Random float from 0 to 1 with 16 bits of randomness.
Standard Math.random() creates repetitive patterns when applied over larger space.
.randInt( [page:Integer low], [page:Integer high] ) [page:Integer]
Random integer from *low* to *high* interval.
.randFloat( [page:Float low], [page:Float high] ) [page:Float]
Random float from *low* to *high* interval.
.randFloatSpread( [page:Float range] ) [page:Float]
Random float from *- range / 2* to *range / 2* interval.
.sign( [page:Float x] ) [page:Float]
Returns -1 if *x* is less than 0, 1 if *x* is greater than 0, and 0 if *x* is zero.
.degToRad([page:Float degrees]) [page:Float]
degrees -- [page:Float]
Converts degrees to radians.
.radToDeg([page:Float radians]) [page:Float]
radians -- [page:Float]
Converts radians to degrees
.smoothstep([page:Float x], [page:Float min], [page:Float max]) [page:Float]
x -- The value to evaluate based on its position between min and max.
min -- Any x value below min will be 0
max -- Any x value above max will be 1
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.
[link:http://en.wikipedia.org/wiki/Smoothstep Wikipedia]
.smootherstep([page:Float x], [page:Float min], [page:Float max]) [page:Float]
x -- The value to evaluate based on its position between min and max.
min -- Any x value below min will be 0
max -- Any x value above max will be 1
Returns a value between 0-1. It works the same as smoothstep, but more smooth.
Source
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]