Expand description
§clothoid
A Rust library for computing and fitting Clothoids (also known as Euler spirals or Cornu spirals). A clothoid is a curve whose curvature changes linearly with its arc length.
§Usage
use clothoid::Clothoid;
let clothoid = Clothoid::new(1.0);
let angle = clothoid.direction_angle(0.5);§Choosing an Optimizer
The FitState supports two derivative-free optimizers for path fitting:
- Nelder-Mead (default) — The original simplex method. Fast per-iteration
(500 evaluations per step), good for simple paths. Created with
FitState::new(). Requires thenelder-meadfeature (enabled by default). - CMA-ES — Covariance Matrix Adaptation Evolution Strategy. More robust on
difficult, non-convex landscapes but evaluates more candidates per generation.
Created with
FitState::cma_es(). Requires thecma-esfeature (enabled by default).
Both share the same FitState API. Press O in the interactive demo to toggle
between them.
§Path Traits
When the path-traits feature is enabled (default), the crate provides
ClothoidArc, LinearSegment, ClothoidPath, and Vec2 implementing
the path_traits hierarchy. This allows
downstream crates to treat clothoid paths generically via traits such as
Path, SegmentedPath, Tangent, Heading, Curved, FrenetFrame, and
Project.
use clothoid::ClothoidArc;
use clothoid::optimizer::Pose;
use path_traits::{Path, Heading, Curved};
let arc = ClothoidArc {
start: Pose::new(0.0, 0.0, 0.0),
ks: 0.0,
ke: 1.0,
length: 5.0,
n_steps: 256,
};
let pt = arc.sample_at(2.5).unwrap();
let heading = arc.heading_at(2.5).unwrap();
let curvature = arc.curvature_at(2.5).unwrap();Use Clothoid::into_arc to convert a Clothoid into a bounded arc:
use clothoid::Clothoid;
use path_traits::Path;
let c = Clothoid::new(2.0);
let arc = c.into_arc(4.0);
assert!((arc.length() - 4.0).abs() < 1e-10);§Features
fresnel— enables high-precision Fresnel integral computation via the externalfresnelcrate. When disabled, uses an approximation based on auxiliary functions (Wilde 2009 / Abramowitz & Stegun).optimizers(default) — enables bothnelder-meadandcma-essolvers, plus thefitmodule.nelder-mead— enables the Nelder-Mead simplex optimizer and thefitmodule.cma-es— enables the CMA-ES optimizer and thefitmodule.path-traits(default) — enablespath_traitsintegration withClothoidArc,LinearSegment,ClothoidPath, andVec2.
Re-exports§
pub use fit::DefaultPlanner;nelder-meadorcma-espub use fit::Planner;nelder-meadorcma-espub use optimizer::PlanObjective;pub use optimizer::SymmetryMode;pub use optimizer::CmaEs;cma-espub use optimizer::NelderMead;nelder-meadpub use optimizer::Optimizer;nelder-meadorcma-espub use path_traits_impls::ArcSegment;path-traitspub use path_traits_impls::ClothoidArc;path-traitspub use path_traits_impls::ClothoidPath;path-traitspub use path_traits_impls::LinearSegment;path-traitspub use path_traits_impls::Vec2;path-traits
Modules§
- fit
nelder-meadorcma-es - Incremental path fitting using clothoid segments.
- optimizer
- Path evaluation and optimization utilities for clothoid fitting.
- path_
traits_ impls path-traits - Implementation of
path_traitsfor clothoid types.