'Understanding Bezier derivation code that leads nowhere

I'm trying to convert Bezier.js implementation of calculating normals to a Shadertoy program, and the code appears to not use any of the calculated values. It needs to be for quadratic rationals as well.

I found the Javascript code a slight bit hard to follow, so I simplified it for my Shadertoy program:

vec2[3] derive(vec2[3] p)
{
    vec2[3] dpoints;
    int l_length = 0, j;
    for (int i = 2; i > 0; --i) {
      vec2[3] l;
      for (j = 0; j < i; j++) {
        vec2 dpt = vec2(
          float(i) * (p[j + 1].x - p[j].x),
          float(i) * (p[j + 1].y - p[j].y));
        dpoints[l_length] = dpt;
        l[l_length] = dpt; ++l_length;
      }
      p = l;
    }
    return dpoints;
}

The Bezier.js program continues to add functionality for 3d beziers, in case that has anything to do with rational beziers.

I need to make sense of the rest of the program, since I don't know the theory for calculating the normals.



Solution 1:[1]

To spell Pomax's answer out loud:

Only the last calculated value is used, to make a "curve" (line) from origin.

The weights are calculated as w'0 = 2(w1-w0), w'1 = 2(w2-w1).

The resulting bezier at t gives the tangent of the original bezier at t.

I hope I got this right I haven't tried this yet.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Illari