I have a set of 3D points defining a 3D contour. What I want to do is to obtain the minimal surface representation corresponding to this contour (see Minimal Surfaces in Wikipedia). Basically this requires to solve a nonlinear partial differential equation.
In Matlab this is almost straightforward using the pdenonlin
function (see Matlab's documentation). An example of its usage for solving a minimal surface problem can be found here: Minimal Surface Problem on the Unit Disk.
I need to make such an implementation in Python, but up to know I haven't found any web resources on how to to this.
Can anyone point me any resources/examples of such implementation?
Thanks, Miguel.
UPDATE
The 3D surface (ideally a triangular mesh representation) I want to find is bounded by this set of 3D points (as seen in this figure, the points lie in the best-fit plane):
Ok, so doing some research I found that this minimal surface problem is related with the solution of the Biharmonic Equation, and I also found that the Thin-plate spline is the fundamental solution to this equation.
So I think the approach would be to try to fit this sparse representation of the surface (given by the 3D contour of points) using thin-plate splines. I found this example in scipy.interpolate where scattered data (x,y,z format) is interpolated using thin-plate splines to obtain the ZI coordinates on a uniform grid (XI,YI).
Two questions arise: (1) Would thin-plate spline interpolation be the correct approach for the problem of computing the surface from the set of 3D contour points? (2) If so, how to perform thin-plate interpolation on scipy with a NON-UNIFORM grid?
Thanks again! Miguel
UPDATE: IMPLEMENTATION IN MATLAB (BUT IT DOESN'T WORK ON SCIPY PYTHON)
I followed this example using Matlab's tpaps
function and obtained the minimal surface fitted to my contour on a uniform grid. This is the result in Matlab (looks great!):
However I need to implement this in Python, so I'm using the package scipy.interpolate.Rbf and the thin-plate
function. Here's the code in python (XYZ
contains the 3D coordinates of each point in the contour):
GRID_POINTS = 25 x_min = XYZ[:,0].min() x_max = XYZ[:,0].max() y_min = XYZ[:,1].min() y_max = XYZ[:,1].max() xi = np.linspace(x_min, x_max, GRID_POINTS) yi = np.linspace(y_min, y_max, GRID_POINTS) XI, YI = np.meshgrid(xi, yi) from scipy.interpolate import Rbf rbf = Rbf(XYZ[:,0],XYZ[:,1],XYZ[:,2],function='thin-plate',smooth=0.0) ZI = rbf(XI,YI)
However this is the result (quite different from that obtained in Matlab):
It's evident that scipy's result does not correspond to a minimal surface.
Is scipy.interpolate.Rbf + thin-plate doing as expected, why does it differ from Matlab's result?
Mean curvature definition: A surface M ⊂ R3 is minimal if and only if its mean curvature is equal to zero at all points.
The question states that we need to solve a nonlinear partial differential equation. However Wikipedia states that 'They are difficult to study: there are almost no general techniques that work for all such equations, and usually each individual equation has to be studied as a separate problem.' However, you didn't give the equation! And does Matlab sometimes use genetic algorithms to arrive at its surfaces? That is, does it use a rule of thumb to make a best guess and then tries out small variations in the component squares until no smaller surface can be found. Implementing that kind of solution would be laborious but not conceptually difficult (assuming you like that sort of thing). Also remember that the calculus of continuous functions is just a special case of the calculus of all the linear approximations of functions (the increment is set to zero instead of some finite value). This was made clear to me by reading the books of J L Bell on smooth infinitesimal analysis - just use that algebra with finite increments and leave the resulting factors in the derivations instead of 'neglecting' them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With