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
30
31
32
33
34
35
36
37
38
39
40
use super::{Kernel, Orientation};
use crate::Coordinate;
#[derive(Default)]
pub struct RobustKernel;
use num_traits::{Float, NumCast};
impl<T: Float> Kernel<T> for RobustKernel {
fn orient2d(p: Coordinate<T>, q: Coordinate<T>, r: Coordinate<T>) -> Orientation {
use robust::{orient2d, Coord};
let orientation = orient2d(
Coord {
x: <f64 as NumCast>::from(p.x).unwrap(),
y: <f64 as NumCast>::from(p.y).unwrap(),
},
Coord {
x: <f64 as NumCast>::from(q.x).unwrap(),
y: <f64 as NumCast>::from(q.y).unwrap(),
},
Coord {
x: <f64 as NumCast>::from(r.x).unwrap(),
y: <f64 as NumCast>::from(r.y).unwrap(),
},
);
if orientation < 0. {
Orientation::Clockwise
} else if orientation > 0. {
Orientation::CounterClockwise
} else {
Orientation::Collinear
}
}
}