## org.biojava.bio.structure
Class Calc

    java.lang.Object
      org.biojava.bio.structure.Calc

    public class Calc

extends Object

utility operations on Atoms, AminoAcids, etc.

Currently the coordinates of an Atom are stored as an array of size 3 (double[3]). It would be more powerful to use Point3D from javax.vecmath. but unfortunately this is not a part of standard java installations, since it comes with java3d . So to keep things simple at the moment biojava does not depend on java3d.

Since:
  1.4
Version:
  %I% %G%
Author:
  Andreas Prlic

Field Summary
`static float` `degreesPerRadian` Degrees per radian.
`static float` `radiansPerDegree` Radians per degree.

Constructor Summary
`Calc()`

Method Summary
`static Atom` `add(Atom a, Atom b)` add two atoms ( a + b).
`static double` `amount(Atom a)` amount.
`static double` `angle(Atom a, Atom b)` angle.
`static Atom[]` `centerAtoms(Atom[] atomSet)` Center the atoms at the Centroid.
`static Atom` `createVirtualCBAtom(AminoAcid amino)` creates a virtual C-beta atom.
`static Atom` `getCenterVector(Atom[] atomSet)` Returns the Vector that needs to be applied to shift a set of atoms to the Centroid.
`static Atom` `getCentroid(Atom[] atomSet)` Returns the center of mass of the set of atoms.
`static double` `getDistance(Atom a, Atom b)` calculate distance between two atoms.
`static double` `getPhi(AminoAcid a, AminoAcid b)` phi angle.
`static double` `getPsi(AminoAcid a, AminoAcid b)` psi angle.
`static double[]` `getXYZEuler(Matrix m)` Convert a rotation Matrix to Euler angles.
`static double[]` `getZYZEuler(Matrix m)` Gget euler angles for a matrix given in ZYZ convention.
`static boolean` `isConnected(AminoAcid a, AminoAcid b)` test if two amino acids are connected, i.e.
`static Matrix` `matrixFromEuler(double heading, double attitude, double bank)` This conversion uses NASA standard aeroplane conventions as described on page: http://www.euclideanspace.com/maths/geometry/rotations/euler/index.htm Coordinate System: right hand Positive angle: right hand Order of euler angles: heading first, then attitude, then bank.
`static void` `plus(Structure s, Matrix matrix)` calculate structure + Matrix coodinates ...
`static void` `rotate(Atom atom, double[][] m)` rotate a single atom aroud a rotation matrix.
`static void` `rotate(Atom atom, Matrix m)` Rotate an atom around a Matrix object.
`static void` `rotate(Group group, double[][] rotationmatrix)` rotate a structure .
`static void` `rotate(Group group, Matrix m)` Rotate a group object.
`static void` `rotate(Structure structure, double[][] rotationmatrix)` Rotate a structure.
`static void` `rotate(Structure structure, Matrix m)` Rotate a structure object.
`static void` `shift(Atom a, Atom b)` Shift a vector.
`static void` `shift(Group group, Atom a)` Shift a Group with a vector.
`static void` `shift(Structure structure, Atom a)` shift a structure with a vector.
`static double` `skalarProduct(Atom a, Atom b)` skalar product.
`static Atom` `substract(Atom a, Atom b)` substract two atoms ( a - b).
`static double` `torsionAngle(Atom a, Atom b, Atom c, Atom d)` torsion angle = angle between the normal vectors of the two plains a-b-c and b-c-d.
`static Atom` `unitVector(Atom a)` return the unit vector of vector a .
`static Atom` `vectorProduct(Atom a, Atom b)` Vector product .

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### radiansPerDegree

    public static final float radiansPerDegree

  Radians per degree.

  See Also:
    Constant Field Values

### degreesPerRadian

    public static final float degreesPerRadian

  Degrees per radian.

  See Also:
    Constant Field Values

Constructor Detail

### Calc

    public Calc()

Method Detail

