Skip to main content

axiolid_linear/
polyline.rs

1//! Piecewise-linear curves.
2
3use axiolid_core::{Point2, Point3};
4
5/// Piecewise-linear curve preserving source vertex order.
6///
7/// Its native parameter is one unit per segment, not arc length and not a
8/// normalised `(0, 1)`: an open n-point polyline spans `(0, n - 1)` and a
9/// closed one `(0, n)`. A trim or profile-segment domain of `(0, 1)` on a
10/// multi-segment polyline therefore selects only its first edge; the scalar
11/// flattener in `axiolid-evaluate` refuses that rather than silently dropping
12/// the remaining vertices.
13#[derive(Debug, Clone, Default, PartialEq)]
14#[cfg_attr(
15    feature = "serde",
16    derive(serde::Serialize, serde::Deserialize),
17    serde(deny_unknown_fields)
18)]
19pub struct Polyline<P> {
20    /// Ordered control points.
21    pub points: Vec<P>,
22    /// Whether the final point connects back to the first.
23    pub closed: bool,
24}
25
26/// Two-dimensional polyline.
27pub type Polyline2 = Polyline<Point2>;
28/// Three-dimensional polyline.
29pub type Polyline3 = Polyline<Point3>;