loadXyz function
Load atoms from xyz file format.
Implementation
List<AtomObject> loadXyz(String xyz) {
final atomObjects = <AtomObject>[];
final lines = xyz.split('\n');
for (var line in lines) {
final parts = line.split(RegExp(r'\s+'));
if (parts.length == 4) {
final elementName = parts[0];
final position = Vector3(
double.parse(parts[1]),
double.parse(parts[2]),
double.parse(parts[3]),
);
atomObjects.add(AtomObject.fromElementName(elementName, position));
}
}
return atomObjects;
}