/* * @tparam T point type * @param first Given the starting point of a line segment * @param last The endpoint of a given line segment * @param third Given point * @return T Distance from point to line */ template <typename T> static T PointToLineDistance(const Point<T>& first, const Point<T>& last, const Point<T>& third){ float dis_suqare = ((first.y - last.y) * third.x + (last.x - first.x) * third.y + (first.x * last.y - last.x * first.y)) * ((first.y - last.y) * third.x + (last.x - first.x) * third.y + (first.x * last.y - last.x * first.y)) / ((last.x - first.x) * (last.x - first.x) + (last.y - first.y) * (last.y - first.y)); return std::sqrt(dis_suqare); }