本文整理汇总了C++中Point2::distance方法的典型用法代码示例。如果您正苦于以下问题:C++ Point2::distance方法的具体用法?C++ Point2::distance怎么用?C++ Point2::distance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point2
的用法示例。
在下文中一共展示了Point2::distance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: edgeDistance
double edgeDistance(Point2 p1, Point2 p2, Point2 p)
{
double x1 = p1.x;
double x2 = p2.x;
double y1 = p1.y;
double y2 = p2.y;
double x0 = p.x;
double y0 = p.y;
double den = fabs((y2 - y1)*x0 - (x2-x1)*y0 + x2*y1-y2*x1);
double num = sqrt((y2-y1)*(y2-y1) + (x2-x1)*(x2-x1));
double linedist = den / num;
double p1_dist = p1.distance(p);
double p2_dist = p2.distance(p);
double edge_len = p1.distance(p2);
if (p1_dist > edge_len)
return std::numeric_limits<double>::infinity();
if (p2_dist > edge_len)
return std::numeric_limits<double>::infinity();
return linedist;
}
示例2: getClosestPin
Vertex KVFModel::getClosestPin(Point2 point, double radius) const
{
Vertex result = -1;
double distance = radius;
for (auto iter = pinnedVertexes.begin() ;iter != pinnedVertexes.end(); iter++) {
Point2 pinLocation = vertices[*iter];
if (point.distance(pinLocation) < distance)
result = *iter;
}
return result;
}