示例#1
0
def get_geoms(model_details):
    disk = shapely_rotate(
        shapely_scale(Point(*model_details['disk']['mu']).buffer(1.0),
                      xfact=model_details['disk']['rEff'],
                      yfact=model_details['disk']['rEff'] *
                      model_details['disk']['axRatio']),
        -np.rad2deg(model_details['disk']['roll'])
    ) if model_details['disk'] is not None else None
    bulge = shapely_rotate(
        shapely_scale(Point(*model_details['bulge']['mu']).buffer(1.0),
                      xfact=model_details['bulge']['rEff'],
                      yfact=model_details['bulge']['rEff'] *
                      model_details['bulge']['axRatio']),
        -np.rad2deg(model_details['bulge']['roll'])
    ) if model_details['bulge'] is not None else None
    bar = shapely_rotate(
        box(
            model_details['bar']['mu'][0] -
            model_details['bar']['rEff'] / model_details['bar']['axRatio'],
            model_details['bar']['mu'][1] - model_details['bar']['rEff'],
            model_details['bar']['mu'][0] +
            model_details['bar']['rEff'] / model_details['bar']['axRatio'],
            model_details['bar']['mu'][1] + model_details['bar']['rEff'],
        ), -np.rad2deg(model_details['bar']['roll'])
    ) if model_details['bar'] is not None else None
    return disk, bulge, bar
    def _shape_of_vehicle(self, vehicle_id):
        p = self._traci_conn.vehicle.getPosition(vehicle_id)
        length = self._traci_conn.vehicle.getLength(vehicle_id)
        width = self._traci_conn.vehicle.getWidth(vehicle_id)
        heading = Heading.from_sumo(self._traci_conn.vehicle.getAngle(vehicle_id))

        poly = shapely_box(p[0] - width * 0.5, p[1] - length, p[0] + width * 0.5, p[1],)
        return shapely_rotate(poly, heading, use_radians=True)
    def _shape_of_vehicle(self, sumo_vehicle_state, vehicle_id):
        p = sumo_vehicle_state[vehicle_id][tc.VAR_POSITION]
        length = sumo_vehicle_state[vehicle_id][tc.VAR_LENGTH]
        width = sumo_vehicle_state[vehicle_id][tc.VAR_WIDTH]
        heading = Heading.from_sumo(sumo_vehicle_state[vehicle_id][tc.VAR_ANGLE])

        poly = shapely_box(p[0] - width * 0.5, p[1] - length, p[0] + width * 0.5, p[1],)
        return shapely_rotate(poly, heading, use_radians=True)
示例#4
0
 def to_polygon(self) -> Polygon:
     p = self.pose.position
     d = self.dimensions
     poly = shapely_box(
         p[0] - d.width * 0.5,
         p[1] - d.length * 0.5,
         p[0] + d.width * 0.5,
         p[1] + d.length * 0.5,
     )
     return shapely_rotate(poly, self.pose.heading, use_radians=True)
示例#5
0
def make_box(comp):
    if not comp or comp['axRatio'] == 0:
        return None
    return shapely_rotate(
        box(
            comp['mu'][0] - comp['rEff'] / 2 / comp['axRatio'],
            comp['mu'][1] - comp['rEff'] / 2,
            comp['mu'][0] + comp['rEff'] / 2 / comp['axRatio'],
            comp['mu'][1] + comp['rEff'] / 2,
        ), -np.rad2deg(comp['roll']))
示例#6
0
 def to_polygon(self) -> Polygon:
     """Convert the chassis to a 2D shape."""
     p = self.pose.as_position2d()
     d = self.dimensions
     poly = shapely_box(
         p[0] - d.width * 0.5,
         p[1] - d.length * 0.5,
         p[0] + d.width * 0.5,
         p[1] + d.length * 0.5,
     )
     return shapely_rotate(poly, self.pose.heading, use_radians=True)
示例#7
0
def make_ellipse(comp):
    if comp is None:
        return None
    return shapely_rotate(
        shapely_scale(
            Point(comp['mux'], comp['muy']).buffer(1.0),
            xfact=comp['Re'] * comp['q'],
            yfact=comp['Re']
        ),
        comp['roll'],
        use_radians=True,
    )
示例#8
0
def make_box(comp):
    if comp is None:
        return None
    return shapely_rotate(
        box(
            comp['mux'] - comp['Re'] * comp['q'],
            comp['muy'] - comp['Re'],
            comp['mux'] + comp['Re'] * comp['q'],
            comp['muy'] + comp['Re'],
        ),
        comp['roll'],
        use_radians=True,
    )
示例#9
0
def rotate(cell, angle, origin='center'):
    rotated_cell = deepcopy(cell)
    rotated_cell.center = shapely_rotate(cell.center, angle, origin)
    rotated_cell.vertices = shapely_rotate(cell.vertices, angle, origin)
    return rotated_cell
示例#10
0
def ellipse_geom_from_zoo(a):
    ellipse = shapely_rotate(
        shapely_scale(Point(a['x'], a['y']).buffer(1.0),
                      xfact=a['rx'],
                      yfact=a['ry']), -a['angle'])
    return ellipse
示例#11
0
def bar_geom_from_zoo(a):
    b = box(a['x'], a['y'], a['x'] + a['width'], a['y'] + a['height'])
    return shapely_rotate(b, a['angle'])
示例#12
0
def make_ellipse(comp):
    return shapely_rotate(
        shapely_scale(Point(*comp['mu']).buffer(1.0),
                      xfact=comp['rEff'],
                      yfact=comp['rEff'] * comp['axRatio']),
        -np.rad2deg(comp['roll'])) if comp else None