% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/shape.R
\name{compute_hausdorff_distance}
\alias{compute_hausdorff_distance}
\title{Computes the Hausdorff distance between streamlines}
\usage{
compute_hausdorff_distance(x, y = NULL)
}
\arguments{
\item{x}{A \link{streamline} or \link{bundle} object.}

\item{y}{A \link{streamline} or \link{bundle} object, or \code{NULL} (default). When \code{NULL}
and \code{x} is a \link{bundle}, the pairwise distance matrix within \code{x} is
returned.}
}
\value{
\itemize{
\item A non-negative numeric scalar when both \code{x} and \code{y} are \link{streamline}s.
\item A \code{\link[stats:dist]{dist}} object of size \eqn{n} when \code{x} is a \link{bundle}
and \code{y} is \code{NULL} or a \link{bundle} (use \code{\link[=as.matrix]{as.matrix()}} to expand to a full
\eqn{n \times n} matrix).
\item A numeric vector of length \eqn{n} when \code{x} is a \link{bundle} and \code{y} is
a \link{streamline}.
}
}
\description{
\code{compute_hausdorff_distance()} is an S7 generic that computes the symmetric
Hausdorff distance between \link{streamline} objects based on their 3-D
coordinate matrices, with methods available for the following classes:

\itemize{
\item \code{ANY}
\item \code{\link[=compute_hausdorff_distance-fiber-bundle-method]{fiber::bundle}}
\item \code{\link[=compute_hausdorff_distance-fiber-streamline-method]{fiber::streamline}}
}

The four dispatch cases are:
\itemize{
\item \strong{\code{streamline} + \code{streamline}}: returns a single numeric scalar — the
symmetric Hausdorff distance between the two streamlines.
\item \strong{\code{bundle} + missing}: returns a symmetric numeric distance matrix of
dimension \eqn{n \times n}, where \eqn{n} is the number of streamlines in
the bundle, giving all pairwise Hausdorff distances.
\item \strong{\code{bundle} + \code{streamline}}: returns a numeric vector of length \eqn{n}
giving the Hausdorff distance from \code{y} to each streamline in \code{x}.
\item \strong{\code{bundle} + \code{bundle}}: returns a symmetric numeric distance matrix of
dimension \eqn{(n_x + n_y) \times (n_x + n_y)}, treating the
concatenation of all streamlines from \code{x} and \code{y} as one collection.
}
}
\examples{
pts1 <- matrix(runif(30), ncol = 3)
colnames(pts1) <- c("X", "Y", "Z")
sl1 <- streamline(points = pts1)
pts2 <- matrix(runif(30), ncol = 3)
colnames(pts2) <- c("X", "Y", "Z")
sl2 <- streamline(points = pts2)

# streamline x streamline -> scalar
compute_hausdorff_distance(sl1, sl2)

# bundle x missing -> pairwise dist object
b <- bundle(streamlines = list(sl1, sl2))
compute_hausdorff_distance(b)
as.matrix(compute_hausdorff_distance(b))

# bundle x streamline -> vector
compute_hausdorff_distance(b, sl1)

# bundle x bundle -> combined pairwise matrix
b2 <- bundle(streamlines = list(sl2))
compute_hausdorff_distance(b, b2)
}
