Polygon
- class compas.geometry.Polygon(points, **kwargs)[source]
Bases:
compas.geometry.primitives._primitive.PrimitiveAn object representing an ordered collection of points in space connected by straight line segments forming a closed boundary around the interior space.
A polygon has a closed boundary that separates its interior from the exterior. The boundary does not intersect itself, and is described by an ordered set of of points.
- Parameters
points (list of point) – An ordered list of points.
- Attributes
data (dict) – The data representation of the polygon.
points (list of
compas.geometry.Point) – The polygon points.lines (list of
compas.geometry.Line, read-only) – The polygon segments.centroid (
compas.geometry.Point, read-only) – The centroid of the polygon surface.normal (
compas.geometry.Vector, read-only) – The normal vector of the polygon plane.length (float, read-only) – The length of the polygon boundary.
area (float, read-only) – The area of the polygon surface.
Notes
All
Polygonobjects are considered closed. Therefore the first and last element in the list of points are not the same. The existence of the closing edge is implied.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.0Attributes
DATASCHEMAThe schema of the data of this object.
JSONSCHEMANAMEareaThe area of the polygon.
centroidThe centroid of the polygon.
dataThe data dictionary that represents the polygon.
lengthThe length of the boundary.
linesThe lines of the polygon.
normalThe (average) normal of the polygon.
pointsThe points of the polygon.
Inherited Attributes
JSONSCHEMAThe schema of the JSON representation of the data of this object.
dtypeThe type of the object in the form of a '2-level' import and a class name.
guidThe globally unique identifier of the object.
jsondefinitionsReusable schema definitions.
jsonstringThe representation of the object data in JSON format.
jsonvalidatorJSON schema validator for draft 7.
nameThe name of the object.
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 (self.DATASCHEMA).
Validate the object's data against its json schema (self.JSONSCHEMA).