Skip to main content

axiolid_curve/
lib.rs

1#![forbid(unsafe_code)]
2
3//! Exact, format-neutral curve representations and evaluation contracts.
4//!
5//! Composite, trimmed, offset, and surface-bound curves are graph relations in
6//! `axiolid-model`; keeping them there avoids a curve/surface dependency cycle.
7//! The pieces of atomic curves such a relation runs along are a neutral value
8//! here, [`CurvePath`], which an evaluator measures (#290).
9
10pub mod banked;
11pub mod chain;
12pub mod conic;
13pub mod elevation;
14pub mod evaluate;
15pub mod implicit;
16mod intrinsic;
17mod intrinsic3;
18pub mod linear;
19pub mod pair_section;
20pub mod path;
21pub mod quadric_section;
22pub mod seam;
23pub mod sinusoid;
24pub mod spline;
25pub mod spline_surface;
26pub mod torus_section;
27
28pub use banked::{
29    bank_angle, BankConvention, BankError, Banked3, CantForm, CantLaw, CantPiece, CantValue,
30    RailSide,
31};
32pub use chain::{Chain2, ChainPiece2};
33pub use conic::{Circle2, Circle3, Ellipse2, Ellipse3};
34pub use elevation::{Elevated3, ElevationLaw};
35pub use evaluate::CurveEvaluator;
36pub use implicit::{
37    Axis, Basis, Carrier, Field2, ImplicitCell, ImplicitCurve2, ImplicitSection3, Jet2,
38    LiftedCurve2, PatchField2, SeriesField2, SurfaceJet,
39};
40pub use intrinsic::{CurvatureLaw, Harmonic, Intrinsic2};
41pub use intrinsic3::Intrinsic3;
42pub use linear::{Line, Line2, Line3, Polyline, Polyline2, Polyline3};
43pub use pair_section::{PairNode, PairSection3};
44pub use path::{
45    CurvePath, OffsetFrame, OffsetLaw, PathBound, PathCurve, PathOffset, PathOffsets, PathPiece,
46};
47pub use quadric_section::{Branch, QuadraticGraph2, RuledCarrier, RuledSection3, Trig2};
48pub use seam::SeamSide;
49pub use sinusoid::Sinusoid2;
50pub use spline::{BSplineCurve, BSplineCurve2, BSplineCurve3, KnotSpec};
51pub use spline_surface::BSplineSurface;
52pub use torus_section::{AngleGraph2, TorusCarrier, TorusSection3};
53
54/// The focused linear vocabulary, re-exported for consumers that want to name
55/// its origin explicitly. A line-only consumer should depend on
56/// `axiolid-linear` directly instead of paying for this aggregate.
57pub mod linear_vocabulary {
58    pub use axiolid_linear::*;
59}
60
61/// Atomic two-dimensional curve values.
62#[non_exhaustive]
63#[derive(Debug, Clone, PartialEq)]
64#[cfg_attr(
65    feature = "serde",
66    derive(serde::Serialize, serde::Deserialize),
67    serde(deny_unknown_fields)
68)]
69pub enum Curve2 {
70    /// Infinite line.
71    Line(Line2),
72    /// Circle.
73    Circle(Circle2),
74    /// Ellipse.
75    Ellipse(Ellipse2),
76    /// Piecewise linear curve.
77    Polyline(Polyline2),
78    /// Polynomial or rational B-spline.
79    BSpline(BSplineCurve2),
80    /// Curve given by its natural equation: curvature as a function of arc
81    /// length, anchored to a start frame. Carries clothoid and other
82    /// transition spirals exactly, which no parametric variant can.
83    Intrinsic(Intrinsic2),
84    /// The graph `v = mean + a cos(t) + b sin(t)`: the exact pcurve of a
85    /// plane's cut across a cylinder, read in the cylinder's (angle, height)
86    /// parameters. See [`Sinusoid2`] (ADR 0071).
87    Sinusoid(Sinusoid2),
88    /// One root of `a(t) v^2 + b(t) v + c(t) = 0` as a graph over `t`: the
89    /// exact pcurve of a quadric's cut across a cylinder or cone. See
90    /// [`QuadraticGraph2`] (ADR 0076).
91    QuadraticGraph(QuadraticGraph2),
92    /// A solution of `a(t) cos u + b(t) sin u = c(t)` as `u` over `t`: the
93    /// exact pcurve of a plane's or sphere's cut across a torus. See
94    /// [`AngleGraph2`] (ADR 0076).
95    AngleGraph(AngleGraph2),
96    /// A stretch of a field's zero set, the field being another analytic
97    /// surface's equation read in this surface's parameters: the exact
98    /// pcurve of any section between planes, quadrics and tori. See
99    /// [`ImplicitCurve2`] (ADR 0077).
100    Implicit(ImplicitCurve2),
101    /// A space curve read in an analytic surface's parameters, sharing the
102    /// curve's parameter: the pcurve of a B-spline's section on the analytic
103    /// face it meets. See [`LiftedCurve2`] (ADR 0077).
104    Lifted(LiftedCurve2),
105    /// Pieces placed rigidly end to end and parameterised by cumulative arc
106    /// length: curvature-law pieces and parametric curves read by arc
107    /// length, such as a cubic parabola between a line and an arc. Usable
108    /// as the plan of an [`Elevated3`]. See [`Chain2`].
109    Chain(Chain2),
110}
111
112/// Atomic three-dimensional curve values.
113#[non_exhaustive]
114#[derive(Debug, Clone, PartialEq)]
115#[cfg_attr(
116    feature = "serde",
117    derive(serde::Serialize, serde::Deserialize),
118    serde(deny_unknown_fields)
119)]
120pub enum Curve3 {
121    /// Infinite line.
122    Line(Line3),
123    /// Circle in a plane.
124    Circle(Circle3),
125    /// Ellipse in a plane.
126    Ellipse(Ellipse3),
127    /// Piecewise linear curve.
128    Polyline(Polyline3),
129    /// Polynomial or rational B-spline.
130    BSpline(BSplineCurve3),
131    /// Curve given by its natural equations: curvature AND torsion as
132    /// functions of arc length, anchored to a start frame. Carries helices
133    /// and general space spirals as exact values.
134    Intrinsic(Intrinsic3),
135    /// A planar curve paired with an elevation law: the exact composition an
136    /// alignment centreline is authored as. See [`Elevated3`].
137    Elevated(Elevated3),
138    /// A quadric's cut across a cylinder or cone: the carrier evaluated along
139    /// a [`QuadraticGraph2`]. See [`RuledSection3`] (ADR 0076).
140    RuledSection(RuledSection3),
141    /// A plane's or sphere's cut across a torus: the torus evaluated along
142    /// an [`AngleGraph2`]. See [`TorusSection3`] (ADR 0076).
143    TorusSection(TorusSection3),
144    /// An [`ImplicitCurve2`] on its analytic carrier: the section of a
145    /// torus by a cylinder, cone or torus, and any other analytic pair with
146    /// no closed form. See [`ImplicitSection3`] (ADR 0077).
147    ImplicitSection(ImplicitSection3),
148    /// Where two B-spline surfaces meet, carried by nodes on both and
149    /// defined between them by the surfaces themselves. See
150    /// [`PairSection3`] (ADR 0077).
151    PairSection(PairSection3),
152    /// An elevated centreline carrying a cant law: the section rolls about
153    /// the tangent by a bank angle, under a named convention. See
154    /// [`Banked3`] (ADR 0081).
155    Banked(Banked3),
156}