Skip to content

Instantly share code, notes, and snippets.

@randompast
Forked from anonymous/lerpArray.js
Last active August 29, 2015 14:16
Show Gist options
  • Save randompast/e656e33399692ed52f49 to your computer and use it in GitHub Desktop.
Save randompast/e656e33399692ed52f49 to your computer and use it in GitHub Desktop.
var a = [1,2,3,4,9,20];
a.lerp = function(n){
var a = this[Math.floor(n)];
//console.log("a: " + a);
var b = this[Math.ceil(n)];
//console.log("b: " + b);
var t = n-Math.floor(n);
//console.log("t: " + t);
return (1-t)*a + t*b;
}
console.log(a.lerp(4.5))
//could be expanded to bezier, maybe b splines too.
//The idea was to have a[4.5] be an alias for a.lerp(4.5)
//but I suppose this works...
@randompast
Copy link
Author

Oops, accidentally created this while anonymous >.<

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment