0

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? Closed Path in Polar Coordinates

Community
  • 1
  • 1
Karthik V
  • 1,867
  • 1
  • 16
  • 23

1 Answers1

-1

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)
Matt Hall
  • 7,614
  • 1
  • 23
  • 36
Paweł Kordowski
  • 2,688
  • 1
  • 14
  • 21
  • Yes, I could do that. However, I was wondering if there was a direct way internal to matplotlib that would do the coordinate transform for me directly. – Karthik V Nov 22 '15 at 18:14