815 |
|
} |
816 |
|
} |
817 |
|
|
818 |
+ |
} |
819 |
+ |
|
820 |
+ |
Vector3d SimInfo::getComVel(){ |
821 |
+ |
SimInfo::MoleculeIterator i; |
822 |
+ |
Molecule* mol; |
823 |
+ |
|
824 |
+ |
Vector3d comVel(0.0); |
825 |
+ |
double totalMass = 0.0; |
826 |
+ |
|
827 |
+ |
|
828 |
+ |
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
829 |
+ |
double mass = mol->getMass(); |
830 |
+ |
totalMass += mass; |
831 |
+ |
comVel += mass * mol->getComVel(); |
832 |
+ |
} |
833 |
+ |
|
834 |
+ |
comVel /= totalMass; |
835 |
+ |
|
836 |
+ |
return comVel; |
837 |
|
} |
838 |
|
|
839 |
+ |
Vector3d SimInfo::getCom(){ |
840 |
+ |
SimInfo::MoleculeIterator i; |
841 |
+ |
Molecule* mol; |
842 |
+ |
|
843 |
+ |
Vector3d com(0.0); |
844 |
+ |
double totalMass = 0.0; |
845 |
+ |
|
846 |
+ |
for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) { |
847 |
+ |
double mass = mol->getMass(); |
848 |
+ |
totalMass += mass; |
849 |
+ |
com += mass * mol->getCom(); |
850 |
+ |
} |
851 |
+ |
|
852 |
+ |
com /= totalMass; |
853 |
+ |
|
854 |
+ |
return com; |
855 |
+ |
|
856 |
+ |
} |
857 |
+ |
|
858 |
|
std::ostream& operator <<(std::ostream& o, SimInfo& info) { |
859 |
|
|
860 |
|
return o; |