43 #include <ilqgames/utils/types.h> 45 #include <glog/logging.h> 50 PointList2 RoundaboutLaneCenter(
float entrance_angle,
float exit_angle,
51 float distance_from_roundabout) {
53 constexpr
float kRoundaboutRadius = 12.0;
54 constexpr
float kLaneHalfWidth = 2.5;
57 const Point2 entry_arc_center(
58 (kRoundaboutRadius + kLaneHalfWidth) * std::cos(entrance_angle),
59 (kRoundaboutRadius + kLaneHalfWidth) * std::sin(entrance_angle));
62 const float first_entry_arc_point_angle = entrance_angle - M_PI_2;
63 const Point2 first_point_in_entry_arc =
65 kLaneHalfWidth * Point2(std::cos(first_entry_arc_point_angle),
66 std::sin(first_entry_arc_point_angle));
69 first_point_in_entry_arc +
70 distance_from_roundabout *
71 Point2(std::cos(entrance_angle), std::sin(entrance_angle)),
72 first_point_in_entry_arc};
75 constexpr
size_t kNumPointsInArc = 3;
76 for (
size_t ii = 1; ii <= kNumPointsInArc; ii++) {
77 const float angle = first_entry_arc_point_angle -
78 M_PI_2 *
static_cast<float>(ii) / kNumPointsInArc;
79 points.push_back(entry_arc_center +
80 kLaneHalfWidth * Point2(std::cos(angle), std::sin(angle)));
84 const Point2 first_point_on_roundabout(
85 kRoundaboutRadius * std::cos(entrance_angle),
86 kRoundaboutRadius * std::sin(entrance_angle));
87 CHECK_LT((points.back() - first_point_on_roundabout).norm(),
88 constants::kSmallNumber);
91 constexpr
size_t kNumPointsInRoundabout = 10;
92 for (
size_t ii = 1; ii <= kNumPointsInRoundabout; ii++) {
93 const float next_angle = entrance_angle + (exit_angle - entrance_angle) *
94 static_cast<float>(ii) /
95 kNumPointsInRoundabout;
96 points.emplace_back(kRoundaboutRadius * std::cos(next_angle),
97 kRoundaboutRadius * std::sin(next_angle));
101 constexpr
float kFarAway = 1e4;
102 points.emplace_back(kFarAway * std::cos(exit_angle),
103 kFarAway * std::sin(exit_angle));