2016-08-07 1 views
0

私は、異なる時間レベルで10ポイントのような座標を持っており、その座標を軌道のように見せるためにそれらの座標に参加したいですか?複数の時刻に私の座標が分かっている点からどのように軌跡をプロットするのですか?

def euler_method(points, x_dot, y_dot, x1, x2, time_step, n_steps): 
    n_points = len(points[:, 0]) 
    point_trajectory = np.zeros((n_points, 2, n_steps)) 
    for i in range(0, n_steps): 
     point_trajectory[:, :, i] = points 
     f1 = sp.lambdify((x1, x2), x_dot, "numpy") 
     f2 = sp.lambdify((x1, x2), y_dot, "numpy") 
     u = f1(points[:, [0]], points[:, [1]]) 
     v = f2(points[:, [0]], points[:, [1]])     
     points_new_x = points[:, [0]] + u*time_step 
     points_new_y = points[:, [1]] + v*time_step 
     points = np.hstack((points_new_x, points_new_y)) 
    return point_trajectory 

デフplot_trajectory(points_at_diff_time)から私はそれを表現する方法を考えることはできませんよ

を作成したいものです。 matplotlibで行うことをお勧めします。

EDIT:このようなもの - 異なる座標で異なる時刻に移動する点。

enter image description here

+0

あなたが求めているものは明らかではありません。おそらくあなたは写真を描き、あなたの質問にインラインで書くことができます。 –

+0

ok let put then – Manish

+0

軌道のパラメトリック形式はありますか?たとえば、それは砲弾の弾道ですか? –

答えて

1
import numpy as np 
import matplotlib.pyplot as plt 

# make fake data to test with 
pt = np.zeros((6, 2, 3)) # 6 points, (x,y), 3 timesteps 
pt[:,0] = [-2,-1,1] # x=time, same for all 

# set y values 
pt[0,1] = [3,4,4.5] 
pt[1,1] = [2,2.9,3.4] 
pt[2,1] = [1,1.9,2.4] 
pt[3,1] = [0,0.6,1.0] 
pt[4,1] = [-1.5,-1.6,-1.6] 
pt[5,1] = [-2.8,-3.7,-3.8] 

# now plot: x and y are 2D 
x = pt[:,0].T 
y = pt[:,1].T 

plt.plot(x, y) 
plt.show() 

resulting plot

あなたがラインを滑らかにしたい場合は、こちらを参照してください。https://stackoverflow.com/a/5284038/4323

+0

このメソッドは、エレガントで実際に目的を果たしました。このアプローチの背景にある一般的な考え方を説明してください。行列wrtを行列にプロットするときは、常に各行を独立して取りますか? – Manish

関連する問題