|  |  | (and heck, while we're at it, why not just throw in 2 functions to degree
elevate and degree reduce a Bezier spline)
untested, not generalized (but I think you can see the pattern):
#macro DegreeElevateBezier(P0, P1, P2, P3)
  #local Q0 = P0;
  #local Q1 = (1/4)*P0 + (3/4)*P1;
  #local Q2 = (1/2)*P1 + (1/2)*P2;
  #local Q3 = (3/4)*P2 + (1/4)*P3;
  #local Q4 = P3;
  // Return the new control points
  array[5] {Q0, Q1, Q2, Q3, Q4}
#end
#macro DegreeReduceBezier(Q0, Q1, Q2, Q3, Q4)
  #local P0 = Q0;
  #local P1 = (4/3)*Q1 - (1/3)*Q0;
  #local P2 = (4/3)*Q3 - (1/3)*Q4;
  #local P3 = Q4;
  // Return the new control points
  array[4] {P0, P1, P2, P3}
#end
Post a reply to this message
 |  |