MCPcopy Create free account
hub / github.com/Rex-sys-hk/PlanScope / plot_box

Function plot_box

src/utils/vis.py:83–115  ·  view source on GitHub ↗
(
    ax: plt.Axes,
    cur_location: np.ndarray,
    heading: float,
    color: str,
    bbox_size: Tuple[float, float],
    alpha=1.0,
    label=None,
    zorder=50,
    fill=True,
    **kwargs,
)

Source from the content-addressed store, hash-verified

81
82
83def plot_box(
84 ax: plt.Axes,
85 cur_location: np.ndarray,
86 heading: float,
87 color: str,
88 bbox_size: Tuple[float, float],
89 alpha=1.0,
90 label=None,
91 zorder=50,
92 fill=True,
93 **kwargs,
94) -> None:
95 (bbox_length, bbox_width) = bbox_size
96
97 # Compute coordinate for pivot point of bounding box
98 d = np.hypot(bbox_length, bbox_width)
99 theta_2 = math.atan2(bbox_width, bbox_length)
100 pivot_x = cur_location[0] - (d / 2) * math.cos(heading + theta_2)
101 pivot_y = cur_location[1] - (d / 2) * math.sin(heading + theta_2)
102
103 vehicle_bounding_box = Rectangle(
104 xy=(pivot_x, pivot_y),
105 width=bbox_length,
106 height=bbox_width,
107 angle=np.degrees(heading),
108 fc=color if fill else "none",
109 ec="dimgrey",
110 alpha=alpha,
111 label=label,
112 zorder=zorder,
113 **kwargs,
114 )
115 ax.add_patch(vehicle_bounding_box)
116
117
118def plot_polygon(

Callers 1

plot_sdcFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected