Skip to contents

regular_ngon_polygon2d() creates a regular n-gon Polygon2D object centered at (x, y) with circumradius radius.

Usage

regular_ngon_polygon2d(n, x = 0, y = 0, radius = 0.5, theta = degrees(90))

Arguments

n

Number of vertices.

x

X-coordinate of the center (default 0).

y

Y-coordinate of the center (default 0).

radius

Circumradius: distance from center to each vertex (default 0.5).

theta

Angle of the first vertex (default degrees(90)). Will be coerced by degrees().

Value

A Polygon2D object with $is_convex == TRUE.

See also

isotoxal_2ngon_polygon2d() for isotoxal star polygons. rectangle_polygon2d() for rectangles.

Examples

# A regular hexagon
p <- regular_ngon_polygon2d(6)
p$is_convex
#> [1] TRUE
plot(p)