Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ConvexHull in Graphics - Mathematica

Trying to plot a ConvexHull Using PlanarGraphPlot from the ComputationalGeometry package, it does not work when used in graphics.

Any Idea on how to plot the ConvexHull using Graphics ?

like image 862
500 Avatar asked Jun 07 '11 19:06

500


1 Answers

Needs["ComputationalGeometry`"]
pts = RandomReal[{0, 10}, {60, 2}];

Graphics[
 {
  Point@pts,
  FaceForm[], EdgeForm[Red],
  Polygon@pts[[ConvexHull[pts]]]
  }
 ]

or

cpts = pts[[ConvexHull[pts]]];
AppendTo[cpts, cpts[[1]]];

Graphics[
 {
  Point@pts,
  Red,
  Line@cpts
  }
 ]

enter image description here

like image 199
Sjoerd C. de Vries Avatar answered Sep 30 '22 10:09

Sjoerd C. de Vries