177static inline struct CoppJet3 copp_constant(double x)
179 struct CoppJet3 out = {x, 0.0, 0.0, 0.0};
188 struct CoppJet3 out = {a.v + b.v, a.d1 + b.d1, a.d2 + b.d2, a.d3 + b.d3};
197 struct CoppJet3 out = {a.v + b, a.d1, a.d2, a.d3};
206 struct CoppJet3 out = {a.v - b.v, a.d1 - b.d1, a.d2 - b.d2, a.d3 - b.d3};
215 struct CoppJet3 out = {a.v - b, a.d1, a.d2, a.d3};
224 struct CoppJet3 out = {a - b.v, -b.d1, -b.d2, -b.d3};
233 struct CoppJet3 out = {-x.v, -x.d1, -x.d2, -x.d3};
242 struct CoppJet3 out = {
244 a.d1 * b.v + a.v * b.d1,
245 a.d2 * b.v + 2.0 * a.d1 * b.d1 + a.v * b.d2,
246 a.d3 * b.v + 3.0 * (a.d2 * b.d1 + a.d1 * b.d2) + a.v * b.d3};
255 struct CoppJet3 out = {a.v * b, a.d1 * b, a.d2 * b, a.d3 * b};
264 const double inv = 1.0 / b.
v;
265 const double inv2 = inv * inv;
266 const double inv3 = inv2 * inv;
267 const double inv4 = inv3 * inv;
268 const double d1sq = b.d1 * b.d1;
269 struct CoppJet3 out = {
272 a * (2.0 * inv3 * d1sq - inv2 * b.d2),
273 a * (-6.0 * inv4 * d1sq * b.d1 + 6.0 * inv3 * b.d1 * b.d2 - inv2 * b.d3)};
282 return copp_mul_f64(a, 1.0 / b);
290 return copp_mul(a, copp_f64_div(1.0, b));
298 const double sv = sin(x.v);
299 const double cv = cos(x.v);
300 const double d1sq = x.d1 * x.d1;
301 struct CoppJet3 out = {
304 -sv * d1sq + cv * x.d2,
305 -cv * d1sq * x.d1 - 3.0 * sv * x.d1 * x.d2 + cv * x.d3};
314 const double sv = sin(x.v);
315 const double cv = cos(x.v);
316 const double d1sq = x.d1 * x.d1;
317 struct CoppJet3 out = {
320 -cv * d1sq - sv * x.d2,
321 sv * d1sq * x.d1 - 3.0 * cv * x.d1 * x.d2 - sv * x.d3};
330 const double ev = exp(x.v);
331 const double d1sq = x.d1 * x.d1;
332 struct CoppJet3 out = {
336 ev * (d1sq * x.d1 + 3.0 * x.d1 * x.d2 + x.d3)};
345 const double inv = 1.0 / x.
v;
346 const double inv2 = inv * inv;
347 const double inv3 = inv2 * inv;
348 const double d1sq = x.d1 * x.d1;
349 struct CoppJet3 out = {
352 -inv2 * d1sq + inv * x.d2,
353 2.0 * inv3 * d1sq * x.d1 - 3.0 * inv2 * x.d1 * x.d2 + inv * x.d3};
362 const double sqrtv = sqrt(x.v);
363 const double inv_sqrt = 1.0 / sqrtv;
364 const double inv_v_sqrt = inv_sqrt / x.v;
365 const double inv_v2_sqrt = inv_v_sqrt / x.v;
366 const double d1sq = x.d1 * x.d1;
367 struct CoppJet3 out = {
369 0.5 * inv_sqrt * x.d1,
370 -0.25 * inv_v_sqrt * d1sq + 0.5 * inv_sqrt * x.d2,
371 0.375 * inv_v2_sqrt * d1sq * x.d1 - 0.75 * inv_v_sqrt * x.d1 * x.d2 + 0.5 * inv_sqrt * x.d3};
381 return copp_constant(1.0);
384 const double nf = (double)n;
385 const double coeff2 = nf * (nf - 1.0);
386 const double coeff3 = coeff2 * (nf - 2.0);
387 const double dv = nf * pow(x.v, nf - 1.0);
388 const double ddv = coeff2 == 0.0 ? 0.0 : coeff2 * pow(x.v, nf - 2.0);
389 const double dddv = coeff3 == 0.0 ? 0.0 : coeff3 * pow(x.v, nf - 3.0);
390 const double d1sq = x.d1 * x.d1;
391 struct CoppJet3 out = {
394 ddv * d1sq + dv * x.d2,
395 dddv * d1sq * x.d1 + 3.0 * ddv * x.d1 * x.d2 + dv * x.d3};
739 bool *out_has_report,
Core status, memory, matrix, and shared solver option types.
CoppStatus
C ABI status code returned by COPP FFI functions.
struct CoppPath CoppPath
Opaque C handle for a library-owned Path.
enum CoppStatus copp_path_evaluate_up_to_3rd(const struct CoppPath *path, struct CoppSliceF64 s, struct CoppMatrixF64 *out_q, struct CoppMatrixF64 *out_dq, struct CoppMatrixF64 *out_ddq, struct CoppMatrixF64 *out_dddq)
Evaluate q, dq, ddq, and dddq at the supplied path parameters.
enum CoppStatus copp_path_from_waypoints(struct CoppMatrixViewF64 waypoints, struct CoppPathOptions options, struct CoppPath **out_path)
Build an interpolating waypoint spline path.
enum CoppStatus copp_path_dim(const struct CoppPath *path, size_t *out_dim)
Return the path dimension.
enum CoppStatus(* CoppPathEvaluate2ndFn)(void *user_data, size_t dim, size_t n, const double *s, double *q, double *dq, double *ddq)
C callback for evaluating q, dq, and ddq.
CoppPathOutOfRangeMode
C ABI path out-of-range behavior.
enum CoppStatus copp_path_s_range(const struct CoppPath *path, double *out_s_min, double *out_s_max)
Return the valid path parameter range.
enum CoppStatus copp_smoothing_default_options(struct CoppSmoothingOptions *out_options)
Write default tolerance-bounded fitting options into out_options.
enum CoppStatus copp_path_from_evaluator_2nd(size_t dim, double s_min, double s_max, CoppPathEvaluate2ndFn evaluate_2nd, void *user_data, struct CoppPath **out_path)
Build a path from a C callback that provides derivatives up to 2nd order.
enum CoppStatus copp_path_smoothing_report(const struct CoppPath *path, bool *out_has_report, struct CoppSmoothingReport *out_report)
Return the construction report of a tolerance-fitted waypoint path.
enum CoppStatus(* CoppPathEvaluate3rdFn)(void *user_data, size_t dim, size_t n, const double *s, double *q, double *dq, double *ddq, double *dddq)
C callback for evaluating q, dq, ddq, and dddq.
void copp_path_free(struct CoppPath *path)
Release a path handle created by this module.
enum CoppStatus copp_path_from_parametric(size_t dim, double s_min, double s_max, CoppPathParametricFn evaluate, void *user_data, struct CoppPath **out_path)
Build a path from a scalar-parametric C callback.
enum CoppStatus copp_path_evaluate_up_to_2nd(const struct CoppPath *path, struct CoppSliceF64 s, struct CoppMatrixF64 *out_q, struct CoppMatrixF64 *out_dq, struct CoppMatrixF64 *out_ddq)
Evaluate q, dq, and ddq at the supplied path parameters.
enum CoppStatus copp_path_from_waypoints_interpolating(struct CoppMatrixViewF64 waypoints, struct CoppPathOptions options, struct CoppPath **out_path)
Build an interpolating waypoint spline path.
enum CoppStatus copp_path_from_evaluator_3rd(size_t dim, double s_min, double s_max, CoppPathEvaluate2ndFn evaluate_2nd, CoppPathEvaluate3rdFn evaluate_3rd, void *user_data, struct CoppPath **out_path)
Build a path from C callbacks that provide derivatives up to 3rd order.
CoppPathParametrization
C ABI waypoint-spline parametrization.
enum CoppStatus copp_path_from_waypoints_fitting(struct CoppMatrixViewF64 waypoints, struct CoppSmoothingOptions options, struct CoppPath **out_path)
Build a tolerance-bounded waypoint-fitting path.
enum CoppStatus copp_path_default_options(double s_min, double s_max, struct CoppPathOptions *out_options)
Write default waypoint spline options into out_options.
void copp_smoothing_report_free(struct CoppSmoothingReport report)
Release memory owned by a CoppSmoothingReport.
enum CoppStatus(* CoppPathParametricFn)(void *user_data, size_t dim, struct CoppJet3 s, struct CoppJet3 *q)
C callback for evaluating a scalar-parametric path with automatic derivatives.
@ COPP_PATH_OUT_OF_RANGE_MODE_CLAMP
Clamp query parameters into [s_min, s_max].
@ COPP_PATH_OUT_OF_RANGE_MODE_ERROR
Return an error when a query parameter is outside [s_min, s_max].
@ COPP_PATH_PARAMETRIZATION_UNIFORM
Uniform parameter spacing between waypoints.
C-compatible third-order automatic-differentiation scalar.
double d1
First derivative with respect to s.
double d3
Third derivative with respect to s.
double d2
Second derivative with respect to s.
Library-owned column-major f64 matrix returned to C.
Borrowed immutable f64 matrix passed from C to COPP.
Options for waypoint spline path construction.
size_t order
Spline order.
enum CoppPathParametrization parametrization
Waypoint parametrization mode.
struct CoppMatrixViewF64 end_state
Boundary derivatives at s_max, or empty for zero boundary derivatives.
enum CoppPathOutOfRangeMode out_of_range_mode
Behavior for out-of-range path evaluation.
struct CoppMatrixViewF64 start_state
Boundary derivatives at s_min, or empty for zero boundary derivatives.
double s_min
Lower bound of the path parameter range.
double s_max
Upper bound of the path parameter range.
Borrowed immutable f64 slice passed from C to COPP.
Borrowed immutable size_t slice passed from C to COPP.
Options for tolerance-bounded waypoint fitting.
size_t max_segments
Maximum number of polynomial spans used by the selected axes.
struct CoppSliceF64 parameters
Optional common path parameter assigned to each waypoint column.
size_t max_refinements
Maximum number of adaptive knot-refinement passes.
struct CoppSliceUsize axes
Optional 0-based input rows allowed to deviate from their reference polylines.
struct CoppSliceF64 tolerance_per_axis
Optional per-axis absolute tolerances.
enum CoppPathOutOfRangeMode out_of_range_mode
Behavior for out-of-range evaluation of the returned path.
double tolerance
Absolute tolerance broadcast to every selected axis when tolerance_per_axis is empty.
Diagnostics recorded while constructing a tolerance-fitted waypoint path.
size_t segments
Number of final polynomial spans shared by the selected axes.
size_t refinements
Number of completed local knot-refinement passes.
struct CoppVecUsize axes
Selected 0-based input-row indices, in tolerance/report order.
size_t checked_intervals
Number of reference-polyline intervals visited by numerical audits, including revisits and the final ...
size_t fitting_rows
Number of discrete or quadrature fitting rows assembled, counting rows assembled again during local r...
size_t interpolated_segments
Number of spans in the separate unselected-axis interpolant.
struct CoppVecF64 max_errors
Final whole-domain absolute-error bound for each selected axis.
Library-owned f64 vector returned to C.
Library-owned usize vector returned to C.