Polygon
- class compas.geometry.Polygon(points, **kwargs)[source]
Bases:
Primitive
A polygon is defined by a sequence of points forming a closed loop.
- Parameters
points (list[[float, float, float] |
compas.geometry.Point
]) – An ordered list of points.- Attributes
points (list of
compas.geometry.Point
) – The points of the polygon.lines (list of
compas.geometry.Line
, read-only) – The lines of the polygon.length (float, read-only) – The length of the boundary.
centroid (
compas.geometry.Point
, read-only) – The centroid of the polygon.normal (
compas.geometry.Vector
, read-only) – The (average) normal of the polygon.area (float, read-only) – The area of the polygon.
Notes
A polygon is defined by a sequence of points connected by line segments forming a closed boundary that separates its interior from the exterior.
In the sequence of points, the first and last element are not the same. The existence of the closing edge is implied. The boundary should not intersect itself.
Polygons are not necessarily planar by construction; they can be warped.
Examples
>>> polygon = Polygon([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]]) >>> polygon.centroid Point(0.500, 0.500, 0.000) >>> polygon.area 1.0
Methods
Construct a polygon from its data representation.
Construct a polygon from a number of sides and a radius.
Determine if the polygon is convex.
Determine if the polygon is planar.
Transform this polygon.
Inherited Methods
Make an independent copy of the data object.
Construct an object from serialized data contained in a JSON file.
Construct an object from serialized data contained in a JSON string.
Convert an object to its native data representation.
Serialize the data representation of an object to a JSON file.
Serialize the data representation of an object to a JSON string.
Returns a transformed copy of this geometry.
Validate the object's data against its data schema.
Validate the object's data against its json schema.