Mathfx

Description
The following snippet provides short functions for floating point numbers. See the usage section for individualized information.

Usage

 * Hermite - This method will interpolate while easing in and out at the limits.
 * [[Image:Mathfx-Hermite.png|Graph of the Hermite function.]]


 * Sinerp - Short for 'sinusoidal interpolation', this method will interpolate while easing around the end, when value is near one.
 * [[Image:Mathfx-Sinerp.png|Graph of the Sinerp function.]]


 * Coserp - Similar to Sinerp, except it eases in, when value is near zero, instead of easing out (and uses cosine instead of sine).
 * Berp - Short for 'boing-like interpolation', this method will first overshoot, then waver back and forth around the end value before coming to a rest.
 * [[Image:Mathfx-Berp.png|Graph of the Berp function.]]


 * Bounce - Returns a value between 0 and 1 that can be used to easily make bouncing GUI items (a la OS X's Dock)
 * [[Image:Mathfx-Bounce.png|Graph of the Bounce function.]]


 * SmoothStep - Works like Lerp, but has ease-in and ease-out of the values.
 * Lerp - Short for 'linearly interpolate', this method is equivalent to Unity's Mathf.Lerp, included for comparison.
 * [[Image:Mathfx-Lerp.png|Graph of the Lerp function.]]


 * NearestPoint - Will return the nearest point on a line to a point. Useful for making an object follow a track.
 * NearestPointStrict - Works like NearestPoint except the end of the line is clamped.

History

 * Added Approx function for testing float value within an offset range. All thanks to Opless for this!
 * Clerp added by Jeff Craighead 10:51, 2 May 2008 (PDT)
 * Added JavaScript conversion

Js - Mathfx.js
I converted from the original C# format above.