|
KanoopCommonQt 2.1.1
Kanoop foundational Qt utility library
|
|
A 2D polygon defined by an ordered list of vertices. More...
#include <polygon.h>
Public Member Functions | |
| Polygon () | |
| Default constructor — creates an empty (invalid) polygon. | |
| void | appendPoint (const Point &point) |
| Append a vertex to the polygon. | |
| double | area () const |
| Compute the area of the polygon using the shoelace formula. | |
| void | move (double bearing, double distance) |
| Move all vertices by a bearing and distance. | |
| void | rotate (const Point ¢roid, double angle) |
| Rotate all vertices around a centroid by an angle. | |
| Point | centroid () const |
| Compute the centroid (geometric centre) of the polygon. | |
| bool | contains (const Point &point) const |
| Test whether a point lies inside the polygon. | |
| Line::List | lines () const |
| Return the edges of the polygon as a list of lines. | |
| Rectangle | boundingRectangle () const |
| Return the bounding rectangle of this polygon. | |
| bool | isValid () const |
| Test whether this polygon has at least 3 vertices. | |
Static Public Member Functions | |
| static Polygon | fromLine (const Line &line, int expandBy) |
| Construct a rectangle-shaped polygon from a line expanded by a width. | |
A 2D polygon defined by an ordered list of vertices.
Represents a 2D polygon as an ordered list of Point vertices.
Provides area, centroid, containment, and movement operations.
|
inline |
|
inline |
| double Polygon::area | ( | ) | const |
Compute the area of the polygon using the shoelace formula.
| Rectangle Polygon::boundingRectangle | ( | ) | const |
Return the bounding rectangle of this polygon.
| Point Polygon::centroid | ( | ) | const |
Compute the centroid (geometric centre) of the polygon.
| bool Polygon::contains | ( | const Point & | point | ) | const |
Test whether a point lies inside the polygon.
| point | Point to test |
Construct a rectangle-shaped polygon from a line expanded by a width.
| line | Centre line of the polygon |
| expandBy | Half-width of the resulting rectangular polygon |
|
inline |
| Line::List Polygon::lines | ( | ) | const |
Return the edges of the polygon as a list of lines.
| void Polygon::move | ( | double | bearing, |
| double | distance | ||
| ) |
Move all vertices by a bearing and distance.
| bearing | Direction of movement in degrees |
| distance | Distance to move |
| void Polygon::rotate | ( | const Point & | centroid, |
| double | angle | ||
| ) |
Rotate all vertices around a centroid by an angle.
| centroid | Centre of rotation |
| angle | Rotation angle in degrees |