ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
esphome::ld2450::Polygon Struct Reference

A polygon in radar coordinates. Trivially copyable so it can be saved to preferences as-is. More...

#include <polygon.h>

Public Member Functions

bool empty () const
 True when the polygon has no points, which disables the zone.
 
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 parse (const char *str, size_t len)
 Parse "x,y;x,y;..." (mm) into this polygon.
 
void format (char *buf) const
 Write the polygon as "x,y;x,y;..." into buf, which must hold at least POLYGON_STR_SIZE bytes.
 

Data Fields

std::array< Point, MAX_POLYGON_POINTS > points {}
 
uint8_t count {0}
 

Detailed Description

A polygon in radar coordinates. Trivially copyable so it can be saved to preferences as-is.

Definition at line 26 of file polygon.h.

Member Function Documentation

◆ contains()

bool esphome::ld2450::Polygon::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.

Definition at line 73 of file polygon.cpp.

◆ empty()

bool esphome::ld2450::Polygon::empty ( ) const
inline

True when the polygon has no points, which disables the zone.

Definition at line 31 of file polygon.h.

◆ format()

void esphome::ld2450::Polygon::format ( char * buf) const

Write the polygon as "x,y;x,y;..." into buf, which must hold at least POLYGON_STR_SIZE bytes.

Definition at line 114 of file polygon.cpp.

◆ is_valid()

bool esphome::ld2450::Polygon::is_valid ( ) const

True when the polygon is empty, or has a valid number of points that are all inside the radar area.

Definition at line 60 of file polygon.cpp.

◆ parse()

bool esphome::ld2450::Polygon::parse ( const char * str,
size_t len )

Parse "x,y;x,y;..." (mm) into this polygon.

Spaces around numbers and a trailing ';' are allowed. An empty or all-space string gives an empty polygon.

Returns
false if the text is invalid; the polygon is then left unchanged.

Definition at line 91 of file polygon.cpp.

Field Documentation

◆ count

uint8_t esphome::ld2450::Polygon::count {0}

Definition at line 28 of file polygon.h.

◆ points

std::array<Point, MAX_POLYGON_POINTS> esphome::ld2450::Polygon::points {}

Definition at line 27 of file polygon.h.


The documentation for this struct was generated from the following files: