Bezier functions - minor doc bug

I was playing with the new bezier functions and noticed a small bug in the documentation:

bezierQuadratic(t, p0, p1, p2)

Return a quadratic bezier curve at t given the start point p0, control point p1 and end point p2.
(bezierQuadratic should take 5 parameters, ending with p3)

bezierCubic(t, p0, p1, p2)

Return a cubic bezier curve at t given the start point p0, control points p1, p2, and end point p3.
(bezierQuadratic should take 4 parameters, ending with p2)

Otherwise, all good. Fast and fun! Will be super helpful for animators, and anybody else who needs to build smooth, precise curves.

v3.30 bezier test pattern - click for code
// Bezier Testbed -- Look! I can draw silly things!
// Requires Pixelblaze3 with v3.30 or higher firmware
// 11/2022 ZRanger1

export function beforeRender(delta) {
  t1 = time(0.04);
  c1 = wave(t1);
  c4 = wave(-0.25-t1);
  
  t2 = time(0.01)
  c2 = wave(t2)
  c3 = wave(-0.25-t2)  
}

export function render2D(index,x,y) {
  d = bezierCubic(x,c1,c2,c3,c4);
  v = 1-min(1,(abs(y-d)/ 0.165));
  
  hsv(t1+d, 1, v*v*v)
}
1 Like

I’m going off of Wikipedia’s definition:

A Bézier curve is defined by a set of control points P 0 through P n, where n is called the order of the curve (n = 1 for linear, 2 for quadratic, 3 for cubic, etc.).

I know quad sounds like it should be 4 of something, but in algebra it’s means power of 2.

You’re right, bezierQuadratic is fine, my mistake. It’s the prototype definition of bezierCubic above that’s missing p3. The description text is ok.

1 Like