code: def truncate(self, distance):
          
          position = np.searchsorted(self._cum_norm, distance)
          offset = distance - self._cum_norm[position - 1]
  
          if offset < constants.tol_path.merge:
              truncated = self._points[:position + 1]
          else:
              vector = unitize(np.diff(self._points[np.arange(2) + position],
                                       axis=0).reshape(-1))
              vector *= offset
              endpoint = self._points[position] + vector
              truncated = np.vstack((self._points[:position + 1],
                                     endpoint))
  
          assert (np.linalg.norm(np.diff(truncated, axis=0),
                                 axis=1).sum() - distance) < constants.tol_path.merge
  
          return truncated
docs: Return a truncated version of the path.
          Only one vertex (at the endpoint) will be added.