Convex Hull for vertical points list

Convex Hull for vertical points list

Anonymous
Not applicable
792 Views
2 Replies
Message 1 of 3

Convex Hull for vertical points list

Anonymous
Not applicable

Hi Everyone,

 

Recently I'm using the function ConvexHull of Jeremy in this link:

https://thebuildingcoder.typepad.com/blog/2016/08/online-revit-api-docs-and-convex-hull.html

 

It worked fine with the horizontal points to create a floor. But the problem is, if I have a bunch of vertical points, it seems not work and stucked in a infinity loop.

XYZ y1 = XYZ.Zero;
XYZ y2 = new XYZ(5, 0, 0);
XYZ y3 = new XYZ(5, 0, 5);
XYZ y4 = new XYZ(0, 0, 5);
List<XYZ> points = new List<XYZ> { y3, y1, y4, y2 };
List<XYZ> convexPoints = Util.ConvexHull(points);

 

Does anyone have idea about creating a Convex Hull for vertical points or any points in 3D?

 

Thank you.

 

0 Likes
793 Views
2 Replies
Replies (2)
Message 2 of 3

jeremytammik
Autodesk
Autodesk

I assume that the convex hull implementation and algorithm that you refer to is for a 2D situation only.

 

Checking, I note that is specifically states:

 

 

Therefore, I assume that if XYZ points are passed in to it, they are reduced to XY coordinates only, and Z is ignored.

 

In the sample points you share, it appears that you wish to ignore the Y component, not Z.

 

Therefore, I would suggest that you project your points from the XZ plane to the XY plane before passing them in to the algorithm.

 

Alternatively, you can rewrite the algorithm to work in a different plane than the canonical XY plane.

  



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 3

jeremytammik
Autodesk
Autodesk

In order to project your points from the XZ plane to the XY plane before passing them in to the algorithm, it will simply suffice to swap the Y and Z coordinates. Possible you may need to move the Z values to the X coord and the X values to the Y coord in order to preserve right-handedness or something. Please try it out and let us know whether it works well for you. 

  



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes