geop_core_topology/argument_validation/
curve_start_and_end.rs1use geop_core_geometry::nurb_curve::NurbCurve3D;
2use geop_core_math::{
3 geop_error::{GeopError, GeopResult},
4 scalars::Scalar,
5 vector::Vector3,
6};
7
8pub fn validate_curve_start_and_end<S: Scalar>(
9 curve: &NurbCurve3D<S>,
10 start: &Vector3<S>,
11 end: &Vector3<S>,
12) -> GeopResult<()> {
13 let (t0, t1) = curve.domain();
14 let curve_start = curve.evaluate(t0)?;
15 if !curve_start.could_be_equal(&start) {
16 return Err(GeopError::new(format!(
17 "curve {curve} start point {curve_start:?} does not match the given 3D point {start:?}"
18 )));
19 }
20 let curve_end = curve.evaluate(t1)?;
21 if !curve_end.could_be_equal(&end) {
22 return Err(GeopError::new(format!(
23 "curve {curve} end point {curve_end:?} does not match the given 3D point {end:?}"
24 )));
25 }
26 Ok(())
27}