gmac/core/utilities.rs
1/// Computes the squared Euclidean distance between two array of equal length.
2///
3/// # Arguments
4/// * `a`: A floating point array.
5/// * `b`: A second floating point array.
6///
7/// # Returns
8/// The squared Euclidean distance.
9pub fn squared_euclidean_distance_3d(a: [f64; 3], b: [f64; 3]) -> f64 {
10 let dx = a[0] - b[0];
11 let dy = a[1] - b[1];
12 let dz = a[2] - b[2];
13 dx * dx + dy * dy + dz * dz
14}
15
16/// Computes the Euclidean distance between two array of equal length.
17///
18/// # Arguments
19/// * `a`: A floating point array.
20/// * `b`: A second floating point array.
21///
22/// # Returns
23/// The Euclidean distance.
24pub fn euclidean_distance_3d(a: [f64; 3], b: [f64; 3]) -> f64 {
25 squared_euclidean_distance_3d(a, b).sqrt()
26}