Как я могу определить площадь перекрытия двух участков разной формы? - PullRequest
0 голосов
/ 27 мая 2020

Итак, я выполняю астрономическую программу, в которой окруженный кольцом pl anet (Сатурн) проходит мимо звезды (Солнца). Мне нужно уметь определить площадь pl anet и его колец, которые перекрываются с Солнцем. Есть ли для этого какая-нибудь удобная функция?

И в качестве бонуса: как я могу заполнить область колец pl anet черным цветом, которая НЕ перекрывается со звездой? введите описание изображения здесь Мой код здесь:

import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import math
from PIL import Image
from math import pi, cos, sin
import numpy as np
from matplotlib.patches import Ellipse
from matplotlib.widgets import Button

r_star = 696000
r_planet = 60000
mean = [5000000, 5000000]
meanx = 4280000
meany = 5000000
width = 2*int(r_planet) + 20000
height = 2*int(r_planet) - 14000
angle = 180
Tau = 0.10
inclination = 45

star = plt.Circle((mean), int(r_star), color = "white")
planet = plt.Circle((meanx,meany), int(r_planet), color = "black")
external_ring = mpl.patches.Ellipse(xy=[meanx, meany], width=width+120000, height=height+24000, angle = 180+angle, edgecolor='gray', lw=0.1, facecolor='grey')
inner_ring = mpl.patches.Ellipse(xy=[meanx, meany], width=width, height=height, angle = 180+angle, edgecolor='gray', lw=0.1, facecolor='white')

fig, ax = plt.subplots()
ax.set(xlim = (0, 10000000), ylim = (0, 10000000))
ax.set_ylabel("Million kilometers")
ax.set_xlabel("Million kilometers")
background = plt.fill_between((0, 10000000), 0, 10000000 ,color='black')
ax.add_artist(star)
ax.add_artist(external_ring)
ax.add_artist(inner_ring)
ax.add_artist(planet)
ax.set_aspect('equal')

plt.show()
...