Normalize a value between two bounds - Node.js Math

Node.js examples for Math:Map Value

Description

Normalize a value between two bounds

Demo Code


/**// www  . ja  v  a 2  s  .  c  o m
 * Normalize a value between two bounds
 *
 * @param  {number} min Minimum boundary
 * @param  {number} max Maximum boundary
 * @param  {number} x   Value to normalize
 * @return {number}     Normalized value
 */
export default function normalize(min, max, x) {
  return (x - min) / (max - min);
}

Related Tutorials