Skip to contents

rectangle_polygon2d() creates a rectangle Polygon2D object centered at (x, y).

Usage

rectangle_polygon2d(width = 1, height = 1, x = 0, y = 0, theta = degrees(0))

Arguments

width

Width of the rectangle (default 1).

height

Height of the rectangle (default 1).

x

X-coordinate of the center (default 0).

y

Y-coordinate of the center (default 0).

theta

Rotation angle (default degrees(0)). Will be coerced by degrees().

Value

A Polygon2D object with $is_convex == TRUE.

See also

isotoxal_2ngon_polygon2d() for isotoxal star polygons. regular_ngon_polygon2d() for regular convex polygons.

Examples

# A unit square
p <- rectangle_polygon2d()
p$is_convex
#> [1] TRUE
plot(p)


# A rotated rectangle
p2 <- rectangle_polygon2d(width = 2, height = 1, theta = degrees(45))
plot(p2)