Polygon.from_sides_and_radius_xy

classmethod Polygon.from_sides_and_radius_xy(n, radius)[source]

Construct a polygon from a number of sides and a radius. The resulting polygon is planar, equilateral and equiangular.

Parameters
  • n (int) – The number of sides.

  • radius (float) – The radius of the circle the polygon will be circumscribed to.

Returns

compas.geometry.Polygon – The constructed polygon.

Notes

The first point of the polygon aligns with the Y-axis. The order of the polygon’s points is counterclockwise.

Examples

>>> from compas.geometry import dot_vectors
>>> from compas.geometry import subtract_vectors
>>> pentagon = Polygon.from_sides_and_radius_xy(5, 1.0)
>>> len(pentagon.lines) == 5
True
>>> len({round(line.length, 6) for line in pentagon.lines}) == 1
True
>>> dot_vectors(pentagon.normal, [0.0, 0.0, 1.0]) == 1
True
>>> centertofirst = subtract_vectors(pentagon.points[0], pentagon.centroid)
>>> dot_vectors(centertofirst, [0.0, 1.0, 0.0]) == 1
True