1
\$\begingroup\$

I am generating a bunch of quadratic curves that are connected together, creating an array of curves, and a function which returns the position on the curve for a given time.

    quadraticBezier: function(a, b, c, t) {
      var diff = 1 - t;
      return diff * diff * a + diff * 2 * t * b + t * t * c;
    },

So I am selecting the appropriate curve based off of current time, and calling that function with the control points (a,b,c) like:

      i = Math.floor(timer) % numberOfCurves;

      p0 = curves[i][0];
      p1 = curves[i][1];
      p2 = curves[i][2];

      t = timer % 1;
      polygon.x = quadraticBezier(p0.x, p1.x, p2.x, t);
      polygon.y = quadraticBezier(p0.y, p1.y, p2.y, t);

My question is, what is the best way to handle normalizing the speed of the polygon (adding some value to t), so that it will be perceived to look like it has a constant speed moving across curves of varying lengths?

\$\endgroup\$

0

You must log in to answer this question.

Browse other questions tagged .