polygons¶
Polygons are closed shapes formed by a sequence of points.
Provides polygon construction and manipulation for the Model class.
This module facilitates the creation and management of polygon elements within the model. It allows for defining polygons using lists of points or point identifiers and supports calculating properties like side lengths and area.
- class geometor.model.polygons.PolygonsMixin
Bases:
objectMixin for the Model class containing polygon construction operations.
This mixin extends the Model with functionality to define polygons. It includes methods for creating polygons from both direct point objects and their corresponding string IDs, ensuring flexibility in how geometric shapes are defined.
- set_polygon_by_IDs(poly_pts_IDs: list[str], classes: list[str] | None = None, ID: str = '') Polygon
Find points by ID and use them with
Model.set_polygon().This helper method resolves a list of point IDs to their corresponding point objects in the model and then delegates to set_polygon to create the polygon element.
- Parameters:
poly_pts_IDs – A list of point IDs.
classes – A list of class labels.
ID – A string ID for the polygon.
- Returns:
The constructed
sympy.geometry.polygon.Polygon.
- set_polygon(poly_pts: list[Point], classes: list[str] | None = None, ID: str = '') Polygon
Set polygon (list of 3 or more points).
This method constructs a polygon from a list of points and adds it to the model. It calculates the lengths of the polygon’s sides, generates an ID if one is not provided, and logs the polygon’s properties including side lengths and area.
- Parameters:
poly_pts – A list of 3 or more points defining the polygon vertices.
classes – A list of class labels.
ID – A string ID for the polygon. If empty, one is generated.
- Returns:
The constructed
sympy.geometry.polygon.Polygon.