% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rotation.R
\name{rotation}
\alias{rotation}
\alias{R}
\alias{R.coords}
\alias{R.pdb}
\title{Rotation of Atomic Coordinates}
\usage{
R(...)

\method{R}{coords}(obj, angle = 0, x = 0, y = 0, z = 1, mask = TRUE, crystal = NULL, ...)

\method{R}{pdb}(obj, angle = 0, x = 0, y = 0, z = 1, mask = TRUE, crystal = obj$crystal, ...)
}
\arguments{
\item{\dots}{further arguments passed to or from other methods.}

\item{obj}{an R object containing atomic coordinates.}

\item{angle}{the angle of the rotation in degrees.}

\item{x}{the x-component of the rotation vector.}

\item{y}{the y-component of the rotation vector.}

\item{z}{the z-component of the rotation vector.}

\item{mask}{a logical vector indicating the set of coordinates to which the rotation has to be applyed.}

\item{crystal}{an object of class \sQuote{crystal} used to convert fractional into Cartesian coordinates (when needed).}
}
\value{
An object of the same class as \code{x} with rotated coordinates.
}
\description{
Rotation of atomic coordinates around a given vector.
}
\details{
\code{R} is a generic function. Method for objects of class \sQuote{coords}
first convert the coordinates into Cartesian coordinates using \code{crystal}
if needed. Once rotated, the coordinates are reconverted back to the original
basis set using again \code{crystal}. Method for objects of class \sQuote{pdb}
first extracts coordinates from the object using the function \code{coords},
performs the rotation, and updates the coordinates of the \sQuote{pdb} object
using the function \code{coords<-}.
}
\examples{
# First lets read a pdb file
x <- read.pdb(system.file("examples/PCBM_ODCB.pdb", package="Rpdb"))
cell <- cell.coords(x)
visualize(x, mode = NULL)

# Rotation of the structure around the c-axis
visualize(R(x, 90, x=cell["x","c"], y=cell["y","c"], z=cell["z","c"]),
          mode = NULL)
# Rotation of the residue 1 around the c-axis
visualize(R(x, 90, x=cell["x","c"], y=cell["y","c"], z=cell["z","c"], mask = x$atoms$resid == 1),
          mode = NULL)
          
}
\seealso{
Helper functions for rotation around a given Cartesian vector:\cr
\code{\link{Rx}}, \code{\link{Ry}}, \code{\link{Rz}}\cr
Passing from Cartesian to fractional coordinates (or Vis Versa):\cr
\code{\link{xyz2abc}}, \code{\link{abc2xyz}}
}
\keyword{manip}
