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:
32  const geometry_msgs::msg::Point start_point;
33  const geometry_msgs::msg::Point end_point;
34  const geometry_msgs::msg::Vector3 vector;
35  const geometry_msgs::msg::Vector3 vector_2d;
36  const double length;
37  const double length_2d;
38 
40  const geometry_msgs::msg::Point & start_point, const geometry_msgs::msg::Point & end_point);
42  const geometry_msgs::msg::Point & start_point, const geometry_msgs::msg::Vector3 & vec,
43  double length);
44 
45  auto isIntersect2D(const geometry_msgs::msg::Point & point) const -> bool;
46  auto isIntersect2D(const LineSegment & line) const -> bool;
47  auto isInBounds2D(const geometry_msgs::msg::Point & point) const -> bool;
48 
49  auto getPoint(const double s, const bool denormalize_s = false) const
50  -> geometry_msgs::msg::Point;
51  auto getPose(const double s, const bool denormalize_s = false, const bool fill_pitch = true) const
52  -> geometry_msgs::msg::Pose;
54  const geometry_msgs::msg::Point & point, const bool denormalize_s = false) const
55  -> std::optional<double>;
56  auto get2DIntersectionSValue(const LineSegment & line, const bool denormalize_s = false) const
57  -> std::optional<double>;
58  auto getIntersection2D(const LineSegment & line) const
59  -> std::optional<geometry_msgs::msg::Point>;
60  auto getSValue(
61  const geometry_msgs::msg::Pose & pose, double threshold_distance, bool denormalize_s) const
62  -> std::optional<double>;
63  auto getNormalVector() const -> geometry_msgs::msg::Vector3;
64  auto get2DVectorSlope() const -> double;
66  const geometry_msgs::msg::Point & point, const double s, const bool denormalize_s = false) const
67  -> double;
69  const geometry_msgs::msg::Point & point, const double s, const bool denormalize_s = false) const
70  -> geometry_msgs::msg::Vector3;
71  auto relativePointPosition2D(const geometry_msgs::msg::Point & point) const -> int;
72 
73 private:
74  auto denormalize(const std::optional<double> & s, const bool throw_error_on_out_of_range = true)
75  const -> std::optional<double>;
76  auto denormalize(const double s) const -> double;
77 };
78 
79 auto getLineSegments(
80  const std::vector<geometry_msgs::msg::Point> & points, const bool close_start_end = false)
81  -> std::vector<LineSegment>;
82 } // namespace geometry
83 } // namespace math
84 
85 #endif // GEOMETRY__POLYGON__LINE_SEGMENT_
Definition: line_segment.hpp:30
const double length_2d
Definition: line_segment.hpp:37
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:256
const double length
Definition: line_segment.hpp:36
auto relativePointPosition2D(const geometry_msgs::msg::Point &point) const -> int
Determines the relative position of a point with respect to the line segment.
Definition: line_segment.cpp:357
const geometry_msgs::msg::Vector3 vector_2d
Definition: line_segment.hpp:35
auto get2DIntersectionSValue(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:168
const geometry_msgs::msg::Vector3 vector
Definition: line_segment.hpp:34
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:242
auto getNormalVector() const -> geometry_msgs::msg::Vector3
Get normal vector of the line segment.
Definition: line_segment.cpp:217
LineSegment(const geometry_msgs::msg::Point &start_point, const geometry_msgs::msg::Point &end_point)
Definition: line_segment.cpp:30
auto getIntersection2D(const LineSegment &line) const -> std::optional< geometry_msgs::msg::Point >
Find intersection point of two line segments.
Definition: line_segment.cpp:207
const geometry_msgs::msg::Point start_point
Definition: line_segment.hpp:32
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:107
auto get2DVectorSlope() const -> double
Definition: line_segment.cpp:226
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:125
auto getSValue(const geometry_msgs::msg::Pose &pose, double threshold_distance, bool denormalize_s) const -> std::optional< double >
Definition: line_segment.cpp:137
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:73
const geometry_msgs::msg::Point end_point
Definition: line_segment.hpp:33
auto isInBounds2D(const geometry_msgs::msg::Point &point) const -> bool
Checks if the given point lies within the bounding box of the line segment.
Definition: line_segment.cpp:334
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:308
Definition: bounding_box.hpp:32
Definition: cache.hpp:27