标签:bool int poi turn als 2.x bsp false amp
struct Point{
int x1,y1,x2,y2;
}A[20];
int arr[20];
struct Node{
int x,y;
};
bool judge(Point p1,Point p2){ //相交最基本的条件
if(max(p1.x1,p1.x2)<min(p2.x1,p2.x2)||max(p1.y1,p1.y2)<min(p2.y1,p2.y2)||min(p1.x1,p1.x2)>max(p2.x1,p2.x2)||min(p1.y1,p1.y2)>max(p2.y1,p2.y2))
return false;
return true;
}
int cultilate(Point p1,Point p2){ //判断是不是在异侧,或有个点在另外一个点另外一条直线上
Node AB,AC,AD,CD,CB,CA;
AB.x=p1.x2-p1.x1,AB.y=p1.y2-p1.y1;
AC.x=p2.x1-p1.x1,AC.y=p2.y1-p1.y1;
AD.x=p2.x2-p1.x1,AD.y=p2.y2-p1.y1;
CD.x=p2.x2-p2.x1,CD.y=p2.y2-p2.y1;
CB.x=p1.x2-p2.x1,CB.y=p1.y2-p2.y1;
CA.x=p1.x1-p2.x1,CA.y=p1.y1-p2.y1;
if((AB.x*AC.y-AB.y*AC.x)*(AB.x*AD.y-AB.y*AD.x)<=0&&(CD.x*CB.y-CD.y*CB.x)*(CD.x*CA.y-CD.y*CA.x)<=0)
return 1;
return 0;
}
标签:bool int poi turn als 2.x bsp false amp
原文地址:https://www.cnblogs.com/qq-1585047819/p/10701972.html