码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-11-02 22:52:03      阅读:352      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!