MCPcopy Create free account
hub / github.com/OpenDriveLab/DriveAdapter / RotatedRectangle

Class RotatedRectangle

scenario_runner/srunner/tools/scenario_helper.py:483–510  ·  view source on GitHub ↗

This class contains method to draw rectangle and find intersection point.

Source from the content-addressed store, hash-verified

481
482
483class RotatedRectangle(object):
484
485 """
486 This class contains method to draw rectangle and find intersection point.
487 """
488
489 def __init__(self, c_x, c_y, width, height, angle):
490 self.c_x = c_x
491 self.c_y = c_y
492 self.w = width # pylint: disable=invalid-name
493 self.h = height # pylint: disable=invalid-name
494 self.angle = angle
495
496 def get_contour(self):
497 """
498 create contour
499 """
500 w = self.w
501 h = self.h
502 c = shapely.geometry.box(-w / 2.0, -h / 2.0, w / 2.0, h / 2.0)
503 rc = shapely.affinity.rotate(c, self.angle)
504 return shapely.affinity.translate(rc, self.c_x, self.c_y)
505
506 def intersection(self, other):
507 """
508 Obtain a intersection point between two contour.
509 """
510 return self.get_contour().intersection(other.get_contour())

Callers 1

detect_lane_obstacleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected