Kar*_*Rei 5 python interpolation mesh
是否有任何体面的 Pythonic 方法可以在三角形网格中进行插值,还是我需要自己实现?也就是说,给定一个我们称之为 P 的 (X,Y) 点和一个网格(在 (X,Y) 处的顶点,其值为 Z,形成三角面),估计 P 处的值。所以这意味着首先找到包含点的面,然后进行插值 - 理想情况下是更高阶的插值,而不仅仅是“在面的顶点之间线性”(即,考虑到相邻的面)?
我可以自己实现它,但是如果 Python 中已经有可用的东西......
(我检查了 scipy.interpolate,但它的“网格”似乎只是常规点网格。这不是网格,它是真正的 2D 网格;顶点可以位于任何地方。)
为此,我经常使用 matplotlib.tri。这里 Xv,Yv 是三角形的顶点(或节点),Zv 是这些节点处的值:
from matplotlib.tri import Triangulation, LinearTriInterpolator, CubicTriInterpolator
#you can add keyword triangles here if you have the triangle array, size [Ntri,3]
triObj = Triangulation(Xv,Yv)
#linear interpolation
fz = LinearTriInterpolator(triObj,Zv)
Z = fz(X,Y)
#cubic interpolation
fzc = CubicTriInterpolator(triObj,Zv)
Zc = fz(X,Y)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2857 次 |
| 最近记录: |