sampling_planning/
goal.rs1use crate::StateSpace;
4
5#[derive(Debug, Clone, PartialEq)]
9pub struct GoalRegion<S> {
10 center: S,
12 tolerance: f64,
14}
15
16impl<S> GoalRegion<S> {
17 #[must_use]
23 pub fn new(center: S, tolerance: f64) -> Self {
24 assert!(
25 tolerance.is_finite() && tolerance >= 0.0,
26 "goal tolerance must be non-negative and finite"
27 );
28
29 Self { center, tolerance }
30 }
31
32 #[must_use]
34 pub const fn center(&self) -> &S {
35 &self.center
36 }
37
38 #[must_use]
40 pub const fn tolerance(&self) -> f64 {
41 self.tolerance
42 }
43
44 #[must_use]
46 pub fn contains<Sp: StateSpace<State = S>>(&self, space: &Sp, state: &S) -> bool {
47 space.distance(state, &self.center) <= self.tolerance
48 }
49}