簡體   English   中英

如何在matplotlib中檢查點是否位於極坐標中的多邊形內

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

我在極坐標中生成了一條閉合路徑,如下所示

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)

如何檢查該路徑內是否有特定點說(0,0)?

雖然可以使用matplotlib.pathPath.contains_point方法獲得笛卡爾坐標,如下所示 ,但如何考慮極坐標轉換呢? 極坐標中的閉合路徑

為什么不將坐標轉換為笛卡爾坐標並使用您引用的解決方案?

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM