     var asTuple : (CGFloat, CGFloat) { get { return (x, y) } }
 }
 
-//    func cross(o:CGPoint, a:CGPoint, b:CGPoint) -> Bool {
-////       let d = (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x)
-////       return d <= 0.0
-//        return Turn(o,a,b) == .Left
-//    }
-
-
 public extension CGPoint {
     func map(transform: CGFloat -> CGFloat) -> CGPoint {
         return CGPoint(x:transform(x), y:transform(y))

        y = sin(direction) * magnitude
    }

    var magnitude : CGFloat { get { return sqrt(x ** 2 + y ** 2) } }
    var normalized : CGPoint { get { return CGPoint(x:x / magnitude, y:y / magnitude) } }
}

public func atan2(point:CGPoint) -> CGFloat {
    return atan2(point.y, point.x)
}


public func round(value:CGPoint) -> CGPoint {
    return value.map { round($0) }
}

// MARK: Distance and angle between two points or vectors

public extension CGPoint {

    func distanceTo(point:CGPoint) -> CGFloat {
        return (self - point).magnitude
    }
    
    func distanceTo(p1:CGPoint, p2:CGPoint) -> CGFloat {
        return (p2-p1).crossProduct(self-p1)
    }

    func angleTo(vec:CGPoint) -> CGFloat {       // [-M_PI, M_PI)
        return atan2(crossProduct(vec), dotProduct(vec))
    }
}

// MARK: Equatable

extension CGPoint : Equatable {
}

public func == (lhs:CGPoint, rhs:CGPoint) -> Bool {
    return CGPointEqualToPoint(lhs, rhs)
}

extension CGPoint : FuzzyEquatable {
}

public func ==% (lhs:CGPoint, rhs:CGPoint) -> Bool {
    return (lhs - rhs).isZero
}
