Fixed SmoothStepInterpolation and SmootherStepInterpolation implementations.

Improved documentation consistency of SmoothStep, SmootherStep, SmoothStepInterpolation and SmootherStepInterpolation.
This commit is contained in:
Chris Andrew 2018-05-24 18:48:12 +01:00
parent f38a0683ff
commit 2f3c35c5b5
4 changed files with 10 additions and 10 deletions

View file

@ -5,7 +5,7 @@
*/
/**
* Calculate a smooth percentage of interpolation of `x` between `min` and `max`.
* Calculate a smooth interpolation percentage of `x` between `min` and `max`.
*
* The function receives the number `x` as an argument and returns 0 if `x` is less than or equal to the left edge,
* 1 if `x` is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial,
@ -19,7 +19,7 @@
* @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'.
* @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'.
*
* @return {number} A percentage of interpolation, between 0 and 1.
* @return {number} The percentage of interpolation, between 0 and 1.
*/
var SmoothStep = function (x, min, max)
{

View file

@ -5,7 +5,7 @@
*/
/**
* Calculate a smoother percentage of interpolation of `x` between `min` and `max`.
* Calculate a smoother interpolation percentage of `x` between `min` and `max`.
*
* The function receives the number `x` as an argument and returns 0 if `x` is less than or equal to the left edge,
* 1 if `x` is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial,
@ -21,7 +21,7 @@
* @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'.
* @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'.
*
* @return {number} The smoothly interpolated value.
* @return {number} The percentage of interpolation, between 0 and 1.
*/
var SmootherStep = function (x, min, max)
{

View file

@ -13,7 +13,7 @@ var SmoothStep = require('../SmoothStep');
* @since 3.9.0
* @see {@link https://en.wikipedia.org/wiki/Smoothstep}
*
* @param {number} x - The input value.
* @param {number} x - The percentage of interpolation, between 0 and 1.
* @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'.
* @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'.
*
@ -21,9 +21,9 @@ var SmoothStep = require('../SmoothStep');
*/
var SmoothStepInterpolation = function (x, min, max)
{
var t = SmoothStep(x, min, max);
var t = SmoothStep(min + (max - min) * x, min, max);
return (max - min) * t + min;
return min + (max - min) * t;
};
module.exports = SmoothStepInterpolation;

View file

@ -13,7 +13,7 @@ var SmootherStep = require('../SmootherStep');
* @since 3.9.0
* @see {@link https://en.wikipedia.org/wiki/Smoothstep#Variations}
*
* @param {number} x - The input value.
* @param {number} x - The percentage of interpolation, between 0 and 1.
* @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'.
* @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'.
*
@ -21,9 +21,9 @@ var SmootherStep = require('../SmootherStep');
*/
var SmootherStepInterpolation = function (x, min, max)
{
var t = SmootherStep(x, min, max);
var t = SmootherStep(min + (max - min) * x, min, max);
return (max - min) * t + min;
return min + (max - min) * t;
};
module.exports = SmootherStepInterpolation;