import numpy as np mu = 3.98e-4 m = 100000 r = lambda x, y, z: sqrt((x**2) + (y**2) + (z**2)) rt = 6.373 orb = [0, rt + 0.405, 0] v = [-0.00766, 0.0001, 0] N = ReferenceFrame(orb, name='iss') iss = Object(m, ref_frame=N, Io=np.diag([50, 50, 50]), name='iss') f = Force([0, 0, 0], ref_frame=N, name='gravity') f.add_expression(lambda x, y, z, t: -mu * m * np.array([x, y, z]) / (r(x, y, z)**3)) iss.apply_forces([f]) iss.apply_w([0.005, 0.007, 0.006]) iss.apply_v(v) #DISEGNAMO LA TERRA t, f = np.meshgrid(np.linspace(0, pi, 200), np.linspace(0, 2 * pi, 200)) xs = rt * np.sin(t) * np.cos(f) ys = rt * np.sin(t) * np.sin(f) zs = rt * np.cos(t) fig = plt.figure() ax = fig.add_subplot(111, projection='3d', aspect='equal', xlim=(-10, 10), ylim=(-10, 10),
npoints=100 theta = np.linspace(-10,10,npoints) xs=5*np.cos(theta) ys=5*np.sin(theta) zs=0.3*theta obj.compute_io(xs,ys,zs) print(obj.Io) obj.apply_w([1,0,7]) obj.apply_v([10,-10,-10]) mpoint=obj.mass/npoints r = lambda x,y,z: sqrt((x**2)+(y**2)+(z**2)) GM=50000 farr=[] for i in range(npoints): f=Force([xs[i],ys[i],zs[i]],name='gravity_'+str(i)) expr = lambda x,y,z,t: -GM*mpoint*np.array([x,y,z])/(r(x,y,z)**3) f.add_expression(expr) farr.append(f) obj.apply_forces(farr) dr=Drawing_Schema(lim=(-80,80)) dr.update_schema('e',('b-',3.5)) obj.integrate_and_draw(np.linspace(0,30,1000),drawing_schema=dr,custom_obj=[xs,ys,zs])