simulation.utils.geometry.line module

Line.

Summary

Classes:

Line

List of points as a Line class inheriting from shapely’s LineString class.

Functions:

ensure_valid_arc_length

Check if an arc length is on the line and can be used for approximation.

Reference

ensure_valid_arc_length(*, approx_distance=5e-05) → Callable[source]

Check if an arc length is on the line and can be used for approximation.

If the arc_length is too close to the end points of the line, it is moved further away from the edges.

Parameters

approx_distance (float) – Approximation step length to be used in further calculations. Arc length will be at least that far away from the end of the line.

class Line(*args, frame=None)[source]

Bases: shapely.geometry.linestring.LineString

List of points as a Line class inheriting from shapely’s LineString class.

Inheriting from shapely enables to use their powerful operations in combination with other objects, e.g. polygon intersections.

Initialization can be done in one of the following ways.

Parameters
  • 1 ([Point]) – List of points or anything that can be initialized as a point, e.g. Vector, geometry_msgs.Point,np.array)

  • 2 ([]) – Empty list creates an empty line.

classmethod cut(line: simulation.utils.geometry.line.Line, arc_length: float) → Tuple[simulation.utils.geometry.line.Line, simulation.utils.geometry.line.Line][source]

Cuts a line in two at a arc_length from its starting point.

See: https://shapely.readthedocs.io/en/latest/manual.html?highlight=cut#linear-referencing-methods

get_points() → List[simulation.utils.geometry.point.Point][source]

Points of line.

Returns

list of points on the line.

Rotate the line tf.rotation around (0,0,0) and translate by tf.xyz

parallel_offset(*args, **kwargs)

Returns a LineString or MultiLineString geometry at a distance from the object on its right or its left side.

The side parameter may be ‘left’ or ‘right’ (default is ‘right’). The resolution of the buffer around each vertex of the object increases by increasing the resolution keyword parameter or third positional parameter. Vertices of right hand offset lines will be ordered in reverse.

The join style is for outside corners between line segments. Accepted values are JOIN_STYLE.round (1), JOIN_STYLE.mitre (2), and JOIN_STYLE.bevel (3).

The mitre ratio limit is used for very sharp corners. It is the ratio of the distance from the corner to the end of the mitred offset corner. When two line segments meet at a sharp angle, a miter join will extend far beyond the original geometry. To prevent unreasonable geometry, the mitre limit allows controlling the maximum length of the join corner. Corners with a ratio which exceed the limit will be beveled.

simplify(*args, **kwargs)

Returns a simplified geometry produced by the Douglas-Peucker algorithm

Coordinates of the simplified geometry will be no more than the tolerance distance from the original. Unless the topology preserving option is used, the algorithm may produce self-intersecting or otherwise invalid geometries.

interpolate_direction(arc_length)[source]
interpolate_curvature(arc_length: float) → float[source]

Interpolate the curvature at a given arc_length.

The curvature is approximated by calculating the Menger curvature as defined and described here: https://en.wikipedia.org/wiki/Menger_curvature#Definition

Parameters

arc_length (float) – Length along the line starting from the first point

Raises

ValueError – If the arc_length is <0 or more than the length of the line.

Returns

Corresponding curvature.

interpolate_pose(arc_length)[source]
to_geometry_msgs() → List[geometry_msgs.msg._Point.Point][source]

To ROS geometry_msgs.

Returns

This line as a list of geometry_msgs/Point.

to_numpy() → numpy.ndarray[source]

To numpy array.

Returns

Line as a numpy array of np.arrays.