Skip to main content

Module curve

Module curve 

Source
Expand description

Concrete space curves.

Each analytic curve is a thin parameterization over the shape descriptions in ogeom-math; the spline curve carries its own control points. All of them are reachable through Curve, an enum rather than a boxed trait object.

§Why an enum

Curves are stored in their millions in a real model, compared constantly, and eventually serialized. An enum makes each of those cheap: no allocation, no vtable, Clone and PartialEq derived, and (most usefully) exhaustive matching, so adding a curve type produces a compile error at every site that needs to know rather than a silent fallthrough.

Deliberately not #[non_exhaustive]. Marking it so would force every match outside this crate to carry a wildcard arm, which is exactly the silent fallthrough the enum exists to prevent: a new curve type would then compile everywhere and be mishandled everywhere. The cost is that adding a variant is a breaking change, which for a kernel this size is the right trade: a curve type nobody handles is worse than a version bump.

CurveKind is non-exhaustive, because matching on it is for opting into an analytic shortcut and a caller that does not recognise a kind should fall back to the general path rather than fail to compile.

The Curve3d trait is still the interface algorithms are written against; Curve implements it and forwards.

Structs§

BSplineCurve
A B-spline curve, polynomial or rational.
CircleCurve
A circle, parameterized by angle.
CurveOnSurface
A pcurve composed with the surface it is drawn on: the space curve a trimming boundary actually traces.
EllipseCurve
An ellipse, parameterized by eccentric angle.
HelixCurve
A helix about its frame’s z, parameterized by turn angle.
HyperbolaCurve
One branch of a hyperbola.
LineCurve
A straight line, parameterized by length from its origin.
OffsetCurve
A space curve displaced a constant signed distance perpendicular to a reference direction: the offset direction at t is the unit vector of tangent x reference, the classical spelling.
ParabolaCurve
A parabola.
TrimmedCurve
Another curve restricted to a sub-interval of its domain.

Enums§

Curve
A curve in space.

Constants§

LINE_EXTENT
How far along a line the default domain reaches either side of its origin.