Thunderbots Project
Loading...
Searching...
No Matches
polygon.h
1#pragma once
2
3#include <vector>
4
5#include "software/geom/segment.h"
6#include "software/geom/shape.h"
7
11class Polygon : public virtual Shape
12{
13 public:
14 Polygon() = delete;
20 explicit Polygon(const std::vector<Point>& points);
21
27 explicit Polygon(const std::initializer_list<Point>& points);
28
34 Point centroid() const;
35
44 Polygon expand(double expansion_amount) const;
45
51 double perimeter() const;
52
57 const std::vector<Segment>& getSegments() const;
58
63 const std::vector<Point>& getPoints() const;
64
76 static Polygon fromSegment(const Segment& segment, double length_radius,
77 double width_radius);
78 static Polygon fromSegment(const Segment& segment, double radius);
79
80 protected:
84 void initSegments();
85
86 std::vector<Point> points_;
87 std::vector<Segment> segments_;
88};
89
90bool operator==(const Polygon& poly1, const Polygon& poly2);
91
92bool operator!=(const Polygon& poly1, const Polygon& poly2);
93
102std::ostream& operator<<(std::ostream& os, const Polygon& poly);
Definition point.h:14
Definition polygon.h:12
const std::vector< Segment > & getSegments() const
Definition polygon.cpp:135
Point centroid() const
Definition polygon.cpp:27
Polygon expand(double expansion_amount) const
Definition polygon.cpp:51
const std::vector< Point > & getPoints() const
Definition polygon.cpp:140
double perimeter() const
Definition polygon.cpp:145
static Polygon fromSegment(const Segment &segment, double length_radius, double width_radius)
Definition polygon.cpp:84
void initSegments()
Definition polygon.cpp:17
Definition segment.h:7
Definition shape.h:9