I have a mesh generated from cloudpoint, which could be described as z = f(x,y)
, so I'm using scipy.interpolate.bisplrep
and bisplev
, with good results.
bisplev
can be used with parameters dx=n
and/or dy=n
so that the results are derivatives of order n
at the evaluated points. I plan to use this to calculate mean and gaussian curvatures (called surfature
in Matlab), and that should involve getting the second-order partial derivatives of the survace
The results using one of the partial derivatives at a time, say dx
are great, clearly representing the gradient as a "shading" effect, as seen in this image from a human back (code first):
self.spline = inter.bisplrep(self.pointlist[:,1],
self.pointlist[:,0],
self.pointlist[:,2], s=smoothing_factor)
self.mesh_shadow = inter.bisplev(yy.flat, xx.flat, self.spline, dy=1)
So far, so good. The problem is: I can't understand (and can't find any explanation) what's the meaning of the result when I ask for both partial derivatives at the same time, since there isn't any obvious numeric or visual meaning. For example, if I use dx
AND dy
:
self.mesh_shadow = inter.bisplev(yy.flat, xx.flat, self.spline, dx=1, dy=1)
I get this:
So, I wonder:
bislplev(..., dx=1, dy=1)
, if any?bislplev(..., dx=1, dy=1)
?(..., dx=1, dy=2)
and the function seems to produce "valid" results, but would that make any sense?Every time, the returned value is a (Y,X)-shaped array of single float values (Z or one of its derivative-related values).
Any help?
Thanks for reading
The partial derivative you get with dx=n, dy=m is the mathematical object (or rather, its numerical approximation)
(d/dx)^n (d/dy)^m f(x,y)
You cannot compute the Gaussian curvature just from dx=2,dy=0 and dx=0,dy=2 --- you in general also need also the cross-derivative dx=1,dy=1.
Partial derivatives (d/dx)^n (d/dy)^m f(x,y) are mathematically well-defined. With splines, if you go to too high orders, you should start getting zeros or discontinuities.