Polygon
- class compas.geometry.Polygon[source]
Bases:
Geometry
A polygon is a geometric object defined by a sequence of points forming a closed loop.
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 or skewed.
The polygon does not have a coordinate frame. Its geometry is always defined with respect to the world coordinate system.
Polygons can be constructed parametrically by the number of sides and a radius, but the geometry of the resulting object is defined by a list of explicit point locations.
- Parameters:
- pointslist[[float, float, float] |
compas.geometry.Point
] An ordered list of points.
- namestr, optional
The name of the polygon.
- pointslist[[float, float, float] |
See also
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
- Attributes:
- pointslist of
compas.geometry.Point
The points of the polygon.
- lineslist of
compas.geometry.Line
, read-only The lines of the polygon.
- lengthfloat, 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.
- areafloat, read-only
The area of the polygon.
- is_convexbool, read-only
True if the polygon is convex.
- is_planarbool, read-only
True if the polygon is planar.
- pointslist of
Methods
Compute the boolean difference of this polygon and another polygon.
Compute the boolean intersection of this polygon and another polygon.
Compute the boolean symmetric difference of this polygon and another polygon.
Compute the boolean union of this polygon and another polygon.
Construct a rectangle.
Construct a polygon from a number of sides and a radius.
Returns a brep representation of the polygon.
Returns a mesh representation of the polygon.
Returns a list of vertices and faces.
Transform this polygon.
Inherited Methods
Converts the instance to a string.
Compute the axis-aligned bounding box of the geometry.
Compute the oriented bounding box of the geometry.
Make an independent copy of the data object.
Construct an object of this type from a JSON file.
Construct an object of this type from a JSON string.
Rotate the geometry.
Returns a rotated copy of this geometry.
Scale the geometry.
Returns a scaled copy of this geometry.
Compute a hash of the data for comparison during version control using the sha256 algorithm.
Convert an object to its native data representation and save it to a JSON file.
Convert an object to its native data representation and save it to a JSON string.
Returns a transformed copy of this geometry.
Translate the geometry.
Returns a translated copy of this geometry.
Validate the data against the object's data schema.