fn geometry_to_coords(geom: &Geometry) -> Vec<f64>Expand description
Converts a molecular geometry to a flat coordinate vector.
This utility function extracts all atomic coordinates from a geometry object and arranges them in a single flat vector. This representation is convenient for mathematical operations, distance calculations, and vector arithmetic used throughout reaction path methods.
§Data Layout
The output vector contains coordinates in the following order:
[x₁, y₁, z₁, x₂, y₂, z₂, ..., xₙ, yₙ, zₙ]where (xᵢ, yᵢ, zᵢ) are the Cartesian coordinates of atom i.
§Arguments
geom- The molecular geometry to convert
§Returns
A Vec<f64> with length 3×N_atoms containing all coordinate components
in sequential order.
§Applications
§Mathematical Operations
- Vector arithmetic: Addition, subtraction, scaling of entire geometries
- Distance calculations: RMSD and path length computations
- Linear algebra: Matrix operations on coordinate sets
§Path Analysis
- Interpolation: Generate intermediate geometries along paths
- Tangent vectors: Compute path directions for NEB
- Displacement analysis: Study atomic movements during reactions
§Optimization Algorithms
- Gradient calculations: Flat vectors for optimization routines
- Constraint handling: Vector operations for constraint satisfaction
- Force applications: Apply forces to all atoms simultaneously
§Memory Layout
The flat representation is memory-efficient and cache-friendly:
- Contiguous storage: All coordinates in a single array
- Predictable access: Sequential memory access patterns
- SIMD compatibility: Suitable for vectorized operations
§Examples
// Convert geometry for mathematical operations
let coords = geometry_to_coords(&geometry);
println!("Total coordinates: {}", coords.len());
println!("Number of atoms: {}", coords.len() / 3);
// Access specific atom coordinates
let atom_index = 2; // Third atom (0-based)
let x = coords[atom_index * 3];
let y = coords[atom_index * 3 + 1];
let z = coords[atom_index * 3 + 2];
println!("Atom {} position: ({:.3}, {:.3}, {:.3})", atom_index, x, y, z);§Coordinate System
- Units: Same as input geometry (typically Angstroms)
- Origin: Arbitrary (depends on input geometry)
- Axes: Standard Cartesian (x, y, z)
- Handedness: Right-handed coordinate system assumed