已知圆1与圆2,圆2不动,圆1绕圆2转一圈,圆1自转多少圈?

答:圆1的圆心走了 2 π ( r 1 + r 2 ) 2\pi(r_1+r_2) 2π(r1​+r2​),圆1自转了的路程也是 2 π ( r 1 + r 2 ) 2\pi(r_1+r_2) 2π(r1​+r2​),因此圆1自转了 2 π ( r 1 + r 2 ) 2 π r 1 \frac{2\pi(r_1+r_2)}{2\pi r_1} 2πr1​2π(r1​+r2​)​圈

动图

# -*- coding: utf-8 -*-
"""
Created on Mon Jun 14 20:22:04 2021@author: Leslie Lee
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animationdef coord(time, step, W, w, r1, r2):'''r1为动圆半径 r2为静圆半径 W为公转角速度 w为自转角速度 time为离散时间长度'''t = np.arange(0, time, step)x = np.sin(W*t)*r1y = np.cos(W*t)*r1x1 = np.sin(W*t)*(r1+r2)y1 = np.cos(W*t)*(r1+r2)x2 = x1 + r1*np.sin(w*t/2)y2 = y1 - r1*np.cos(w*t/2)return x, y, x1, y1, x2, y2time = 500
step = 0.05
r1 = 2
r2 = 2
W = np.deg2rad(3.6)*10
w =np.deg2rad(3.6)*10
x,y,x1,y1,x2,y2 = coord(time, step, W, w, r1, r2)# 建立fig
fig = plt.figure()
ax = fig.add_subplot(111, autoscale_on=False, xlim=(-8, 8), ylim=(-8, 8))
ax.grid()
line, = ax.plot([], [], 'o-', lw=2)
time_template = 'time = %.1fs' # 格式化输出 保留一位浮点数
time_text = ax.text(0.05, 0.9, '', transform=ax.transAxes)def init():line.set_data([], [])time_text.set_text('')return line, time_textdef animate(i):thisx = [0, x[i], x1[i], x2[i]]thisy = [0, y[i], y1[i], y2[i]]line.set_data(thisx, thisy)time_text.set_text(time_template % (i*step))return line, time_textani = animation.FuncAnimation(fig, animate, np.arange(0, len(y)),interval=25, blit=True, init_func=init)
plt.show()

在动画的基础上又将轨迹画了上去

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animationdef coord(time, step, W, w, r1, r2):'''r1为动圆半径 r2为静圆半径 W为公转角速度 w为自转角速度 time为离散时间长度'''t = np.arange(0, time, step)x = np.sin(W*t)*r1y = np.cos(W*t)*r1x1 = np.sin(W*t)*(r1+r2)y1 = np.cos(W*t)*(r1+r2)x2 = x1 + r1*np.sin(w*t/2)y2 = y1 - r1*np.cos(w*t/2)return x, y, x1, y1, x2, y2time = 500
step = 0.05
r1 = 2
r2 = 2
W = np.deg2rad(3.6)*10
w =np.deg2rad(3.6)*10
x,y,x1,y1,x2,y2 = coord(time, step, W, w, r1, r2)fig = plt.figure()
ax = plt.gca()
ax.set_aspect(1)plt.plot(x, y)
plt.plot(x1, y1)
plt.plot(x2, y2)line, = ax.plot([], [], 'o-', lw=2)
time_template = 'time = %.1fs' # 格式化输出 保留一位浮点数
time_text = ax.text(0.05, 0.9, '', transform=ax.transAxes)def init():line.set_data([], [])time_text.set_text('')return line, time_textdef animate(i):thisx = [0, x[i], x1[i], x2[i]]thisy = [0, y[i], y1[i], y2[i]]line.set_data(thisx, thisy)time_text.set_text(time_template % (i*step))return line, time_textani = animation.FuncAnimation(fig, animate, np.arange(0, len(y)),interval=25, blit=True, init_func=init)
plt.show()

保存gif,需要安装pillow

ani.save('F:\double_pendulum.gif', writer='pillow')

验证

如何验证圆1自转了多少圈?
即验证蓝线上的红点走够一圈,绿线的长度是否为 2 π ( r 1 + r 2 ) 2\pi(r_1+r_2) 2π(r1​+r2​)
方1. 曲线积分,已知曲线参数方程 ( x 2 ( t ) , y 2 ( t ) ) (x_2(t),y_2(t)) (x2​(t),y2​(t)),来求弧长
方2. 已知绿线的离散点,对相邻两个离散点求距离,将所有距离累计起来便是弧长
方1出现了不可积项,因此放弃

方1积分程序

# -*- coding: utf-8 -*-
"""
Created on Tue Jun 15 08:44:13 2021@author: Leslie Lee  用python的库 sympy 求积分 https://blog.csdn.net/t4ngw/article/details/105770161
https://wenku.baidu.com/view/5b46565491c69ec3d5bbfd0a79563c1ec4dad71c.html
"""
import numpy as np
from sympy import var, diff, integrate, sin, cos, sqrt, simplify, trigsimp, pidef arc(r1, r2, W, w):var("t")x1 = sin(W*t)*(r1+r2)y1 = cos(W*t)*(r1+r2)x2 = x1 + r1*sin(w*t/2)y2 = y1 - r1*cos(w*t/2)# 求导dx2 = diff(x2, t)dy2 = diff(y2, t)# 积分end = 2*pi/wres = integrate(sqrt(dx2**2+dy2**2), (t, 0, end))res = trigsimp(simplify(res))return resW = np.deg2rad(3.6)*10
w =np.deg2rad(3.6)*10
r1 = 2
r2 = 2
res = arc(2, 2, W, w)

方2累加程序

# -*- coding: utf-8 -*-
"""
Created on Mon Jun 21 11:27:28 2021@author: Leslie Lee
"""import numpy as np
import matplotlib.pyplot as pltdef arc(r1, r2, W, w, num):time = 2*np.pi/Wstep = time/num# print(time, step)t = np.arange(0, time, step)x1 = np.sin(W*t)*(r1+r2)y1 = np.cos(W*t)*(r1+r2)x2 = x1 + r1*np.sin(w*t/2)y2 = y1 - r1*np.cos(w*t/2)# 实际值res = 0for i in range(int(len(x2)-1)):res = res + ((x2[i+1] - x2[i])**2 + (y2[i+1] - y2[i])**2)**0.5# 目标值target_res = 2*np.pi*(r1+r2)return res, target_res# 结果与转速无关 与离散时间的间隔有关
W = np.deg2rad(3.6)*10
w =np.deg2rad(3.6)*10
r1 = 2
r2 = 2nums = []
results = []
target_results = []
for i in range(1, 1000, 10): res, t_res = arc(2, 2, W, w, i)nums.append(i)results.append(res)target_results.append(t_res)
plt.plot(nums, results, label='real')
plt.plot(nums, target_results, label='target')
plt.xlabel('the length of time series')
plt.legend()
plt.show()


验证了确实对了,但时间序列间隔也不是越小越好,有个限度,比如这个例子中间隔为50结果就是正常结果(两条曲线交点)

参考:
求解双摆与单摆运动轨迹并绘制动图。https://blog.csdn.net/qq_37083038/article/details/117884311
python学习之matplotlib绘制动图(FuncAnimation()参数)。https://www.cnblogs.com/zhouzhe-blog/p/9614360.html

动图之一个圆绕另一个圆转动相关推荐

  1. 字符动图_手把手教你做一个python+matplotlib的炫酷的数据可视化动图

    1.数据可视化动图,是数据可视化的高级显示,最近很流行. 2.比如下面将告诉你如何制作一个如下的数据可视化动图. 3.例: 3.1 准备一组数据,虚拟的csv资料,对应关系如下 4个项目:namegr ...

  2. Python3,为了无损压缩gif动图,我不得不写了一个压缩神器,真香。

    gif动图无损压缩 1.引言 2.代码实战 2.1 模块介绍 2.2 安装 2.3 代码示例 3.总结 1.引言 小屌丝:鱼哥, 求助~ 求助~ 求助~ 小鱼:你这是告诉我,重要的事情 说三遍吗? 小 ...

  3. python制作数据增长动图_手把手教你做一个python+matplotlib的炫酷的数据可视化动图...

    #第1步:导出模块,固定 importpandas as pdimportmatplotlib.pyplot as pltimportmatplotlib.ticker as tickerimport ...

  4. 为什么python画不了图-python-为什么pygame不画一个圆?

    我对pygame几乎一无所知,所以我无能为力了--但是我认为您在做的事总是使自己陷入困境.试试看: pygame.init() screen = pygame.display.set_mode((64 ...

  5. 有趣 GIF 动图集 - 仿佛每张小动图都诉说了一个小笑话或者小故事

    点这里 来自法国南特(Nantes)的 Guillaume Kurkdjian 目前还是个学生.Kurkdjian 擅长创作一些平面动态图像,这些有趣的小动图仿佛每张都诉说了一个小笑话或者小故事,像个 ...

  6. python棋盘覆盖问题_棋盘覆盖问题可视化动图——python

    棋盘覆盖问题可视化动图--python 棋盘覆盖问题是一个经典的分治法解决的问题,具体内容可以参照以下博主的解析 为了更好的理解该算法分治的过程 利用了python中的matplotlib库进行了该算 ...

  7. linux中打开gif图片命令,在Linux终端中安装使用Gifski创建GIF动图

    Gifski 是一款跨平台的高质量 GIF 编码器,在 Linux 终端中可以安装及使用 Gifski 来创建高质量的 GIF 动图及使用 Gifski 从视频创建 GIF 动图. Gifski 简介 ...

  8. 如何用Qt展示你的GIF动图

    如果想用Qt把喜欢的GIF动图贴在对话框里,我们应该怎么做呢? 首先你可以使用软件Ulead Gif Animator 按帧保存你看中的动图,或者自己亲手制作一个GIf动图的每一帧图片.然后把这些图片 ...

  9. OLED上播放动图的一种笨方法

    声明:本文章纯属学习研究,之所以使用这个素材,一是觉着好玩,二是在这个动图中,人物的动作比较大,这样子效果比较好.没有冒犯他人之意. 再者,文章若有侵权请联系本人进行删除. 工具:硬件:STC8A8K ...

最新文章

  1. webpack版本查看_浅谈webpack技术
  2. QT利用lamda正则表达式取出字符串中的浮点数与整数
  3. 08.15《CEP职业发展规划课》
  4. SQL SERVER 表分区
  5. 昆仑通态如何连接sqlserver数据库_sqlserver数据库怎么开启远程连接,给到别人访问...
  6. 个性化推荐的另一种思路: 学习用户行为的解纠缠表示
  7. java swt 双屏_SWT(JFace)体验之打开多个Form
  8. GANs之信息量、信息熵、交叉熵、KL散度、JS散度、Wasserstein距离
  9. Happy Birthday to You
  10. js 去除html标签
  11. 计算机学院实验室安全管理办法,江苏大学计算机学院实验室安全管理制度
  12. (附源码)springboot猪场管理系统 毕业设计 160901
  13. negroni-gzip源代码分析
  14. 2021年中国人工智能产业及其重点企业分析(阿里巴巴、百度、腾讯、科大讯飞)[图]
  15. 什么是 Headless CMS?
  16. 一个围绕中心点旋转的动画效果
  17. 移动web微金所实战项目——导航栏
  18. 2018年前端年度工作总结
  19. 美女手机壁纸采集源码
  20. H.迷宫,(算法选修)

热门文章

  1. android rndis win10,RNDIS驱动程序
  2. 科普知识普及 - 桥接VS中继
  3. GIS坐标系转换工具CoordSystemTransform使用教程
  4. XXT-dpkg-脚本
  5. 后记——再见南航829
  6. 【数学】固定弦长公式
  7. CAD图块:什么是动态块?CAD动态块怎么使用?
  8. [工具]K8tools 20190721/K8工具合集/K8网盘
  9. 小羊驼和你一起学习cocos2d-x之二(屏幕匹配、多分辨率解决方案、分辨率适配)
  10. python小游戏 2048小游戏设计与实现