% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/distances.R
\name{distances}
\alias{distances}
\alias{dist.point}
\alias{distances.default}
\alias{distances.coords}
\alias{distances.atoms}
\alias{distances.connect}
\alias{distances.pdb}
\alias{dist.point.default}
\alias{is.distances}
\alias{norm}
\alias{norm.distances}
\alias{norm.connect}
\title{Inter-Atomic Distances}
\usage{
distances(...)

dist.point(...)

\method{distances}{default}(
  dx1 = numeric(0),
  dx2 = numeric(0),
  dx3 = numeric(0),
  basis = "xyz",
  ...
)

\method{distances}{coords}(x, sel1, sel2, ...)

\method{distances}{atoms}(x, sel1, sel2, ...)

\method{distances}{connect}(x, data, ...)

\method{distances}{pdb}(x, sel1, sel2, ...)

\method{dist.point}{default}(data, x, y = NULL, z = NULL, subset = NULL, ...)

is.distances(x)

norm(...)

\method{norm}{distances}(x, type = "xyz", ...)

\method{norm}{connect}(x, data, type = "xyz", ...)
}
\arguments{
\item{\dots}{further arguments passed to or from other methods.}

\item{dx1, dx2, dx3}{numeric arrays containing the first, second and third components of the distance vectors.}

\item{basis}{a single element character vector indicating the type of basis vector used to express the coordinates.}

\item{x, y, z}{an R object containing atomic coordinates, or a a connect object (for the corresponding method);}

\item{sel1, sel2}{integer or logical vectors defining two atomic selections between which the distance vectors are computed.}

\item{data}{an object of type pdb, atoms or coords, containing atomic coordinates.}

\item{subset}{enables sub-setting the coords object;}

\item{type}{a single element character vector indicating how to project the distances vectors before computing the norms. See details.}
}
\value{
The \code{distances} and \code{dist.point} functions return an object
  of class \sQuote{distances} containing inter-atomic distance vectors.
The \code{norm} function return an array, with the same dimensions as
  the \code{dx1}, \code{dx2}, \code{dx3} components of the \sQuote{distances} object
  for which the norms have been computed, containing the norm of the distance vectors. 
\cr\cr
\code{is.distances} returns TRUE if x is an object of class \sQuote{distances}
and FALSE otherwise.
}
\description{
Computes inter-atomic distance vectors.
}
\details{
The purpose of the \sQuote{distances} class is to store the inter-atomic 
distance vectors and facilitate their manipulation when passing from the 
Cartesian to fractional references and vice versa.\cr
The default method of the \code{distances} function is actually a builder
  allowing to create a \sQuote{distances} object from its different components, i.e.:
  \code{dx1}, \code{dx2}, \code{dx3}, and \code{basis}.
  All the arguments have to be specified except 'basis' which
  by default is set to "xyz" (Cartesian reference).

For objects of class \sQuote{coords}, \sQuote{atoms}, \sQuote{pdb},
two sets of atomic coordinates, defined by \code{sel1} and \code{sel2},
are extracted and inter-atomic distance vectors are computed 
between these two sets.
For objects of class \sQuote{connect}, distances are computed for the atoms
  specified by the \sQuote{connect} object.

The method for the \sQuote{dist.point} function computes the inter-atomic distances
between the atoms and a specified point.

The method of the \code{norm} function for objects of class \sQuote{distances}
  computes the norm of the distances vectors.
\code{type} specify how to project the distance vectors before 
  computing the norms. By default no projection is perform.
  The three dx, dy, and dz components of the distance vectors
  are used to compute the norm. 
\code{type} can take the following values:
   \itemize{
   \item   x: The distance vectors are projected over x.
   \item   y: The distance vectors are projected over y.
   \item   z: The distance vectors are projected over z.
   \item  xy: The distance vectors are projected in the xy-plan.
   \item  yz: The distance vectors are projected in the yz-plan.
   \item  zx: The distance vectors are projected in the zx-plan.
   \item xyz: The distance vectors are not projected 
     (The three components of the distance vectors are used to compute the norm).}
\code{is.distances} tests if x is an object of class \sQuote{distances};
the test is limited to the class attribute.
}
\examples{
x <- read.pdb(system.file("examples/PCBM_ODCB.pdb", package="Rpdb"))
is.DCB7 <- x$atoms$resname == "DCB" & x$atoms$resid == 7
is.DCB8 <- x$atoms$resname == "DCB" & x$atoms$resid == 8
d <- distances(x, is.DCB7, is.DCB8)
norm(d, type = "xyz")
norm(d, type = "xy")
norm(d, type = "x")
d <- dist.point(x, c(0,0,0), subset = is.DCB7)
norm(d, type = "xyz")

}
\seealso{
\code{\link{coords}}, \code{\link{basis}}, \code{\link{xyz2abc}}, \code{\link{abc2xyz}}
}
\keyword{classes}
\keyword{manip}
