1

For two given polygons generated as shown below, how do I find the points that are intersected on the rectangle by the circle? [The polygon was created using the Alphashape function]

(Similar to Returning percentage of area of polygon intersecting another polygon using shapely which is answered but I have not used Shapely to generate polygon for the distribution)

Polygon Intersection

Code implemented:

import sys
from descartes import PolygonPatch
import matplotlib.pyplot as plt
import alphashape
import numpy as np
x = np.random.uniform(41.03641664650488, 59.06406419360736, 1000)
y = np.random.uniform(100.96028140425065, 118.84533708184047, 1000)
test = np.vstack((x,y)).T
alpha_shape = alphashape.alphashape(test, 0.)
fig = plt.figure(1, figsize=(12, 5))
ax = fig.add_subplot(111, aspect='equal')
ax.scatter(*zip(*test))
ax.add_patch(PolygonPatch(alpha_shape, alpha=0.2))
circle = plt.Circle((50,100), 4, color='r', fill=True)
plt.gca().add_patch(circle)
plt.autoscale()
plt.show()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.