rotation {Rpdb} | R Documentation |
Rotation of Atomic Coordinates
Description
Rotation of atomic coordinates around a given vector.
Usage
R(...)
## S3 method for class 'coords'
R(obj, angle = 0, x = 0, y = 0, z = 1, mask = TRUE, cryst1 = NULL, ...)
## S3 method for class 'pdb'
R(obj, angle = 0, x = 0, y = 0, z = 1, mask = TRUE, cryst1 = obj$cryst1, ...)
Arguments
... |
further arguments passed to or from other methods. |
obj |
an R object containing atomic coordinates. |
angle |
the angle of the rotation in degrees. |
x |
the x-component of the rotation vector. |
y |
the y-component of the rotation vector. |
z |
the z-component of the rotation vector. |
mask |
a logical vector indicating the set of coordinates to which the rotation has to be applyed. |
cryst1 |
an object of class ‘cryst1’ use to convert fractional into Cartesian coordinates when need. |
Details
R
is generic functions. Method for objects of class ‘coords’
first convert the coordinates into Cartesian coordinates using cryst1
if needed. Once rotated, the coordinates are reconverted back to the orginal
basis set using again cryst1
. Method for objects of class ‘pdb’
first extract coordinates from the object using the function coords
,
perform the rotation, and update the coordinates of the ‘pdb’ object
using the function coords<-
.
Value
An object of the same class as x
with rotated coordinates.
See Also
Helper functions for rotation around a given Cartesian vector:
Rx
, Ry
, Rz
Passing from Cartesian to fractional coordinates (or Vis Versa):
xyz2abc
, abc2xyz
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)