meshi.geometry
Class Distance

java.lang.Object
  extended by meshi.geometry.Distance
All Implemented Interfaces:
Attributable
Direct Known Subclasses:
BondedDistance, DistanceMirror, FreeDistance, FrozenDistance

public class Distance
extends java.lang.Object
implements Attributable

The distance between two meshi.molecularElements.atoms
. Almost any measurable feature of a molecule is related to distances between pairs of meshi.molecularElements.atoms. Thus, The calculation of distances (and their inverse and derivatives) are typically a computational bottleneck in computational structural biology applications. In all applications that we are aware of (Please, enlighten us if you know better) distance calculation is done as part of the procedures that use it (say, as part of the van-der-Waals energy calculation). As a result the distance between two atoms may be calculated more then once. For example the distance between two atoms may be calculated both during angle and torsion angle energies calculations. In Meshi We tried to consentrate all distance related issues in a few classes: this one, its subclasses and the closely connected class DistanceMatrix.

Possible pitfalls

  1. The object variables dx, dy, dz, distance, distance2, invDistance, dDistanceDx, dDistanceDy and dDistanceDz should have been private and accessed through "get methods". Energy functions though, use the values of these variables intensively and a considerable computational gain is achieved granting them public accessability (protected for dx, dy and dz) and removing the function call overhead. Thus, changing the values of these variables by other classes is possible (from the compiler point of view) but not very much recommended.
  2. The distance object "is not aware" of changes in the atoms coordinates. The values stored in this object are correct only after the update method is explicitly called.


    Field Summary
     AtomCore atom1
              This object represent the distance between atom1 and atom2.
     int atom1Number
               
     AtomCore atom2
              This object represent the distance between atom1 and atom2.
    protected  int atom2Number
               
    private  AttributesRack attributes
               
     double distance
              The distance between atom1 & atom2
    Not that the public accessability of of this variable improves computational efficiency but opens a wide door for bugs.
     double dx
              atom1.x - atom2.x Not that the protected accessability of of this variable improves computational efficiency but opens a wide door for bugs.
     double dy
              atom1.y - atom2.y Not that the protected accessability of of this variable improves computational efficiency but opens a wide door for bugs.
     double dz
              atom1.z - atom2.z Not that the protected accessability of of this variable improves computational efficiency but opens a wide door for bugs.
    static double INFINITE_DISTANCE
               
     double invDistance
              The inverse of the distance between atom1 & atom2.
     AtomType largeType
               
    protected  DistanceMode mode
               
     AtomType smallType
               
     
    Constructor Summary
    Distance(AtomCore atom1, AtomCore atom2, double dx, double dy, double dz, double distance)
               
     
    Method Summary
     void addAttribute(MeshiAttribute attribute)
               
     Atom atom1()
              Get atom1.
     Atom atom2()
              Get atom2.
     int atom2Number()
               
     double dDistanceDx()
              The derivative of the distance between atom1 & atom2 by the X coordinate of atom1.
     double dDistanceDy()
              The derivative of the distance between atom1 & atom2 by the Y coordinate of atom1.
     double dDistanceDz()
              The derivative of the distance between atom1 & atom2 by the Z coordinate of atom1.
     boolean dead()
               
     double distance()
              Get the distance between atom1 and atom2.
     double dx()
               
     double dy()
               
     double dz()
               
     MeshiAttribute getAttribute(int key)
               
     double invDistance()
              Get the inverse of the distance between atom1 and atom2.
     DistanceMode mode()
               
     void setMode(DistanceMode mode)
               
     java.lang.String toString()
               
    protected  void update(double rMax2)
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
     

    Field Detail

    INFINITE_DISTANCE

    public static final double INFINITE_DISTANCE
    See Also:
    Constant Field Values

    atom1

    public final AtomCore atom1
    This object represent the distance between atom1 and atom2.


    atom2

    public final AtomCore atom2
    This object represent the distance between atom1 and atom2.


    atom1Number

    public final int atom1Number

    atom2Number

    protected int atom2Number

    mode

    protected DistanceMode mode

    invDistance

    public double invDistance
    The inverse of the distance between atom1 & atom2.
    Not that the public accessability of of this variable improves computational efficiency but opens a wide door for bugs.


    distance

    public double distance
    The distance between atom1 & atom2
    Not that the public accessability of of this variable improves computational efficiency but opens a wide door for bugs.


    dx

    public double dx
    atom1.x - atom2.x Not that the protected accessability of of this variable improves computational efficiency but opens a wide door for bugs.


    dy

    public double dy
    atom1.y - atom2.y Not that the protected accessability of of this variable improves computational efficiency but opens a wide door for bugs.


    dz

    public double dz
    atom1.z - atom2.z Not that the protected accessability of of this variable improves computational efficiency but opens a wide door for bugs.


    largeType

    public final AtomType largeType

    smallType

    public final AtomType smallType

    attributes

    private AttributesRack attributes
    Constructor Detail

    Distance

    public Distance(AtomCore atom1,
                    AtomCore atom2,
                    double dx,
                    double dy,
                    double dz,
                    double distance)
    Method Detail

    addAttribute

    public final void addAttribute(MeshiAttribute attribute)
    Specified by:
    addAttribute in interface Attributable

    getAttribute

    public final MeshiAttribute getAttribute(int key)
    Specified by:
    getAttribute in interface Attributable

    update

    protected void update(double rMax2)

    distance

    public double distance()
    Get the distance between atom1 and atom2.


    invDistance

    public double invDistance()
    Get the inverse of the distance between atom1 and atom2.


    dDistanceDx

    public double dDistanceDx()
    The derivative of the distance between atom1 & atom2 by the X coordinate of atom1. The derivative by the X coordinate of atom2 is this value multiplied by -1.


    dDistanceDy

    public double dDistanceDy()
    The derivative of the distance between atom1 & atom2 by the Y coordinate of atom1. The derivative by the Y coordinate of atom2 is this value multiplied by -1.


    dDistanceDz

    public double dDistanceDz()
    The derivative of the distance between atom1 & atom2 by the Z coordinate of atom1. The derivative by the Z coordinate of atom2 is this value multiplied by -1.


    atom1

    public Atom atom1()
    Get atom1.


    atom2

    public Atom atom2()
    Get atom2.


    atom2Number

    public int atom2Number()

    dx

    public double dx()

    dy

    public double dy()

    dz

    public double dz()

    toString

    public java.lang.String toString()
    Overrides:
    toString in class java.lang.Object

    mode

    public final DistanceMode mode()

    setMode

    public void setMode(DistanceMode mode)

    dead

    public boolean dead()