Algorithmic Solutions > LEDA > LEDA Guide > Geometry Algorithms > Convex Hull > Example 3D Convex Hull

Example 3D Convex Hull

 The following program uses a d3_window to visualize the convex hull of a set of three-dimensional points. The following program generates a ```list L ``` of 50 `d3_rat_points` in the ball with radius 75 centered at the orgin and computes the convex hull `H` of `L`. Then it uses a ``` window W``` and a ```d3_window d3win``` to visualize the convex hull in 3D. On the right there is a screenshot of the program. Clicking on the picture shows the screenshot in original size.
```#include <LEDA/geo/d3_hull.h>
#include <LEDA/graphics/d3_window.h>

using namespace leda;

int main()
{
//construct a random set of points L
list<d3_rat_point> L;
random_d3_rat_points_in_ball(50,75,L);

//construct convex hull H of L
GRAPH<d3_rat_point,int> H;
CONVEX_HULL(L,H);

//open a window W
window W(400,400,"d3 hull demo");
W.init(-100,+100,-100);
W.display(window::center,window::center);

//extract the node positions into an array of vectors
node_array<rat_vector> pos(H);
node v;
forall_nodes(v,H) pos[v]=H[v].to_vector();

//and display H in a d3_window for window W
d3_window d3win(W,H,pos);

W.screenshot("d3_convex_hull");

return 0;
}  ```

Convex Hull

Data Types for 3-D Geometry

Linear Lists

Windows and Panels

3 Dimensional Windows

Geometry

Number Types

Manual Entries

Manual Page Windows

Manual Page d3_window

Please send any suggestions, comments or questions to leda@algorithmic-solutions.com
© Copyright 2001-2003, Algorithmic Solutions Software GmbH