Skip to main content

oxiphysics_geometry/implicit_geometry/
sdfrepeat_traits.rs

1//! # SdfRepeat - Trait Implementations
2//!
3//! This module contains trait implementations for `SdfRepeat`.
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::SdfRepeat;
16
17impl<S: Sdf> Sdf for SdfRepeat<S> {
18    fn dist(&self, p: [f64; 3]) -> f64 {
19        fn rmod(v: f64, period: f64) -> f64 {
20            if period < 1e-15 {
21                return v;
22            }
23            v - period * (v / period).round()
24        }
25        let q = [
26            rmod(p[0], self.period_x),
27            rmod(p[1], self.period_y),
28            rmod(p[2], self.period_z),
29        ];
30        self.inner.dist(q)
31    }
32}