code: def interpolate_jagged(xyz,nseg):
      
      
      # Spherical coordinates specifying the angles of all line
      # segments that make up the section path
      (r,theta,phi) = sequential_spherical(xyz)
      
      # cumulative length of section path at each coordinate
      rcum = np.append(0,np.cumsum(r))
  
      # breakpoints for segment paths along section path
      breakpoints = np.linspace(0,rcum[-1],nseg+1)
      np.delete(breakpoints,0)
      
      # Find segment paths
      seg_paths = []
      for a in range(nseg):
          path = []
          
          # find (x,y,z) starting coordinate of path
          if a == 0:
              start_coord = xyz[0,:]
          else:
              start_coord = end_coord # start at end of last path
          path.append(start_coord)
  
          # find all coordinates between the start and end points
          start_length = breakpoints[a]
          end_length = breakpoints[a+1]
          mid_boolean = (rcum > start_length) & (rcum < end_length)
          mid_indices = np.nonzero(mid_boolean)[0]
          for mi in mid_indices:
              path.append(xyz[mi,:])
  
          # find (x,y,z) ending coordinate of path
          end_coord = find_coord(end_length,xyz,rcum,theta,phi)
          path.append(end_coord)
  
          # Append path to list of segment paths
          seg_paths.append(np.array(path))
      
      # Return all segment paths
      return seg_paths
docs: Interpolates along a jagged path in 3D
      
      Args:
          xyz = section path specified in cartesian coordinates
          nseg = number of segment paths in section path
          
      Returns:
          interp_xyz = interpolated path