Skip to main content

oxiphysics_geometry/implicit_geometry/
sdflinesegment_traits.rs

1//! # SdfLineSegment - Trait Implementations
2//!
3//! This module contains trait implementations for `SdfLineSegment`.
4//!
5//! ## Implemented Traits
6//!
7//! - `Sdf`
8//!
9//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
10
11use super::functions::*;
12use super::types::SdfLineSegment;
13
14impl Sdf for SdfLineSegment {
15    fn dist(&self, p: [f64; 3]) -> f64 {
16        let pa = sub(p, self.a);
17        let ba = sub(self.b, self.a);
18        let h = clamp01(dot(pa, ba) / dot(ba, ba));
19        len(sub(pa, scale(ba, h))) - self.radius
20    }
21}