Hi, I want to calucate the convex hull of the point set and get the points of the convex hull polygon. The code is as follows:
public ArrayList ConvexHull(ArrayList pts)
{
IGeometryCollection geomCol = null;
object missing = Type.Missing;
IPoint geom;
geom = new PointClass();
geomCol = new MultipointClass();
for (int i = 0; i < pts.Count; i++)
{
geom.X = ((MyPoint)pts).x;
geom.Y = ((MyPoint)pts).z;
geomCol.AddGeometry(geom as IGeometry, ref missing, ref missing);
}
ITopologicalOperator topoOP =geomCol as ITopologicalOperator;
if (!topoOP.IsSimple) topoOP.Simplify();
IGeometry convexHull = topoOP.ConvexHull();
IPointCollection ps = (convexHull as IPolygon) as IPointCollection;
ArrayList c=new ArrayList();
for (int i = 0; i < ps.PointCount; i++)
{
c.Add(ps.get_Point(i));
}
return c;
}
But I didn't get right result. Why? Thank you very much.