Python中的面积计算

时间:2018-08-09 20:51:36

标签: python-2.7 pixel area

我有两个带有多个圆圈的图,我正在尝试计算阴影区域的面积。我在“数学堆栈”中提出了该问题,并因问题与页面无关而受到批评。如果您能帮助我,我将非常感谢。

    date1 <- "2018-08-09 20:00:00 BST"
    date2 <- as.POSIXct(date1 , format="%Y-%m-%d %H:%M:%S")
    date3 <-date2+10*60
    date3 

[1] "2018-08-09 20:10:00 PDT"

定义函数后,

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)

输出: enter image description here

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()

输出: enter image description here

0 个答案:

没有答案