package etomica.atom;

import etomica.space.IVector;
import etomica.space.Space;


/**
 * Atom type for a rigid molecule with an orientation and (therefore) a moment
 * of inertia.  The molecule holds the orientation and the type holds the
 * moment.  The type does not actually know how to calculate the moment, so
 * the moment must be initialized by whoever creates this type.
 */
public class AtomTypeMoleculeOriented extends AtomTypeMolecule {
    
    public AtomTypeMoleculeOriented(Space space) {
        super(new AtomPositionCOM(space));
        moment = space.makeVector();
    }

    /**
     * Returns the principle components of the moment of inertia of the
     * molecule within the body-fixed frame.
     */
    public IVector momentOfInertia() {
        return moment;
    }

    private static final long serialVersionUID = 1L;
    protected final IVector moment;
}
@@ -247,137 +247,8 @@
 ent.
-  The type does not actually know how to calculate the moment, so%0A * the moment must be initialized by whoever creates this type.
 %0A */
@@ -448,16 +448,916 @@
 ector();
+%0A%0A        // make a pretend molecule and calculate its moment of inertia%0A        IMolecule molecule = species.makeMolecule();%0A        AtomSet children = molecule.getChildList();%0A        conformation.initializePositions(children);%0A        IVector com = space.makeVector();%0A        com.E(positionDefinition.position(molecule));%0A        double%5B%5D I = new double%5B3%5D;%0A        IVector xWork = space.makeVector();%0A        for (int i=0; i%3Cchildren.getAtomCount(); i++) %7B%0A            IAtomPositioned atom = (IAtomPositioned)children.getAtom(i);%0A            xWork.Ev1Mv2(atom.getPosition(), com);%0A            double atomMass = ((AtomTypeLeaf)atom.getType()).getMass();%0A            for (int j=0; j%3C3; j++) %7B%0A                for (int k=0; k%3C3; k++) %7B%0A                    if (j==k) continue;%0A                    I%5Bj%5D += atomMass*xWork.x(k)*xWork.x(k);%0A                %7D%0A            %7D%0A        %7D%0A        moment.E(I);
 %0A    %7D%0A%0A
@@ -1480,16 +1480,79 @@
 d frame.
+  Do NOT modify the returned moment%0A     * of inertia returned.
 %0A     */

add comment to not modify moment