trajectory/
utils.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use num_traits::Float;

pub fn is_inputs_valid<T>(times: &[T], points: &[Vec<T>]) -> bool
where
    T: Float,
{
    if times.len() != points.len() {
        return false;
    }
    for i in 0..times.len() - 1 {
        // not sorted time
        if times[i] >= times[i + 1] {
            return false;
        }
    }
    if points.is_empty() {
        return false;
    }
    if points[0].is_empty() {
        return false;
    }
    let dim = points[0].len();
    for p in points {
        if p.len() != dim {
            return false;
        }
    }
    true
}