rotation: Rotation of Atomic Coordinates

rotationR 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, crystal = NULL, ...)

## S3 method for class 'pdb'
R(obj, angle = 0, x = 0, y = 0, z = 1, mask = TRUE, crystal = obj$crystal, ...)

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.

crystal

an object of class ‘crystal’ used to convert fractional into Cartesian coordinates (when needed).

Details

R is a generic function. Method for objects of class ‘coords’ first convert the coordinates into Cartesian coordinates using crystal if needed. Once rotated, the coordinates are reconverted back to the original basis set using again crystal. Method for objects of class ‘pdb’ first extracts coordinates from the object using the function coords, performs the rotation, and updates 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)
          

Rpdb documentation built on March 16, 2026, 5:07 p.m.