惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
CERT Recently Published Vulnerability Notes
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
Stack Overflow Blog
Stack Overflow Blog
aimingoo的专栏
aimingoo的专栏
C
Check Point Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Tor Project blog
P
Proofpoint News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Latest news
Latest news
L
LINUX DO - 热门话题
罗磊的独立博客
T
Tenable Blog
The Hacker News
The Hacker News
美团技术团队
N
Netflix TechBlog - Medium
V
Vulnerabilities – Threatpost
阮一峰的网络日志
阮一峰的网络日志
Last Week in AI
Last Week in AI
博客园 - 司徒正美
Jina AI
Jina AI
Cyberwarzone
Cyberwarzone
云风的 BLOG
云风的 BLOG
S
Secure Thoughts
Cloudbric
Cloudbric
S
Security @ Cisco Blogs
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Microsoft Security Blog
Microsoft Security Blog
Spread Privacy
Spread Privacy
U
Unit 42
雷峰网
雷峰网
C
CXSECURITY Database RSS Feed - CXSecurity.com
Webroot Blog
Webroot Blog
爱范儿
爱范儿
博客园 - 【当耐特】
Know Your Adversary
Know Your Adversary
P
Privacy International News Feed
P
Palo Alto Networks Blog
Google Online Security Blog
Google Online Security Blog
The Last Watchdog
The Last Watchdog
博客园 - 聂微东
Help Net Security
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
F
Full Disclosure
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Security Affairs
Project Zero
Project Zero

博客园 - 遗忘海岸

简协运动模拟 电磁场中的运动轨迹模拟 圆周运动模拟 带阻力的平抛运动 C# 队列的一些并发模拟 devexpress gridview master,detail视图 focuseRowHandle 同步选中 C# Tcp Server端实现,使用TcpListener 深信服务超融合管理Api调用 GDI+画工作流图的一些总结 绘制贝塞而曲线 GDI+画直线带箭头 devexpress schedulerControl Gantt View 使用 逻辑回归损失函数求导 matplotlim柱状图 C# 实现排列 python 类鸟群Boids C#动态编译 正太分布数据排序后分段数据的方差与标准差 Android 的一个通用列表单选AlertDialog封装
匀加速运动模拟python,(matplotlib)
遗忘海岸 · 2024-02-11 · via 博客园 - 遗忘海岸

等距离方式

import numpy as np
import matplotlib
matplotlib.use("TKAgg")
import matplotlib.pyplot as plt

g=9.8
s=100
ds=0.00001 #单位米
v0=0.001 #m/s
v=[v0]
t=[ds/v0]
t_sum=0
ds_num=int(s/ds)
x=[]
y=[]
for i in range(ds_num+1):
    if i==0 :
        continue
    vi=v[i-1] + g * t[i-1]
    v.append(vi)
    ti=ds/vi
    t.append(ti)
    t_sum +=ti
    x.append(t_sum)
    y.append(ds * i)
    
fig,ax=plt.subplots()


x1=np.arange(0,np.sqrt(2*s/9.8),0.01)
y1=0.5 * g * x1**2

ax.plot(x,y, color='green',linewidth=0.1)
ax.plot(x1,y1, color='red', linewidth=0.1)
print(np.sqrt(20/9.8))
plt.show()

View Code

 等时间方式

import matplotlib
matplotlib.use("TKAgg")
import matplotlib.pyplot as plt
import numpy as np

# 初始参数
initial_velocity = 0  # 初始速度,单位是米/秒
acceleration = 9.8  # 加速度,单位是米/秒^2
time_step = 0.0001  # 时间步长,单位是秒
total_time = 1.428  # 总时间,单位是秒

# 计算总时间内的步数
num_steps = int(total_time / time_step)

# 存储每个时间步长的位移
displacements = []

# 存储每个时间步长的速度
velocities = []

# 模拟匀加速运动
for i in range(num_steps):
    # 计算当前时间步长的速度
    current_velocity = initial_velocity + acceleration * ( time_step)
    velocities.append(current_velocity)
    
    # 计算当前时间步长的位移
    current_displacement = ((initial_velocity + current_velocity) / 2) * time_step
    s=0
    if i>0:
        s=displacements[i-1]
        
    displacements.append(s + current_displacement)
    
    initial_velocity=current_velocity





# 绘制速度-时间图像
plt.figure(figsize=(10, 5))
plt.subplot(1, 2, 1)
plt.plot(np.arange(num_steps) * time_step, velocities, label='Velocity')
plt.xlabel('Time (s)')
plt.ylabel('Velocity (m/s)')
plt.title('Velocity-Time Graph')
plt.legend()

#绘制位移-时间图像
plt.subplot(1, 2, 2)
plt.plot(np.arange(num_steps) * time_step, displacements, label='Displacement')
plt.xlabel('Time (s)')
plt.ylabel('Displacement (m)')
plt.title('Displacement-Time Graph')
plt.legend()

# 显示图形
plt.tight_layout()
plt.show()

View Code