code: def resample_to_num_points(self, num_points):
          
          assert len(self.points) > 1, "can not resample the line of one point"
  
          section_length = self.get_length() / (num_points - 1)
          resampled_points = [self.points[0]]
  
          segment = 0
          acc_length = 0
          last_segment_length = 0
  
          for i in range(num_points - 1):
              tot_length = (i + 1) * section_length
              while tot_length > acc_length and segment < len(self.points) - 1:
                  last_segment_length = self.points[segment].distance(
                      self.points[segment + 1]
                  )
                  acc_length += last_segment_length
                  segment += 1
              p1, p2 = self.points[segment - 1:segment + 1]
              offset = tot_length - (acc_length - last_segment_length)
              if offset < 1e-5:
                  # forward geodetic transformations for very small distances
                  # are very inefficient (and also unneeded). if target point
                  # is just 1 cm away from original (non-resampled) line vertex,
                  # don't even bother doing geodetic calculations.
                  resampled = p1
              else:
                  resampled = p1.equally_spaced_points(p2, offset)[1]
              resampled_points.append(resampled)
  
          return Line(resampled_points)
docs: Resample the line to a specified number of points.
  
          :param num_points:
              Integer number of points the resulting line should have.
          :returns:
              A new line with that many points as requested.