JavaCAD
SimpleExample.java
Go to the documentation of this file.
1 package eu.mihosoft.vrl.v3d.ext.quickhull3d;
2 
3 // TODO: Auto-generated Javadoc
10 class SimpleExample
11 {
12 
18  public static void main (String[] args)
19  {
20  // x y z coordinates of 6 points
21  Point3d[] points = new Point3d[]
22  { new Point3d (0.0, 0.0, 0.0),
23  new Point3d (1.0, 0.5, 0.0),
24  new Point3d (2.0, 0.0, 0.0),
25  new Point3d (0.5, 0.5, 0.5),
26  new Point3d (0.0, 0.0, 2.0),
27  new Point3d (0.1, 0.2, 0.3),
28  new Point3d (0.0, 2.0, 0.0),
29  };
30 
31  QuickHull3D hull = new QuickHull3D();
32  hull.build (points);
33 
34  System.out.println ("Vertices:");
35  Point3d[] vertices = hull.getVertices();
36  for (int i=0; i<vertices.length; i++)
37  { Point3d pnt = vertices[i];
38  System.out.println (pnt.x + " " + pnt.y + " " + pnt.z);
39  }
40 
41  System.out.println ("Faces:");
42  int[][] faceIndices = hull.getFaces();
43  for (int i=0; i<vertices.length; i++)
44  { for (int k=0; k<faceIndices[i].length; k++)
45  { System.out.print (faceIndices[i][k] + " ");
46  }
47  System.out.println ("");
48  }
49  }
50 }