scenario_simulator_v2 C++ API
Public Member Functions | Public Attributes | List of all members
math::geometry::LineSegment Class Reference

#include <line_segment.hpp>

Public Member Functions

 LineSegment (const geometry_msgs::msg::Point &start_point, const geometry_msgs::msg::Point &end_point)
 
 LineSegment (const geometry_msgs::msg::Point &start_point, const geometry_msgs::msg::Vector3 &vec, double length)
 
 ~LineSegment ()
 
LineSegmentoperator= (const LineSegment &)
 
auto getPoint (const double s, const bool denormalize_s=false) const -> geometry_msgs::msg::Point
 Get point on the line segment from s value. More...
 
auto getPose (const double s, const bool denormalize_s=false, const bool fill_pitch=true) const -> geometry_msgs::msg::Pose
 Get pose on the line segment from s value. Orientation of thee return value was calculated from the vector of the line segment. More...
 
auto isIntersect2D (const geometry_msgs::msg::Point &point) const -> bool
 Checking the intersection with 1 line segment and 1 point in 2D (x,y) coordinate. Ignore z axis. More...
 
auto isIntersect2D (const LineSegment &l0) const -> bool
 Checking the intersection with 2 line segments in 2D (x,y) coordinate. Ignore z axis. More...
 
auto getIntersection2DSValue (const geometry_msgs::msg::Point &point, const bool denormalize_s=false) const -> std::optional< double >
 Find intersection point of 1 line segment and 1 point. More...
 
auto getIntersection2DSValue (const LineSegment &line, const bool denormalize_s=false) const -> std::optional< double >
 Get S value of the intersection point of two line segment. More...
 
auto getIntersection2D (const LineSegment &line) const -> std::optional< geometry_msgs::msg::Point >
 Find intersection point of two line segments. More...
 
auto getSValue (const geometry_msgs::msg::Pose &pose, double threshold_distance, bool denormalize_s) const -> std::optional< double >
 
auto getVector () const -> geometry_msgs::msg::Vector3
 
auto getNormalVector () const -> geometry_msgs::msg::Vector3
 Get normal vector of the line segment. More...
 
auto get2DVector () const -> geometry_msgs::msg::Vector3
 
auto getLength () const -> double
 
auto get2DLength () const -> double
 
auto getSlope () const -> double
 
auto getSquaredDistanceIn2D (const geometry_msgs::msg::Point &point, const double s, const bool denormalize_s=false) const -> double
 Get squared distance (Square of euclidean distance) between specified 3D point and specified 3D point on line segment in 2D. (x,y) More...
 
auto getSquaredDistanceVector (const geometry_msgs::msg::Point &point, const double s, const bool denormalize_s=false) const -> geometry_msgs::msg::Vector3
 Get 3D vector from specified 3D point to specified 3D point on line segment. More...
 

Public Attributes

const geometry_msgs::msg::Point start_point
 
const geometry_msgs::msg::Point end_point
 

Constructor & Destructor Documentation

◆ LineSegment() [1/2]

math::geometry::LineSegment::LineSegment ( const geometry_msgs::msg::Point &  start_point,
const geometry_msgs::msg::Point &  end_point 
)

◆ LineSegment() [2/2]

math::geometry::LineSegment::LineSegment ( const geometry_msgs::msg::Point &  start_point,
const geometry_msgs::msg::Vector3 &  vec,
double  length 
)

◆ ~LineSegment()

math::geometry::LineSegment::~LineSegment ( )

Member Function Documentation

◆ get2DLength()

auto math::geometry::LineSegment::get2DLength ( ) const -> double

◆ get2DVector()

auto math::geometry::LineSegment::get2DVector ( ) const -> geometry_msgs::msg::Vector3

◆ getIntersection2D()

auto math::geometry::LineSegment::getIntersection2D ( const LineSegment line) const -> std::optional<geometry_msgs::msg::Point>

Find intersection point of two line segments.

Parameters
lineLine segment of you want to find intersection.
Returns
std::optional<geometry_msgs::msg::Point> Intersection point, if the value is std::nullopt, lines have no intersection point.

◆ getIntersection2DSValue() [1/2]

auto math::geometry::LineSegment::getIntersection2DSValue ( const geometry_msgs::msg::Point &  point,
const bool  denormalize_s = false 
) const -> std::optional<double>

Find intersection point of 1 line segment and 1 point.

Parameters
pointpoint of you want to find intersection.
Returns
std::optional<double>
Note
If start_point and end_point is a same point, checking the point is same as end_point or not.
If the line segment is parallel to y axis, calculate s value from y axis value.
If the line segment is not parallel to x and y axis, calculate s value from x axis value.

