-
-
Save randompast/e656e33399692ed52f49 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oops, accidentally created this while anonymous >.<