Skip to content

Instantly share code, notes, and snippets.

@paniq
Last active May 10, 2018 07:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paniq/fd70eee87fd860148ed47855fc224017 to your computer and use it in GitHub Desktop.
Save paniq/fd70eee87fd860148ed47855fc224017 to your computer and use it in GitHub Desktop.
Bernstein Polynomial Basis Coefficients as derived from mix()
// Bernstein Polynomial Basis Coefficients as derived from mix()
// x is in range 0..1
void basis (float x) {
// basis 0
float b00 = 1.0;
// basis 1
float b10 = mix(b00, 0.0, x);
float b11 = mix(0.0, b00, x);
// basis 2
float b20 = mix(b10, 0.0, x);
float b21 = mix(b11, b10, x);
float b22 = mix(0.0, b11, x);
// basis 3
float b30 = mix(b20, 0.0, x);
float b31 = mix(b21, b20, x);
float b32 = mix(b22, b21, x);
float b33 = mix(0.0, b22, x);
// and so on
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment