axiolid_curve/
evaluate.rs

1//! Backend-open curve evaluation capability.
2//!
3//! This crate declares the trait and implements it for nothing: it holds
4//! curve data, and evaluation is an algorithm. The scalar implementation is
5//! `axiolid_evaluate::curve::ScalarCurve` (ADR 0018), also reachable as
6//! `axiolid_reference::curve`. Do not add an evaluator here.
7
8use axiolid_core::{Interval, Scalar, Tolerance};
9
10/// Evaluate and differentiate one curve representation.
11///
12/// The trait is generic over the curve value so third-party backends can add
13/// implementations without a central enum or source-format dependency.
14pub trait CurveEvaluator<C>: core::fmt::Debug + Send + Sync {
15    /// Point returned by evaluation.
16    type Point;
17    /// First derivative returned by evaluation.
18    type Derivative;
19    /// Evaluator-specific structured error.
20    type Error: std::error::Error + Send + Sync + 'static;
21
22    /// Supported parameter interval.
23    fn domain(&self, curve: &C) -> Interval;
24
25    /// Position at parameter `t`.
26    fn evaluate(
27        &self,
28        curve: &C,
29        t: Scalar,
30        tolerance: Tolerance,
31    ) -> Result<Self::Point, Self::Error>;
32
33    /// First derivative at parameter `t`.
34    fn derivative(
35        &self,
36        curve: &C,
37        t: Scalar,
38        tolerance: Tolerance,
39    ) -> Result<Self::Derivative, Self::Error>;
40}