# sinusoidal-decimal

Input a number and a range (min-max), get the number's position along the range eased by a sine curve

## Stats

StarsIssuesVersionUpdatedCreatedSize
sinusoidal-decimal
001.0.04 years ago4 years ago

sinusoidal-decimal
This is a lightweight way to apply a sine curve to numbers in a numeric range.
It is similar to easing, but intended for cases where you have a numeric start point, end point, and position(s) relative to these points.
``````const sinusoidal = require('sinusoidal-decimal')

// Usage: sinusoidal(value, min, max, returnDecimal)

sinusoidal(0, 10, 50) // 10
sinusoidal(10, 10, 50) // 10
sinusoidal(20, 10, 50) // 15.8578...
sinusoidal(30, 10, 50) // 30
sinusoidal(40, 10, 50) // 44.1421...
sinusoidal(50, 10, 50) // 50
sinusoidal(60, 10, 50) // 50

// If returnDecimal flag is true, returns decimal position on sine curve

sinusoidal(0, 10, 50, true) // 0
sinusoidal(10, 10, 50, true) // 0
sinusoidal(20, 10, 50, true) // 0.1464...
sinusoidal(30, 10, 50, true) // 0.5
sinusoidal(40, 10, 50, true) // 0.8535...
sinusoidal(50, 10, 50, true) // 1
sinusoidal(60, 10, 50, true) // 1``````