本文介绍了图形中的凸凹 - Mathematica的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有关如何使用图形绘制ConvexHull的任何想法?

解决方案
  Needs [ComputationalGeometry`] 
pts = RandomReal [ 0,10},{60,2}];

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

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

图形[
{
Point @ pts,
Red,
Line @ cpts
}
]

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 ?

解决方案
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
  }
 ]

这篇关于图形中的凸凹 - Mathematica的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 03:18