### getDistance

    public static double getDistance(Atom a,
                                     Atom b)
                              throws StructureException

  calculate distance between two atoms.

  Parameters:
    `a` - an Atom object
    `b` - an Atom object
  Returns:
    a double
  Throws:
    `StructureException` - ...

### add

    public static Atom add(Atom a,
                           Atom b)

  add two atoms ( a + b).

  Parameters:
    `a` - an Atom object
    `b` - an Atom object
  Returns:
    an Atom object

### substract

    public static Atom substract(Atom a,
                                 Atom b)
                          throws StructureException

  substract two atoms ( a - b).

  Parameters:
    `a` - an Atom object
    `b` - an Atom object
  Returns:
    an Atom object
  Throws:
    `StructureException` - ...

### vectorProduct

    public static Atom vectorProduct(Atom a,
                                     Atom b)

  Vector product .

  Parameters:
    `a` - an Atom object
    `b` - an Atom object
  Returns:
    an Atom object

### skalarProduct

    public static double skalarProduct(Atom a,
                                       Atom b)

  skalar product.

  Parameters:
    `a` - an Atom object
    `b` - an Atom object
  Returns:
    a double

### amount

    public static double amount(Atom a)

  amount.

  Parameters:
    `a` - an Atom object
  Returns:
    a double

### angle

    public static double angle(Atom a,
                               Atom b)

  angle.

  Parameters:
    `a` - an Atom object
    `b` - an Atom object
  Returns:
    a double

### unitVector

    public static Atom unitVector(Atom a)

  return the unit vector of vector a .

  Parameters:
    `a` - an Atom object
  Returns:
    an Atom object

### torsionAngle

    public static double torsionAngle(Atom a,
                                      Atom b,
                                      Atom c,
                                      Atom d)
                               throws StructureException

  torsion angle = angle between the normal vectors of the two plains a-b-c and b-c-d.

  Parameters:
    `a` - an Atom object
    `b` - an Atom object
    `c` - an Atom object
    `d` - an Atom object
  Returns:
    a double
  Throws:
    `StructureException` - ...

### getPhi

    public static double getPhi(AminoAcid a,
                                AminoAcid b)
                         throws StructureException

  phi angle.

  Parameters:
    `a` - an AminoAcid object
    `b` - an AminoAcid object
  Returns:
    a double
  Throws:
    `StructureException` - ...

### getPsi

    public static double getPsi(AminoAcid a,
                                AminoAcid b)
                         throws StructureException

  psi angle.

  Parameters:
    `a` - an AminoAcid object
    `b` - an AminoAcid object
  Returns:
    a double
  Throws:
    `StructureException` - ...

### isConnected

    public static boolean isConnected(AminoAcid a,
                                      AminoAcid b)
                               throws StructureException

  test if two amino acids are connected, i.e. if the distance from C to N < 2,5 Angstrom.

  Parameters:
    `a` - an AminoAcid object
    `b` - an AminoAcid object
  Returns:
    true if ...
  Throws:
    `StructureException` - ...

### rotate

    public static void rotate(Atom atom,
                              double[][] m)

  rotate a single atom aroud a rotation matrix. matrix must be a 3x3 matrix.

  Parameters:
    `atom` - atom to be rotated
    `m` - a rotation matrix represented as a double[3][3] array

### rotate

    public static void rotate(Structure structure,
                              double[][] rotationmatrix)
                       throws StructureException

  Rotate a structure.

  Parameters:
    `structure` - a Structure object
    `rotationmatrix` - an array (3x3) of double representing the rotation matrix.
  Throws:
    `StructureException` - ...

### rotate

    public static void rotate(Group group,
                              double[][] rotationmatrix)
                       throws StructureException

  rotate a structure .

  Parameters:
    `group` - a group object
    `rotationmatrix` - an array (3x3) of double representing the rotation matrix.
  Throws:
    `StructureException` - ...

