Users of MIConvexHull will likely be programming a larger research project in Visual Studio (2010 or higher). In this way, MIConvexHull may be used either as the precompiled binary (found under Downloads) or the C# project (MIConvexHull.csproj) in Source Code. This page shows detailed instructions on the logic of MIConvexHull, for examples and for understanding the source code organization, click here.

In either case, you will need to add MIConvexHull as a reference to your main project – the project from which you want to call the convex hull, voronoi, or delaunay functions. Under solution explorer in Visual Studio, right-click on References and “Add Reference…” under your project. Then find the dll via Browse, or find the source code project under Projects.

Back in your code – you’ll also need to add the proper “using” statement (or whatever they call it in Visual Basic or C++ or F#, etc.). Add a reference to the namespace MIConvexHull.

Then, in your code you can call one of the three ConvexHull constructor that receive the vertices):

  1.         new ConvexHull(List<IVertexConvHull> vertices)
            new ConvexHull(IList vertices)
            new ConvexHull(double[,] vertices)

    Invoking these creates a ConvexHull object loaded with the vertices to work on, give a local name. You will likely only be using it in one line of code
    ConvexHull convexHull =    new ConvexHull(List<IVertexConvHull> vertices);
    The most efficient constructors the first shown above: input them as a list of type IVertexConvHull (for more information see Interfaces). Since this may not be possible, I have provided a two overloads that convert your collection or array into a list for the main program to manipulate. The most likely representation beyond a standard class for your vertices is likely some set of 1D arrays which include the coordinates of each vertex; to be more specific, your coordinates are like double[]. In the second option above (IList), the vertices are added to an internal list of type IVertexConvHull or type double[], this is also invoke if your input is a an array of IVertexConvHull's or of double[] (essentially an array of arrays). In the last overload, the rows of a large matrix are set to the vertices to solve for. In this case the number of dimensions is equivalent to the number of columns in the matrix.

  2.         List<IVertexConvHull> ConvexHull.FindConvexHull(optional int dimensions)
            List<IVertexConvHull> ConvexHull.FindConvexHull(out List<IFaceConvHull> faces, Type face_Type,
    optional int dimensions)

    This is the main function of this work – and the bulk of the programming effort. It is possible to call the function with no arguments since in the first option above the dimensions is optional. These functions return the subset of the original vertices which comprise the convex hull. Now, since the faces are often just, if not more, important than which vertices “made the cut.” Please see the section on Interfaces to understand the purpose of the IFaceConvHull class. But, first, the dimensions value is simple the dimension of the vectors, if it is not provided, it will be inferred from the size of the coordinate arrays. Don’t be shocked by the default value of –1. This is just a placeholder for determining if the dimensions need to be inferred or not.
    In the second option for calling FindConvexHull above, the faces can be returned, which are of the type face_Type. If you already have class for faces, you will need to pass it to this function along with an empty list to fill up with the faces. For example,  
                var faces = new List<IFaceConvHull>;
                convexHullVertices = ConvexHull.FindConvexHull(out faces, typeof(myFace), 3);

    In this manner, we are able to get the vertices and the faces that comprise the hull back at the same time.

  3.         List<IFaceConvHull> ConvexHull.FindDelaunayTriangulation(optional Type face_Type, optional int dimensions = -1)

    This function along with the Voronoi graph function below, are performed by calling the FindConvexHull function above. It is well understood that the Delaunay triangulation and the Voronoi graph can be determined by finding the faces in a convex hull. Like the second overload above for FindConvexHull, this function will return the faces as a list of IFaceConvHull each constructed of type, face_type. Again, the dimensions are optional – determined by the code, if all coordinates are the same length. If the function is not told what class faces are created from, then the library will return faces in the format of this library (see Interfaces for more detail.

  4.         void ConvexHull.FindVoronoiGraph(out List<IVertexConvHull> nodes, out List<Tuple<IVertexConvHull, IVertexConvHull>> edges,

    FindVoronoiGraph invokes both the convexhull and the delaunay triangulation results.

Last edited Oct 29, 2010 at 3:44 PM by mattica, version 7

Comments

No comments yet.