oxiphysics_geometry/implicit_geometry/
sdfroundedcylinder_traits.rs1#[allow(unused_imports)]
12use super::functions::*;
13#[allow(unused_imports)]
14use super::functions::*;
15use super::types::SdfRoundedCylinder;
16
17impl Sdf for SdfRoundedCylinder {
18 fn dist(&self, p: [f64; 3]) -> f64 {
19 let r = self.radius - self.rounding;
20 let h = self.half_height - self.rounding;
21 let d0 = len2([p[0], p[2]]) - r;
22 let d1 = p[1].abs() - h;
23 let d_in = d0.max(d1).min(0.0);
24 let d_out = len2([d0.max(0.0), d1.max(0.0)]);
25 d_in + d_out - self.rounding
26 }
27}