ConvexHull in Graphics - Mathematica

后端 未结 2 816
清酒与你
清酒与你 2021-01-13 01:44

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 ConvexH

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-13 02:25

    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

提交回复
热议问题