% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/segment.R
\name{as_segment2d}
\alias{as_segment2d}
\alias{as_segment2d.Coord2D}
\alias{as_segment2d.Polygon2D}
\title{Cast to Segment2D object}
\usage{
as_segment2d(...)

\method{as_segment2d}{Coord2D}(p1, ..., p2, vec)

\method{as_segment2d}{Polygon2D}(p, ...)
}
\arguments{
\item{...}{Ignored.}

\item{p1}{A \link{Coord2D} object of first endpoints.}

\item{p2}{A \link{Coord2D} object of second endpoints.
If missing, \code{vec} must be supplied.}

\item{vec}{A \link{Coord2D} object of edge vectors (\code{p2 - p1}).
Used only when \code{p2} is missing.}

\item{p}{A \link{Polygon2D} object whose edges should be returned.}
}
\value{
A \link{Segment2D} object.
}
\description{
\code{as_segment2d()} creates a \link{Segment2D} object.
}
\examples{
p1 <- as_coord2d(x = c(0, 1), y = c(0, 0))
p2 <- as_coord2d(x = c(1, 1), y = c(0, 1))
s <- as_segment2d(p1, p2 = p2)
s$p1
s$p2
s$mid_point

# From a polygon's edges
poly <- as_polygon2d(as_coord2d(x = c(0, 1, 1, 0), y = c(0, 0, 1, 1)))
as_segment2d(poly)
}
