use brepkit_geometry::extrema::{
SurfaceProjection, point_to_cone as geo_point_to_cone,
point_to_cylinder as geo_point_to_cylinder, point_to_plane as geo_point_to_plane,
point_to_sphere as geo_point_to_sphere, point_to_torus as geo_point_to_torus,
};
use brepkit_math::surfaces::{
ConicalSurface, CylindricalSurface, SphericalSurface, ToroidalSurface,
};
use brepkit_math::vec::{Point3, Vec3};
fn extract(proj: SurfaceProjection) -> (f64, Point3) {
(proj.distance, proj.point)
}
pub fn point_to_cylinder(point: Point3, cyl: &CylindricalSurface) -> (f64, Point3) {
extract(geo_point_to_cylinder(point, cyl))
}
pub fn point_to_cone(point: Point3, cone: &ConicalSurface) -> (f64, Point3) {
extract(geo_point_to_cone(point, cone))
}
pub fn point_to_sphere(point: Point3, sphere: &SphericalSurface) -> (f64, Point3) {
extract(geo_point_to_sphere(point, sphere))
}
pub fn point_to_torus(point: Point3, torus: &ToroidalSurface) -> (f64, Point3) {
extract(geo_point_to_torus(point, torus))
}
pub fn point_to_plane(point: Point3, normal: Vec3, d: f64) -> (f64, Point3) {
let origin = Point3::new(normal.x() * d, normal.y() * d, normal.z() * d);
extract(geo_point_to_plane(point, origin, normal))
}