您的位置:首页 > 其它

POJ1584 判断多边形是否为凸多边形,并判断点到直线的距离

2015-11-02 21:34 302 查看
求点到直线的距离:

double dis(point p1,point p2)
{
if(fabs(p1.x-p2.x)<exp)//相等的
{
return fabs(p2.x-pegx);
}
else
{
double k=(p2.y-p1.y)/(p2.x-p1.x);
double b=p2.y-k*p2.x;
return fabs(k*pegx-pegy+b)/sqrt(k*k+1);//返回的是距离的
}
}
判断多边形是否为凸多边形

if the hole contains any protrusions (i.e., if there exist any two interior points in the hole that, if connected by a line segment, that segment would cross one or more edges of the hole)(括号里的是凸多边形定义的英文描述), then the filled-in-hole would not be structurally sound enough to support the peg under normal stress as the furniture is used.

按顺序读入边,边和边是按照一个顺序转的(叉积全为正或者全为负)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: