DesignEngrLab / MIConvexHull

A .Net fast convex hull library for 2, 3, and higher dimensions.
http://designengrlab.github.io/MIConvexHull/
MIT License
334 stars 61 forks source link

Vertex really need to be a double[]? #35

Open haruby511 opened 4 years ago

haruby511 commented 4 years ago

As you know, most of 3D applications in C# are using struct for Vertex or Vector. Because it does not generate garbage at all in most cases.

However, In this situation, cannot access the member X, Y, Z with byte offset. Such as 0 for X, 1 for Y etc. If really need to access the member by index and must avoid switch, use array instead even though it will be a garbage.

I wonder that, the MIConvexHull really need array for the vertex?

I can see the IVertex interface. It should work as reference and a struct will be boxed which has implemented the interface. But, should avoid boxing/unboxing as well in performance critical situation.

I suggest that adding a struct Vertex the MIConvexHull own, or use a single double collection for whole vertices.

micampbell commented 4 years ago

I've been thinking about this as well. I've been keeping my eye on the development of System.Numerics.Vector (in corefx) for this very reason. However, many of the uses of MIConvexhull are for dimensions greater than 3 (especially in the context of solving 3D voronoi or delauanay triangulation). That said, we have been hard at work at the specialized 2d version of convex hull (see recent commits) - so it does seem natural to extend this 3d for the very purpose that you recommend. Unfortunately, I'm a bit crushed right now. but it is something that I would like to see get done.