code: def _stroke_simplification(self, pointlist):
          
  
          # Find the point with the biggest distance
          dmax = 0
          index = 0
          for i in range(1, len(pointlist)):
              d = geometry.perpendicular_distance(pointlist[i],
                                                  pointlist[0],
                                                  pointlist[-1])
              if d > dmax:
                  index = i
                  dmax = d
  
          # If the maximum distance is bigger than the threshold 'epsilon', then
          # simplify the pointlist recursively
          if dmax >= self.epsilon:
              # Recursive call
              rec_results1 = self._stroke_simplification(pointlist[0:index])
              rec_results2 = self._stroke_simplification(pointlist[index:])
              result_list = rec_results1[:-1] + rec_results2
          else:
              result_list = [pointlist[0], pointlist[-1]]
  
          return result_list
docs: The Douglas-Peucker line simplification takes a list of points as an
             argument. It tries to simplifiy this list by removing as many points
             as possible while still maintaining the overall shape of the stroke.
             It does so by taking the first and the last point, connecting them
             by a straight line and searchin for the point with the highest
             distance. If that distance is bigger than 'epsilon', the point is
             important and the algorithm continues recursively.