pub fn dist2(&self, first:&PosVec, second:&PosVec) -> (PosVec, Nanometer2<f32>) {
            let (vec_a, vec_b, vec_c) = self.boxvecs.clone();
            let mut r2s: Vec<(PosVec, Nanometer2<f32>)> = vec![];

            for a in [-1.0, 0.0, 1.0].iter() {
                for b in [-1.0, 0.0, 1.0].iter() {
                    for c in [-1.0, 0.0, 1.0].iter() {
                        let offset = vec_a.clone() * a.clone()
                            + vec_b.clone() * b.clone()
                            + vec_c.clone() * c.clone();
                        let diff = first - second + offset;
                        let diff2 = diff.clone().norm2();
                        r2s.push((diff, diff2));
                    }
                }
            }
            r2s.into_iter()
                .min_by(|(_, a), (_, b)| a.partial_cmp(b).expect("Tried to compare a NaN"))
                .unwrap()
        }
/// Get the minimum image convention distance between two vectors,
/// and the corresponding distance vector
Get the minimum image convention distance between two vectors,
and the corresponding distance vector
Get the minimum image convention distance between two vectors and the corresponding distance vector
pub fn dist2(&self, first:&PosVec, second:&PosVec) -> (PosVec, Nanometer2<f32>) {
            let (vec_a, vec_b, vec_c) = self.boxvecs.clone();
            let mut r2s: Vec<(PosVec, Nanometer2<f32>)> = vec![];
            for a in [-1.0, 0.0, 1.0].iter() {
                for b in [-1.0, 0.0, 1.0].iter() {
                    for c in [-1.0, 0.0, 1.0].iter() {
                        let offset = vec_a.clone() * a.clone()
                            + vec_b.clone() * b.clone()
                            + vec_c.clone() * c.clone();
                        let diff = first - second + offset;
                        let diff2 = diff.clone().norm2();
                        r2s.push((diff, diff2));
                    }
                }
            }
            r2s.into_iter()
                .min_by(|(_, a), (_, b)| a.partial_cmp(b).expect("Tried to compare a NaN"))
                .unwrap()
        }
pub fn dist2 ( & self , first : & PosVec , second : & PosVec ) -> ( PosVec , Nanometer2 < f32 > ) { let ( vec_a , vec_b , vec_c ) = self . boxvecs . clone ( ) ; let mut r2s : Vec < ( PosVec , Nanometer2 < f32 > ) > = vec ! [ ] ; for a in [ - 1.0 , 0.0 , 1.0 ] . iter ( ) { for b in [ - 1.0 , 0.0 , 1.0 ] . iter ( ) { for c in [ - 1.0 , 0.0 , 1.0 ] . iter ( ) { let offset = vec_a . clone ( ) * a . clone ( ) + vec_b . clone ( ) * b . clone ( ) + vec_c . clone ( ) * c . clone ( ) ; let diff = first - second + offset ; let diff2 = diff . clone ( ) . norm2 ( ) ; r2s . push ( ( diff , diff2 ) ) ; } } } r2s . into_iter ( ) . min_by ( | ( _ , a ) , ( _ , b ) | a . partial_cmp ( b ) . expect ( " " ) ) . unwrap ( ) }
Get the minimum image convention distance between two vectors,
and the corresponding distance vector
Get the minimum image convention distance between two vectors and the corresponding distance vector
&self
first
&PosVec
second
&PosVec
&self
first
&PosVec
second
&PosVec