* import numpy as np
* import matplotlib as mpl
* mpl.use(“TkAgg”)
* from matplotlib import pyplot as plt
* from mpl_toolkits.mplot3d import Axes3D# use mpl_toolkits.mplot3d lower Axes3D draw 3D graphical
* import matplotlib.animation as animmation
*
* r1=5
* r2=8
* r3=11
* r4=16
* r5=20
* r6=27
* r7=36
* r8=50# Set track radius
* omega1 = 13* np.pi
* omega2 = 9* np.pi
* omega3 = 7* np.pi
* omega4 = 6* np.pi
* omega5 = 5* np.pi
* omega6 = 4* np.pi
* omega7 = 3* np.pi
* omega8 = 2* np.pi# Set planet angular speed
*
*
*
* def
update(data):# Over time t Set new planet position coordinates , That is, with animmation.FuncAnimation The frame number parameter of the function changes the picture object parameters at different coordinate positions of each frame
* global line1,line2,line3,line4,line5,line6,line7,line8
* line1.set_data([data[0], data[1]])
* line1.set_3d_properties(data[2])
* line2.set_data([data[3],data[4]])
* line2.set_3d_properties(data[5])
* line3.set_data([data[6], data[7]])
* line3.set_3d_properties(data[8])
* line4.set_data([data[9], data[10]])
* line4.set_3d_properties(data[11])
* line5.set_data([data[12], data[13]])
* line5.set_3d_properties(data[14])
* line6.set_data([data[15], data[16]])
* line6.set_3d_properties(data[17])
* line7.set_data([data[18], data[19]])
* line7.set_3d_properties(data[20])
* line8.set_data([data[21], data[22]])
* line8.set_3d_properties(data[23])
* return line1,line2,line3,line4,line5,line6,line7,line8
* def init():# The starting position of the planet
* global line1, line2, line3,line4,line5,line6,line7,line8
* ti = 0
* t = t_drange[np.mod(ti, t_dlen)]
*
* xt1 = x0 + r1 * np.cos(omega1 * t)
* yt1 = y0 + r1 * np.sin(omega1 * t)
* zt1 = z0 + 0
* xt2 = x0 + r1 * np.cos(omega2 * t)
* yt2 = y0 + r1 * np.sin(omega2 * t)
* zt2 = z0 + 0
* xt3 = x0 + r1 * np.cos(omega3 * t)
* yt3 = y0 + r1 * np.sin(omega3 * t)
* zt3 = z0 + 0
* xt4 = x0 + r1 * np.cos(omega4 * t)
* yt4 = y0 + r1 * np.sin(omega4 * t)
* zt4 = z0 + 0
* xt5 = x0 + r1 * np.cos(omega5 * t)
* yt5 = y0 + r1 * np.sin(omega5 * t)
* zt5 = z0 + 0
* xt6 = x0 + r1 * np.cos(omega6 * t)
* yt6 = y0 + r1 * np.sin(omega6 * t)
* zt6 = z0 + 0
* xt7 = x0 + r1 * np.cos(omega7 * t)
* yt7 = y0 + r1 * np.sin(omega7 * t)
* zt7 = z0 + 0
* xt8 = x0 + r1 * np.cos(omega8 * t)
* yt8 = y0 + r1 * np.sin(omega8 * t)
* zt8 = z0 + 0
* line1, = ax.plot([xt1], [yt1], [zt1], marker='o',
color='yellow',markersize=4)
* line2, = ax.plot([xt2], [yt2], [zt2], marker='o',
color='yellow',markersize=4)
* line3, = ax.plot([xt3], [yt3], [zt3], marker='o', color='blue',markersize=4)
* line4, = ax.plot([xt4], [yt4], [zt4], marker='o', color='red',markersize=4)
* line5, = ax.plot([xt5], [yt5], [zt5], marker='o',
color='brown',markersize=10)
* line6, = ax.plot([xt6], [yt6], [zt6], marker='o',
color='blue',markersize=10)
* line7, = ax.plot([xt7], [yt7], [zt7], marker='o', color='blue',markersize=8)
* line8, = ax.plot([xt8], [yt8], [zt8], marker='o',
color='green',markersize=8)
* return line1,line2, line3,line4,line5,line6,line7,line8
* def data_gen():# Over time t Transformed planetary coordinates , That is to say animmation.FuncAnimation Frame parameter of function
* global x0,y0,z0,t_dlen
*
* #while true:
* data = []
* for ti in range(1,t_dlen):
* t = t_drange[ti]
* # The relation equation between planets and solar coordinates
* xt1 = x0 + r1 * np.cos(omega1 * t)
* yt1 = y0 + r1 * np.sin(omega1 * t)
* zt1 = z0
* xt2 = x0 + r2 * np.cos(omega2 * t)
* yt2 = y0 + r2 * np.sin(omega2 * t)
* zt2 = z0
* xt3 = x0 + r3 * np.cos(omega3 * t)
* yt3 = y0 + r3 * np.sin(omega3 * t)
* zt3 = z0
* xt4 = x0 + r4 * np.cos(omega4 * t)
* yt4 = y0 + r4 * np.sin(omega4 * t)
* zt4 = z0
* xt5 = x0 + r5 * np.cos(omega5 * t)
* yt5 = y0 + r5 * np.sin(omega5 * t)
* zt5 = z0
* xt6 = x0 + r6 * np.cos(omega6 * t)
* yt6 = y0 + r6 * np.sin(omega6 * t)
* zt6 = z0
* xt7 = x0 + r7 * np.cos(omega7 * t)
* yt7 = y0 + r7 * np.sin(omega7 * t)
* zt7 = z0
* xt8 = x0 + r8 * np.cos(omega8 * t)
* yt8 = y0 + r8 * np.sin(omega8 * t)
* zt8 = z0
*
data.append([xt1,yt1,zt1,xt2,yt2,zt2,xt3,yt3,zt3,xt4,yt4,zt4,xt5,yt5,zt5,xt6,yt6,zt6,xt7,yt7,zt7,xt8,yt8,zt8])
* return data
*
*
* t_range = np.arange(0, 1 + 0.005, 0.005)# Set the range of time around a week and the interval between movements
* t_drange = np.arange(0, 1, 0.005 )
* t_len = len(t_range)
* t_dlen = len(t_drange)
* #sun’s coordination
* x0 = 0
* y0 = 0
* z0 = 0
* # Equation of planetary coordinates changing with time
* # Mercury
* x1 = x0 + r1 * np.cos(omega1 * t_range)
* y1 = y0 + r1 * np.sin(omega1 * t_range)
* z1 = z0 + np.zeros(t_len)
* # Venus
* x2 = x0 + r2 * np.cos(omega2 * t_range)
* y2 = y0 + r2 * np.sin(omega2 * t_range)
* z2 = z0 + np.zeros(t_len)
* # earth
* x3 = x0 + r3 * np.cos(omega3 * t_range)
* y3 = y0 + r3 * np.sin(omega3 * t_range)
* z3 = z0 + np.zeros(t_len)
* # Mars
* x4 = x0 + r4 * np.cos(omega4 * t_range)
* y4 = y0 + r4 * np.sin(omega4 * t_range)
* z4 = z0 + np.zeros(t_len)
* # Jupiter
* x5 = x0 + r5 * np.cos(omega5 * t_range)
* y5 = y0 + r5 * np.sin(omega5 * t_range)
* z5 = z0 + np.zeros(t_len)
* # Saturn
* x6 = x0 + r6 * np.cos(omega6 * t_range)
* y6 = y0 + r6 * np.sin(omega6 * t_range)
* z6 = z0 + np.zeros(t_len)
* # Uranus
* x7 = x0 + r7 * np.cos(omega7 * t_range)
* y7 = y0 + r7 * np.sin(omega7 * t_range)
* z7 = z0 + np.zeros(t_len)
* # Neptune
* x8 = x0 + r8 * np.cos(omega8 * t_range)
* y8 = y0 + r8 * np.sin(omega8 * t_range)
* z8 = z0 + np.zeros(t_len)
*
* f = plt.figure(figsize=(12,12))# Drawing canvas
* ax = f.add_subplot(111,projection=‘3d’)# set up 3d Coordinate system
* ax.set_title(“Sun Model”)# Set image title
*
*
* ax.plot([0], [0], [0], marker=‘o’, color= ‘red’, markersize=10)# Set the properties of the sun
* ax.plot(x1, y1, z1, ‘r’)
* ax.plot(x2, y2, z2, ‘r’)
* ax.plot(x3, y3, z3, ‘r’)
* ax.plot(x4, y4, z4, ‘r’)
* ax.plot(x5, y5, z5, ‘r’)
* ax.plot(x6, y6, z6, ‘r’)
* ax.plot(x7, y7, z7, ‘r’)
* ax.plot(x8, y8, z8, ‘r’)# Drawing an image of a planet
* ax.set_xlim([-(r8 + 10), (r8 + 10)])
* ax.set_ylim([-(r8 + 10), (r8 + 10)])
* ax.set_zlim([-5, 5])# The scope of the model in the coordinate system
*
* line1, = ax.plot([], [], [], marker=‘o’,
color=‘yellow’,markersize=4,animated = True)
* line2, = ax.plot([], [], [], marker=‘o’,
color=‘yellow’,markersize=4,animated = True)
* line3, = ax.plot([], [], [], marker=‘o’, color=‘blue’,markersize=4,animated
= True)
* line4, = ax.plot([], [], [], marker=‘o’, color=‘red’,markersize=4,animated
= True)
* line5, = ax.plot([], [], [], marker=‘o’,
color=‘brown’,markersize=10,animated = True)
* line6, = ax.plot([], [], [], marker=‘o’,
color=‘blue’,markersize=10,animated = True)
* line7, = ax.plot([], [], [], marker=‘o’, color=‘blue’,markersize=8,animated
= True)
* line8, = ax.plot([], [], [], marker=‘o’,
color=‘green’,markersize=8,animated = True)# The shape, color and size of planets
* #r
* ani = animmation.FuncAnimation(f, update, frames = data_gen(), init_func =
init,interval = 200)
* #f# Pass in the above function object animmation.FuncAnimation Function to generate a continuous planetary motion model
* plt.show()

Technology
©2019-2020 Toolsou All rights reserved,
Go language Array initialization and basic operations element-ui+vue-treeselect Verification of drop down box ( Essence 2020 year 6 month 2 Daily update ) TypeScript Function explanation Thread.getContextClassLoader And Thread.getClassLoader() difference ( Essence )2020 year 6 month 29 day C# Class library Interface signature verification element-ui Of el-date-picker Component get value springboot Multi profile configuration python obtain excel A column or row of data org.postgresql.util.PSQLException Processing records Mybatis Mapping file Mapper.xml in # and $ The difference between