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
use crate::math::{Point, Vector};
use na::{self, RealField};
#[inline]
pub fn point_cloud_support_point_id<N: RealField>(dir: &Vector<N>, points: &[Point<N>]) -> usize {
let mut best_pt = 0;
let mut best_dot = points[0].coords.dot(dir);
for i in 1..points.len() {
let p = &points[i];
let dot = p.coords.dot(dir);
if dot > best_dot {
best_dot = dot;
best_pt = i;
}
}
best_pt
}
#[inline]
pub fn point_cloud_support_point<N: RealField>(dir: &Vector<N>, points: &[Point<N>]) -> Point<N> {
points[point_cloud_support_point_id(dir, points)]
}