Skip to content

Instantly share code, notes, and snippets.

@ianterrell
Created July 11, 2013 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianterrell/5978833 to your computer and use it in GitHub Desktop.
Save ianterrell/5978833 to your computer and use it in GitHub Desktop.
macros for the De Casteljau algorithm as described here: http://stackoverflow.com/questions/11703283/cubic-bezier-curve-segment/11704152#11704152
#define p1prime(p1,p2,p3,p4) (u0*u0*u0*p1 + (t0*u0*u0 + u0*t0*u0 + u0*u0*t0)*p2 + (t0*t0*u0 + u0*t0*t0 + t0*u0*t0)*p3 + t0*t0*t0*p4)
#define p2prime(p1,p2,p3,p4) (u0*u0*u1*p1 + (t0*u0*u1 + u0*t0*u1 + u0*u0*t1)*p2 + (t0*t0*u1 + u0*t0*t1 + t0*u0*t1)*p3 + t0*t0*t1*p4)
#define p3prime(p1,p2,p3,p4) (u0*u1*u1*p1 + (t0*u1*u1 + u0*t1*u1 + u0*u1*t1)*p2 + (t0*t1*u1 + u0*t1*t1 + t0*u1*t1)*p3 + t0*t1*t1*p4)
#define p4prime(p1,p2,p3,p4) (u1*u1*u1*p1 + (t1*u1*u1 + u1*t1*u1 + u1*u1*t1)*p2 + (t1*t1*u1 + u1*t1*t1 + t1*u1*t1)*p3 + t1*t1*t1*p4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment