Skip to main content

oxiphysics_core/interval/
boundconstraint_traits.rs

1//! # BoundConstraint - Trait Implementations
2//!
3//! This module contains trait implementations for `BoundConstraint`.
4//!
5//! ## Implemented Traits
6//!
7//! - `IntervalConstraint`
8//!
9//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
10
11use super::functions::IntervalConstraint;
12#[allow(unused_imports)]
13use super::functions::*;
14use super::types::{BoundConstraint, Interval};
15
16impl IntervalConstraint for BoundConstraint {
17    fn propagate(&self, box_: &mut [Interval]) -> bool {
18        if let Some(narrowed) = Interval::intersection(box_[self.idx], self.bounds)
19            && (narrowed.lo > box_[self.idx].lo + 1e-15 || narrowed.hi < box_[self.idx].hi - 1e-15)
20        {
21            box_[self.idx] = narrowed;
22            return true;
23        }
24        false
25    }
26}