Cocos2d iphone 如何知道曲线是否与红线相交

Cocos2d iphone 如何知道曲线是否与红线相交,cocos2d-iphone,curve,intersect,Cocos2d Iphone,Curve,Intersect,该曲线由这些点组成。我想知道红线是否与曲线相交。红线由点A和点B组成。我能做什么 struct pos { double x ; double y ; }; struct line { pos st ; pos end ; }; int n ; double Multiply(pos p1, pos p2, pos p0) { return ( (p1.x - p0.x) * (p2.y - p0.y) - (p2.x - p0.x) * (p1.

该曲线由这些点组成。我想知道红线是否与曲线相交。红线由点A和点B组成。我能做什么

    struct pos
{
    double x ;
    double y ;
};
struct line
{
    pos st ;
    pos end ;
};
int n ;
double Multiply(pos p1, pos p2, pos p0)
{
    return ( (p1.x - p0.x) * (p2.y - p0.y) - (p2.x - p0.x) * (p1.y - p0.y) );
}
bool iscross(line L1, line L2)
{
    return( (max(L1.st.x,   L1.end.x) >= min(L2.st.x, L2.end.x)) &&
        (max(L2.st.x,   L2.end.x) >= min(L1.st.x, L1.end.x)) &&
        (max(L1.st.y,   L1.end.y) >= min(L2.st.y, L2.end.y)) &&
        (max(L2.st.y,   L2.end.y) >= min(L1.st.y, L1.end.y)) &&
        (Multiply(L2.st, L1.end, L1.st) * Multiply(L1.end, L2.end, L1.st) >= 0) &&
        (Multiply(L1.st, L2.end, L2.st) * Multiply(L2.end, L1.end, L2.st) >= 0)
    );
}