Class ConvexHull3
- Namespace
- GeometryHelper.Core
- Assembly
- GeometryHelper.dll
The smallest convex body holding a set of points in space.
public static class ConvexHull3
- Inheritance
-
ConvexHull3
- Inherited Members
Remarks
Built incrementally: a tetrahedron on four points far apart, then each further point in turn. A point within the point tolerance of the hull so far, or inside it, changes nothing. One outside it sees some faces; those go, and the rim they leave — the horizon — is joined to the point with a fan of new faces. The triangles are merged where they lie in one plane, so a box comes back with six faces.
Which faces a point sees is read in floating point there, and a point is taken only where it stands further than the tolerance off a face's plane. That build stops at the first rim that is not one loop, or as soon as it stands more triangles than a closed surface on the points taken can have; and where the hull it gives does not close, folds back over itself, or leaves a point further than the tolerance outside its triangles, the hull is built again with an exact test of sides, from the widest tetrahedron the points give, each point left out only where it is within the tolerance of the triangles themselves. A hull that closes and holds every point is kept as it was built, to the bit. The faces of a plate a few thousandths thick meet at its rim so nearly flat that a point 10 off the rim stands within a thousandth of every plane: of 300 sets of 40 points on plates 0.002 thick, every hull was open or wound against itself, 185 left a point out, by up to 24, and none does now; and 200 points in a plate 100 by 100 and 0.002 thick ran the faster build out of memory, as 10 000 in a cube and 3 000 on a sphere did, and take from under a millisecond to an eighth of a second now. Merging the triangles within the tolerance can stand a face as far again from a point: 5 of 1 000 plates 100 by 100 and from 0.002 to 1 thick left a point up to 1.08E-3 outside the merged hull. Where a point stands further than the tolerance outside it, the triangles are merged again within a tenth of the planar tolerance, then a hundredth, and kept as they are where that does not hold it either, so every point is within the tolerance of the hull given; a merged hull that holds every point is kept as it was, to the bit.
A point is read only against the faces that can stand below it, found by the way they face, so the work no longer grows with the square of the points where they all lie on the hull: 10 000 points in a cube take 50 milliseconds as they did, and 12 000 on a sphere 0.18 seconds where they took 2.4. It is still not meant for a laser scan.
Methods
- Of(IEnumerable<GeoPoint3>)
Gets the convex hull of some points, using the default tolerance.
- Of(IEnumerable<GeoPoint3>, Tolerance)
Gets the convex hull of some points, within a tolerance.
- TryOf(IEnumerable<GeoPoint3>, out GeoSolid3)
Tries to get the convex hull of some points, using the default tolerance.
- TryOf(IEnumerable<GeoPoint3>, out GeoSolid3, Tolerance)
Tries to get the convex hull of some points, within a tolerance.