Beispiel #1
0
/*! Distances from the line and vertices are considered. In the case of
    line, perpendicuar distance is used in the case of vertex, radial
    distance is used.  
    \retval qreal minimal distance to the polygon border.
 */
qreal Polygon2D::GetDistance(
   const Point2D& pt //!< distance to this point is calculated.
) const
{
   qreal dD = std::numeric_limits<qreal>::max();
   
   for(unsigned int i=0; i<GetCount(); i++) {
      dD = GetMin(dD, pt.GetDistance(GetVertex(i)));
      Line2D ln = GetLine(i);
      Point2D ptN = ln.GetNearestPoint(pt);
      if(ln.GetPosition(ptN) & Line2D::posInside) 
         dD = GetMin(dD, ptN.GetDistance(pt));
   }
   return dD;
}