### rotate

    public static void rotate(Atom atom,
                              Matrix m)

  Rotate an atom around a Matrix object.

  Parameters:
    `atom` - atom to be rotated
    `m` - rotation matrix to be applied to the atom

### rotate

    public static void rotate(Group group,
                              Matrix m)

  Rotate a group object.

  Parameters:
    `group` - a group to be rotated
    `m` - a Matrix object representing the translation matrix

### rotate

    public static void rotate(Structure structure,
                              Matrix m)

  Rotate a structure object.

  Parameters:
    `structure` - the structure to be rotated
    `m` - rotation matrix to be applied

### plus

    public static void plus(Structure s,
                            Matrix matrix)

  calculate structure + Matrix coodinates ...

  Parameters:
    `s` - the structure to operate on
    `matrix` - a Matrix object

### shift

    public static void shift(Structure structure,
                             Atom a)

  shift a structure with a vector.

  Parameters:
    `structure` - a Structure object
    `a` - an Atom object representing a shift vector

### shift

    public static void shift(Atom a,
                             Atom b)

  Shift a vector.

  Parameters:
    `a` - vector a
    `b` - vector b

### shift

    public static void shift(Group group,
                             Atom a)

  Shift a Group with a vector.

  Parameters:
    `group` - a group object
    `a` - an Atom object representing a shift vector

### getCentroid

    public static Atom getCentroid(Atom[] atomSet)

  Returns the center of mass of the set of atoms.

  Parameters:
    `atomSet` - a set of Atoms
  Returns:
    an Atom representing the Centroid of the set of atoms

### getCenterVector

    public static Atom getCenterVector(Atom[] atomSet)

  Returns the Vector that needs to be applied to shift a set of atoms to the Centroid.

  Parameters:
    `atomSet` - array of Atoms
  Returns:
    the vector needed to shift the set of atoms to its geometric center

### centerAtoms

    public static Atom[] centerAtoms(Atom[] atomSet)
                              throws StructureException

  Center the atoms at the Centroid.

  Parameters:
    `atomSet` - a set of Atoms
  Returns:
    an Atom representing the Centroid of the set of atoms
  Throws:
    `StructureException`

### createVirtualCBAtom

    public static Atom createVirtualCBAtom(AminoAcid amino)
                                    throws StructureException

  creates a virtual C-beta atom. this might be needed when working with GLY thanks to Peter Lackner for a python template of this method.

  Parameters:
    `amino` - the amino acid for which a "virtual" CB atom should be calculated
  Returns:
    a "virtual" CB atom
  Throws:
    `StructureException`

### getZYZEuler

    public static double[] getZYZEuler(Matrix m)

  Gget euler angles for a matrix given in ZYZ convention. (as e.g. used by Jmol)

  Parameters:
    `m` - the rotation matrix
  Returns:
    the euler values for a rotation around Z, Y, Z in degrees...

### getXYZEuler

    public static double[] getXYZEuler(Matrix m)

  Convert a rotation Matrix to Euler angles. This conversion uses conventions as described on page: http://www.euclideanspace.com/maths/geometry/rotations/euler/index.htm Coordinate System: right hand Positive angle: right hand Order of euler angles: heading first, then attitude, then bank

  Parameters:
    `m` - the rotation matrix
  Returns:
    a array of three doubles containing the three euler angles in radians

### matrixFromEuler

    public static Matrix matrixFromEuler(double heading,
                                         double attitude,
                                         double bank)

  This conversion uses NASA standard aeroplane conventions as described on page: http://www.euclideanspace.com/maths/geometry/rotations/euler/index.htm Coordinate System: right hand Positive angle: right hand Order of euler angles: heading first, then attitude, then bank. matrix row column ordering: [m00 m01 m02] [m10 m11 m12] [m20 m21 m22]

  Parameters:
    `heading` - in radians
    `attitude` - in radians
    `bank` - in radians
  Returns:
    the rotation matrix