Smooth a value - Node.js Math

Node.js examples for Math:Map Value

Description

Smooth a value

Demo Code

/**// w  w w .  ja  v  a 2s .co  m
 * Smooth a value
 *
 * @param  {number} min Minimum boundary
 * @param  {number} max Maximum boundary
 * @param  {number} v   Value
 * @return {number}     Smoothed value
 */
export default function smoothStep(min, max, v) {
  const x = Math.max( 0, Math.min( 1, ( v - min ) / ( max - min ) ) );
  return x * x * ( 3 - 2 * x );
}

Related Tutorials