SINTEF / Splipy

Spline modelling made easy.
GNU General Public License v3.0
102 stars 18 forks source link

Derivative splines #13

Closed VikingScientist closed 7 years ago

VikingScientist commented 7 years ago

Derivatives of splines are themselves splines. This allows for an explicit construction of these objects.

It basically allows for this operation here:

  surf2 = surf.get_derivative_spline(direction='u') # type(surf2) == Surface
  surf3 = surf.get_derivative_spline(direction='v')
  u    = np.linspace(surf.start(0), surf.end(0), 7) # evaluation points
  v    = np.linspace(surf.start(1), surf.end(1), 7)
  du   = surf.derivative(u,v, d=(1,0))
  du2  = surf2(u,v) # du == du2 everywhere
  dv   = surf.derivative(u,v, d=(0,1))
  dv2  = surf3(u,v) # dv == dv2
TheBB commented 7 years ago

This looks good but I would rest a bit easier if the transpose_fix hack was fully dimension agnostic. We already have one instance of that in the code. I suggest we replace both with something like this:

def transpose_fix(pardim, direction):
   ret = list(range(1, pardim+1))
   ret.insert(direction, 0)
   return tuple(ret)

From what I can tell this will work as expected.

TheBB commented 7 years ago

IOW I'm suggesting putting this on top https://github.com/TheBB/Splipy/commit/fd2cd93b4c387529939770749d74819f61a53b8d

VikingScientist commented 7 years ago

Fixed

TheBB commented 7 years ago

This one is in!