use crate::surface2::Surface2;
use crate::vector2::Vector2D;
use std::sync::{RwLock, Arc};
pub trait ImplicitSurface2: Surface2 {
fn signed_distance(&self, other_point: &Vector2D) -> f64 {
let sd = self.signed_distance_local(&self.view().transform.to_local_vec(&other_point));
return match self.view().is_normal_flipped {
true => -sd,
false => sd
};
}
fn signed_distance_local(&self, other_point: &Vector2D) -> f64;
fn closest_distance_local(&self, other_point: &Vector2D) -> f64 {
return f64::abs(self.signed_distance_local(other_point));
}
fn is_inside_local(&self, other_point: &Vector2D) -> bool {
return crate::level_set_utils::is_inside_sdf(self.signed_distance_local(other_point));
}
}
pub type ImplicitSurface2Ptr = Arc<RwLock<dyn ImplicitSurface2>>;