Re: [问卦] 乡民救命!这题数学题快把我逼疯了!

楼主: lono (lono)   2023-07-17 23:16:35
帮ChatGPT debug一个小时
终于写出来了
看程式码是圆周两倍没错
这个问题的难度会把ChatGPT
给考倒
https://i.imgur.com/MoR4WtI.gif
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import numpy as np
from matplotlib.animation import FuncAnimation
plt.rcParams['animation.ffmpeg_path'] = '/usr/local/bin/ffmpeg' #请确定你的ffm
peg的路径
fig, ax = plt.subplots()
circle1 = patches.Circle((0, 0), 1, fc='b') # Blue circle
circle2 = patches.Circle((2, 0), 1, fc='r') # Red circle
arrow = None # Placeholder for the arrow
dist_text = ax.text(-2.5, 2.5, '') # Text object for the distance
dist = 0 # Initial distance
def init():
ax.add_patch(circle1)
ax.add_patch(circle2)
ax.set_xlim(-3, 3)
ax.set_ylim(-3, 3)
ax.set_aspect('equal', adjustable='box')
def animate(i):
global arrow, dist # We'll modify the arrow and dist, so we need to decla
re them as global
t = np.radians(i)
x = 2*np.cos(t) # Multiply the cosine and sine values by 2 (the sum of th
e radii)
y = 2*np.sin(t) # to have the edge of circle2 touch the edge of circle1
circle2.center = (x, y)
if arrow is not None: # If an arrow already exists, remove it
arrow.remove()
arrow = patches.FancyArrow(x, y, 0.5*np.cos(t+np.pi/2), 0.5*np.sin(t+np.pi
/2), color='g') # Create a new arrow
ax.add_patch(arrow) # Add the new arrow to the axes
dist += 2*np.pi/360 # Update the distance
dist_text.set_text(f'Distance: {dist:.2f} units') # Update the text objec
t
ani = FuncAnimation(fig, animate, init_func=init, frames=360, repeat=True)
plt.show()
# Save the animation
#ani.save('animation.gif', writer='pillow', fps=30)
※ 引述《a205090a (不再)》之铭言:
刚刚有个朋友突然丢一道题目给我
内容如下
把两个10元硬币上下排列,上面的是A下面的是B,现在用A贴著B旋转一圈直到回到原点,

问A一共需要转几圈??
我把我的答案丢给朋友
结果是错的欸
这答案也太反直觉了吧??
有乡民能第一次就答对吗??
有没有卦??

Links booklink

Contact Us: admin [ a t ] ucptt.com