title: Calculate the arclength, curve length of a cubic bezier curve. Why is not working?
body: <p>I'm calculating the arclength (length of a cubic bezier curve) with this algorithm</p>
  
  <pre><code>    function getArcLength(path) {
  
          var STEPS = 1000; // &gt; precision
          var t = 1 / STEPS;
          var aX=0;
          var aY=0;
          var bX=0, bY=0;
          var dX=0, dY=0;
          var dS = 0;
          var sumArc = 0;
          var j = 0;
  
          for (var i=0; i&lt;STEPS; j = j + t) {
              aX = bezierPoint(j, path[0], path[2], path[4], path[6]);
              aY = bezierPoint(j, path[1], path[3], path[5], path[7]);
              dX = aX - bX;
              dY = aY - bY;
              // deltaS. Pitagora
              dS = Math.sqrt((dX * dX) + (dY * dY));
              sumArc = sumArc + dS;
              bX = aX;
              bY = aY;
              i++;
          }
  
          return sumArc;
      }
  </code></pre>
  
  <p>But what I get is something like 915. But the curve is 480 and no more. (I know for sure this because the curve is almost a line)
  The path array has this values:
  498 51 500 52 500 53 500 530</p>
  
  <p>The bezierPoint function is:</p>
  
  <pre><code>        function bezierPoint(t, o1, c1, c2, e1) {
          var C1 = (e1 - (3.0 * c2) + (3.0 * c1) - o1);
          var C2 = ((3.0 * c2) - (6.0 * c1) + (3.0 * o1));
          var C3 = ((3.0 * c1) - (3.0 * o1));
          var C4 = (o1);
  
          return ((C1*t*t*t) + (C2*t*t) + (C3*t) + C4)
      }
  </code></pre>
  
  <p>What I'm doing wrong?</p>