日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python画车辆轨迹图,在python中绘制轨道轨迹

發布時間:2024/9/27 python 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python画车辆轨迹图,在python中绘制轨道轨迹 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

How can I setup the three body problem in python? How to I define the function to solve the ODEs?

The three equations are

x'' = -mu / np.sqrt(x ** 2 + y ** 2 + z ** 2) * x,

y'' = -mu / np.sqrt(x ** 2 + y ** 2 + z ** 2) * y, and

z'' = -mu / np.sqrt(x ** 2 + y ** 2 + z ** 2) * z.

Written as 6 first order we have

x' = x2,

y' = y2,

z' = z2,

x2' = -mu / np.sqrt(x ** 2 + y ** 2 + z ** 2) * x,

y2' = -mu / np.sqrt(x ** 2 + y ** 2 + z ** 2) * y, and

z2' = -mu / np.sqrt(x ** 2 + y ** 2 + z ** 2) * z

I also want to add in the path Plot o Earth's orbit and Mars which we can assume to be circular.

Earth is 149.6 * 10 ** 6 km from the sun and Mars 227.9 * 10 ** 6 km.

#!/usr/bin/env python

# This program solves the 3 Body Problem numerically and plots the trajectories

import pylab

import numpy as np

import scipy.integrate as integrate

import matplotlib.pyplot as plt

from numpy import linspace

mu = 132712000000 #gravitational parameter

r0 = [-149.6 * 10 ** 6, 0.0, 0.0]

v0 = [29.0, -5.0, 0.0]

dt = np.linspace(0.0, 86400 * 700, 5000) # time is seconds

解決方案

As you've shown, you can write this as a system of six first-order ode's:

x' = x2

y' = y2

z' = z2

x2' = -mu / np.sqrt(x ** 2 + y ** 2 + z ** 2) * x

y2' = -mu / np.sqrt(x ** 2 + y ** 2 + z ** 2) * y

z2' = -mu / np.sqrt(x ** 2 + y ** 2 + z ** 2) * z

You can save this as a vector:

u = (x, y, z, x2, y2, z2)

and thus create a function that returns its derivative:

def deriv(u, t):

n = -mu / np.sqrt(u[0]**2 + u[1]**2 + u[2]**2)

return [u[3], # u[0]' = u[3]

u[4], # u[1]' = u[4]

u[5], # u[2]' = u[5]

u[0] * n, # u[3]' = u[0] * n

u[1] * n, # u[4]' = u[1] * n

u[2] * n] # u[5]' = u[2] * n

Given an initial state u0 = (x0, y0, z0, x20, y20, z20), and a variable for the times t, this can be fed into scipy.integrate.odeint as such:

u = odeint(deriv, u0, t)

where u will be the list as above. Or you can unpack u from the start, and ignore the values for x2, y2, and z2 (you must transpose the output first with .T)

x, y, z, _, _, _ = odeint(deriv, u0, t).T

總結

以上是生活随笔為你收集整理的python画车辆轨迹图,在python中绘制轨道轨迹的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。