[英]Interpolate x,y,z co-ordinates defining a 3D surface to arbitrary plane
假設我有一組定義 3D 結構表面的 x,y,z 坐標:
points = [[x0,y0,z0],
[x1,y1,z1],
[xn,yn,zn]]
您如何建議我獲得定義給定切片結構周長的二維點列表?
例如,我可能需要 y = 1.5 處的結構的 x、z 點,但假設該平面上實際上沒有定義任何點,因此我需要進行線性插值。
我覺得 scipy.interpolate.griddata 擁有答案,但我似乎無法理解如何在這種情況下應用它。 任何幫助將不勝感激。
您可以使用scipy.ndimage.map_coordinates
實現此scipy.ndimage.map_coordinates
:
from scipy.ndimage import map_coordinates
import numpy as np
arr = np.arange(25, dtype=float).reshape((5, 5))
arr
Out[39]:
array([[ 0., 1., 2., 3., 4.],
[ 5., 6., 7., 8., 9.],
[10., 11., 12., 13., 14.],
[15., 16., 17., 18., 19.],
[20., 21., 22., 23., 24.]])
map_coordinates(arr, (np.arange(5), [1.5]*5))
Out[40]: array([ 1.55357143, 6.55357143, 11.55357143, 16.55357143, 21.55357143])
這需要顯式傳遞坐標,我不確定如何利用帶有 map_coordinates 的 numpy 索引來獲取整個列,但這至少是一個解決方案。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.