我认为你试图定义包含无限远点的几何的完整数学,这让你自己的生活变得困难。对于准确计算 Delaunay 三角剖分的原始问题,这不是必需的。
我不久前用 Java 写了一个 Delaunay 生成器,它可以在这里找到:http:
//open.trickl.com/trickl-graph/index.html
请参阅http://open.trickl.com/trickl-graph/apidocs/index.html,特别是:
// Check if fourth point is within the circumcircle defined by the first three
private boolean isWithinCircumcircle(PlanarGraph<V, E> graph, V first,
V second,
V third,
V fourth) {
// Treat the boundary as if infinitely far away
Coordinate p = vertexToCoordinate.get(fourth);
if (PlanarGraphs.isVertexBoundary(graph, first)) {
return isLeftOf(third, second, p);
} else if (PlanarGraphs.isVertexBoundary(graph, second)) {
return isLeftOf(first, third, p);
} else if (PlanarGraphs.isVertexBoundary(graph, third)) {
return isLeftOf(second, first, p);
} else if (PlanarGraphs.isVertexBoundary(graph, fourth)) {
return false;
}
Coordinate a = vertexToCoordinate.get(first);
Coordinate b = vertexToCoordinate.get(second);
Coordinate c = vertexToCoordinate.get(third);
boolean within = (a.x * a.x + a.y * a.y) * getDblOrientedTriangleArea(b, c, p)
- (b.x * b.x + b.y * b.y) * getDblOrientedTriangleArea(a, c, p)
+ (c.x * c.x + c.y * c.y) * getDblOrientedTriangleArea(a, b, p)
- (p.x * p.x + p.y * p.y) * getDblOrientedTriangleArea(a, b, c) > 0;
return within;
}
在这里,边界点在检查外接圆条件时被明确检查,因此它们可以有效地被视为“无限”远。这比弄清楚所有几何含义比您描述的要容易得多。