◆ getIntersection2DSValue() [2/2]

auto math::geometry::LineSegment::getIntersection2DSValue ( const LineSegment line,
const bool  denormalize_s = false 
) const -> std::optional<double>

Get S value of the intersection point of two line segment.

Parameters
lineThe line segment you want to check intersection.
denormalize_sIf true, s value should be normalized in range [0,1]. If false, s value is not normalized.
Returns
std::optional<double>
Note
Hard coded parameter, this parameter describes the tolerance of the range of s value (-s_tolerance ~ 1.0 + s_tolerance)

◆ getLength()

auto math::geometry::LineSegment::getLength ( ) const -> double

◆ getNormalVector()

auto math::geometry::LineSegment::getNormalVector ( ) const -> geometry_msgs::msg::Vector3

Get normal vector of the line segment.

Returns
geometry_msgs::msg::Vector3

◆ getPoint()

auto math::geometry::LineSegment::getPoint ( const double  s,
const bool  denormalize_s = false 
) const -> geometry_msgs::msg::Point

Get point on the line segment from s value.

Parameters
sNormalized s value in coordinate along line segment.
denormalize_sIf true, s value should be normalized in range [0,1]. If false, s value is not normalized.
Returns
geometry_msgs::msg::Point

◆ getPose()

auto math::geometry::LineSegment::getPose ( const double  s,
const bool  denormalize_s = false,
const bool  fill_pitch = true 
) const -> geometry_msgs::msg::Pose

Get pose on the line segment from s value. Orientation of thee return value was calculated from the vector of the line segment.

Parameters
sNormalized s value in coordinate along line segment.
denormalize_sIf true, s value should be normalized in range [0,1]. If false, s value is not normalized.
fill_pitchIf true, the pitch value of the orientation is filled. If false, the pitch value of the orientation is 0. This parameter is introduced for backward-compatibility.
Returns
geometry_msgs::msg::Pose

◆ getSlope()

auto math::geometry::LineSegment::getSlope ( ) const -> double

◆ getSquaredDistanceIn2D()

auto math::geometry::LineSegment::getSquaredDistanceIn2D ( const geometry_msgs::msg::Point &  point,
const double  s,
const bool  denormalize_s = false 
) const -> double

Get squared distance (Square of euclidean distance) between specified 3D point and specified 3D point on line segment in 2D. (x,y)

Parameters
pointSpecified 3D point
Svalue of specified 3D point in coordinate along line segment.
denormalize_sIf true, the s value is denormalized. If false, the s value should be normalized in range [0,1].
Returns
double

◆ getSquaredDistanceVector()

auto math::geometry::LineSegment::getSquaredDistanceVector ( const geometry_msgs::msg::Point &  point,
const double  s,
const bool  denormalize_s = false 
) const -> geometry_msgs::msg::Vector3

Get 3D vector from specified 3D point to specified 3D point on line segment.

Parameters
pointSpecified 3D point
sS value of specified 3D point in coordinate along line segment.
denormalize_sIf true, the s value is denormalized. If false, the s value should be normalized in range [0,1].
Returns
geometry_msgs::msg::Vector3

◆ getSValue()

auto math::geometry::LineSegment::getSValue ( const geometry_msgs::msg::Pose &  pose,
double  threshold_distance,
bool  denormalize_s 
) const -> std::optional<double>

◆ getVector()

auto math::geometry::LineSegment::getVector ( ) const -> geometry_msgs::msg::Vector3

◆ isIntersect2D() [1/2]

auto math::geometry::LineSegment::isIntersect2D ( const geometry_msgs::msg::Point &  point) const -> bool

Checking the intersection with 1 line segment and 1 point in 2D (x,y) coordinate. Ignore z axis.

Parameters
pointpoint you want to check intersection.
Returns
true Intersection detected.
false Intersection does not detected.

◆ isIntersect2D() [2/2]

auto math::geometry::LineSegment::isIntersect2D ( const LineSegment l0) const -> bool

Checking the intersection with 2 line segments in 2D (x,y) coordinate. Ignore z axis.

Parameters
l0line segments you want to check intersection.
Returns
true Intersection detected.
false Intersection does not detected.

◆ operator=()

LineSegment & math::geometry::LineSegment::operator= ( const LineSegment )

Member Data Documentation

◆ end_point

const geometry_msgs::msg::Point math::geometry::LineSegment::end_point

◆ start_point

const geometry_msgs::msg::Point math::geometry::LineSegment::start_point

The documentation for this class was generated from the following files: