code: def setcurve(e, pts, tgs=None):
      """
           Returns the spline curve that path through the list of points P.
           The spline curve is a list of cubic bezier curves (nurbs) that have
           matching tangents at their extreme points.
           The method considered here is taken from "The NURBS book" (Les A. Piegl,
           Wayne Tiller, Springer, 1997) and implements a local interpolation rather
           than a global interpolation.
  
      Args:
          e:
          pts:
          tgs:
  
      Returns:
  
      """
      P = list(map(array, pts))
      n = len(P)
      # tangent estimation
      if tgs:
          assert len(tgs) == n
          T = list(map(array, tgs))
          Q = [P[k + 1] - P[k] for k in range(0, n - 1)]
      else:
          Q, T = tangents(P, n)
      splines = []
      for k in range(n - 1):
          t = T[k] + T[k + 1]
          a = 16.0 - (t.dot(t))
          b = 12.0 * (Q[k].dot(t))
          c = -36.0 * Q[k].dot(Q[k])
          D = (b * b) - 4.0 * a * c
          assert D >= 0
          sd = sqrt(D)
          s1, s2 = (-b - sd) / (2.0 * a), (-b + sd) / (2.0 * a)
          s = s2
          if s1 >= 0:
              s = s1
          C0 = tuple(P[k])
          C1 = tuple(P[k] + (s / 3.0) * T[k])
          C2 = tuple(P[k + 1] - (s / 3.0) * T[k + 1])
          C3 = tuple(P[k + 1])
          splines.append([C0, C1, C2, C3])
      return splines
  
file_path: pygraphistry/graphistry/layout/utils/geometry.py
imports: from numpy import array, cos, sin
  from math import atan2, sqrt
label_desc: Use image node_id 5 for calling a global function with example usage: setcurve(e, pts, tgs) and returns: splines