简体   繁体   中英

How to check in matplotlib if a point lies inside a polygon in polar coordinates

I have a closed path generated in polar coordinates as shown below

import matplotlib.pyplot as plt
import numpy as np
%matplotlib qt

horizon_az = np.array([41, 66, 115, 220, 300, 41])
horizon_alt = np.array([16, 15, 10, 23, 33, 16])

ax = plt.subplot(111, projection='polar')
ax.plot(horizon_az * np.pi / 180, horizon_alt, 'r', linewidth=3)

How can I check if a specific point say (0, 0) is inside this path?

While one can use the Path.contains_point method from matplotlib.path for Cartesian coordinates as shown here , how does one take into account the polar coordinate transformation? 极坐标中的闭合路径

Why not translate your coordinates into Cartesian and use the solution you cited?

horizon_x = horizon_alt * np.cos(horizon_az * np.pi / 180)
horizon_y = horizon_alt * np.sin(horizon_az * np.pi / 180)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM