% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/polygon.R
\name{as_polygon2d}
\alias{as_polygon2d}
\alias{as_polygon2d.Coord2D}
\alias{as_polygon2d.Polygon2D}
\alias{as_polygon2d.numeric}
\alias{as_polygon2d.Ellipse2D}
\title{Cast to Polygon2D object}
\usage{
as_polygon2d(x, ...)

\method{as_polygon2d}{Coord2D}(x, convex = NA, ...)

\method{as_polygon2d}{Polygon2D}(x, convex = NA, ...)

\method{as_polygon2d}{numeric}(x, y = 0, convex = NA, ...)

\method{as_polygon2d}{Ellipse2D}(x, n = 60L, type = c("inner", "outer"), ...)
}
\arguments{
\item{x}{Object to cast.  Either a \link{Coord2D} object of vertices or a
numeric vector of x-coordinates.}

\item{...}{Ignored; only included for S3 method consistency.}

\item{convex}{\code{NA} to auto-detect (default), \code{TRUE} to assert convex,
\code{FALSE} to mark as concave.}

\item{y}{Numeric vector of y-coordinates (used when \code{x} is numeric).}

\item{n}{Number of vertices in the approximating polygon (default \code{60L}).}

\item{type}{\code{"inner"} (default) for an inscribed polygon whose vertices lie
on the ellipse, or \code{"outer"} for a circumscribed polygon whose edges are
tangent to the ellipse.  Both polygons are convex.}
}
\value{
A \link{Polygon2D} object.
}
\description{
\code{as_polygon2d()} casts to a \link{Polygon2D} object.
}
\examples{
vertices <- as_coord2d(x = c(0, 1, 1, 0), y = c(0, 0, 1, 1))
p <- as_polygon2d(vertices)
p$is_convex
print(p)
plot(p)
}
\seealso{
\code{\link[=isotoxal_2ngon_polygon2d]{isotoxal_2ngon_polygon2d()}} and \code{\link[=regular_ngon_polygon2d]{regular_ngon_polygon2d()}} to
directly construct common polygon shapes.
}
