def animate(i): tt = (i - 1) * dt X = X0 + Xdot * tt Y = Y0 + Ydot * tt Z = Z0 + Zdot * tt theta = theta0 + thetadot * tt phi = phi0 + phidot * tt l = r0.len() x = l * sin(theta) * cos(phi) y = l * sin(theta) * sin(phi) z = l * cos(theta) R = Vect3(X, Y, Z) r = Vect3(x, y, z) beta = m2 / (m1 + m2) r1 = Vect3.sub(R, Vect3.mul(beta, r)) r2 = Vect3.add(R, Vect3.mul(1 - beta, r)) g1.center = r1.y, r1.z g2.center = r2.y, r2.z s1 = sizep(2 * R1, r1.x) g1.width = s1 g1.height = s1 s2 = sizep(2 * R2, r2.x) g2.width = s2 g2.height = s2 if r2.x > r1.x: g1.zorder = 2 g2.zorder = 3 else: g1.zorder = 3 g2.zorder = 2 time_text.set_text(time_template % tt) return line, time_text
dt = T / Nt t = np.arange(tbeg, tend + dt, dt) # Define 1st collony R1 = 0.5 r1 = Vect3(0, 0, -R1) m1 = 1 # Define 2nd collony R2 = 0.5 r2 = Vect3(0, 0, R2) m2 = 1 # Caculate r dan R vectors r = Vect3.sub(r2, r1) Rnum = Vect3.add(Vect3.mul(m1, r1), Vect3.mul(m2, r2)) Rden = m1 + m2 R = Vect3.div(Rnum, Rden) # Define size due to perspective in x direction def sizep(d, x): c = 0.2 d = d * (1 + c * x) return d # Set range of x and y rx = [-2, 2, 0.5] ry = [-2, 2, 0.5] xmt = np.arange(rx[0], rx[1] + rx[2], rx[2])