     }
     
     // cube root function yielding real roots
-    static func crt(_ v: CGFloat) -> CGFloat {
+    static private func crt(_ v: Double) -> Double {
         return (v < 0) ? -pow(-v,1.0/3.0) : pow(v,1.0/3.0)
     }
     

                let x1 = t1 * cos(phi/3) - a/3
                let x2 = t1 * cos((phi+tau)/3) - a/3
                let x3 = t1 * cos((phi+2*tau)/3) - a/3
                return [x1, x2, x3].filter(reduce).map(clamp)
            }
            else if discriminant == 0 {
                let u1 = q2 < 0 ? crt(-q2) : -crt(q2)
                let x1 = 2*u1-a/3
                let x2 = -u1 - a/3
                return [x1,x2].filter(reduce).map(clamp)
            }
            else {
                let sd = sqrt(discriminant)
                let u1 = crt(-q2+sd)
                let v1 = crt(q2+sd)
                return [u1-v1-a/3].filter(reduce).map(clamp)
            }
        }
        else {

        let order = points.count - 1
        let p = Utils.align(points, p1: line.p0, p2: line.p1)
        
        let clamp: (Double) -> CGFloat? = {
            if $0 < -epsilon {
                return nil
            }
            else if $0 > 1.0 + epsilon {
                return nil
            }
            else if Utils.approximately($0, 0.0, precision: epsilon) {
                return CGFloat(0.0)
            }
            else if Utils.approximately($0, 1.0, precision: epsilon) {
                return CGFloat(1.0)
            }
            return CGFloat($0)
        }
        
        if order == 2 {
            let a = Double(p[0].y)
            let b = Double(p[1].y)
            let c = Double(p[2].y)
            let d = a - 2*b + c
            if abs(d) > epsilon {
                let m1 = -sqrt(b*b-a*c)
                let m2 = -a+b
                let v1: Double = -( m1+m2)/d
                let v2: Double = -(-m1+m2)/d
                return [v1, v2].compactMap(clamp)
            }
            else if a != b {
                // TODO: also fix in droots!
                return [Double(0.5) * a / (a-b)].compactMap(clamp)
            }
            else {
                return []
