Skip to main content

arc_from_three_points

Function arc_from_three_points 

Source
pub fn arc_from_three_points(
    start: (f64, f64),
    mid: (f64, f64),
    end: (f64, f64),
    weight: f64,
) -> Roi
Expand description

Build a Roi::Arc from three points on the arc plus a radial weight (the band thickness), the faithful port of silx ArcROI._createGeometryFromControlPoints (items/_arc_roi.py:622-664) — the geometry behind silx’s default ThreePointMode sub-mode. start and end are the arc endpoints; mid is a point the arc passes through between them (the curvature control). weight is the full radial thickness, so inner_radius = radius − weight/2 (clamped ≥ 0) and outer_radius = radius + weight/2.

Branches mirror silx exactly:

  • start ≈ end (silx numpy.allclose) → a closed circle through start/mid (silx _ArcGeometry.createCircle): center at the startmid midpoint, swept the full from start’s angle.
  • start, mid, end collinear (|cross| < 1e-5) → silx builds a center-less “rect” intermediate, which siplot’s Roi::Arc (always centered) cannot represent; this falls back to a degenerate zero-radius arc at the startend midpoint. The transient rect editing shape is not modeled (deviation noted on the roadmap row).
  • otherwise → the circumscribed circle through the three points (circle_through, silx _circleEquation) with the sweep direction disambiguated from the mid angle (silx :652-660).