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
11#[allow(unused_imports)]
12use super::functions::*;
13#[allow(unused_imports)]
14use super::functions::*;
15use super::types::SdfLineSegment;
16
17impl Sdf for SdfLineSegment {
18 fn dist(&self, p: [f64; 3]) -> f64 {
19 let pa = sub(p, self.a);
20 let ba = sub(self.b, self.a);
21 let h = clamp01(dot(pa, ba) / dot(ba, ba));
22 len(sub(pa, scale(ba, h))) - self.radius
23 }
24}