maliput_sparse
maliput_sparse::geometry::utility Namespace Reference

Classes

struct  BoundPointsResult
 Holds the result of GetBoundPointsAtP method. More...
 
struct  ClosestPointResult
 Holds the result of GetClosestPoint method. More...
 
struct  ClosestPointToSegmentResult
 Holds the result of GetClosestPointToSegment method. More...
 

Typedefs

using ClosestPointResult3d = ClosestPointResult< maliput::math::Vector3 >
 
using ClosestPointResult2d = ClosestPointResult< maliput::math::Vector2 >
 
using ClosestPointToSegmentResult3d = ClosestPointToSegmentResult< maliput::math::Vector3 >
 
using ClosestPointToSegmentResult2d = ClosestPointToSegmentResult< maliput::math::Vector2 >
 
using OptDistance = std::optional< double >
 
using Segment3d = std::pair< Vector3, Vector3 >
 
using Segment2d = std::pair< Vector2, Vector2 >
 

Functions

LineString3d ComputeCenterline3d (const LineString3d &left, const LineString3d &right)
 Computes a 3-dimensional centerline out of the left and right line string. More...
 
template<typename CoordinateT = maliput::math::Vector3>
CoordinateT InterpolatedPointAtP (const LineString< CoordinateT > &line_string, double p, double tolerance)
 Returns the piecewise linearly interpolated point at the given distance and the distance from the beginning to the first point. More...
 
double GetSlopeAtP (const LineString3d &line_string, double p, double tolerance)
 Returns the slope of a line_string for a given p . More...
 
template<typename CoordinateT = maliput::math::Vector3>
BoundPointsResult GetBoundPointsAtP (const LineString< CoordinateT > &line_string, double p, double tolerance)
 Obtains the points that confines p in the line_string . More...
 
double Get2DHeadingAtP (const LineString3d &line_string, double p, double tolerance)
 Returns the heading of a line_string for a given p . More...
 
maliput::math::Vector2 Get2DTangentAtP (const LineString3d &line_string, double p, double tolerance)
 Returns the 2d-tangent of a line_string for a given p . More...
 
maliput::math::Vector3 GetTangentAtP (const LineString3d &line_string, double p, double tolerance)
 Returns the 3d-tangent of a line_string for a given p . More...
 
template<typename CoordinateT = maliput::math::Vector3>
ClosestPointToSegmentResult< CoordinateT > GetClosestPointToSegment (const CoordinateT &start_segment_point, const CoordinateT &end_segment_point, const CoordinateT &coordinate, double tolerance)
 Gets the closest point in the segment to the given xyz point. More...
 
ClosestPointResult3d GetClosestPoint (const LineString3d &line_string, const maliput::math::Vector3 &xyz, double tolerance)
 Gets the closest point in the line_string to the given xyz point. More...
 
ClosestPointResult3d GetClosestPointUsing2dProjection (const LineString3d &line_string, const maliput::math::Vector3 &xyz, double tolerance)
 Gets the closest point in the line_string to the given xyz point. More...
 
double ComputeDistance (const LineString3d &lhs, const LineString3d &rhs, double tolerance)
 Computes the distance between two LineString3d. More...
 
template maliput::math::Vector3 InterpolatedPointAtP (const LineString3d &, double, double)
 
template ClosestPointToSegmentResult3d GetClosestPointToSegment (const maliput::math::Vector3 &, const maliput::math::Vector3 &, const maliput::math::Vector3 &, double)
 
template ClosestPointToSegmentResult2d GetClosestPointToSegment (const maliput::math::Vector2 &, const maliput::math::Vector2 &, const maliput::math::Vector2 &, double)
 
template BoundPointsResult GetBoundPointsAtP< maliput::math::Vector3 > (const LineString3d &, double, double)
 

Variables

static constexpr bool kLeft {true}
 
static constexpr bool kRight {false}
 
static constexpr double kEpsilon {1e-12}
 

Typedef Documentation

