判断两直线是否相交的叉积方法

 

struct point
{
    double x,y;
};

struct line
{
    point a,b;
}lines[110];

double chaji(point a,point b,point c,point d)
{
    return (b.x-a.x)*(d.y-c.y)-(b.y-a.y)*(d.x-c.x);
}

bool isin(line l1,line l2)
{
    if(chaji(l1.a,l2.a,l1.a,l1.b)*chaji(l1.a,l1.b,l1.a,l2.b)>=0&&chaji(l2.a,l1.b,l2.a,l2.b)*chaji(l2.a,l2.b,l2.a,l1.a)>=0)
        return true;
    return false;
}

 

转载于:https://www.cnblogs.com/wsruning/p/5749050.html

你可能感兴趣的:(判断两直线是否相交的叉积方法)