9static constexpr uint8_t MIN_POLYGON_POINTS = 3;
11static constexpr uint8_t MAX_POLYGON_POINTS = 23;
13static constexpr int16_t POLYGON_MIN_X = -4860;
14static constexpr int16_t POLYGON_MAX_X = 4860;
15static constexpr int16_t POLYGON_MIN_Y = 0;
16static constexpr int16_t POLYGON_MAX_Y = 7560;
18static constexpr size_t POLYGON_STR_SIZE = MAX_POLYGON_POINTS * 11 + 1;
27 std::array<Point, MAX_POLYGON_POINTS>
points{};
44 bool parse(
const char *str,
size_t len);
47 void format(
char *buf)
const;
51static_assert(
sizeof(Polygon) == 94,
"Polygon layout changed; update POLYGON_SAVED_BYTES in text.py");
A polygon in radar coordinates. Trivially copyable so it can be saved to preferences as-is.
std::array< Point, MAX_POLYGON_POINTS > points
bool parse(const char *str, size_t len)
Parse "x,y;x,y;..." (mm) into this polygon.
bool is_valid() const
True when the polygon is empty, or has a valid number of points that are all inside the radar area.
bool contains(int16_t x, int16_t y) const
Return whether the point is inside the polygon (even-odd rule). Always false for an empty polygon.
bool empty() const
True when the polygon has no points, which disables the zone.