From 27179edb8f263e4d7d1e54c094ade59154d97b65 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 10 Oct 2024 18:43:37 +0200 Subject: [PATCH] Add `curve_point_to_surface_point` --- crates/fj-core/src/geometry/util.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/crates/fj-core/src/geometry/util.rs b/crates/fj-core/src/geometry/util.rs index 6a4fdf330..35710d8cc 100644 --- a/crates/fj-core/src/geometry/util.rs +++ b/crates/fj-core/src/geometry/util.rs @@ -6,3 +6,22 @@ //! Whatever's in here isn't expected to stay here permanently. Rather, this //! module provides an easy place to put new things, before it's clear what to //! do with them long-term. + +use fj_math::Point; + +use super::{traits::GenPolyline, Tolerance}; + +/// # Convert a point on a curve from curve coordinates to surface coordinates +pub fn curve_point_to_surface_point( + curve: &dyn GenPolyline<2>, + point_curve: impl Into>, + tolerance: impl Into, +) -> Point<2> { + let point_curve = point_curve.into(); + let tolerance = tolerance.into(); + + let line_segment = curve.line_segment_at(point_curve, tolerance); + let line = line_segment.to_line(); + + line.point_from_line_coords(point_curve) +}