本文整理汇总了C++中HalfEdge::startPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ HalfEdge::startPoint方法的具体用法?C++ HalfEdge::startPoint怎么用?C++ HalfEdge::startPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HalfEdge
的用法示例。
在下文中一共展示了HalfEdge::startPoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pointIntersection
// Return whether a point is inside, on, or outside the cell:
// -1: point is outside the perimeter of the cell
// 0: point is on the perimeter of the cell
// 1: point is inside the perimeter of the cell
//
int Cell::pointIntersection(double x, double y) {
// Check if point in polygon. Since all polygons of a Voronoi
// diagram are convex, then:
// http://paulbourke.net/geometry/polygonmesh/
// Solution 3 (2D):
// "If the polygon is convex then one can consider the polygon
// "as a 'path' from the first vertex. A point is on the interior
// "of this polygons if it is always on the same side of all the
// "line segments making up the path. ...
// "(y - y0) (x1 - x0) - (x - x0) (y1 - y0)
// "if it is less than 0 then P is to the right of the line segment,
// "if greater than 0 it is to the left, if equal to 0 then it lies
// "on the line segment"
HalfEdge* he;
size_t edgeCount = halfEdges.size();
Point2 p0;
Point2 p1;
double r;
while (edgeCount--) {
he = halfEdges[edgeCount];
p0 = *he->startPoint();
p1 = *he->endPoint();
r = (y - p0.y)*(p1.x - p0.x) - (x - p0.x)*(p1.y - p0.y);
if (r == 0) {
return 0;
}
if (r > 0) {
return -1;
}
}
return 1;
}