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