나는 공간 곡선에 맞추고 자하는 차원 좌표 (x,y,z)
을 가지고 있습니다. 누구든지이 파이썬에서 기존 루틴을 알고 있습니까?3 차원 공간에서 1 차원 곡선에 대한 좋은 보간/적합성 얻기 - Python
내가 발견 한 것 (https://docs.scipy.org/doc/scipy/reference/interpolate.html)에는 커브를 2D 좌표 세트에 맞추기위한 기존 모듈과 표면을 3D 좌표 세트에 맞추기위한 기존 모듈이 있습니다. 중간 경로를 원합니다. 곡선을 3D 좌표 세트에 맞추는 것이 좋습니다.
편집 - 나는interpolate.splprep()
및
interpolate.splenv()
를 사용하여 여기에 다른 게시물에 이에 대한 명시적인 답을 발견했다. 여기 내 데이터 포인트는 동안
당신은 적합이 좋지 않은 것을 볼 수 있습니다
,이 이미지는
from scipy import interpolate
from mpl_toolkits.mplot3d import Axes3D
data = data.transpose()
#now we get all the knots and info about the interpolated spline
tck, u= interpolate.splprep(data, k=5)
#here we generate the new interpolated dataset,
#increase the resolution by increasing the spacing, 500 in this example
new = interpolate.splev(np.linspace(0,1,500), tck, der=0)
#now lets plot it!
fig = plt.figure()
ax = Axes3D(fig)
ax.plot(data[0], data[1], data[2], label='originalpoints', lw =2, c='Dodgerblue')
ax.plot(new[0], new[1], new[2], label='fit', lw =2, c='red')
ax.legend()
plt.savefig('junk.png')
plt.show()
: 여기
21.735556483642707 7.9999120559310359 -0.7043281314370935
21.009401429607784 8.0101161320825103 -0.16388503829177037
20.199370045383134 8.0361339131845497 0.25664085801558179
19.318149385194054 8.0540100864979447 0.50434139043379278
18.405497793567243 8.0621753888918484 0.57169888018720161
17.952649703401562 8.8413995204241491 0.39316793526155014
17.539007529982641 9.6245700151356104 0.14326173861202204
17.100154581079089 10.416295524018977 0.011339000091976647
16.645143439968102 11.208477191735446 0.070252116425261066
16.198247656768263 11.967005154933993 0.31087815045809558
16.661378578010989 12.717314230004659 0.54140549139204996
17.126106263351478 13.503461982612732 0.57743407626794219
17.564249250974573 14.28890107482801 0.42307198199366186
17.968265052275274 15.031985807202176 0.10156997950061938
내 코드입니다 이미 허용 된 최대 피팅 주문 값 (
k=5
)을 사용하고 있습니다. 커브가 완전히 볼록하지 않기 때문입니까? 누구든지 내가 적합성을 향상시킬 수있는 방법을 알고 있습니까?
질문이 업데이트되었습니다. 상기 참조하십시오. – ap21