Python中的最小表面解决方案

Python中的最小表面解决方案

本文介绍了Python中的最小表面解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组定义3D轮廓的3D点.我要做的是获取与此轮廓对应的最小表面表示,并且我还发现薄板样条线是对此的基本解决方案等式.

因此,我认为方法将是尝试使用薄板样条线拟合表面的这种稀疏表示(由点的3D轮廓给出).我在scipy.interpolate 此示例在其中使用薄板样条插值分散的数据(x,y,z格式),以在均匀网格(XI,YI)上获得ZI坐标.

出现两个问题:(1)对于根据3D轮廓点集计算表面的问题,薄板样条插值法是正确的方法吗?(2)如果是,如何在具有非均匀网格的scipy上执行薄板插值?

再次感谢!米格尔(Miguel)

更新:在MATLAB中的实现(但无法在Scipy Python上运行)

我遵循了此示例使用Matlab的 tpaps 函数,并获得了在均匀网格上适合我的轮廓的最小曲面.这是Matlab的结果(看起来很棒!):

但是我需要在Python中实现,所以我使用的是scipy.interpolate.Rbf包和 thin-plate 函数.这是python中的代码( XYZ 包含轮廓中每个点的3D坐标):

  GRID_POINTS = 25x_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)从scipy.interpolate导入Rbfrbf = Rbf(XYZ [:,0],XYZ [:,1],XYZ [:,2],function ='thin-plate',smooth = 0.0)ZI = rbf(XI,YI) 

但这是结果(与Matlab中获得的结果完全不同):

很明显,scipy的结果并不对应于最小的表面.

scipy.interpolate.Rbf +薄板是否按预期运行,为什么它与Matlab的结果不同?

解决方案

该问题指出我们需要求解非线性偏微分方程.但是,维基百科指出:它们很难研究:几乎没有适用于所有此类方程式的通用技术,通常每个单独的方程式都必须作为一个单独的问题来研究."但是,您没有给出等式!Matlab有时是否使用遗传算法到达其表面?也就是说,它是否使用经验法则做出最佳猜测,然后尝试对分量平方进行细微的变化,直到找不到更小的表面.实施这种解决方案会很费力,但在概念上并不困难(假设您喜欢这种事情).还请记住,连续函数的演算只是函数的所有线性近似的演算的特例(增量设置为零,而不是某个有限值).通过阅读J L Bell的有关光滑无穷小分析的书,这对我很清楚-只需使用具有有限增量的代数,并将结果因子留在导数中,而不是忽略"它们.

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 pdenonlinfunction (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?

解决方案

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.

这篇关于Python中的最小表面解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 00:10