Function swri_geometry_util::DistanceFromPolygon

Function Documentation

double swri_geometry_util::DistanceFromPolygon(const std::vector<cv::Vec2d> &polygon, const cv::Vec2d &point)

Calcuate the distance between a point and the bounds of a polygon.

The polygon vertices are assumed to be ordered sequentially.

The distance returned is positive even if the point is within the polygon.

Parameters:
  • polygon[in] The list of polygon vertices.

  • point[in] The point.

Returns:

The distance from the point to the polygon. -1 is returned if the polygon is empty.