scenario_simulator_v2 C++ API
line_segment.hpp
Go to the documentation of this file.
1 // Copyright 2015 TIER IV, Inc. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef GEOMETRY__POLYGON__LINE_SEGMENT_
16 #define GEOMETRY__POLYGON__LINE_SEGMENT_
17 
19 #include <geometry_msgs/msg/point.hpp>
20 #include <geometry_msgs/msg/pose.hpp>
21 #include <geometry_msgs/msg/quaternion.hpp>
22 #include <geometry_msgs/msg/vector3.hpp>
23 #include <optional>
24 
25 namespace math
26 {
27 namespace geometry
28 {
30 {
31 public:
33  const geometry_msgs::msg::Point & start_point, const geometry_msgs::msg::Point & end_point);
35  const geometry_msgs::msg::Point & start_point, const geometry_msgs::msg::Vector3 & vec,
36  double length);
37  ~LineSegment();
39  const geometry_msgs::msg::Point start_point;
40  const geometry_msgs::msg::Point end_point;
41  auto getPoint(const double s, const bool denormalize_s = false) const
42  -> geometry_msgs::msg::Point;
43  auto getPose(const double s, const bool denormalize_s = false, const bool fill_pitch = true) const
44  -> geometry_msgs::msg::Pose;
45  auto isIntersect2D(const geometry_msgs::msg::Point & point) const -> bool;
46  auto isIntersect2D(const LineSegment & l0) const -> bool;
48  const geometry_msgs::msg::Point & point, const bool denormalize_s = false) const
49  -> std::optional<double>;
50  auto getIntersection2DSValue(const LineSegment & line, const bool denormalize_s = false) const
51  -> std::optional<double>;
52  auto getIntersection2D(const LineSegment & line) const
53  -> std::optional<geometry_msgs::msg::Point>;
54  auto getSValue(
55  const geometry_msgs::msg::Pose & pose, double threshold_distance, bool denormalize_s) const
56  -> std::optional<double>;
57  auto getVector() const -> geometry_msgs::msg::Vector3;
58  auto getNormalVector() const -> geometry_msgs::msg::Vector3;
59  auto get2DVector() const -> geometry_msgs::msg::Vector3;
60  auto getLength() const -> double;
61  auto get2DLength() const -> double;
62  auto getSlope() const -> double;
64  const geometry_msgs::msg::Point & point, const double s, const bool denormalize_s = false) const
65  -> double;
67  const geometry_msgs::msg::Point & point, const double s, const bool denormalize_s = false) const
68  -> geometry_msgs::msg::Vector3;
69 
70 private:
71  auto denormalize(const std::optional<double> & s, const bool throw_error_on_out_of_range = true)
72  const -> std::optional<double>;
73  auto denormalize(const double s) const -> double;
74 };
75 
76 auto getLineSegments(
77  const std::vector<geometry_msgs::msg::Point> & points, const bool close_start_end = false)
78  -> std::vector<LineSegment>;
79 } // namespace geometry
80 } // namespace math
81 
82 #endif // GEOMETRY__POLYGON__LINE_SEGMENT_
Definition: line_segment.hpp:30
auto get2DLength() const -> double
Definition: line_segment.cpp:285
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.
Definition: line_segment.cpp:318
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.
Definition: line_segment.cpp:170
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...
Definition: line_segment.cpp:304
auto getLength() const -> double
Definition: line_segment.cpp:290
auto getNormalVector() const -> geometry_msgs::msg::Vector3
Get normal vector of the line segment.
Definition: line_segment.cpp:267
auto getVector() const -> geometry_msgs::msg::Vector3
Definition: line_segment.cpp:252
~LineSegment()
Definition: line_segment.cpp:56
LineSegment(const geometry_msgs::msg::Point &start_point, const geometry_msgs::msg::Point &end_point)
Definition: line_segment.cpp:29
auto getIntersection2D(const LineSegment &line) const -> std::optional< geometry_msgs::msg::Point >
Find intersection point of two line segments.
Definition: line_segment.cpp:241
const geometry_msgs::msg::Point start_point
Definition: line_segment.hpp:39
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 v...
Definition: line_segment.cpp:99
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.
Definition: line_segment.cpp:121
auto get2DVector() const -> geometry_msgs::msg::Vector3
Definition: line_segment.cpp:277
LineSegment & operator=(const LineSegment &)
Definition: line_segment.cpp:362
auto getSValue(const geometry_msgs::msg::Pose &pose, double threshold_distance, bool denormalize_s) const -> std::optional< double >
Definition: line_segment.cpp:126
auto getSlope() const -> double
Definition: line_segment.cpp:292
auto getPoint(const double s, const bool denormalize_s=false) const -> geometry_msgs::msg::Point
Get point on the line segment from s value.
Definition: line_segment.cpp:64
const geometry_msgs::msg::Point end_point
Definition: line_segment.hpp:40
auto getLineSegments(const std::vector< geometry_msgs::msg::Point > &points, const bool close_start_end=false) -> std::vector< LineSegment >
Get the line segments from points.
Definition: line_segment.cpp:370
Definition: bounding_box.hpp:32
Definition: cache.hpp:27