◆ ClosestPointResult2d

using ClosestPointResult2d = ClosestPointResult<maliput::math::Vector2>

◆ ClosestPointResult3d

using ClosestPointResult3d = ClosestPointResult<maliput::math::Vector3>

◆ ClosestPointToSegmentResult2d

◆ ClosestPointToSegmentResult3d

◆ OptDistance

using OptDistance = std::optional<double>

◆ Segment2d

using Segment2d = std::pair<Vector2, Vector2>

◆ Segment3d

using Segment3d = std::pair<Vector3, Vector3>

Function Documentation

◆ ComputeCenterline3d()

LineString3d ComputeCenterline3d ( const LineString3d left,
const LineString3d right 
)

Computes a 3-dimensional centerline out of the left and right line string.

Inspired on https://github.com/fzi-forschungszentrum-informatik/Lanelet2/blob/master/lanelet2_core/src/Lanelet.cpp

Parameters
leftLeft line string.
rightRight line string.
Returns
The centerline.

◆ ComputeDistance()

double ComputeDistance ( const LineString3d lhs,
const LineString3d rhs,
double  tolerance 
)

Computes the distance between two LineString3d.

The distance is calculated as the sum of distances between corresponding points between both line strings divided by the number of points. Some notes: 1 - The evaluation points to be used are the ones from the line string with more points. 2 - If the line strings have the same number of points, the evaluation points are the ones from the first line string. 3 - The closest point is calculated for each point in the line string with less points using #ref GetClosestPoint method.

This algorithm is not the most precise one, but it is the most intuitive one and for the expected use cases it is good enough.

TODO(#CreateIssue): Use Frechet distance algorithm instead.

Parameters
lhsA LineString3d.
rhsA LineString3d.
tolerancetolerance.
Returns
The distance between the two line strings defined as above.

◆ Get2DHeadingAtP()

double Get2DHeadingAtP ( const LineString3d line_string,
double  p,
double  tolerance 
)

Returns the heading of a line_string for a given p .

Parameters
line_stringLineString to be computed the heading from.
pP parameter at which compute the heading.
tolerancetolerance.
Exceptions
maliput::common::assertion_errorWhen p ∉ [0., line_string.length()].

◆ Get2DTangentAtP()

Vector2 Get2DTangentAtP ( const LineString3d line_string,
double  p,
double  tolerance 
)

Returns the 2d-tangent of a line_string for a given p .

The tangent is calculated from the line_string projected on the xy plane.

Parameters
line_stringLineString to be computed the 2d-tangent from.
pP parameter at which compute the 2d-tangent.
tolerancetolerance.
Exceptions
maliput::common::assertion_errorWhen p ∉ [0., line_string.length()].

◆ GetBoundPointsAtP()

BoundPointsResult GetBoundPointsAtP ( const LineString< CoordinateT > &  line_string,
double  p,
double  tolerance 
)

Obtains the points that confines p in the line_string .

Template Parameters
CoordinateTThe coordinate type of the line_string .
Parameters
line_stringLineString.
pP parameter.
tolerancetolerance.
Exceptions
maliput::common::assertion_errorWhen p ∉ [0., line_string.length()].

◆ GetBoundPointsAtP< maliput::math::Vector3 >()

template BoundPointsResult maliput_sparse::geometry::utility::GetBoundPointsAtP< maliput::math::Vector3 > ( const LineString3d ,
double  ,
double   
)

◆ GetClosestPoint()

ClosestPointResult3d GetClosestPoint ( const LineString3d line_string,
const maliput::math::Vector3 &  xyz,
double  tolerance 
)

Gets the closest point in the line_string to the given xyz point.

Parameters
line_stringLineString3d to be computed the closest point from.
xyzPoint to be computed the closest point to.
tolerancetolerance.
Returns
A ClosestPointResult struct containing the closest point, the distance between the closest point and xyz and the p coordinate in the LineString3d matching the closest point.

◆ GetClosestPointToSegment() [1/3]

ClosestPointToSegmentResult< CoordinateT > GetClosestPointToSegment ( const CoordinateT &  start_segment_point,
const CoordinateT &  end_segment_point,
const CoordinateT &  coordinate,
double  tolerance 
)

Gets the closest point in the segment to the given xyz point.

Template Parameters
CoordinateTThe coordinate type of the segment .
Parameters
start_segment_pointStart point of the segment.
end_segment_pointEnd point of the segment.
coordinatePoint to be computed the closest point to.
tolerancetolerance.
Returns
A ClosestPointResult struct containing the closest point, the distance between the closest point and xyz and the p coordinate in the segment matching the closest point.

◆ GetClosestPointToSegment() [2/3]

template ClosestPointToSegmentResult2d maliput_sparse::geometry::utility::GetClosestPointToSegment ( const maliput::math::Vector2 &  ,
const maliput::math::Vector2 &  ,
const maliput::math::Vector2 &  ,
double   
)

◆ GetClosestPointToSegment() [3/3]

template ClosestPointToSegmentResult3d maliput_sparse::geometry::utility::GetClosestPointToSegment ( const maliput::math::Vector3 &  ,
const maliput::math::Vector3 &  ,
const maliput::math::Vector3 &  ,
double   
)

◆ GetClosestPointUsing2dProjection()

ClosestPointResult3d GetClosestPointUsing2dProjection ( const LineString3d line_string,
const maliput::math::Vector3 &  xyz,
double  tolerance 
)

Gets the closest point in the line_string to the given xyz point.

This method is similar to #ref GetClosestPoint, but it first projects the line_string and the xyz on the xy plane for finding the closest point. Once the closest point in the plane is found, the z coordinate is recovered from the line_string and the rest of the ClosestPointResult3d struct is filled.

Parameters
line_stringLineString3d to be computed the closest point from.
xyzPoint to be computed the closest point to.
toleranceTolerance.
Returns
A ClosestPointResult struct containing the closest point, the distance between the closest point and xyz

◆ GetSlopeAtP()

double GetSlopeAtP ( const LineString3d line_string,
double  p,
double  tolerance 
)

Returns the slope of a line_string for a given p .

The slope is calculated as the variation in z divided by the variation in the xy plane. The result is expected to be contained within (-inf., inf.).

Parameters
line_stringLineString to be computed the slope from.
pP parameter at which compute the slope.
tolerancetolerance.
Exceptions
maliput::common::assertion_errorWhen p ∉ [0., line_string.length()].
maliput::common::assertion_errorWhen the points that confine p are equal.

◆ GetTangentAtP()

Vector3 GetTangentAtP ( const LineString3d line_string,
double  p,
double  tolerance 
)

Returns the 3d-tangent of a line_string for a given p .

Parameters
line_stringLineString to be computed the 3d-tangent from.
pP parameter at which compute the 3d-tangent.
tolerancetolerance.
Exceptions
maliput::common::assertion_errorWhen p ∉ [0., line_string.length()].

◆ InterpolatedPointAtP() [1/2]

template maliput::math::Vector2 InterpolatedPointAtP ( const LineString3d ,
double  ,
double   
)

◆ InterpolatedPointAtP() [2/2]

CoordinateT InterpolatedPointAtP ( const LineString< CoordinateT > &  line_string,
double  p,
double  tolerance 
)

Returns the piecewise linearly interpolated point at the given distance and the distance from the beginning to the first point.

Template Parameters
CoordinateTThe coordinate type of the line_string .
Parameters
line_stringthe line_string to iterate.
pdistance along line_string.
tolerancetolerance.
Returns
The interpolated point (a new point if not perfectly matching).

Variable Documentation

◆ kEpsilon

constexpr double kEpsilon {1e-12}
staticconstexpr

◆ kLeft

constexpr bool kLeft {true}
staticconstexpr

◆ kRight

constexpr bool kRight {false}
staticconstexpr