Module Geometry¶
Shape¶
Shape
class¶
Rectangle
class¶

class
commonroad.geometry.shape.
Rectangle
(length, width, center=array([0., 0.]), orientation=0.0)[source]¶ The class Rectangle can be used to model occupied regions or rectangular obstacles, e.g., a vehicle. The rectangle is specified by the length in longitudinal direction, the width in lateral direction, the orientation, and its geometric center. If we model the shape of an obstacle, the orientation and geometric center can be omitted; therefore, we set the orientation, and the x and ycoordinate of the geometric center to zero.

center
¶ Geometric center of the rectangle [x, y]. If the rectangle is used to describe the shape of an obstacle, we set the center to the coordinates [0.0, 0.0].
Return type: ndarray

contains_point
(point)[source]¶ Checks if a point is contained in a rectangle.
Parameters: point ( ndarray
) – 2D point as array [x, y]Return type: bool
Returns: true if the rectangle’s interior or boundary intersects with the given point, otherwise false

length
¶ Length of the rectangle in longitudinal direction.
Return type: float

orientation
¶ Orientation of the rectangle. If the rectangle is used to describe the shape of an obstacle, we set the orientation to 0.0.
Return type: float

rotate_translate_local
(translation, angle)[source]¶ A new rectangle is created by first rotating the rectangle around its center and then translating it.
Parameters:  translation (
ndarray
) – translation vector [x_off, y_off] in x and ydirection  angle (
float
) – rotation angle in radian (counterclockwise)
Return type: Returns: transformed rectangle
 translation (

translate_rotate
(translation, angle)[source]¶ A new rectangle is created by first translating and then rotating the rectangle around the origin.
Parameters:  translation (
ndarray
) – translation vector [x_off, y_off] in x and ydirection  angle (
float
) – rotation angle in radian (counterclockwise)
Return type: Returns: transformed rectangle
 translation (

vertices
¶ Vertices of the rectangle: [[x_0, y_0], [x_1, y_1], …].
Return type: ndarray

width
¶ Width of the rectangle in lateral direction.
Return type: float

Circle
class¶

class
commonroad.geometry.shape.
Circle
(radius, center=array([0., 0.]))[source]¶ The class Circle can be used to model occupied regions or circular obstacles, e.g., a pedestrian. A circle is defined by its radius and its geometric center. If we model the shape of an obstacle, the geometric center can be omitted and is set to [0.0, 0.0].

center
¶ Geometric center [x, y] of the circle. If the circle is used to describe the shape of an obstacle, we set the center to the coordinates [0.0, 0.0].
Return type: ndarray

contains_point
(point)[source]¶ Checks if a point is contained in a circle.
Parameters: point ( ndarray
) – 2D point [x, y]Returns: true if the circles’s interior or boundary intersects with the given point, otherwise false

radius
¶ The radius of the circle.
Return type: float

rotate_translate_local
(translation, angle)[source]¶ A new circle is created by translating the center.
Parameters:  translation (
ndarray
) – translation vector [x_off, y_off] in x and ydirection  angle (
float
) – rotation angle in radian (counterclockwise)
Return type: Returns: transformed circle
 translation (

translate_rotate
(translation, angle)[source]¶ A new circle is created by first translating and then rotating the current circle around the origin.
Parameters:  translation (
ndarray
) – translation vector [x_off, y_off] in x and ydirection  angle (
float
) – rotation angle in radian (counterclockwise)
Return type: Returns: transformed circle
 translation (

Polygon
class¶

class
commonroad.geometry.shape.
Polygon
(vertices)[source]¶ The class Polygon can be used to model occupied regions or obstacles. A polygon is defined by an array of ordered points (clockwise or counterclockwise).

center
¶ Computes the geometric center of the polygon.
Return type: ndarray

contains_point
(point)[source]¶ Checks if a point is contained in the polygon.
Parameters: point ( ndarray
) – 2D pointReturn type: bool
Returns: true if the polygons’s interior or boundary intersects with the given point, otherwise false

rotate_translate_local
(translation, angle)[source]¶ A new polygon is created by first rotating the polygon around its center and then translating it.
Parameters:  translation (
ndarray
) – translation vector [x_off, y_off] in x and ydirection  angle (
float
) – rotation angle in radian (counterclockwise)
Return type: Returns: transformed polygon
 translation (

translate_rotate
(translation, angle)[source]¶ A new polygon is created by first translating and then rotating the current polygon.
Parameters:  translation (
ndarray
) – translation vector [x_off, y_off] in x and ydirection  angle (
float
) – rotation angle in radian (counterclockwise)
Return type: Returns: transformed polygon
 translation (

vertices
¶ Array of ordered vertices of the polygon [[x_0, y_0], [x_1, y_1], …].
Return type: ndarray

ShapeGroup
class¶

class
commonroad.geometry.shape.
ShapeGroup
(shapes)[source]¶ The class ShapeGroup represents a collection of primitive shapes, e.g., rectangles and polygons, which can be used to model occupied regions.

contains_point
(point)[source]¶ Checks if a point is contained in any shape of the shape group.
Parameters: point (<builtin function array>) – 2D point [x, y] Returns: true if the interior or boundary of any shape intersects with the given point, otherwise false

rotate_translate_local
(translation, angle)[source]¶ A new shape group is created by first rotating each shape around its center and then translating it.
Parameters:  translation (
ndarray
) – translation vector [x_off, y_off] in x and ydirection  angle (
float
) – rotation angle in radian (counterclockwise)
Return type: Returns: transformed shape group
 translation (

translate_rotate
(translation, angle)[source]¶ A new shape group is created by first translating and then rotating all shapes around the origin.
Parameters:  translation (
ndarray
) – translation vector [x_off, y_off] in x and ydirection  angle (
float
) – rotation angle in radian (counterclockwise)
Return type: Returns: transformed shape group
 translation (

Transform¶

geometry.transform.
translate_rotate
(vertices, translation, angle)[source]¶ First translates the list of vertices, then rotates the list of vertices around the origin.
Parameters:  vertices (
ndarray
) – array of 2D vertices [[x_0, y_0], [x_1, y_1], …]  translation (
Union
[<builtin function array>,List
[float
]]) – translation vector [x_off, y_off] in x and ydirection  angle (
Union
[float
,int
]) – rotation angle in radian (counterclockwise)
Return type: ndarray
Returns: array of transformed vertices [[x’_0, y’_0], [x’_1, y’_1], …]
 vertices (

geometry.transform.
rotate_translate
(vertices, translation, angle)[source]¶ First rotates the list of vertices around the origin and then translates the list of vertices.
Parameters:  vertices (
ndarray
) – array of 2D vertices [[x_0, y_0], [x_1, y_1], …]  translation (
Union
[<builtin function array>,List
[float
]]) – translation vector [x_off, y_off] in x and ydirection  angle (
Union
[float
,int
]) – rotation angle in radian (counterclockwise)
Return type: ndarray
Returns: array of transformed vertices [[x’_0, y’_0], [x’_1, y’_1], …]
 vertices (

geometry.transform.
rotation_translation_matrix
(translation, angle)[source]¶ Creates a matrix that first rotates a vector around the origin and then translates it.
Parameters:  translation (
Union
[<builtin function array>,List
[float
]]) – offset in (x, y) for translating the vector  angle (
Union
[float
,int
]) – angle in rad [2pi, +2pi]
Return type: ndarray
Returns: matrix
 translation (

geometry.transform.
translation_rotation_matrix
(translation, angle)[source]¶ Creates a matrix that first translates a homogeneous point, and then rotates it around the origin.
Parameters:  translation (
Union
[<builtin function array>,List
[float
]]) – offset in (x, y) for translating the vector  angle (
Union
[float
,int
]) – angle in rad [2pi, +2pi]
Return type: ndarray
Returns: matrix
 translation (