summaryrefslogtreecommitdiff
path: root/src/math.rs
blob: 689ee65ba9dded066744e5f5fca98d1a64745c70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
extern crate rand;

use self::rand::distributions::Alphanumeric;
use self::rand::Rng;
use std::iter::repeat;

pub fn distance(l0: (f64, f64, f64), l1: (f64, f64, f64)) -> f64 {
    ((l1.0 - l0.0).powf(2.0) + (l1.1 - l0.1).powf(2.0) + (l1.2 - l0.2).powf(2.0)).sqrt()
}

pub fn rand_name() -> String {
    repeat(())
        .map(|()| rand::thread_rng().sample(Alphanumeric))
        .take(8)
        .collect()
}