% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/polyclip.R
\name{setops}
\alias{setops}
\alias{intersect}
\alias{union}
\alias{setdiff}
\alias{intersect.venny_setops}
\alias{union.venny_setops}
\alias{setdiff.venny_setops}
\title{Set operations}
\usage{
intersect(x, y, ...)

union(x, y, ...)

setdiff(x, y, ...)

\method{intersect}{venny_setops}(x, y, ...)

\method{union}{venny_setops}(x, y, ...)

\method{setdiff}{venny_setops}(x, y, ...)
}
\arguments{
\item{x}{A two-column matrix consists of the point coordinates (x, y) used to construct the ellipse.
This is the reference-ellipse used to be clipped by the others.}

\item{y}{A two-column matrix consists of the point coordinates (x, y) used to construct the ellipse.
This is the object-ellipse used to clip the reference ellipse, i.e. \code{x}.}

\item{...}{The other object-ellipses.}
}
\value{
A list contains one or multiple two-column dataframe.
Each dataframe is the point coordinates (x, y) used to construct a polygon.
}
\description{
Perform intersection (\code{intersect()}), union (\code{union()}), and difference (\code{setdiff()})
for multiple \code{venny_ep} objects representing sets. They are handy wrappers of
the \code{polyclip::polyclip()} function.
}
\details{
These functions override the base versions to make them generic so that \code{venny}
can provide methods to proceed the \code{venny_ep} class object. The default methods
call the base versions.
}
\examples{
data <- list(
    Set_A = c(10:100, 500:600),
    Set_B = c(5:150, 550:650),
    Set_C = c(80:180, 580:680),
    Set_D = c(120:220, 520:620)
)
out <- venny(data, detail = TRUE)
p0 <- out$venn
ep <- out$ellipse_path

#------------- Intersection -------------#
res <- intersect(ep$Set_A, ep$Set_B, ep$Set_D)
highlight(p0, res)

#----------------- Union ----------------#
res <- union(ep$Set_A, ep$Set_C, ep$Set_D)
highlight(p0, res)

#--------------- Difference -------------#
res <- setdiff(ep$Set_B, ep$Set_D, ep$Set_A, ep$Set_C)
highlight(p0, res)

#---------- Multiple operations ---------#
res <- union(ep$Set_A, ep$Set_B, ep$Set_C) |>
    intersect(ep$Set_D) |>
    setdiff(ep$Set_B)
highlight(p0, res)
}
