亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在圓的周長上畫圓?

如何在圓的周長上畫圓?

慕虎7371278 2023-10-11 21:13:46
我正在嘗試繪制這樣的圖:我不知道如何在 for 循環中找到較小圓圈的中心。首先,我嘗試用較少數量的圓圈(例如2個)來繪制它,但我不知道為什么較小的圓圈是半圓?我的嘗試:import numpy as npimport matplotlib.pyplot as pltr = 2, h = 1, k = 1axlim = r + np.max((abs(h),np.max(abs(k))))x = np.linspace(-axlim, axlim, 100)X,Y = np.meshgrid(x,x)F = (X-h)**2 + (Y-k)**2 - r**2plt.contour(X,Y,F,0)F1 = (X-(h+r))**2 + (Y-k)**2 - (r/3)**2plt.contour(X,Y,F1,0)F2 = (X-h)**2 + (Y-(k+r))**2 - (r/3)**2plt.contour(X,Y,F2,0)plt.gca().set_aspect('equal')plt.axis([-4*r, 4*r, -4*r,4*r])# plt.axis('off')plt.show()輸出:
查看完整描述

1 回答

?
皈依舞

TA貢獻1851條經驗 獲得超3個贊

0, 2pi可以使用正弦、余弦和在范圍內均勻劃分的角度:


import numpy as np

import matplotlib.pyplot as plt


num_circ = 7

rad_large = 7

rad_small = 6

thetas = np.linspace(0, 2 * np.pi, num_circ, endpoint=False)


fig, ax = plt.subplots()

ax.add_patch(plt.Circle((0, 0), rad_large, fc='none', ec='navy'))

for theta in thetas:

    ax.add_patch(plt.Circle((rad_large * np.cos(theta), rad_large * np.sin(theta),), rad_small, fc='none', ec='crimson'))

ax.autoscale_view() # calculate the limits for the x and y axis

ax.set_aspect('equal') # show circles as circles

plt.show()

https://img1.sycdn.imooc.com/65269fd200013c4606510253.jpg

查看完整回答
反對 回復 2023-10-11
  • 1 回答
  • 0 關注
  • 138 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號