Logo Search packages:      
Sourcecode: cdk version File versions  Download package

static double org::openscience::cdk::modeling::forcefield::ForceFieldTools::torsionAngleFrom3xNCoordinates ( GVector  coords3d,
int  atomiPosition,
int  atomjPosition,
int  atomkPosition,
int  atomlPosition 
) [inline, static]

Calculate the torsion angle from 4 atoms i,j,k and l positions, where i-j, j-k, and k-l are bonded pairs.

Parameters:
coords3d3xN atoms coordinates.
atomiPositionAtom i position.
atomjPositionAtom j position.
atomkPositionAtom k position.
atomlPositionAtom l position.
Returns:
Torsion angle value.

Definition at line 323 of file ForceFieldTools.java.

Referenced by org::openscience::cdk::modeling::forcefield::Torsions::setPhi().

                                                                                                                                                       {

        atomiCoordinates.set(coords3d.getElement(3 * atomiPosition), coords3d.getElement(3 * atomiPosition + 1), coords3d.getElement(3 * atomiPosition + 2));
        atomjCoordinates.set(coords3d.getElement(3 * atomjPosition), coords3d.getElement(3 * atomjPosition + 1), coords3d.getElement(3 * atomjPosition + 2));
        atomkCoordinates.set(coords3d.getElement(3 * atomkPosition), coords3d.getElement(3 * atomkPosition + 1), coords3d.getElement(3 * atomkPosition + 2));
        atomlCoordinates.set(coords3d.getElement(3 * atomlPosition), coords3d.getElement(3 * atomlPosition + 1), coords3d.getElement(3 * atomlPosition + 2));

        xji = new Vector3d(atomiCoordinates);
        xji.sub(atomjCoordinates);
        xjk = new Vector3d(atomkCoordinates);
        xjk.sub(atomjCoordinates);
        xlk = new Vector3d(atomkCoordinates);
        xlk.sub(atomlCoordinates);

        v1 = new Vector3d();  // v1 = xji x xjk / |xji x xjk|
        v1.cross(xji, xjk);
        v1.normalize();

        v2 = new Vector3d();  // v2 = xjk x xlk / |xjk x xlk|
        v2.cross(xjk, xlk);
        v2.normalize();

        double cosang = v1.dot(v2);

        if (cosang >1){
            cosang = 1;
        }
        if (cosang < -1){
            cosang=-1;
        }

        double torsion = Math.acos(cosang);
        double dot=xji.dot(v2);
        double absDot=Math.abs(dot);
        torsion = (dot/absDot > 0) ? torsion : (2 * Math.PI - torsion);

        //logger.debug("torsion" + torsion);

        return torsion;
    }

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index