43 #include <ilqgames/geometry/draw_shapes.h> 44 #include <ilqgames/geometry/polyline2.h> 45 #include <ilqgames/utils/types.h> 47 #include <glog/logging.h> 51 Polyline2 DrawSquare(
const Point2& center,
float side_length) {
52 CHECK_GT(side_length, 0.0);
53 const float half_side = 0.5 * side_length;
54 return Polyline2({center + Point2(half_side, half_side),
55 center + Point2(-half_side, half_side),
56 center + Point2(-half_side, -half_side),
57 center + Point2(half_side, -half_side),
58 center + Point2(half_side, half_side)});
61 Polyline2 DrawCircle(
const Point2& center,
float radius,
size_t num_segments) {
62 CHECK_GT(radius, 0.0);
65 poly.push_back(center + Point2(radius, 0.0));
66 for (
size_t ii = 0; ii < num_segments; ii++) {
67 const float angle = 2.0 * M_PI *
static_cast<float>(ii + 1) /
68 static_cast<float>(num_segments);
69 poly.push_back(center + radius * Point2(std::cos(angle), std::sin(angle)));
72 return Polyline2(poly);