Skip to main content

section_properties/geometry/
boundary.rs

1use super::Point;
2
3/// Trait for section boundaries that can report their extreme fiber distances.
4///
5/// For polygonal (straight-edge) boundaries, extrema live at vertices.
6/// For curved boundaries (arcs, Bezier, splines), extrema may lie on the
7/// curve between vertices and require analytical or numerical evaluation.
8///
9/// # Future curve support
10///
11/// When curve elements are added, each type implements this trait with its
12/// own strategy:
13///
14/// | Type | Strategy |
15/// |------|----------|
16/// | `Polygon` | Fold over vertices — O(n) |
17/// | `Arc` | Analytical: center ± radius along direction |
18/// | `Bezier` | Root-finding on derivative Bernstein polynomials |
19/// | `CompoundCurve` | max/min across segments |
20pub trait BoundaryExtrema {
21    /// Signed distances `(min, max)` from `center` projected onto `direction`.
22    ///
23    /// * `min` — most negative (farthest in the `-direction` sense).
24    /// * `max` — most positive (farthest in the `+direction` sense).
25    ///
26    /// `direction` does not need to be unit-length; the result scales
27    /// proportionally, which is harmless for section-modulus ratios.
28    fn extreme_distances(&self, center: Point, direction: Point) -> (f64, f64);
29
30    /// Convenience: extreme distances along the global Y axis.
31    fn extreme_y(&self, center: Point) -> (f64, f64) {
32        self.extreme_distances(center, Point::new(0.0, 1.0))
33    }
34
35    /// Convenience: extreme distances along the global X axis.
36    fn extreme_x(&self, center: Point) -> (f64, f64) {
37        self.extreme_distances(center, Point::new(1.0, 0.0))
38    }
39}