3D interpolation in Python revisited

  Kiến thức lập trình

I have a piece-wise linear path in 3D space, comprising an array of (x, y, z) values, and an array of values giving the distance along the path. I want to find the distance along the path of other (x, y, z) points which all lie “on” the path (ie the distance to one of the path segments is less than some tolerance).

I found this algorithm
4D interpolation for irregular (x,y,z) grids by python and reproduced the answers.

However, when I use my values, I get an array of nan‘s. Would appreciate any suggestions to resolve this – thanks in advance!

import scipy.interpolate
import numpy as np

nodes = np.array([
 [511.03925, 897.2107, 48.937611],
 [499.58658, 889.2893, 49.988685],
 [474.94204, 872.2437, 51.114033],
 [461.30299, 862.8101, 51.072050],
 [450.27944, 855.1856, 50.847374],
 [425.61826, 838.1285, 50.344743],
 [400.95708, 821.0714, 49.842111]])

vals = np.array([3496.03,  3510.00,  3540.00,  3556.59,  3570.00,  3600.00,  3630.00])

pts = np.array([
 [492.09, 884.11, 50.33],
 [482.34, 877.36, 50.78],
 [488.52, 881.64, 50.49],
 [476.24, 873.14, 51.05],
 [482.34, 877.36, 50.78]])

dist = scipy.interpolate.griddata(nodes, vals, pts)
print(dist)

LEAVE A COMMENT