code: def discretize_bezier(points,
                        count=None,
                        scale=1.0):
      
      # make sure we have a numpy array
      points = np.asanyarray(points, dtype=np.float64)
  
      if count is None:
          # how much distance does a small percentage of the curve take
          # this is so we can figure out how finely we have to sample t
          norm = np.linalg.norm(np.diff(points, axis=0), axis=1).sum()
          count = np.ceil(norm / (res.seg_frac * scale))
          count = int(np.clip(count,
                              res.min_sections * len(points),
                              res.max_sections * len(points)))
      count = int(count)
  
      # parameterize incrementing 0.0 - 1.0
      t = np.linspace(0.0, 1.0, count)
      # decrementing 1.0-0.0
      t_d = 1.0 - t
      n = len(points) - 1
      # binomial coefficients, i, and each point
      iterable = zip(binomial(n), np.arange(len(points)), points)
      # run the actual interpolation
      stacked = [((t**i) * (t_d**(n - i))).reshape((-1, 1))
                 * p * c for c, i, p in iterable]
      result = np.sum(stacked, axis=0)
  
      # test to make sure end points are correct
      test = np.sum((result[[0, -1]] - points[[0, -1]])**2, axis=1)
      assert (test < tol.merge).all()
      assert len(result) >= 2
  
      return result
docs: Parameters
      ----------
      points : (order, dimension) float
        Control points of the bezier curve
        For a 2D cubic bezier, order=3, dimension=2
      count : int, or None
        Number of segments
      scale : float
        Scale of curve
      Returns
      ----------
      discrete: (n,d) list of points, a polyline representation
                of the bezier curve which respects constants.RES_LENGTH