首页 > 其他 > 详细

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

时间:2015-11-02 22:50:47      阅读:251      评论:0      收藏:0      [点我收藏+]

求点到直线的距离:

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.

按顺序读入边,边和边是按照一个顺序转的(叉积全为正或者全为负)

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

原文:http://www.cnblogs.com/liuhanx1/p/4931468.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!