在Mathematica中绘制Delaunay三角剖分 [英] Plot DelaunayTriangulation in Mathematica

查看:443
本文介绍了在Mathematica中绘制Delaunay三角剖分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑下面的例子(从Sjoerd解决方案上绘制凸形轮廓



  Needs [ComputationalGeometry`] 
pts = RandomReal [{0,10},{60,2}];
dtpts =德劳内三角化[分]



现在,我想绘制德劳内三角化的一组点,但不能找出使用图形的绘图语法。



想法?

解决方案 Graphics [
GraphicsComplex [
pts,
{
函数[{startPt,finishPts},Line [{startPt ,#}]& / @ finishPts] @@@ dtpts,
Red,Point @ Range [Length @ pts]
}
]
]



如果您需要真正的多边形:

 图形[
GraphicsComplex [
点,
{EdgeForm [黑色],
功能[{startPt,finishPts},
{FaceForm [RGBColor [RandomReal [],RandomReal [],RandomReal []] ],
Polygon [{startPt,##}]}& @@@
移调[{撤消[finishPts,1],
掉落[RotateRight @ finishPts,1]
}
]
] @@@ dtpts,
Red,Point @ Range [Length @ pts]
}
]
]


Considering the following example (from Sjoerd Solution on plotting a ConvexHull)

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

I would now like to plot the DelaunayTriangulation for a set of point but can`t figure out the Plot syntax using Graphics.

Thoughts ?

解决方案

Graphics[
  GraphicsComplex[
    pts, 
    {
      Function[{startPt, finishPts},Line[{startPt, #}] & /@ finishPts] @@@ dtpts, 
      Red, Point@Range[Length@pts]
    }
   ]
  ]

And if you need real polygons:

Graphics[
 GraphicsComplex[
  pts, 
  {EdgeForm[Black], 
   Function[{startPt, finishPts}, 
      {FaceForm[RGBColor[RandomReal[], RandomReal[], RandomReal[]]], 
        Polygon[{startPt, ##}]} & @@@ 
          Transpose[{Drop[finishPts, 1], 
                     Drop[RotateRight@finishPts, 1]
                    }
          ]
         ] @@@ dtpts, 
   Red, Point@Range[Length@pts]
  }
 ]
]

这篇关于在Mathematica中绘制Delaunay三角剖分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