最佳拟合矩形网格到平滑的三维曲面

2024-04-27 22:05:20 发布

您现在位置:Python中文网/ 问答频道 /正文

G'day,我正在努力寻找一种方法来创建一个最适合光滑的3D表面的矩形网格。特别是我有一个地震断层的模型显示在this图中。在

这些是断层的深度等值线。我想找到一个定义尺寸的矩形网格(比如10x10km),最适合曲面。它不必(也不可能)完全在曲面上,只要尽可能靠近曲面,它必须是一个矩形,而不仅仅是一个四边形。我有定义曲面的节点,可以很容易地对它们进行插值。在

Python解决方案是受欢迎的,或者是关于我解决这个问题的开源代码的建议。我试过商业网格(ABAQUS),但他们总是返回四合院。我还没弄明白,所以请给我一些提示。在


Tags: 方法模型节点定义尺寸this表面曲面
1条回答
网友
1楼 · 发布于 2024-04-27 22:05:20

如果有定义曲面的节点,则意味着坐标和相应值的栅格不规则。因此,您可以从中生成一个三角剖分(您用来显示这些填充轮廓的工具很可能在屏幕后面使用相同的方法)。在

Matplotlib有两个非常有用的类,可以将三角剖分转换为rectilinear grid(矩形网格的更通用形式):LinearTriInterpolator和{a3}。它们正在this matplotlib example中使用。在

以下是同一个示例中的基本步骤,我对此进行了注释,但是matplotlib贡献者值得称赞:

import matplotlib.pyplot as plt
import matplotlib.tri as mtri
import numpy as np

# Create triangulation.
coords, earthquake_fault = get_coordinate_data() # to be filled in by you
x = coords['x']
y = coords['y']
triang = mtri.Triangulation(x, y)

# Interpolate to regularly-spaced quad grid.
z = earthquake_fault # the "height" data
xi, yi = np.meshgrid(np.linspace(x.min(), x.max() 20), np.linspace(y.min(), y.max(), 20))

interp_lin = mtri.LinearTriInterpolator(triang, z)
zi_lin = interp_lin(xi, yi)

# Plot the triangulation.
plt.subplot(121)
plt.tricontourf(triang, z)
plt.triplot(triang, 'ko-')
plt.title('Triangular grid')

# Plot linear interpolation to quad grid.
plt.subplot(122)
plt.contourf(xi, yi, zi_lin)
plt.title('Rectangular grid')

相关问题 更多 >