Skip to content

Instantly share code, notes, and snippets.

@jhorikawa
Created April 18, 2020 21:24
Show Gist options
  • Save jhorikawa/2527c150ada263c117bbf27ffed594f4 to your computer and use it in GitHub Desktop.
Save jhorikawa/2527c150ada263c117bbf27ffed594f4 to your computer and use it in GitHub Desktop.
Bezier basis function.
function splinePt(points, i, n, t){
let pt1, pt2;
if(n == 1){
pt1 = points[i];
pt2 = points[i+1];
}else{
pt1 = splinePt(points, i, n-1, t);
pt2 = splinePt(points, i+1, n-1, t);
}
let npt = p5.Vector.add(p5.Vector.mult(pt1, (1.0-t)), p5.Vector.mult(pt2, t));
return npt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment