PatchworkOS
Loading...
Searching...
No Matches

Polygon. More...

Functions

void polygon_rotate (point_t *points, uint64_t pointCount, double angle, point_t center)
 Rotate a polygon around a center point.
 
bool polygon_contains (double px, double py, const point_t *points, uint64_t pointCount)
 Check if a point is inside a polygon.
 

Detailed Description

Polygon.

Function Documentation

◆ polygon_contains()

bool polygon_contains ( double  px,
double  py,
const point_t points,
uint64_t  pointCount 
)

Check if a point is inside a polygon.

We use doubles for the point coordinates instead of just point_t to allow for sub-pixel points.

Parameters
pxThe x coordinate of the point.
pyThe y coordinate of the point.
pointsThe points of the polygon.
pointCountThe number of points in the polygon.
Returns
true if the point is inside the polygon, false otherwise.

Definition at line 27 of file polygon.c.

References point_t::x, and point_t::y.

Referenced by draw_polygon().

◆ polygon_rotate()

void polygon_rotate ( point_t points,
uint64_t  pointCount,
double  angle,
point_t  center 
)

Rotate a polygon around a center point.

Parameters
pointsThe points of the polygon.
pointCountThe number of points in the polygon.
angleThe angle to rotate by, in radians.
centerThe center point to rotate around.

Definition at line 4 of file polygon.c.

References cos(), NULL, round(), sin(), point_t::x, and point_t::y.

Referenced by draw_hand(), and draw_marker().