         case let bezier as Bezier<Point>: return bezier.stationary
         default: return []
         }
+    }
+}
+
+extension LineSegment where Element == Point {
+    
+    @inlinable
+    public func offset(_ a: Double) -> LineSegment? {
+        
+        if a.almostZero() {
+            return self
+        }
+        
+        let _x = p1.x - p0.x
+        let _y = p1.y - p0.y
+        
+        if _x.almostZero() && _y.almostZero() {
+            return nil
+        }
+        
+        let m = 1 / sqrt(_x * _x + _y * _y)
+        let s = a * _y * m
+        let t = -a * _x * m
+        
+        return LineSegment(p0 + Point(x: s, y: t), p1 + Point(x: s, y: t))
+    }
+    
+    @inlinable
+    public func offset(_ a0: Double, _ a1: Double) -> LineSegment? {
+        
+        if a0.almostZero() && a1.almostZero() {
+            return self
+        }
+        
+        let r0 = abs(a0)
+        let r1 = abs(a1)
+        
+        guard a0.sign == a1.sign || a0 == 0 || a1 == 0 else { return nil }
+        guard r1 > r0 else { return LineSegment(p1, p0).offset(a1, a0).map { LineSegment($0.p1, $0.p0) } }
+        
+        let d = p1 - p0
+        let m = d.magnitude
+        let p = d.phase
+        
+        let _r = r1 - r0
+        
+        guard m > _r && !m.almostEqual(_r) else { return nil }
+        
+        let a = asin(_r / m)
+        
+        let x1, y1, x2, y2: Double
+        
+        if a0.sign == .plus || a1.sign == .plus {
+            x1 = r0 * cos(0.5 * .pi + a)
+            y1 = r0 * sin(0.5 * .pi + a)
+            x2 = r1 * cos(0.5 * .pi + a)
+            y2 = r1 * sin(0.5 * .pi + a)
+        } else {
+            x1 = r0 * cos(0.5 * .pi + a)
+            y1 = -r0 * sin(0.5 * .pi + a)
+            x2 = r1 * cos(0.5 * .pi + a)
+            y2 = -r1 * sin(0.5 * .pi + a)
+        }
+        
+        let t1 = SDTransform.rotate(p) * SDTransform.translate(x: p0.x, y: p0.y)
+        let t2 = SDTransform.rotate(p) * SDTransform.translate(x: p1.x, y: p1.y)
+        
+        return LineSegment(Point(x: x1, y: y1) * t1, Point(x: x2, y: y2) * t2)
     }
 }
 

    
    return (u, v)
}

    }
}

public func CubicBezierFitting(_ p0: Point, _ p3: Point, _ m0: Point, _ m1: Point, _ points: [(Double, Point)]) -> (Double, Double)? {
    
    var _a1 = 0.0
