pub fn interpolate_linear(
geom1: &Geometry,
geom2: &Geometry,
num_points: usize,
) -> Vec<Geometry>Expand description
Performs Linear Synchronous Transit (LST) interpolation between two geometries.
This function implements the LST method using the Kabsch algorithm for optimal alignment of the geometries before interpolation. The Kabsch algorithm finds the optimal rotation matrix that minimizes the root-mean-square deviation between corresponding atoms.
§Arguments
geom1- The starting geometry (will be aligned to geom2)geom2- The target geometry (reference for alignment)num_points- Number of intermediate points to generate
§Returns
Returns a Vec<Geometry> containing num_points + 2 geometries, including
the aligned starting geometry and the target geometry.
§Panics
Panics if the input geometries have different numbers of atoms.
§Algorithm Details
- Alignment: Uses Kabsch algorithm to find optimal rotation matrix
- Rotation: Applies rotation to align geom1 with geom2
- Interpolation: Linear interpolation between aligned geometries
The Kabsch algorithm steps:
- Compute cross-covariance matrix R = Y * X^T
- Compute R^T * R and its eigendecomposition
- Construct rotation matrix U from eigenvectors and eigenvalues
§Examples
use omecp::lst::interpolate_linear;
use omecp::geometry::Geometry;
let elements = vec!["C".to_string(), "H".to_string()];
let coords1 = vec![0.0, 0.0, 0.0, 1.0, 0.0, 0.0];
let coords2 = vec![0.0, 0.0, 1.0, 1.0, 0.0, 1.0];
let geom1 = Geometry::new(elements.clone(), coords1);
let geom2 = Geometry::new(elements, coords2);
let path = interpolate_linear(&geom1, &geom2, 3);
assert_eq!(path.len(), 5); // 3 intermediate + 2 endpoints§References
Kabsch, W. “A solution for the best rotation to relate two sets of vectors.” Acta Crystallographica Section A 1976, 32(5), 922-923.