У меня есть два графика с множеством кругов на них, и я пытаюсь вычислить площадь заштрихованной области. Я задал вопрос в Math Stack, и меня засыпали критикой, так как вопрос не имеет отношения к странице. Если вы можете мне помочь, я буду очень признателен.
import matplotlib.pyplot as plt
from pylab import *
import numpy as np
import math
np.random.seed(10)
def filledcircle(x, y, r):
circle = plt.Circle((x, y), r,color='lightgray',fill=True, ec='none')
return plt.gca().add_artist(circle)
После определения функции
fig, ax = plt.subplots(figsize=(8, 8))
ax.set_xlim((0, 1))
ax.set_ylim((0, 1))
x = 0.5; y = 0.5; r = 0.2
degree = np.pi
filledcircle(x-r, y, r/2)
filledcircle(x-r/2, y, r/2)
filledcircle(x, y-r, r/2)
filledcircle(x, y-r/2, r/2)
filledcircle(x+r, y, r/2)
filledcircle(x+r/2, y, r/2)
filledcircle(x, y+r, r/2)
filledcircle(x, y+r/2, r/2)
filledcircle(x -r*np.sin(0.75*degree), y + r*np.cos(0.75*degree), r/2)
filledcircle(x -r*np.sin(1.25*degree), y + r*np.cos(1.25*degree), r/2)
filledcircle(x -r*np.sin(1.75*degree), y + r*np.cos(1.75*degree), r/2)
filledcircle(x -r*np.sin(0.25*degree), y + r*np.cos(0.25*degree), r/2)
filledcircle(x -1.5*r*np.sin(0.75*degree), y + 1.5*r*np.cos(0.75*degree), r/2)
filledcircle(x -1.5*r*np.sin(0.25*degree), y + 1.5*r*np.cos(0.25*degree), r/2)
filledcircle(x -1.5*r*np.sin(1.75*degree), y + 1.5*r*np.cos(1.75*degree), r/2)
filledcircle(x -1.5*r*np.sin(1.25*degree), y + 1.5*r*np.cos(1.25*degree), r/2)
filledcircle(x -1.5*r*np.sin(0*degree), y + 1.5*r*np.cos(0*degree), r/2)
filledcircle(x -1.5*r*np.sin(0.5*degree), y + 1.5*r*np.cos(0.5*degree), r/2)
filledcircle(x -1.5*r*np.sin(1*degree), y + 1.5*r*np.cos(1*degree), r/2)
filledcircle(x -1.5*r*np.sin(1.5*degree), y + 1.5*r*np.cos(1.5*degree), r/2)
filledcircle(x -1.5*r*np.sin(0.125*degree), y + 1.5*r*np.cos(0.125*degree), r/2)
filledcircle(x -1.5*r*np.sin(0.375*degree), y + 1.5*r*np.cos(0.375*degree), r/2)
filledcircle(x -1.5*r*np.sin(0.625*degree), y + 1.5*r*np.cos(0.625*degree), r/2)
filledcircle(x -1.5*r*np.sin(0.875*degree), y + 1.5*r*np.cos(0.875*degree), r/2)
filledcircle(x -1.5*r*np.sin(1.125*degree), y + 1.5*r*np.cos(1.125*degree), r/2)
filledcircle(x -1.5*r*np.sin(1.375*degree), y + 1.5*r*np.cos(1.375*degree), r/2)
filledcircle(x -1.5*r*np.sin(1.625*degree), y + 1.5*r*np.cos(1.625*degree), r/2)
filledcircle(x -1.5*r*np.sin(1.875*degree), y + 1.5*r*np.cos(1.875*degree), r/2)
plt.show()
fig, ax = plt.subplots(figsize=(8, 8))
ax.set_xlim((0, 1))
ax.set_ylim((0, 1))
x = 0.5; y = 0.5; r = 0.2
degree = np.pi
filledcircle(x, y, r/2)
filledcircle(x-r, y, r/2)
filledcircle(x, y-r, r/2)
filledcircle(x+r, y, r/2)
filledcircle(x, y+r, r/2)
filledcircle(x -r*np.sin(0.75*degree), y + r*np.cos(0.75*degree), r/2)
filledcircle(x -r*np.sin(1.25*degree), y + r*np.cos(1.25*degree), r/2)
filledcircle(x -r*np.sin(1.75*degree), y + r*np.cos(1.75*degree), r/2)
filledcircle(x -r*np.sin(0.25*degree), y + r*np.cos(0.25*degree), r/2)
filledcircle(x -2*r*np.sin(0.75*degree), y + 2*r*np.cos(0.75*degree), r/2)
filledcircle(x -2*r*np.sin(0.25*degree), y + 2*r*np.cos(0.25*degree), r/2)
filledcircle(x -2*r*np.sin(1.75*degree), y + 2*r*np.cos(1.75*degree), r/2)
filledcircle(x -2*r*np.sin(1.25*degree), y + 2*r*np.cos(1.25*degree), r/2)
filledcircle(x -2*r*np.sin(0*degree), y + 2*r*np.cos(0*degree), r/2)
filledcircle(x -2*r*np.sin(0.5*degree), y + 2*r*np.cos(0.5*degree), r/2)
filledcircle(x -2*r*np.sin(1*degree), y + 2*r*np.cos(1*degree), r/2)
filledcircle(x -2*r*np.sin(1.5*degree), y + 2*r*np.cos(1.5*degree), r/2)
filledcircle(x -2*r*np.sin(0.125*degree), y + 2*r*np.cos(0.125*degree), r/2)
filledcircle(x -2*r*np.sin(0.375*degree), y + 2*r*np.cos(0.375*degree), r/2)
filledcircle(x -2*r*np.sin(0.625*degree), y + 2*r*np.cos(0.625*degree), r/2)
filledcircle(x -2*r*np.sin(0.875*degree), y + 2*r*np.cos(0.875*degree), r/2)
filledcircle(x -2*r*np.sin(1.125*degree), y + 2*r*np.cos(1.125*degree), r/2)
filledcircle(x -2*r*np.sin(1.375*degree), y + 2*r*np.cos(1.375*degree), r/2)
filledcircle(x -2*r*np.sin(1.625*degree), y + 2*r*np.cos(1.625*degree), r/2)
filledcircle(x -2*r*np.sin(1.875*degree), y + 2*r*np.cos(1.875*degree), r/2)
plt.show()
Я хочу рассчитать площадь заштрихованной области. Что не понятного? Я могу использовать какой-нибудь метод подсчета пикселей, но не знаю, как его реализовать.
Я только что сообразил, это было просто это.
До сих пор неясно, о чем вы спрашиваете. Какой у Вас вопрос?