Draw an angle on plt ax.
(
ax: matplotlib.axes.Axes,
head: Point,
p1: Point,
p2: Point,
color: Any = 'red',
alpha: float = 0.5,
frac: float = 1.0,
)
| 844 | |
| 845 | |
| 846 | def draw_angle( |
| 847 | ax: matplotlib.axes.Axes, |
| 848 | head: Point, |
| 849 | p1: Point, |
| 850 | p2: Point, |
| 851 | color: Any = 'red', |
| 852 | alpha: float = 0.5, |
| 853 | frac: float = 1.0, |
| 854 | ) -> None: |
| 855 | """Draw an angle on plt ax.""" |
| 856 | d1 = p1 - head |
| 857 | d2 = p2 - head |
| 858 | |
| 859 | a1 = np.arctan2(float(d1.y), float(d1.x)) |
| 860 | a2 = np.arctan2(float(d2.y), float(d2.x)) |
| 861 | a1, a2 = a1 * 180 / np.pi, a2 * 180 / np.pi |
| 862 | a1, a2 = a1 % 360, a2 % 360 |
| 863 | |
| 864 | if a1 > a2: |
| 865 | a1, a2 = a2, a1 |
| 866 | |
| 867 | if a2 - a1 > 180: |
| 868 | a1, a2 = a2, a1 |
| 869 | |
| 870 | b1, b2 = a1, a2 |
| 871 | if b1 > b2: |
| 872 | b2 += 360 |
| 873 | d = b2 - b1 |
| 874 | # if d >= 90: |
| 875 | # return |
| 876 | |
| 877 | scale = min(2.0, 90 / d) |
| 878 | scale = max(scale, 0.4) |
| 879 | fov = matplotlib.patches.Wedge( |
| 880 | (float(head.x), float(head.y)), |
| 881 | unif(0.075, 0.125) * scale * frac, |
| 882 | a1, |
| 883 | a2, |
| 884 | color=color, |
| 885 | alpha=alpha, |
| 886 | ) |
| 887 | ax.add_artist(fov) |
| 888 | |
| 889 | |
| 890 | def naming_position( |
no outgoing calls
no test coverage detected