oxiphysics_geometry/csg/csgunion_traits.rs
1//! # CsgUnion - Trait Implementations
2//!
3//! This module contains trait implementations for `CsgUnion`.
4//!
5//! ## Implemented Traits
6//!
7//! - `ImplicitSurface`
8//!
9//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
10
11use super::functions::ImplicitSurface;
12use super::types::CsgUnion;
13
14impl ImplicitSurface for CsgUnion {
15 fn sdf(&self, p: [f64; 3]) -> f64 {
16 self.a.sdf(p).min(self.b.sdf(p))
17 }
18 fn gradient(&self, p: [f64; 3]) -> [f64; 3] {
19 if self.a.sdf(p) < self.b.sdf(p) {
20 self.a.gradient(p)
21 } else {
22 self.b.gradient(p)
23 }
24 }
25}